tools/lib/spatial_adapter/README in GeoRuby-1.3.1 vs tools/lib/spatial_adapter/README in GeoRuby-1.3.2

- old
+ new

@@ -27,11 +27,11 @@ add_index "table_points", "geom", :spatial=>true end Here is a related statement valid for MySql version <= 5.0.16 : ActiveRecord::Schema.define do - create_table "table_points", :options=>"ENGINE=MyISAM", :force => true do |t| + create_table "table_points", ;options=>"ENGINE=MyISAM", :force => true do |t| t.column "data", :string t.column "geom", :point, :null=>false end add_index "table_points", "geom", :spatial=>true @@ -61,15 +61,15 @@ pt = TablePoint.find_first puts pt.geom.x #access the geom column like any other ==== 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 the spatial adapter provides a method to do it for you: +to_fixture_format+. It works for both MySQL and PostGIS (although the string returned is different for each database). You would use it like this, if the geometric column is a point: +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 the spatial adapter provides a method to do it for you: +to_yaml+. It works for both MySQL and PostGIS (although the string returned is different for each database). You would use it like this, if the geometric column is a point: fixture: id: 1 data: HELLO - geom: <%= Point.from_x_y(123.5,321.9).to_fixture_format %> + geom: <%= Point.from_x_y(123.5,321.9).to_yaml %> ==== 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 box equality test in PostGIS, it uses a bounding box intersection: && in PostGIS and MBRIntersects in MySQL, which can both make use of a spatial index if one is present to speed up the queries. You could use this query, for example, if you need to display data from the database: You would want only the geometries which are in the screen rectangle and you could use a bounding box query for that. Since this is a common case, it is the default. You have 2 ways to use the find_by_[geom_column]: Either by passing a geometric object directly, or passing an array with the 2 opposite corners of a bounding box (with 2 or 3 coordinates depending of the dimension of the data). Park.find_by_geom(LineString.from_coordinates([[1.4,5.6],[2.7,8.9],[1.6,5.6]])) @@ -101,10 +101,10 @@ - The PostGIS adapter and the MySql Spatial adapter have been merged into one plugin. The correct files to load is determined using the type of connection defined in the environment. - Geometric columns can now be dumped just like other base data types. This means you can use the ruby schema mode, even if you use the plugin. - Support of M dimensions in migrations. The <tt>:dimension</tt> key in the column definition has disappeared and has been replaced by <tt>:with_z</tt> and <tt>:with_m</tt>. - Addition of unit tests. At the plugin root, Run <tt>rake test:mysql</tt> to run the mysql tests and <tt>rake test:postgis</tt> for the postgis ones. You will need to configure your connection in <tt>test/db/database_mysql.yml</tt> and <tt>test/db/database_postgis.yml</tt>. If you get errors on your platform, please report to mailto:guilhem.vellut+georuby@gmail.com. - Addition of a find_by methods with a special behaviour for geometries -- Addition of a to_fixture_format method to use inside a YAML fixture +- Addition of a to_yaml method to use inside a YAML fixture ===TODO - Support of other geometric datatype libraries in addition to GeoRuby - Tutorials \ No newline at end of file