README.md in armg-0.1.0 vs README.md in armg-0.2.0
- old
+ new
@@ -1,9 +1,11 @@
# Armg
Add MySQL geometry type to Active Record.
+[![Build Status](https://travis-ci.org/winebarrel/armg.svg?branch=master)](https://travis-ci.org/winebarrel/armg)
+
## Installation
Add this line to your application's Gemfile:
```ruby
@@ -22,28 +24,21 @@
```ruby
require 'active_record'
require 'armg'
-ActiveRecord::Base.establish_connection(adapter: 'mysql2', database: 'my_app');
+ActiveRecord::Base.establish_connection(adapter: 'mysql2', database: 'my_db');
-ActiveRecord::Migration.create_table :geoms do |t|
- t.geometry 'location'
+ActiveRecord::Migration.create_table :geoms, options: 'ENGINE=MyISAM' do |t|
+ t.geometry 'location', null: false
+ t.index ['location'], name: 'idx_location', type: :spatial
end
class Geom < ActiveRecord::Base; end
-Geom.create!(geometry: [1, 1.0, 1.0])
-#=> #<Geom id: 15 geometry: [1, 1.0, 1.0]>
+wkt_parser = RGeo::WKRep::WKTParser.new(nil, support_ewkt: true)
+point = wkt_parser.parse('SRID=4326;Point(-122.1 47.3)')
+Geom.create!(location: point)
-# 1: Point
-# 2: LineString
-# 3: Polygon
-# 4: MultiPoint
-# 5: MultiLineString
-# 6: MultiPolygon
-# 7:GeometryCollection.
-# see https://dev.mysql.com/doc/refman/5.6/en/gis-data-formats.html
-
Geom.first
-#=> #<Geom id: 1, geometry: [1, 1.0, 1.0]>
+#=> #<Geom id: 1, location: #<RGeo::Cartesian::PointImpl:0x... "POINT (-122.1 47.3)">>
```