activerecord-postgis 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/active_record/connection_adapters/postgis/schema_dumper.rb +5 -0
- data/lib/active_record/connection_adapters/postgis/type/geometry.rb +2 -2
- data/lib/active_record/connection_adapters/postgis/type/geometry_collection.rb +2 -2
- data/lib/active_record/connection_adapters/postgis/type/multi_line_string.rb +2 -2
- data/lib/active_record/connection_adapters/postgis/type/multi_point.rb +2 -2
- data/lib/active_record/connection_adapters/postgis/type/polygon.rb +2 -2
- data/lib/active_record/connection_adapters/postgis/version.rb +1 -1
- data/lib/active_record/connection_adapters/postgis.rb +9 -8
- data/lib/activerecord-postgis.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b452469d6861f42a259853b4f6b3f7e5a694d98c325141d5a43ac09eaf40e967
|
4
|
+
data.tar.gz: ada960ed4d93542ae2f2f805412d8b39dc58ae52cfa1612b8007e53e2bf2952f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3c0f7fa79a22ba014655f18198bc4c048f3287fa6ade5e5c1442e8f0099c910394bc7592939b3a8c911670d9c4a54b5bbb8d0d29b568dddaf0406cba310c453
|
7
|
+
data.tar.gz: 14c0462864a39e967b1c2c684a0dda6a6e0d6b1d902c87561398dc214f4934238594f8847b26ba33e52df669f00d998828df0c2ca29305fc56f94209e45019bc
|
@@ -64,6 +64,11 @@ module ActiveRecord
|
|
64
64
|
geom_type = $2
|
65
65
|
srid = $3&.to_i
|
66
66
|
|
67
|
+
# Add geographic option for geography columns
|
68
|
+
if spatial_type.downcase == "geography"
|
69
|
+
spec[:geographic] = true
|
70
|
+
end
|
71
|
+
|
67
72
|
# Add SRID if not default
|
68
73
|
if srid && srid != default_srid(spatial_type)
|
69
74
|
spec[:srid] = srid
|
@@ -7,8 +7,8 @@ module ActiveRecord
|
|
7
7
|
module PostGIS
|
8
8
|
module Type
|
9
9
|
class Geometry < Spatial
|
10
|
-
def initialize(srid: 0, has_z: false, has_m: false)
|
11
|
-
super(geo_type: "geometry", srid: srid, has_z: has_z, has_m: has_m)
|
10
|
+
def initialize(srid: 0, has_z: false, has_m: false, geographic: false)
|
11
|
+
super(geo_type: "geometry", srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
|
12
12
|
end
|
13
13
|
|
14
14
|
def type
|
@@ -7,8 +7,8 @@ module ActiveRecord
|
|
7
7
|
module PostGIS
|
8
8
|
module Type
|
9
9
|
class GeometryCollection < Spatial
|
10
|
-
def initialize(srid: 0, has_z: false, has_m: false)
|
11
|
-
super(geo_type: "geometry_collection", srid: srid, has_z: has_z, has_m: has_m)
|
10
|
+
def initialize(srid: 0, has_z: false, has_m: false, geographic: false)
|
11
|
+
super(geo_type: "geometry_collection", srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
|
12
12
|
end
|
13
13
|
|
14
14
|
def type
|
@@ -7,8 +7,8 @@ module ActiveRecord
|
|
7
7
|
module PostGIS
|
8
8
|
module Type
|
9
9
|
class MultiLineString < Spatial
|
10
|
-
def initialize(srid: 0, has_z: false, has_m: false)
|
11
|
-
super(geo_type: "multi_line_string", srid: srid, has_z: has_z, has_m: has_m)
|
10
|
+
def initialize(srid: 0, has_z: false, has_m: false, geographic: false)
|
11
|
+
super(geo_type: "multi_line_string", srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
|
12
12
|
end
|
13
13
|
|
14
14
|
def type
|
@@ -7,8 +7,8 @@ module ActiveRecord
|
|
7
7
|
module PostGIS
|
8
8
|
module Type
|
9
9
|
class MultiPoint < Spatial
|
10
|
-
def initialize(srid: 0, has_z: false, has_m: false)
|
11
|
-
super(geo_type: "multi_point", srid: srid, has_z: has_z, has_m: has_m)
|
10
|
+
def initialize(srid: 0, has_z: false, has_m: false, geographic: false)
|
11
|
+
super(geo_type: "multi_point", srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
|
12
12
|
end
|
13
13
|
|
14
14
|
def type
|
@@ -7,8 +7,8 @@ module ActiveRecord
|
|
7
7
|
module PostGIS
|
8
8
|
module Type
|
9
9
|
class Polygon < Spatial
|
10
|
-
def initialize(srid: 0, has_z: false, has_m: false)
|
11
|
-
super(geo_type: "polygon", srid: srid, has_z: has_z, has_m: has_m)
|
10
|
+
def initialize(srid: 0, has_z: false, has_m: false, geographic: false)
|
11
|
+
super(geo_type: "polygon", srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
|
12
12
|
end
|
13
13
|
|
14
14
|
def type
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_record/connection_adapters/postgresql_adapter"
|
3
4
|
require_relative "postgis/version"
|
4
5
|
require_relative "postgis/type/geography"
|
5
6
|
require_relative "postgis/type/geometry"
|
@@ -37,18 +38,18 @@ module ActiveRecord
|
|
37
38
|
@initialized = true
|
38
39
|
|
39
40
|
# Extend PostgreSQL Column class with spatial functionality
|
40
|
-
|
41
|
+
PostgreSQL::Column.include(ColumnExtensions)
|
41
42
|
|
42
43
|
# Add spatial object quoting support
|
43
|
-
|
44
|
+
PostgreSQLAdapter.prepend(Quoting)
|
44
45
|
|
45
46
|
# Allow PostGIS specific options in table definitions
|
46
47
|
# The `define_column_methods` call already makes these available on the `TableDefinition` instance.
|
47
48
|
# The issue might be deeper in how schema.rb is processed or how options are validated.
|
48
49
|
# Let's ensure that the column methods are defined *before* any schema loading that might trigger validation.
|
49
50
|
|
50
|
-
|
51
|
-
|
51
|
+
PostgreSQL::Table.include(
|
52
|
+
PostGIS::TableDefinition
|
52
53
|
)
|
53
54
|
|
54
55
|
# Using st_* prefix to avoid conflicts with PostgreSQL native geometric types
|
@@ -74,7 +75,7 @@ module ActiveRecord
|
|
74
75
|
|
75
76
|
|
76
77
|
# Tell Rails these are valid column methods for schema dumping - PostgreSQL only
|
77
|
-
|
78
|
+
PostgreSQL::TableDefinition.send(:define_column_methods,
|
78
79
|
:st_geography, :st_geometry, :st_geometry_collection, :st_line_string,
|
79
80
|
:st_multi_line_string, :st_multi_point, :st_multi_polygon, :st_point, :st_polygon,
|
80
81
|
# Legacy column methods for compatibility with activerecord-postgis-adapter
|
@@ -83,10 +84,10 @@ module ActiveRecord
|
|
83
84
|
*SPATIAL_OPTIONS_FOR_REGISTRATION)
|
84
85
|
|
85
86
|
# prevent unknown OID warning and register PostGIS types
|
86
|
-
|
87
|
+
PostgreSQLAdapter.singleton_class.prepend(RegisterTypes)
|
87
88
|
|
88
89
|
# Prepend our extensions to handle spatial columns
|
89
|
-
|
90
|
+
PostgreSQLAdapter.prepend(AdapterExtensions)
|
90
91
|
|
91
92
|
# Register spatial types with ActiveRecord::Type - use st_* prefix to avoid conflicts
|
92
93
|
adapter_name = :postgresql
|
@@ -113,7 +114,7 @@ module ActiveRecord
|
|
113
114
|
ActiveRecord::Type.register(:polygon, Type::Polygon, adapter: adapter_name)
|
114
115
|
|
115
116
|
# Ignore PostGIS system tables in schema dumps - PostgreSQL specific
|
116
|
-
|
117
|
+
PostgreSQL::SchemaDumper.ignore_tables |= %w[
|
117
118
|
geography_columns
|
118
119
|
geometry_columns
|
119
120
|
layer
|
data/lib/activerecord-postgis.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# dependencies
|
4
3
|
require "active_support"
|
5
4
|
require "active_record"
|
5
|
+
require "active_record/connection_adapters"
|
6
|
+
require_relative "active_record/connection_adapters/postgis"
|
7
|
+
require "rgeo-activerecord"
|
6
8
|
|
7
9
|
# Initialize when PostgreSQL adapter is loaded
|
8
10
|
ActiveSupport.on_load(:active_record_postgresqladapter) do
|
9
|
-
require "rgeo-activerecord"
|
10
|
-
require_relative "active_record/connection_adapters/postgis"
|
11
11
|
ActiveRecord::ConnectionAdapters::PostGIS.initialize!
|
12
12
|
end
|