README.rdoc in postgis_adapter-0.5.1 vs README.rdoc in postgis_adapter-0.7.1

- old
+ new

@@ -5,10 +5,11 @@ It also provides a way to manage these columns in migrations. This fork adds handy methods to make geometrical calculations on postgis. Based on http://georuby.rubyforge.org Spatial Adapter +RDocs - http://docs.github.com/nofxx/postgis_adapter Postgis Manual - http://postgis.refractions.net/documentation/manual-svn *PostGIS and Rails 2+ only*. @@ -30,10 +31,11 @@ Rails: config.gem "postgis_adapter" + Github version: sudo gem install nofxx-postgis_adapter --source http://gems.github.com @@ -75,35 +77,43 @@ == PostGIS Functions Here are this fork additions. To use it: + acts_as_geom [column_name] => [geom_type] + +Examples: + + class POI < ActiveRecord::Base + acts_as_geom :geom => :point + end + class Street < ActiveRecord::Base - acts_as_geom :line + acts_as_geom :line => :line_string end ... - @place = Poi.new( :data => **Point** ) - @park = Park.new( :area => **Polygon** ) - @street = Street.new( :line => **LineString** ) == Play! + @place = Poi.new( :geom => Point.from_x_y(10,20) ) + @park = Park.new( :area => **Polygon** ) + @street = Street.new( :line => **LineString** ) + @place.inside?(@park) => true @place.in_bounds?(@park, 0.5) # margin => false @place.outside?(@park) - @street.crosses?(@park) - @area.contains?(@place) + ... === Polygons: @park.area @@ -119,21 +129,18 @@ @park.area(SRID) => Area with new SRID -=== Line Strings: +=== LineStrings: @street_east.intersects?(@street_west) => false @street_central.length => 4508.53636 - @street_central.length(:miles) - => 2.81798593 - @street.length_spheroid => 4.40853636 === Class Methods @@ -145,11 +152,11 @@ => [Array streets in order by distance... Country.contain(@point) => The Conutry that contains the point - Areas.contains(@point) + Area.contains(@point) => [Array of areas contains the point... === BBox Support @@ -181,27 +188,20 @@ @area.bbox "|>>", @point @area.bbox "@", @park - === Warning *To be fixed:* This only supports one geom column per model. Still looking for the best way to implement a multi geom. http://nofxx.lighthouseapp.com/projects/20712/tickets/3-multiple-geoms-in-model -=== Wiki - -Check out the wiki pages (http://github.com/nofxx/postgis_adapter/wikis). -For all functions. - - === Find_by find_by_*column* has been redefined when column is of a geometric type. Instead of using the Rails default '=' operator, for which I can't see a definition for MySql spatial datatypes and which performs a bounding @@ -235,20 +235,33 @@ Here is an example of code for the creation of a table with a geometric column in PostGIS, along with the addition of a spatial index on the column : ActiveRecord::Schema.define do - create_table :places do |t| - t.string :name - t.point :geom, :srid => 123, :with_z => true, :null => false + create_table :places do |t| + t.string :name + t.point :geom, :srid => 4326, :with_z => true, :null => false t.timestamps end - add_index :table_points, :geom, :spatial=>true + + add_index :places, :geom, :spatial => true end +Types: + + point + polygon + line_string + multi_point + multi_polygon + multi_line_string + geometry + geometry_collection + + === Fixtures If you use fixtures for your unit tests, at some point, you will want to input a geometry. You could transform your geometries to a form suitable for YAML yourself everytime but @@ -309,17 +322,17 @@ Postgis Adapter is released under the MIT license. == Support -Tested using rails 2.2.2/2.3.0 / postgresql 8.3.5 / postgis 1.3.3 / linux / osx +Tested using rails 2.2.2/2.3.3 / postgresql 8.3.7 / postgis 1.3.3 / linux / osx Any questions, enhancement proposals, bug notifications or corrections: === PostgisAdapter -Project Tracker http://nofxx.lighthouseapp.com/projects/20712-postgis_adapter +http://github.com/nofxx/postgis_adapter/issues === SpatialAdapter http://georuby.rubyforge.org