Class: Parse::Constraint::WithinGeoBoxQueryConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- Parse::Constraint::WithinGeoBoxQueryConstraint
- Defined in:
- lib/parse/query/constraints.rb
Overview
Equivalent to the $within Parse query operation and $box geopoint
constraint. The rectangular bounding box is defined by a southwest point as
the first parameter, followed by the a northeast point. Please note that Geo
box queries that cross the international date lines are not currently
supported by Parse.
q.where :field.within_box => [soutwestGeoPoint, northeastGeoPoint]
sw = Parse::GeoPoint.new 32.82, -117.23 # San Diego ne = Parse::GeoPoint.new 36.12, -115.31 # Las Vegas
get all PlaceObjects inside this bounding box
PlaceObject.all :location.within_box => [sw,ne]
Instance Method Summary collapse
-
#build ⇒ Hash
The compiled constraint.
-
#within_box ⇒ WithinGeoBoxQueryConstraint
A registered method on a symbol to create the constraint.
Instance Method Details
#build ⇒ Hash
Returns the compiled constraint.
1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 |
# File 'lib/parse/query/constraints.rb', line 1837 def build geopoint_values = formatted_value unless geopoint_values.is_a?(Array) && geopoint_values.count == 2 && geopoint_values.first.is_a?(Parse::GeoPoint) && geopoint_values.last.is_a?(Parse::GeoPoint) raise(ArgumentError, "[Parse::Query] Invalid query value parameter passed to `within_box` constraint. " + "Values in array must be `Parse::GeoPoint` objects and " + "it should be in an array format: [southwestPoint, northeastPoint]") end { @operation.operand => { :$within => { :$box => geopoint_values } } } end |
#within_box ⇒ WithinGeoBoxQueryConstraint
A registered method on a symbol to create the constraint. Maps to Parse operator "$within".
1833 |
# File 'lib/parse/query/constraints.rb', line 1833 constraint_keyword :$within |