Module: LooseChange::Spatial
- Included in:
- Base
- Defined in:
- lib/loose_change/spatial.rb
Constant Summary collapse
- GEOMETRIES =
To define a spatial geometry property on a CouchDB document, use the geo_* methods as following:
class Bar < LooseChange::Base geo_point :location geo_multipoint :catchment_area end = Bar.new(:location => [41.3913, 73.9813])
For information on geometries see the GeoJSON documentation at geojson.org/geojson-spec.html
%w(Point MultiPoint)
Instance Method Summary collapse
-
#by_bounding_box(name, lat1, lng1, lat2, lng2) ⇒ Object
Locate documents with a bounding box (defined as two coordinate pairs, from lower-left to upper-right).
Instance Method Details
#by_bounding_box(name, lat1, lng1, lat2, lng2) ⇒ Object
Locate documents with a bounding box (defined as two coordinate pairs, from lower-left to upper-right). The :name
parameter identifies which location property to search.
Bar.by_bounding_box(:location, 40, 72, 43, 74)
40 41 42 43 44 |
# File 'lib/loose_change/spatial.rb', line 40 def by_bounding_box(name, lat1, lng1, lat2, lng2) JSON.parse(RestClient.get("#{ design_document_uri(database, model_name) }/_spatial/#{name}?bbox=#{ [lat1,lng1,lat2,lng2].join(',') }", default_headers))['rows'].map do |row| find(row['id']) end end |