activerecord-postgis 0.6.0 → 0.6.2
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/spatial_column_type.rb +5 -5
- data/lib/active_record/connection_adapters/postgis/table_definition.rb +14 -2
- data/lib/active_record/connection_adapters/postgis/type/spatial.rb +15 -10
- data/lib/active_record/connection_adapters/postgis/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c4caab5fe6b63c11ebb789f2e77cb8997ac1c495333cc08e2cba397e043916fa
|
|
4
|
+
data.tar.gz: a8688b2c439daf278f07fe7c9ff00fd791ef82f964a74f0032ec088e5a495144
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 55b212ec58aff548cd55062d88728b75383859b246a66cd49cda54e1f86d2acde0ad3b6a3df8d921e4e7678efe99c9898f78efa4557e978b9361e520996bd823
|
|
7
|
+
data.tar.gz: 5c33782d1350c14a8f8bf1edbe3ae8495bd40527293241f80e5d6b140f964c70b953d2f3fc8b513a1c5df8fb218c896540d6fcc80645ef4573c7e7460abc11e0
|
|
@@ -25,9 +25,9 @@ module ActiveRecord
|
|
|
25
25
|
has_z = geo_part.end_with?("Z") || geo_part.end_with?("ZM")
|
|
26
26
|
has_m = geo_part.end_with?("M") || geo_part.end_with?("ZM")
|
|
27
27
|
end
|
|
28
|
-
elsif o.limit.is_a?(String) && o.limit.include?(",")
|
|
28
|
+
elsif o.options[:limit].is_a?(String) && o.options[:limit].include?(",")
|
|
29
29
|
# Fallback to parsing limit string (for schema loading)
|
|
30
|
-
geo_part, srid_part = o.limit.split(",", 2)
|
|
30
|
+
geo_part, srid_part = o.options[:limit].split(",", 2)
|
|
31
31
|
srid = srid_part.to_i if srid_part && !srid_part.empty?
|
|
32
32
|
if geo_part
|
|
33
33
|
has_z = geo_part.end_with?("Z") || geo_part.end_with?("ZM")
|
|
@@ -42,9 +42,9 @@ module ActiveRecord
|
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
sql_type = type_to_sql(o.type.to_sym,
|
|
45
|
-
limit: o.options[:spatial_sql] || o.limit,
|
|
46
|
-
precision: o.precision,
|
|
47
|
-
scale: o.scale,
|
|
45
|
+
limit: o.options[:spatial_sql] || o.options[:limit],
|
|
46
|
+
precision: o.options[:precision],
|
|
47
|
+
scale: o.options[:scale],
|
|
48
48
|
srid: srid,
|
|
49
49
|
geographic: geographic,
|
|
50
50
|
has_z: has_z,
|
|
@@ -22,8 +22,9 @@ module ActiveRecord
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
if spatial_column_type?(col_type)
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
case (limit = options.delete(:limit))
|
|
26
|
+
when ::Hash then options.merge!(limit)
|
|
27
|
+
when ::String then options.reverse_merge!(ColumnDefinitionUtils.options_from_limit(limit))
|
|
27
28
|
end
|
|
28
29
|
|
|
29
30
|
# Set geographic option for geography types
|
|
@@ -125,6 +126,17 @@ module ActiveRecord
|
|
|
125
126
|
end
|
|
126
127
|
end
|
|
127
128
|
|
|
129
|
+
# Inverse of limit_from_options: "POINTZ,4326" => { srid: 4326, has_z: true }
|
|
130
|
+
def options_from_limit(limit)
|
|
131
|
+
geo_part, srid_part = limit.split(",", 2)
|
|
132
|
+
dimensions = geo_part.to_s.upcase[/(ZM|Z|M)\z/].to_s
|
|
133
|
+
options = {}
|
|
134
|
+
options[:srid] = Integer(srid_part) if srid_part.present?
|
|
135
|
+
options[:has_z] = true if dimensions.include?("Z")
|
|
136
|
+
options[:has_m] = true if dimensions.include?("M")
|
|
137
|
+
options
|
|
138
|
+
end
|
|
139
|
+
|
|
128
140
|
def limit_from_options(type, options = {})
|
|
129
141
|
has_z = options[:has_z] ? "Z" : ""
|
|
130
142
|
has_m = options[:has_m] ? "M" : ""
|
|
@@ -15,13 +15,6 @@ module ActiveRecord
|
|
|
15
15
|
@has_z = has_z
|
|
16
16
|
@has_m = has_m
|
|
17
17
|
@geographic = geographic
|
|
18
|
-
@factory = RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
|
|
19
|
-
geo_type: @geo_type.underscore,
|
|
20
|
-
srid: srid,
|
|
21
|
-
has_z: has_z,
|
|
22
|
-
has_m: has_m,
|
|
23
|
-
sql_type: (@geographic ? "geography" : "geometry")
|
|
24
|
-
)
|
|
25
18
|
end
|
|
26
19
|
|
|
27
20
|
def type
|
|
@@ -40,6 +33,18 @@ module ActiveRecord
|
|
|
40
33
|
|
|
41
34
|
private
|
|
42
35
|
|
|
36
|
+
# Not memoized: types are frozen for Ractor sharing, and factories
|
|
37
|
+
# hold mutexes/procs. SpatialFactoryStore already caches them.
|
|
38
|
+
def factory
|
|
39
|
+
RGeo::ActiveRecord::SpatialFactoryStore.instance.factory(
|
|
40
|
+
geo_type: @geo_type.underscore,
|
|
41
|
+
srid: @srid,
|
|
42
|
+
has_z: @has_z,
|
|
43
|
+
has_m: @has_m,
|
|
44
|
+
sql_type: (@geographic ? "geography" : "geometry")
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
43
48
|
def cast_value(value)
|
|
44
49
|
case value
|
|
45
50
|
when ::RGeo::Feature::Instance
|
|
@@ -56,11 +61,11 @@ module ActiveRecord
|
|
|
56
61
|
def parse_wkt(string)
|
|
57
62
|
if binary_string?(string)
|
|
58
63
|
# Parse WKB (Well-Known Binary) format
|
|
59
|
-
wkb_parser = RGeo::WKRep::WKBParser.new(
|
|
64
|
+
wkb_parser = RGeo::WKRep::WKBParser.new(factory, support_ewkb: true, default_srid: @srid)
|
|
60
65
|
wkb_parser.parse(string)
|
|
61
66
|
else
|
|
62
67
|
# Parse WKT (Well-Known Text) format
|
|
63
|
-
wkt_parser = RGeo::WKRep::WKTParser.new(
|
|
68
|
+
wkt_parser = RGeo::WKRep::WKTParser.new(factory, support_ewkt: true, default_srid: @srid)
|
|
64
69
|
wkt_parser.parse(string)
|
|
65
70
|
end
|
|
66
71
|
rescue RGeo::Error::ParseError
|
|
@@ -74,7 +79,7 @@ module ActiveRecord
|
|
|
74
79
|
def parse_hash(hash)
|
|
75
80
|
# Support GeoJSON-style hash
|
|
76
81
|
if hash["type"] && hash["coordinates"]
|
|
77
|
-
RGeo::GeoJSON.decode(hash.to_json, geo_factory:
|
|
82
|
+
RGeo::GeoJSON.decode(hash.to_json, geo_factory: factory)
|
|
78
83
|
else
|
|
79
84
|
nil
|
|
80
85
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activerecord-postgis
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Abdelkader Boudih
|
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
136
136
|
- !ruby/object:Gem::Version
|
|
137
137
|
version: '0'
|
|
138
138
|
requirements: []
|
|
139
|
-
rubygems_version: 4.0.
|
|
139
|
+
rubygems_version: 4.0.20
|
|
140
140
|
specification_version: 4
|
|
141
141
|
summary: PostGIS Type support for ActiveRecord
|
|
142
142
|
test_files: []
|