lib/postgis_adapter/functions/common.rb
#
# Return UTM Zone for a geom
#
# Return Integer
Return UTM Zone for a geom
Return Integer
Return UTM Zone for a geom Return Integer
def utm_zone
    if srid == 4326
      geom = centroid
    else
      geomdup = transform(4326)
      mezzo = geomdup.length / 2
      geom = case geomdup
             when Point      then  geomdup
             when LineString then  geomdup[mezzo]
             else
               geomgeog[mezzo][geomgeo[mezzo]/2]
             end
    end
    pref = geom.y > 0 ? 32700 : 32600
    zone = ((geom.x + 180) / 6 + 1).to_i
    zone + pref
  end
def utm_zone if srid == 4326 geom = centroid else geomdup = transform ( 4326 ) mezzo = geomdup . length / 2 geom = case geomdup when Point then geomdup when LineString then geomdup [ mezzo ] else geomgeog [ mezzo ] [ geomgeo [ mezzo ] / 2 ] end end pref = geom . y > 0 ? 32700 : 32600 zone = ( ( geom . x + 180 ) / 6 + 1 ) . to_i zone + pref end
Return UTM Zone for a geom
Return Integer
Return UTM Zone for a geom Return Integer