Permalink
Browse files

some readme

  • Loading branch information...
nofxx committed Sep 22, 2012
1 parent 04021c4 commit eb0c2d0a6cad2214837eea0316b1f0a6e77b02b6
Showing with 25 additions and 7 deletions.
  1. +25 −7 README.md
View
@@ -34,13 +34,13 @@ You can also use an external Geometric/Spatial alongside.
# Just like mongoid,
field :name, type: String
# define your field, but choose a geometry type:
- field :location, type: Point, :spatial => true
+ field :location, type: Point
field :route, type: Linestring
field :area, type: Polygon
# If your are going to query on your points, don't forget to index:
spatial_index :location
-
+ # You can index points with :spatial => true option too, see below.
end
@@ -234,13 +234,13 @@ You can create Point, Line, Circle, Box and Polygon on your models:
include Mongoid::Document
include Mongoid::Geospatial
- field :location, type: Point
+ field :location, type: Point, :spatial => true, :delegate => true
- field :route, type: Line
- field :area, type: Polygon
+ field :route, type: Line
+ field :area, type: Polygon
- field :square, type: Box
- field :around, type: Circle
+ field :square, type: Box
+ field :around, type: Circle
# spatial indexing
spatial_index :mouth
@@ -253,6 +253,24 @@ You can create Point, Line, Circle, Box and Polygon on your models:
end
+Helpers
+-------
+
+You can use `:spatial => true` to add an '2d' index automatically,
+No need for `spatial_index :location`:
+
+
+ field :location, type: Point, :spatial => true
+
+
+You can delegate some point methods to the instance itself:
+
+
+ field :location, type: Point, :delegate => true
+
+
+Now instead of `instance.location.x` you may call `instance.x`.
+
Nearby
------

0 comments on commit eb0c2d0

Please sign in to comment.