postgres_ext-postgis 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0249f0e74ab37125453139a6dfbacaacfc41949d
4
- data.tar.gz: 2590696b3a4a761ce7ddce79ee37a9eb0d5cde2f
3
+ metadata.gz: 4e706507f13ca6fab29f8149ba2602cd7db3fa3b
4
+ data.tar.gz: f20e89d32e6c79ba09bfdbde445b8db66e99756b
5
5
  SHA512:
6
- metadata.gz: d09d2c4474a3ef99b59168258a3e032ff913d6fa391c992540b680c206127ae613d171ba8ec824fc3d04447026388be5064c7fe2ae33a769477ddc27094772c2
7
- data.tar.gz: a1297753c17dc788e4085cffd815bf45bf3852051572441ef6dd794647044bc5b762a97938b686f61911dd2ca42348d9cf8a1ae8fba4d8271bb8d52b92d8b121
6
+ metadata.gz: 97d68faeddbd2314dc823d202b4f9b4cf3ad0ef6f3d9aae1f6ea17e99a5c06e406fd036ebf6f2e62c8f6040c2f3c3942ba07b874f6aa3ec10001b339305b7b72
7
+ data.tar.gz: 5d3b8aba42f5d1c530fd24e00f885e5ab029ef5082e030f9f7ee5bf8944a0aada39caa60bafa384be8ece64898b65065979ea57423b4291a33ef0c3a18d0d16a
data/Rakefile CHANGED
@@ -64,6 +64,7 @@ namespace :db do
64
64
 
65
65
  ActiveRecord::Base.connection.create_table :places, force: true do |t|
66
66
  t.geometry :location
67
+ t.column :location_2, :geography
67
68
  end
68
69
 
69
70
  puts 'Database migrated'
@@ -76,6 +76,8 @@ module PostgresExt::Postgis::ActiveRecord::ConnectionAdapters
76
76
 
77
77
  def simplified_type(field_type)
78
78
  case field_type
79
+ when /geography/
80
+ :geography
79
81
  when /geometry(\(\w,\d\))?/
80
82
  :geometry
81
83
  else
@@ -89,6 +89,7 @@ module PostgresExt::Postgis::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
89
89
  module OID
90
90
  def self.prepended(klass)
91
91
  klass.register_type 'geometry', OID::Geometry.new
92
+ klass.register_type 'geography', OID::Geometry.new
92
93
  end
93
94
 
94
95
  class Geometry < ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::Type
@@ -1,5 +1,5 @@
1
1
  module PostgresExt
2
2
  module Postgis
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
@@ -36,3 +36,28 @@ SQL
36
36
  place.location.srid.must_equal 1
37
37
  end
38
38
  end
39
+
40
+ describe 'geography casts' do
41
+ it 'converts WKB from PostgreSQL into RGeo objects' do
42
+ connection.execute <<-SQL
43
+ INSERT INTO places (location_2)
44
+ VALUES (ST_GeographyFromText('POINT(1 1)'));
45
+ SQL
46
+ place = Place.first
47
+
48
+ (RGeo::Feature::Point === place.location_2).must_equal true
49
+ place.location_2.x.must_equal 1
50
+ place.location_2.y.must_equal 1
51
+ place.location_2.srid.must_equal 4326
52
+ end
53
+
54
+ it 'parses WKT attributes into RGeo objects' do
55
+ place = Place.new
56
+
57
+ place.location_2 = 'SRID=4623;POINT(1 1)'
58
+ (RGeo::Feature::Point === place.location_2).must_equal true
59
+ place.location_2.x.must_equal 1
60
+ place.location_2.y.must_equal 1
61
+ place.location_2.srid.must_equal 4623
62
+ end
63
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postgres_ext-postgis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan McClain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: postgres_ext