rgeo 0.1.20 → 0.1.21
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.
- data/History.rdoc +10 -0
- data/README.rdoc +38 -35
- data/Version +1 -1
- data/lib/active_record/connection_adapters/mysql2spatial_adapter.rb +1 -3
- data/lib/active_record/connection_adapters/mysqlspatial_adapter.rb +4 -4
- data/lib/active_record/connection_adapters/postgis_adapter.rb +426 -0
- data/lib/active_record/connection_adapters/spatialite_adapter.rb +488 -0
- data/lib/rgeo.rb +10 -29
- data/lib/rgeo/active_record/arel_modifications.rb +1 -0
- data/lib/rgeo/active_record/base_modifications.rb +27 -10
- data/lib/rgeo/active_record/common.rb +128 -0
- data/lib/rgeo/active_record/mysql_common.rb +14 -51
- data/lib/rgeo/cartesian/factory.rb +2 -2
- data/lib/rgeo/coord_sys.rb +1 -1
- data/lib/rgeo/coord_sys/proj4.rb +3 -2
- data/lib/rgeo/error.rb +0 -3
- data/lib/rgeo/feature.rb +1 -3
- data/lib/rgeo/feature/factory_generator.rb +8 -0
- data/lib/rgeo/geography/factory.rb +2 -2
- data/lib/rgeo/geography/interface.rb +3 -3
- data/lib/rgeo/geos/zm_factory.rb +2 -2
- data/lib/rgeo/wkrep/wkb_parser.rb +35 -36
- data/lib/rgeo/wkrep/wkt_parser.rb +36 -38
- data/test/active_record/common_setup_methods.rb +129 -0
- data/test/active_record/readme.txt +10 -0
- data/test/active_record/tc_mysqlspatial.rb +22 -71
- data/test/active_record/tc_postgis.rb +282 -0
- data/test/active_record/tc_spatialite.rb +198 -0
- data/test/coord_sys/tc_proj4.rb +12 -5
- data/test/projected_geography/tc_geometry_collection.rb +1 -1
- data/test/projected_geography/tc_line_string.rb +1 -1
- data/test/projected_geography/tc_multi_line_string.rb +1 -1
- data/test/projected_geography/tc_multi_point.rb +1 -1
- data/test/projected_geography/tc_multi_polygon.rb +2 -2
- data/test/projected_geography/tc_point.rb +4 -4
- data/test/projected_geography/tc_polygon.rb +1 -1
- data/test/simple_mercator/tc_geometry_collection.rb +1 -1
- data/test/simple_mercator/tc_line_string.rb +1 -1
- data/test/simple_mercator/tc_multi_line_string.rb +1 -1
- data/test/simple_mercator/tc_multi_point.rb +1 -1
- data/test/simple_mercator/tc_multi_polygon.rb +2 -2
- data/test/simple_mercator/tc_point.rb +4 -4
- data/test/simple_mercator/tc_polygon.rb +1 -1
- data/test/simple_mercator/tc_window.rb +1 -1
- data/test/spherical_geography/tc_geometry_collection.rb +1 -1
- data/test/spherical_geography/tc_line_string.rb +1 -1
- data/test/spherical_geography/tc_multi_line_string.rb +1 -1
- data/test/spherical_geography/tc_multi_point.rb +1 -1
- data/test/spherical_geography/tc_multi_polygon.rb +2 -2
- data/test/spherical_geography/tc_point.rb +4 -4
- data/test/spherical_geography/tc_polygon.rb +1 -1
- data/test/tc_oneoff.rb +3 -3
- data/test/wkrep/tc_wkb_parser.rb +14 -14
- data/test/wkrep/tc_wkt_parser.rb +37 -45
- metadata +10 -3
@@ -48,10 +48,10 @@ module RGeo
|
|
48
48
|
|
49
49
|
|
50
50
|
def setup
|
51
|
-
@factory = ::RGeo::Geography.
|
52
|
-
@zfactory = ::RGeo::Geography.
|
53
|
-
@mfactory = ::RGeo::Geography.
|
54
|
-
@zmfactory = ::RGeo::Geography.
|
51
|
+
@factory = ::RGeo::Geography.spherical_factory
|
52
|
+
@zfactory = ::RGeo::Geography.spherical_factory(:support_z_coordinate => true)
|
53
|
+
@mfactory = ::RGeo::Geography.spherical_factory(:support_m_coordinate => true)
|
54
|
+
@zmfactory = ::RGeo::Geography.spherical_factory(:support_z_coordinate => true, :support_m_coordinate => true)
|
55
55
|
end
|
56
56
|
|
57
57
|
|
data/test/tc_oneoff.rb
CHANGED
@@ -45,9 +45,9 @@ module RGeo
|
|
45
45
|
|
46
46
|
|
47
47
|
def setup
|
48
|
-
@mercator_factory = ::RGeo::Geography.
|
49
|
-
@spherical_factory = ::RGeo::Geography.
|
50
|
-
@projected_factory = ::RGeo::Geography.
|
48
|
+
@mercator_factory = ::RGeo::Geography.simple_mercator_factory
|
49
|
+
@spherical_factory = ::RGeo::Geography.spherical_factory(:support_z_coordinate => true)
|
50
|
+
@projected_factory = ::RGeo::Geography.projected_factory(:projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857, :support_z_coordinate => true)
|
51
51
|
@geos_factory = ::RGeo::Geos.factory(:srid => 4326, :support_z_coordinate => true)
|
52
52
|
@cartesian_factory = ::RGeo::Cartesian.simple_factory(:srid => 1, :support_z_coordinate => true)
|
53
53
|
@entity_factory = ::RGeo::GeoJSON::EntityFactory.instance
|
data/test/wkrep/tc_wkb_parser.rb
CHANGED
@@ -65,7 +65,7 @@ module RGeo
|
|
65
65
|
|
66
66
|
def test_point_with_ewkb_z
|
67
67
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
68
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
68
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
69
69
|
obj_ = parser_.parse_hex('00800000013ff000000000000040000000000000004008000000000000')
|
70
70
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
71
71
|
assert_equal(3, obj_.z)
|
@@ -75,7 +75,7 @@ module RGeo
|
|
75
75
|
|
76
76
|
def test_point_with_ewkb_m
|
77
77
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_m_coordinate => true)
|
78
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
78
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
79
79
|
obj_ = parser_.parse_hex('00400000013ff000000000000040000000000000004008000000000000')
|
80
80
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
81
81
|
assert_equal(3, obj_.m)
|
@@ -85,7 +85,7 @@ module RGeo
|
|
85
85
|
|
86
86
|
def test_point_with_ewkb_zm
|
87
87
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true, :support_m_coordinate => true)
|
88
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
88
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
89
89
|
obj_ = parser_.parse_hex('00c00000013ff0000000000000400000000000000040080000000000004010000000000000')
|
90
90
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
91
91
|
assert_equal(3, obj_.z)
|
@@ -95,7 +95,7 @@ module RGeo
|
|
95
95
|
|
96
96
|
def test_point_with_wkb12_z
|
97
97
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
98
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
98
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
99
99
|
obj_ = parser_.parse_hex('00000003e93ff000000000000040000000000000004008000000000000')
|
100
100
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
101
101
|
assert_equal(3, obj_.z)
|
@@ -105,7 +105,7 @@ module RGeo
|
|
105
105
|
|
106
106
|
def test_point_with_wkb12_m
|
107
107
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_m_coordinate => true)
|
108
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
108
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
109
109
|
obj_ = parser_.parse_hex('00000007d13ff000000000000040000000000000004008000000000000')
|
110
110
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
111
111
|
assert_equal(3, obj_.m)
|
@@ -115,7 +115,7 @@ module RGeo
|
|
115
115
|
|
116
116
|
def test_point_with_wkb12_zm
|
117
117
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true, :support_m_coordinate => true)
|
118
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
118
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
119
119
|
obj_ = parser_.parse_hex('0000000bb93ff0000000000000400000000000000040080000000000004010000000000000')
|
120
120
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
121
121
|
assert_equal(3, obj_.z)
|
@@ -125,7 +125,7 @@ module RGeo
|
|
125
125
|
|
126
126
|
def test_point_with_wkb12_z_without_wkb12_support
|
127
127
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
128
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
128
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_)
|
129
129
|
assert_raise(::RGeo::Error::ParseError) do
|
130
130
|
obj_ = parser_.parse_hex('00000003e93ff000000000000040000000000000004008000000000000')
|
131
131
|
end
|
@@ -134,7 +134,7 @@ module RGeo
|
|
134
134
|
|
135
135
|
def test_point_with_wkb12_z_without_enough_data
|
136
136
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
137
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
137
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
138
138
|
assert_raise(::RGeo::Error::ParseError) do
|
139
139
|
obj_ = parser_.parse_hex('00000003e93ff00000000000004000000000000000')
|
140
140
|
end
|
@@ -143,7 +143,7 @@ module RGeo
|
|
143
143
|
|
144
144
|
def test_point_with_ewkb_z_and_srid
|
145
145
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
146
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
146
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
147
147
|
parser_.to_generate_factory do |config_|
|
148
148
|
::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true, :srid => config_[:srid])
|
149
149
|
end
|
@@ -167,7 +167,7 @@ module RGeo
|
|
167
167
|
|
168
168
|
def test_linestring_with_ewkb_z
|
169
169
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
170
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
170
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
171
171
|
obj_ = parser_.parse_hex('0080000002000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000')
|
172
172
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
173
173
|
assert_equal(2, obj_.num_points)
|
@@ -178,7 +178,7 @@ module RGeo
|
|
178
178
|
|
179
179
|
def test_linestring_with_ewkb_z_and_srid
|
180
180
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
181
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
181
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
182
182
|
parser_.to_generate_factory do |config_|
|
183
183
|
::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true, :srid => config_[:srid])
|
184
184
|
end
|
@@ -193,7 +193,7 @@ module RGeo
|
|
193
193
|
|
194
194
|
def test_linestring_with_wkb12_z
|
195
195
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
196
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
196
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_wkb12 => true)
|
197
197
|
obj_ = parser_.parse_hex('00000003ea000000023ff000000000000040000000000000004008000000000000401000000000000040140000000000004018000000000000')
|
198
198
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
199
199
|
assert_equal(2, obj_.num_points)
|
@@ -250,7 +250,7 @@ module RGeo
|
|
250
250
|
|
251
251
|
def test_multipoint_with_ewkb_z
|
252
252
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
253
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
253
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
254
254
|
obj_ = parser_.parse_hex('00800000040000000200800000013ff0000000000000400000000000000040140000000000000080000001400800000000000040100000000000004018000000000000')
|
255
255
|
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
256
256
|
assert_equal(2, obj_.num_geometries)
|
@@ -264,7 +264,7 @@ module RGeo
|
|
264
264
|
|
265
265
|
def test_multipoint_ewkb_with_mixed_z
|
266
266
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
267
|
-
parser_ = ::RGeo::WKRep::WKBParser.new(
|
267
|
+
parser_ = ::RGeo::WKRep::WKBParser.new(factory_, :support_ewkb => true)
|
268
268
|
assert_raise(::RGeo::Error::ParseError) do
|
269
269
|
obj_ = parser_.parse_hex('00800000040000000200800000013ff000000000000040000000000000004014000000000000000000000140080000000000004010000000000000')
|
270
270
|
end
|
data/test/wkrep/tc_wkt_parser.rb
CHANGED
@@ -74,7 +74,7 @@ module RGeo
|
|
74
74
|
|
75
75
|
def test_values_negative
|
76
76
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
77
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
77
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
78
78
|
obj_ = parser_.parse('POINT(-1. -.5 -5.5)')
|
79
79
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
80
80
|
assert_equal(-1.0, obj_.x)
|
@@ -102,7 +102,7 @@ module RGeo
|
|
102
102
|
|
103
103
|
def test_point_with_z
|
104
104
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
105
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
105
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
106
106
|
obj_ = parser_.parse('POINT(1 2 3)')
|
107
107
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
108
108
|
assert_equal(3, obj_.z)
|
@@ -112,7 +112,7 @@ module RGeo
|
|
112
112
|
|
113
113
|
def test_point_with_m
|
114
114
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_m_coordinate => true)
|
115
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
115
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
116
116
|
obj_ = parser_.parse('POINT(1 2 3)')
|
117
117
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
118
118
|
assert_equal(3, obj_.m)
|
@@ -122,7 +122,7 @@ module RGeo
|
|
122
122
|
|
123
123
|
def test_point_with_too_many_coords
|
124
124
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
125
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
125
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
126
126
|
assert_raise(::RGeo::Error::ParseError) do
|
127
127
|
obj_ = parser_.parse('POINT(1 2 3)')
|
128
128
|
end
|
@@ -131,7 +131,7 @@ module RGeo
|
|
131
131
|
|
132
132
|
def test_point_wkt12_z
|
133
133
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
134
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
134
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
|
135
135
|
obj_ = parser_.parse('POINT Z(1 2 3)')
|
136
136
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
137
137
|
assert_equal(3, obj_.z)
|
@@ -141,7 +141,7 @@ module RGeo
|
|
141
141
|
|
142
142
|
def test_point_wkt12_z_unsupported_factory
|
143
143
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
144
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
144
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
|
145
145
|
assert_raise(::RGeo::Error::ParseError) do
|
146
146
|
obj_ = parser_.parse('POINT Z(1 2 3)')
|
147
147
|
end
|
@@ -150,7 +150,7 @@ module RGeo
|
|
150
150
|
|
151
151
|
def test_point_wkt12_m
|
152
152
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_m_coordinate => true)
|
153
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
153
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
|
154
154
|
obj_ = parser_.parse('POINT M(1 2 3)')
|
155
155
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
156
156
|
assert_equal(3, obj_.m)
|
@@ -160,7 +160,7 @@ module RGeo
|
|
160
160
|
|
161
161
|
def test_point_wkt12_m_with_factory_zm
|
162
162
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true, :support_m_coordinate => true)
|
163
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
163
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
|
164
164
|
obj_ = parser_.parse('POINT M(1 2 3)')
|
165
165
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
166
166
|
assert_equal(3, obj_.m)
|
@@ -170,7 +170,7 @@ module RGeo
|
|
170
170
|
|
171
171
|
def test_point_wkt12_m_too_many_coords
|
172
172
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_m_coordinate => true)
|
173
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
173
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
|
174
174
|
assert_raise(::RGeo::Error::ParseError) do
|
175
175
|
obj_ = parser_.parse('POINT M(1 2 3 4)')
|
176
176
|
end
|
@@ -179,7 +179,7 @@ module RGeo
|
|
179
179
|
|
180
180
|
def test_point_wkt12_zm
|
181
181
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true, :support_m_coordinate => true)
|
182
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
182
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
|
183
183
|
obj_ = parser_.parse('POINT ZM(1 2 3 4)')
|
184
184
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
185
185
|
assert_equal(3, obj_.z)
|
@@ -189,7 +189,7 @@ module RGeo
|
|
189
189
|
|
190
190
|
def test_point_wkt12_zm_not_enough_coords
|
191
191
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true, :support_m_coordinate => true)
|
192
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
192
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
|
193
193
|
assert_raise(::RGeo::Error::ParseError) do
|
194
194
|
obj_ = parser_.parse('POINT ZM(1 2 3)')
|
195
195
|
end
|
@@ -198,7 +198,7 @@ module RGeo
|
|
198
198
|
|
199
199
|
def test_point_ewkt_z
|
200
200
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
201
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
201
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_ewkt => true)
|
202
202
|
obj_ = parser_.parse('POINT(1 2 3)')
|
203
203
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
204
204
|
assert_equal(3, obj_.z)
|
@@ -208,7 +208,7 @@ module RGeo
|
|
208
208
|
|
209
209
|
def test_point_ewkt_m
|
210
210
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_m_coordinate => true)
|
211
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
211
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_ewkt => true)
|
212
212
|
obj_ = parser_.parse('POINTM(1 2 3)')
|
213
213
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
214
214
|
assert_equal(3, obj_.m)
|
@@ -217,11 +217,7 @@ module RGeo
|
|
217
217
|
|
218
218
|
|
219
219
|
def test_point_ewkt_with_srid
|
220
|
-
|
221
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(:default_factory => factory_, :support_ewkt => true)
|
222
|
-
parser_.to_generate_factory do |config_|
|
223
|
-
::RGeo::Cartesian.preferred_factory(:support_m_coordinate => true, :srid => config_[:srid])
|
224
|
-
end
|
220
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory), :support_ewkt => true)
|
225
221
|
obj_ = parser_.parse('SRID=1000;POINTM(1 2 3)')
|
226
222
|
assert_equal(::RGeo::Feature::Point, obj_.geometry_type)
|
227
223
|
assert_equal(3, obj_.m)
|
@@ -232,7 +228,7 @@ module RGeo
|
|
232
228
|
|
233
229
|
def test_point_ewkt_m_too_many_coords
|
234
230
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_m_coordinate => true)
|
235
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
231
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_ewkt => true)
|
236
232
|
assert_raise(::RGeo::Error::ParseError) do
|
237
233
|
obj_ = parser_.parse('POINTM(1 2 3 4)')
|
238
234
|
end
|
@@ -241,7 +237,7 @@ module RGeo
|
|
241
237
|
|
242
238
|
def test_point_strict_wkt11_with_z
|
243
239
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
244
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
240
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :strict_wkt11 => true)
|
245
241
|
assert_raise(::RGeo::Error::ParseError) do
|
246
242
|
obj_ = parser_.parse('POINT(1 2 3)')
|
247
243
|
end
|
@@ -250,7 +246,7 @@ module RGeo
|
|
250
246
|
|
251
247
|
def test_point_non_ewkt_with_srid
|
252
248
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
253
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
249
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
254
250
|
parser_.factory_generator = ::RGeo::Cartesian.method(:preferred_factory)
|
255
251
|
assert_raise(::RGeo::Error::ParseError) do
|
256
252
|
obj_ = parser_.parse('SRID=1000;POINT(1 2)')
|
@@ -260,7 +256,7 @@ module RGeo
|
|
260
256
|
|
261
257
|
def test_linestring_basic
|
262
258
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
263
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
259
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
264
260
|
obj_ = parser_.parse('LINESTRING(1 2, 3 4, 5 6)')
|
265
261
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
266
262
|
assert_equal(3, obj_.num_points)
|
@@ -271,7 +267,7 @@ module RGeo
|
|
271
267
|
|
272
268
|
def test_linestring_with_z
|
273
269
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
274
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
270
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
275
271
|
obj_ = parser_.parse('LINESTRING(1 2 3, 4 5 6,7 8 9)')
|
276
272
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
277
273
|
assert_equal(3, obj_.num_points)
|
@@ -282,7 +278,7 @@ module RGeo
|
|
282
278
|
|
283
279
|
def test_linestring_with_inconsistent_coords
|
284
280
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
285
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
281
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
286
282
|
assert_raise(::RGeo::Error::ParseError) do
|
287
283
|
obj_ = parser_.parse('LINESTRING(1 2 3, 4 5,7 8 9)')
|
288
284
|
end
|
@@ -291,7 +287,7 @@ module RGeo
|
|
291
287
|
|
292
288
|
def test_linestring_wkt12_m
|
293
289
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true, :support_m_coordinate => true)
|
294
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
290
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
|
295
291
|
obj_ = parser_.parse('LINESTRING M(1 2 3,5 6 7)')
|
296
292
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
297
293
|
assert_equal(2, obj_.num_points)
|
@@ -303,11 +299,7 @@ module RGeo
|
|
303
299
|
|
304
300
|
|
305
301
|
def test_linestring_ewkt_with_srid
|
306
|
-
|
307
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(:default_factory => factory_, :support_ewkt => true)
|
308
|
-
parser_.to_generate_factory do |config_|
|
309
|
-
::RGeo::Cartesian.preferred_factory(:support_m_coordinate => true, :srid => config_[:srid])
|
310
|
-
end
|
302
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(::RGeo::Cartesian.method(:preferred_factory), :support_ewkt => true)
|
311
303
|
obj_ = parser_.parse('SRID=1000;LINESTRINGM(1 2 3, 4 5 6)')
|
312
304
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
313
305
|
assert_equal(3, obj_.point_n(0).m)
|
@@ -318,7 +310,7 @@ module RGeo
|
|
318
310
|
|
319
311
|
def test_linestring_empty
|
320
312
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
321
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
313
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
322
314
|
obj_ = parser_.parse('LINESTRING EMPTY')
|
323
315
|
assert_equal(::RGeo::Feature::LineString, obj_.geometry_type)
|
324
316
|
assert_equal(0, obj_.num_points)
|
@@ -327,7 +319,7 @@ module RGeo
|
|
327
319
|
|
328
320
|
def test_polygon_basic
|
329
321
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
330
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
322
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
331
323
|
obj_ = parser_.parse('POLYGON((1 2, 3 4, 5 6, 1 2))')
|
332
324
|
assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
|
333
325
|
assert_equal(4, obj_.exterior_ring.num_points)
|
@@ -338,7 +330,7 @@ module RGeo
|
|
338
330
|
|
339
331
|
def test_polygon_with_holes_and_z
|
340
332
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
341
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
333
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
342
334
|
obj_ = parser_.parse('POLYGON((0 0 -1, 10 0 -2, 10 10 -3, 0 10 -4, 0 0 -5),(1 1 -6, 2 3 -7, 3 1 -8, 1 1 -9))')
|
343
335
|
assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
|
344
336
|
assert_equal(5, obj_.exterior_ring.num_points)
|
@@ -352,7 +344,7 @@ module RGeo
|
|
352
344
|
|
353
345
|
def test_polygon_empty
|
354
346
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
355
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
347
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
356
348
|
obj_ = parser_.parse('POLYGON EMPTY')
|
357
349
|
assert_equal(::RGeo::Feature::Polygon, obj_.geometry_type)
|
358
350
|
assert_equal(0, obj_.exterior_ring.num_points)
|
@@ -361,7 +353,7 @@ module RGeo
|
|
361
353
|
|
362
354
|
def test_multipoint_basic
|
363
355
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
364
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
356
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
365
357
|
obj_ = parser_.parse('MULTIPOINT((1 2),(0 3))')
|
366
358
|
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
367
359
|
assert_equal(2, obj_.num_geometries)
|
@@ -372,7 +364,7 @@ module RGeo
|
|
372
364
|
|
373
365
|
def test_multipoint_empty
|
374
366
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
375
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
367
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
376
368
|
obj_ = parser_.parse('MULTIPOINT EMPTY')
|
377
369
|
assert_equal(::RGeo::Feature::MultiPoint, obj_.geometry_type)
|
378
370
|
assert_equal(0, obj_.num_geometries)
|
@@ -381,7 +373,7 @@ module RGeo
|
|
381
373
|
|
382
374
|
def test_multilinestring_basic
|
383
375
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
384
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
376
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
385
377
|
obj_ = parser_.parse('MULTILINESTRING((1 2, 3 4, 5 6),(0 -3, 0 -4, 1 -5))')
|
386
378
|
assert_equal(::RGeo::Feature::MultiLineString, obj_.geometry_type)
|
387
379
|
assert_equal(2, obj_.num_geometries)
|
@@ -392,7 +384,7 @@ module RGeo
|
|
392
384
|
|
393
385
|
def test_multilinestring_empty
|
394
386
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
395
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
387
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
396
388
|
obj_ = parser_.parse('MULTILINESTRING EMPTY')
|
397
389
|
assert_equal(::RGeo::Feature::MultiLineString, obj_.geometry_type)
|
398
390
|
assert_equal(0, obj_.num_geometries)
|
@@ -401,7 +393,7 @@ module RGeo
|
|
401
393
|
|
402
394
|
def test_multipolygon_basic
|
403
395
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
404
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
396
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
405
397
|
obj_ = parser_.parse('MULTIPOLYGON(((-1 -2 0, -3 -4 0, -5 -6 0, -1 -2 0)),((0 0 -1, 10 0 -2, 10 10 -3, 0 10 -4, 0 0 -5),(1 1 -6, 2 3 -7, 3 1 -8, 1 1 -9)))')
|
406
398
|
assert_equal(::RGeo::Feature::MultiPolygon, obj_.geometry_type)
|
407
399
|
assert_equal(2, obj_.num_geometries)
|
@@ -419,7 +411,7 @@ module RGeo
|
|
419
411
|
|
420
412
|
def test_multipolygon_empty
|
421
413
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
422
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
414
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
423
415
|
obj_ = parser_.parse('MULTIPOLYGON EMPTY')
|
424
416
|
assert_equal(::RGeo::Feature::MultiPolygon, obj_.geometry_type)
|
425
417
|
assert_equal(0, obj_.num_geometries)
|
@@ -428,7 +420,7 @@ module RGeo
|
|
428
420
|
|
429
421
|
def test_collection_basic
|
430
422
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
431
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
423
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
432
424
|
obj_ = parser_.parse('GEOMETRYCOLLECTION(POINT(-1 -2),LINESTRING(1 2, 3 4, 5 6))')
|
433
425
|
assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
|
434
426
|
assert_equal(2, obj_.num_geometries)
|
@@ -442,7 +434,7 @@ module RGeo
|
|
442
434
|
|
443
435
|
def test_collection_z
|
444
436
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
445
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
437
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
446
438
|
obj_ = parser_.parse('GEOMETRYCOLLECTION(POINT(-1 -2 0),LINESTRING(1 2 0, 3 4 0, 5 6 0))')
|
447
439
|
assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
|
448
440
|
assert_equal(2, obj_.num_geometries)
|
@@ -456,7 +448,7 @@ module RGeo
|
|
456
448
|
|
457
449
|
def test_collection_dimension_mismatch
|
458
450
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true)
|
459
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
451
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
460
452
|
assert_raise(::RGeo::Error::ParseError) do
|
461
453
|
obj_ = parser_.parse('GEOMETRYCOLLECTION(POINT(-1 -2),LINESTRING(1 2 0, 3 4 0, 5 6 0))')
|
462
454
|
end
|
@@ -465,7 +457,7 @@ module RGeo
|
|
465
457
|
|
466
458
|
def test_collection_wkt12_type_mismatch
|
467
459
|
factory_ = ::RGeo::Cartesian.preferred_factory(:support_z_coordinate => true, :support_m_coordinate => true)
|
468
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
460
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_, :support_wkt12 => true)
|
469
461
|
assert_raise(::RGeo::Error::ParseError) do
|
470
462
|
obj_ = parser_.parse('GEOMETRYCOLLECTION Z(POINT Z(-1 -2 0),LINESTRING M(1 2 0, 3 4 0, 5 6 0))')
|
471
463
|
end
|
@@ -474,7 +466,7 @@ module RGeo
|
|
474
466
|
|
475
467
|
def test_collection_empty
|
476
468
|
factory_ = ::RGeo::Cartesian.preferred_factory
|
477
|
-
parser_ = ::RGeo::WKRep::WKTParser.new(
|
469
|
+
parser_ = ::RGeo::WKRep::WKTParser.new(factory_)
|
478
470
|
obj_ = parser_.parse('GEOMETRYCOLLECTION EMPTY')
|
479
471
|
assert_equal(::RGeo::Feature::GeometryCollection, obj_.geometry_type)
|
480
472
|
assert_equal(0, obj_.num_geometries)
|