Class: Parse::GeoJSON::MultiPolygon
- Defined in:
- lib/parse/model/geojson.rb
Overview
‘MultiPolygon` — an Array of Polygons, each Polygon an Array of linear rings, each ring an Array of `[lng, lat]` pairs. The canonical use case is administrative or territorial regions made up of disjoint pieces (Hawaii, Indonesia, multi-island service areas, postal-code clusters).
GeoJSON nesting depth is 4: ‘coordinates[ring][lng_or_lat]`. Each ring must contain ≥ 4 points and be explicitly closed.
Constant Summary collapse
- TYPE =
"MultiPolygon"- MIN_RING_POINTS =
4
Constants inherited from Geometry
Constants inherited from Model
Model::CLASS_AUDIENCE, Model::CLASS_INSTALLATION, Model::CLASS_JOB_SCHEDULE, Model::CLASS_JOB_STATUS, Model::CLASS_PRODUCT, Model::CLASS_PUSH_STATUS, Model::CLASS_ROLE, Model::CLASS_SCHEMA, Model::CLASS_SESSION, Model::CLASS_USER, Model::ID, Model::KEY_CLASS_NAME, Model::KEY_CREATED_AT, Model::KEY_OBJECT_ID, Model::KEY_UPDATED_AT, Model::OBJECT_ID, Model::TYPE_ACL, Model::TYPE_BYTES, Model::TYPE_DATE, Model::TYPE_FIELD, Model::TYPE_FILE, Model::TYPE_GEOPOINT, Model::TYPE_NUMBER, Model::TYPE_OBJECT, Model::TYPE_POINTER, Model::TYPE_POLYGON, Model::TYPE_RELATION
Instance Attribute Summary
Attributes inherited from Geometry
Instance Method Summary collapse
-
#polygons ⇒ Array<Parse::Polygon>
Each member polygon as a Polygon (with axis swap back to Parse’s ‘[lat, lng]`).
Methods inherited from Geometry
#==, from_geojson, geojson_type, #geojson_type, #initialize, #inspect, #to_geojson, #to_json
Methods inherited from Model
Methods included from Client::Connectable
Constructor Details
This class inherits a constructor from Parse::GeoJSON::Geometry
Instance Method Details
#polygons ⇒ Array<Parse::Polygon>
211 212 213 214 215 216 |
# File 'lib/parse/model/geojson.rb', line 211 def polygons @coordinates.map do |rings| outer = rings.first Parse::Polygon.new(outer.map { |(lng, lat)| [lat.to_f, lng.to_f] }) end end |