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 Also known as: to_g_url_value_point

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

#to_g_url_value_bounds(precision = 6) ⇒ Object

Force to Google’s toUrlValue as a set of bounds.



32
33
34
35
# File 'lib/geos/google_maps/api_common.rb', line 32

def to_g_url_value_bounds(precision = 6)
  url_value = self.to_g_url_value(precision)
  "#{url_value},#{url_value}"
end