README.md in mongoid_geospatial-2.8.3 vs README.md in mongoid_geospatial-3.0.0
- old
+ new
@@ -17,11 +17,11 @@
Quick Start
-----------
This gem focus on (making helpers for) spatial features MongoDB has.
-You can also use an external Geometric/Spatial alongside.
+You may also use an external Geometric/Spatial gem alongside.
# Gemfile
gem 'mongoid_geospatial'
# A place to illustrate Point, Line and Polygon
@@ -45,19 +45,16 @@
For geo points, an extra macro `geo_field` is available
- class Place
- include Mongoid::Document
- include Mongoid::Geospatial
-
- # field :location, type: Point, spatial: true
geo_field :location
- end
+ # Will generate:
+ field :location, type: Point, spatial: true
+
Generate indexes on MongoDB:
rake db:mongoid:create_indexes
@@ -102,16 +99,19 @@
hudson.mouth # => [-74.026667, 40.703056]
If you need a hash
- hudson.mouth.to_hsh # => { x: -74.026667, y: 40.703056 }
+ hudson.mouth.to_hsh # => { x: -74.026667, y: 40.703056 }
If you are using GeoRuby or RGeo
- hudson.mouth.to_geo # => NiceGeolib::Point
+ hudson.mouth.to_geo # => GeoRuby::Point
+ hudson.mouth.to_rgeo # => RGeo::Point
+
+
Conventions:
This lib uses #x and #y everywhere.
It's shorter than lat or lng or another variation that also confuses.
A point is a 2D mathematical notation, longitude/latitude is when you use that notation to map an sphere.
@@ -203,12 +203,14 @@
Geometry Helpers
----------------
We currently support GeoRuby and RGeo.
-If you require one of those, a #to_geo method will be available to all
-spatial fields, returning the external library corresponding object.
+If you require one of those, a #to_geo and #to_rgeo, respectivelly,
+method(s) will be available to all spatial fields, returning the
+external library corresponding object.
+
To illustrate:
class Person
include Mongoid::Document
include Mongoid::Geospatial
@@ -222,27 +224,27 @@
point.class # Mongoid::Geospatial::Point
point.to_geo.class # GeoRuby::SimpleFeatures::Point
# Example with RGeo
point.class # Mongoid::Geospatial::Point
- point.to_geo.class # RGeo::Geographic::SphericalPointImpl
+ point.to_rgeo.class # RGeo::Geographic::SphericalPointImpl
Configure
---------
Assemble it as you need (use a initializer file):
With RGeo
- Mongoid::Geospatial.use_rgeo
+ Mongoid::Geospatial.with_rgeo!
# Optional
# Mongoid::Geospatial.factory = RGeo::Geographic.spherical_factory
With GeoRuby
- Mongoid::Geospatial.use_georuby
+ Mongoid::Geospatial.with_georuby!
Defaults (change if you know what you're doing)
Mongoid::Geospatial.lng_symbol = :x