Module: Geos::GoogleMaps::ApiCommon::Geometry

Included in:
Geos::GoogleMaps::Api2::Geometry, Geos::GoogleMaps::Api3::Geometry
Defined in:
lib/geos/google_maps/api_common.rb

Instance Method Summary collapse

Instance Method Details

#to_g_json_pointObject

Spit out Google’s JSON geocoder Point format. The extra 0 is added on as Google’s format seems to like including the Z coordinate.



8
9
10
11
12
# File 'lib/geos/google_maps/api_common.rb', line 8

def to_g_json_point
  {
    :coordinates => (self.centroid.to_a << 0)
  }
end

#to_g_lat_lon_boxObject

Spit out Google’s JSON geocoder ExtendedData LatLonBox format.



15
16
17
18
19
20
21
22
# File 'lib/geos/google_maps/api_common.rb', line 15

def to_g_lat_lon_box
  {
    :north => self.north,
    :east => self.east,
    :south => self.south,
    :west => self.west
  }
end

#to_g_url_value(precision = 6) ⇒ Object

Spit out Google’s toUrlValue format.



25
26
27
28
# File 'lib/geos/google_maps/api_common.rb', line 25

def to_g_url_value(precision = 6)
  c = self.centroid
  "#{Geos::Helper.number_with_precision(c.lat, precision)},#{Geos::Helper.number_with_precision(c.lng, precision)}"
end