rgeo 0.1.19 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +11 -0
- data/README.rdoc +23 -7
- data/Version +1 -1
- data/ext/geos_c_impl/factory.c +1 -1
- data/{lib/rgeo/geography/simple_mercator.rb → ext/proj4_c_impl/extconf.rb} +35 -30
- data/ext/proj4_c_impl/main.c +256 -0
- data/lib/rgeo.rb +54 -42
- data/lib/rgeo/active_record/arel_modifications.rb +2 -2
- data/lib/rgeo/active_record/base_modifications.rb +1 -1
- data/lib/rgeo/active_record/mysql_common.rb +12 -12
- data/lib/rgeo/all.rb +5 -4
- data/lib/rgeo/cartesian.rb +3 -2
- data/lib/rgeo/cartesian/bounding_box.rb +9 -9
- data/lib/rgeo/cartesian/factory.rb +30 -13
- data/lib/rgeo/cartesian/feature_classes.rb +33 -33
- data/lib/rgeo/cartesian/interface.rb +2 -2
- data/lib/rgeo/{geography/all.rb → coord_sys.rb} +22 -4
- data/lib/rgeo/coord_sys/proj4.rb +275 -0
- data/lib/rgeo/{errors.rb → error.rb} +5 -6
- data/lib/rgeo/{features.rb → feature.rb} +22 -20
- data/lib/rgeo/{features → feature}/curve.rb +6 -6
- data/lib/rgeo/{features → feature}/factory.rb +19 -3
- data/lib/rgeo/{features → feature}/factory_generator.rb +1 -1
- data/lib/rgeo/{features → feature}/geometry.rb +34 -34
- data/lib/rgeo/{features → feature}/geometry_collection.rb +4 -4
- data/lib/rgeo/{features → feature}/line.rb +1 -1
- data/lib/rgeo/{features → feature}/line_string.rb +4 -4
- data/lib/rgeo/{features → feature}/linear_ring.rb +1 -1
- data/lib/rgeo/{features → feature}/multi_curve.rb +3 -3
- data/lib/rgeo/{features → feature}/multi_line_string.rb +1 -1
- data/lib/rgeo/{features → feature}/multi_point.rb +1 -1
- data/lib/rgeo/{features → feature}/multi_polygon.rb +1 -1
- data/lib/rgeo/{features → feature}/multi_surface.rb +4 -4
- data/lib/rgeo/{features → feature}/point.rb +5 -5
- data/lib/rgeo/{features → feature}/polygon.rb +5 -5
- data/lib/rgeo/{features → feature}/surface.rb +4 -4
- data/lib/rgeo/feature/types.rb +301 -0
- data/lib/rgeo/geo_json.rb +1 -1
- data/lib/rgeo/geo_json/coder.rb +13 -13
- data/lib/rgeo/geo_json/interface.rb +2 -2
- data/lib/rgeo/geography.rb +33 -6
- data/lib/rgeo/geography/factory.rb +82 -39
- data/lib/rgeo/geography/interface.rb +135 -89
- data/lib/rgeo/geography/proj4_projector.rb +98 -0
- data/lib/rgeo/geography/projected_feature_classes.rb +213 -0
- data/lib/rgeo/geography/projected_feature_methods.rb +228 -0
- data/lib/rgeo/geography/projected_window.rb +7 -7
- data/lib/rgeo/geography/simple_mercator_projector.rb +133 -0
- data/lib/rgeo/geography/spherical_feature_classes.rb +212 -0
- data/lib/rgeo/geography/{simple_spherical/feature_methods.rb → spherical_feature_methods.rb} +39 -43
- data/lib/rgeo/geography/{simple_spherical/calculations.rb → spherical_math.rb} +7 -7
- data/lib/rgeo/geos.rb +1 -1
- data/lib/rgeo/geos/factory.rb +37 -19
- data/lib/rgeo/geos/impl_additions.rb +10 -11
- data/lib/rgeo/geos/interface.rb +1 -1
- data/lib/rgeo/geos/zm_factory.rb +15 -15
- data/lib/rgeo/geos/zm_impl.rb +10 -10
- data/lib/rgeo/{impl_helpers.rb → impl_helper.rb} +8 -8
- data/lib/rgeo/{impl_helpers → impl_helper}/basic_geometry_collection_methods.rb +13 -13
- data/lib/rgeo/{impl_helpers → impl_helper}/basic_geometry_methods.rb +2 -2
- data/lib/rgeo/{impl_helpers → impl_helper}/basic_line_string_methods.rb +13 -13
- data/lib/rgeo/{impl_helpers → impl_helper}/basic_point_methods.rb +5 -5
- data/lib/rgeo/{impl_helpers → impl_helper}/basic_polygon_methods.rb +6 -6
- data/lib/rgeo/{impl_helpers → impl_helper}/math.rb +1 -1
- data/lib/rgeo/shapefile.rb +1 -1
- data/lib/rgeo/shapefile/reader.rb +3 -3
- data/lib/rgeo/wkrep.rb +1 -1
- data/lib/rgeo/wkrep/wkb_generator.rb +17 -17
- data/lib/rgeo/wkrep/wkb_parser.rb +12 -12
- data/lib/rgeo/wkrep/wkt_generator.rb +8 -8
- data/lib/rgeo/wkrep/wkt_parser.rb +10 -10
- data/{tests → test}/active_record/readme.txt +0 -0
- data/{tests → test}/active_record/tc_mysqlspatial.rb +2 -2
- data/{tests → test}/common/geometry_collection_tests.rb +22 -22
- data/{tests → test}/common/line_string_tests.rb +20 -20
- data/{tests → test}/common/multi_line_string_tests.rb +19 -19
- data/{tests → test}/common/multi_point_tests.rb +17 -17
- data/{tests → test}/common/multi_polygon_tests.rb +16 -16
- data/{tests → test}/common/point_tests.rb +9 -9
- data/{tests → test}/common/polygon_tests.rb +9 -9
- data/test/coord_sys/tc_proj4.rb +111 -0
- data/{tests → test}/geos/tc_factory.rb +1 -1
- data/{tests → test}/geos/tc_geometry_collection.rb +1 -1
- data/{tests → test}/geos/tc_line_string.rb +0 -0
- data/{tests → test}/geos/tc_misc.rb +1 -1
- data/{tests → test}/geos/tc_multi_line_string.rb +1 -1
- data/{tests → test}/geos/tc_multi_point.rb +1 -1
- data/{tests → test}/geos/tc_multi_polygon.rb +1 -1
- data/{tests → test}/geos/tc_point.rb +1 -1
- data/{tests → test}/geos/tc_polygon.rb +0 -0
- data/{tests → test}/geos/tc_zmfactory.rb +2 -2
- data/test/projected_geography/tc_geometry_collection.rb +62 -0
- data/test/projected_geography/tc_line_string.rb +62 -0
- data/test/projected_geography/tc_multi_line_string.rb +62 -0
- data/test/projected_geography/tc_multi_point.rb +62 -0
- data/test/projected_geography/tc_multi_polygon.rb +63 -0
- data/test/projected_geography/tc_point.rb +93 -0
- data/test/projected_geography/tc_polygon.rb +62 -0
- data/{tests → test}/shapefile/shapelib_testcases/readme.txt +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test.dbf +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test0.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test0.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test1.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test1.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test10.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test10.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test11.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test11.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test12.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test12.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test13.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test13.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test2.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test2.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test3.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test3.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test4.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test4.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test5.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test5.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test6.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test6.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test7.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test7.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test8.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test8.shx +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test9.shp +0 -0
- data/{tests → test}/shapefile/shapelib_testcases/test9.shx +0 -0
- data/{tests → test}/shapefile/tc_shapelib_tests.rb +17 -17
- data/{tests → test}/simple_cartesian/tc_calculations.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_geometry_collection.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_line_string.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_multi_line_string.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_multi_point.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_multi_polygon.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_point.rb +0 -0
- data/{tests → test}/simple_cartesian/tc_polygon.rb +0 -0
- data/{tests → test}/simple_mercator/tc_geometry_collection.rb +1 -1
- data/{tests → test}/simple_mercator/tc_line_string.rb +0 -0
- data/{tests → test}/simple_mercator/tc_multi_line_string.rb +1 -1
- data/{tests → test}/simple_mercator/tc_multi_point.rb +1 -1
- data/{tests → test}/simple_mercator/tc_multi_polygon.rb +1 -1
- data/{tests → test}/simple_mercator/tc_point.rb +2 -2
- data/{tests → test}/simple_mercator/tc_polygon.rb +0 -0
- data/{tests → test}/simple_mercator/tc_window.rb +1 -1
- data/test/spherical_geography/tc_calculations.rb +203 -0
- data/{tests/simple_spherical → test/spherical_geography}/tc_geometry_collection.rb +2 -2
- data/{tests/simple_spherical → test/spherical_geography}/tc_line_string.rb +2 -2
- data/{tests/simple_spherical → test/spherical_geography}/tc_multi_line_string.rb +2 -2
- data/{tests/simple_spherical → test/spherical_geography}/tc_multi_point.rb +2 -2
- data/{tests/simple_spherical → test/spherical_geography}/tc_multi_polygon.rb +3 -3
- data/{tests/simple_spherical → test/spherical_geography}/tc_point.rb +7 -7
- data/{tests/simple_spherical → test/spherical_geography}/tc_polygon.rb +2 -2
- data/{tests → test}/tc_cartesian_analysis.rb +0 -0
- data/{tests → test}/tc_geojson.rb +0 -0
- data/{tests → test}/tc_oneoff.rb +2 -1
- data/{tests → test}/wkrep/tc_wkb_generator.rb +0 -0
- data/{tests → test}/wkrep/tc_wkb_parser.rb +32 -32
- data/{tests → test}/wkrep/tc_wkt_generator.rb +0 -0
- data/{tests → test}/wkrep/tc_wkt_parser.rb +46 -46
- metadata +183 -164
- data/lib/rgeo/features/types.rb +0 -272
- data/lib/rgeo/geography/simple_mercator/feature_classes.rb +0 -279
- data/lib/rgeo/geography/simple_mercator/feature_methods.rb +0 -278
- data/lib/rgeo/geography/simple_mercator/projector.rb +0 -112
- data/lib/rgeo/geography/simple_spherical.rb +0 -68
- data/lib/rgeo/geography/simple_spherical/feature_classes.rb +0 -216
- data/tests/simple_spherical/tc_calculations.rb +0 -203
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
module RGeo
|
38
38
|
|
39
|
-
module
|
39
|
+
module ImplHelper # :nodoc:
|
40
40
|
|
41
41
|
|
42
42
|
module BasicGeometryCollectionMethods # :nodoc:
|
@@ -45,9 +45,9 @@ module RGeo
|
|
45
45
|
def initialize(factory_, elements_)
|
46
46
|
_set_factory(factory_)
|
47
47
|
@elements = elements_.map do |elem_|
|
48
|
-
elem_ =
|
48
|
+
elem_ = Feature.cast(elem_, factory_)
|
49
49
|
unless elem_
|
50
|
-
raise
|
50
|
+
raise Error::InvalidGeometry, "Could not cast #{elem_}"
|
51
51
|
end
|
52
52
|
elem_
|
53
53
|
end
|
@@ -92,7 +92,7 @@ module RGeo
|
|
92
92
|
|
93
93
|
|
94
94
|
def geometry_type
|
95
|
-
|
95
|
+
Feature::GeometryCollection
|
96
96
|
end
|
97
97
|
|
98
98
|
|
@@ -110,9 +110,9 @@ module RGeo
|
|
110
110
|
def initialize(factory_, elements_)
|
111
111
|
_set_factory(factory_)
|
112
112
|
@elements = elements_.map do |elem_|
|
113
|
-
elem_ =
|
113
|
+
elem_ = Feature.cast(elem_, factory_, Feature::LineString, :keep_subtype)
|
114
114
|
unless elem_
|
115
|
-
raise
|
115
|
+
raise Error::InvalidGeometry, "Could not cast #{elem_}"
|
116
116
|
end
|
117
117
|
elem_
|
118
118
|
end
|
@@ -121,7 +121,7 @@ module RGeo
|
|
121
121
|
|
122
122
|
|
123
123
|
def geometry_type
|
124
|
-
|
124
|
+
Feature::MultiLineString
|
125
125
|
end
|
126
126
|
|
127
127
|
|
@@ -166,9 +166,9 @@ module RGeo
|
|
166
166
|
def initialize(factory_, elements_)
|
167
167
|
_set_factory(factory_)
|
168
168
|
@elements = elements_.map do |elem_|
|
169
|
-
elem_ =
|
169
|
+
elem_ = Feature.cast(elem_, factory_, Feature::Point, :keep_subtype)
|
170
170
|
unless elem_
|
171
|
-
raise
|
171
|
+
raise Error::InvalidGeometry, "Could not cast #{elem_}"
|
172
172
|
end
|
173
173
|
elem_
|
174
174
|
end
|
@@ -177,7 +177,7 @@ module RGeo
|
|
177
177
|
|
178
178
|
|
179
179
|
def geometry_type
|
180
|
-
|
180
|
+
Feature::MultiPoint
|
181
181
|
end
|
182
182
|
|
183
183
|
|
@@ -195,9 +195,9 @@ module RGeo
|
|
195
195
|
def initialize(factory_, elements_)
|
196
196
|
_set_factory(factory_)
|
197
197
|
@elements = elements_.map do |elem_|
|
198
|
-
elem_ =
|
198
|
+
elem_ = Feature.cast(elem_, factory_, Feature::Polygon, :keep_subtype)
|
199
199
|
unless elem_
|
200
|
-
raise
|
200
|
+
raise Error::InvalidGeometry, "Could not cast #{elem_}"
|
201
201
|
end
|
202
202
|
elem_
|
203
203
|
end
|
@@ -206,7 +206,7 @@ module RGeo
|
|
206
206
|
|
207
207
|
|
208
208
|
def geometry_type
|
209
|
-
|
209
|
+
Feature::MultiPolygon
|
210
210
|
end
|
211
211
|
|
212
212
|
|
@@ -36,12 +36,12 @@
|
|
36
36
|
|
37
37
|
module RGeo
|
38
38
|
|
39
|
-
module
|
39
|
+
module ImplHelper # :nodoc:
|
40
40
|
|
41
41
|
|
42
42
|
module BasicGeometryMethods # :nodoc:
|
43
43
|
|
44
|
-
include ::RGeo::
|
44
|
+
include ::RGeo::Feature::Type::Instance
|
45
45
|
|
46
46
|
|
47
47
|
def inspect # :nodoc:
|
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
module RGeo
|
38
38
|
|
39
|
-
module
|
39
|
+
module ImplHelper # :nodoc:
|
40
40
|
|
41
41
|
|
42
42
|
module BasicLineStringMethods # :nodoc:
|
@@ -45,9 +45,9 @@ module RGeo
|
|
45
45
|
def initialize(factory_, points_)
|
46
46
|
_set_factory(factory_)
|
47
47
|
@points = points_.map do |elem_|
|
48
|
-
elem_ =
|
48
|
+
elem_ = Feature.cast(elem_, factory_, Feature::Point)
|
49
49
|
unless elem_
|
50
|
-
raise
|
50
|
+
raise Error::InvalidGeometry, "Could not cast #{elem_}"
|
51
51
|
end
|
52
52
|
elem_
|
53
53
|
end
|
@@ -57,7 +57,7 @@ module RGeo
|
|
57
57
|
|
58
58
|
def _validate_geometry
|
59
59
|
if @points.size == 1
|
60
|
-
raise
|
60
|
+
raise Error::InvalidGeometry, 'LineString cannot have 1 point'
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -92,7 +92,7 @@ module RGeo
|
|
92
92
|
|
93
93
|
|
94
94
|
def geometry_type
|
95
|
-
|
95
|
+
Feature::LineString
|
96
96
|
end
|
97
97
|
|
98
98
|
|
@@ -141,13 +141,13 @@ module RGeo
|
|
141
141
|
|
142
142
|
def initialize(factory_, start_, end_)
|
143
143
|
_set_factory(factory_)
|
144
|
-
cstart_ =
|
144
|
+
cstart_ = Feature.cast(start_, factory_, Feature::Point)
|
145
145
|
unless cstart_
|
146
|
-
raise
|
146
|
+
raise Error::InvalidGeometry, "Could not cast start: #{start_}"
|
147
147
|
end
|
148
|
-
cend_ =
|
148
|
+
cend_ = Feature.cast(end_, factory_, Feature::Point)
|
149
149
|
unless cend_
|
150
|
-
raise
|
150
|
+
raise Error::InvalidGeometry, "Could not cast end: #{end_}"
|
151
151
|
end
|
152
152
|
@points = [cstart_, cend_]
|
153
153
|
_validate_geometry
|
@@ -157,13 +157,13 @@ module RGeo
|
|
157
157
|
def _validate_geometry # :nodoc:
|
158
158
|
super
|
159
159
|
if @points.size > 2
|
160
|
-
raise
|
160
|
+
raise Error::InvalidGeometry, 'Line must have 0 or 2 points'
|
161
161
|
end
|
162
162
|
end
|
163
163
|
|
164
164
|
|
165
165
|
def geometry_type
|
166
|
-
|
166
|
+
Feature::Line
|
167
167
|
end
|
168
168
|
|
169
169
|
|
@@ -178,14 +178,14 @@ module RGeo
|
|
178
178
|
if @points.size > 0
|
179
179
|
@points << @points.first if @points.first != @points.last
|
180
180
|
if !is_ring?
|
181
|
-
raise
|
181
|
+
raise Error::InvalidGeometry, 'LinearRing failed ring test'
|
182
182
|
end
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
186
|
|
187
187
|
def geometry_type
|
188
|
-
|
188
|
+
Feature::LinearRing
|
189
189
|
end
|
190
190
|
|
191
191
|
|
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
module RGeo
|
38
38
|
|
39
|
-
module
|
39
|
+
module ImplHelper # :nodoc:
|
40
40
|
|
41
41
|
|
42
42
|
module BasicPointMethods # :nodoc:
|
@@ -86,7 +86,7 @@ module RGeo
|
|
86
86
|
|
87
87
|
|
88
88
|
def geometry_type
|
89
|
-
|
89
|
+
Feature::Point
|
90
90
|
end
|
91
91
|
|
92
92
|
|
@@ -118,11 +118,11 @@ module RGeo
|
|
118
118
|
def equals?(rhs_)
|
119
119
|
return false unless rhs_.is_a?(self.class) && rhs_.factory == self.factory
|
120
120
|
case rhs_
|
121
|
-
when
|
121
|
+
when Feature::Point
|
122
122
|
rhs_.x == @x && rhs_.y == @y
|
123
|
-
when
|
123
|
+
when Feature::LineString
|
124
124
|
rhs_.num_points > 0 && rhs_.points.all?{ |elem_| equals?(elem_) }
|
125
|
-
when
|
125
|
+
when Feature::GeometryCollection
|
126
126
|
rhs_.num_geometries > 0 && rhs_.all?{ |elem_| equals?(elem_) }
|
127
127
|
else
|
128
128
|
false
|
@@ -36,7 +36,7 @@
|
|
36
36
|
|
37
37
|
module RGeo
|
38
38
|
|
39
|
-
module
|
39
|
+
module ImplHelper # :nodoc:
|
40
40
|
|
41
41
|
|
42
42
|
module BasicPolygonMethods # :nodoc:
|
@@ -44,14 +44,14 @@ module RGeo
|
|
44
44
|
|
45
45
|
def initialize(factory_, exterior_ring_, interior_rings_)
|
46
46
|
_set_factory(factory_)
|
47
|
-
@exterior_ring =
|
47
|
+
@exterior_ring = Feature.cast(exterior_ring_, factory_, Feature::LinearRing)
|
48
48
|
unless @exterior_ring
|
49
|
-
raise
|
49
|
+
raise Error::InvalidGeometry, "Failed to cast exterior ring #{exterior_ring_}"
|
50
50
|
end
|
51
51
|
@interior_rings = (interior_rings_ || []).map do |elem_|
|
52
|
-
elem_ =
|
52
|
+
elem_ = Feature.cast(elem_, factory_, Feature::LinearRing)
|
53
53
|
unless elem_
|
54
|
-
raise
|
54
|
+
raise Error::InvalidGeometry, "Could not cast interior ring #{elem_}"
|
55
55
|
end
|
56
56
|
elem_
|
57
57
|
end
|
@@ -94,7 +94,7 @@ module RGeo
|
|
94
94
|
|
95
95
|
|
96
96
|
def geometry_type
|
97
|
-
|
97
|
+
Feature::Polygon
|
98
98
|
end
|
99
99
|
|
100
100
|
|
data/lib/rgeo/shapefile.rb
CHANGED
@@ -163,7 +163,7 @@ module RGeo
|
|
163
163
|
# srid and dimension settings in the input. The factory generator
|
164
164
|
# should understand the configuration options
|
165
165
|
# <tt>:support_z_coordinate</tt> and <tt>:support_m_coordinate</tt>.
|
166
|
-
# See RGeo::
|
166
|
+
# See RGeo::Feature::FactoryGenerator for more information.
|
167
167
|
# If no generator is provided, the <tt>:default_factory</tt> is
|
168
168
|
# used.
|
169
169
|
# <tt>:srid</tt>::
|
@@ -611,7 +611,7 @@ module RGeo
|
|
611
611
|
unless @assume_inner_follows_outer
|
612
612
|
geos_factory_ = Geos.factory
|
613
613
|
unless geos_factory_
|
614
|
-
raise
|
614
|
+
raise Error::RGeoError, "GEOS is not available, but is required for correct interpretation of polygons in shapefiles."
|
615
615
|
end
|
616
616
|
end
|
617
617
|
|
@@ -763,7 +763,7 @@ module RGeo
|
|
763
763
|
unless @assume_inner_follows_outer
|
764
764
|
geos_factory_ = Geos.factory
|
765
765
|
unless geos_factory_
|
766
|
-
raise
|
766
|
+
raise Error::RGeoError, "GEOS is not available, but is required for correct interpretation of polygons in shapefiles."
|
767
767
|
end
|
768
768
|
end
|
769
769
|
|
data/lib/rgeo/wkrep.rb
CHANGED
@@ -76,15 +76,15 @@ module RGeo
|
|
76
76
|
|
77
77
|
# :stopdoc:
|
78
78
|
TYPE_CODES = {
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
79
|
+
Feature::Point => 1,
|
80
|
+
Feature::LineString => 2,
|
81
|
+
Feature::LinearRing => 2,
|
82
|
+
Feature::Line => 2,
|
83
|
+
Feature::Polygon => 3,
|
84
|
+
Feature::MultiPoint => 4,
|
85
|
+
Feature::MultiLineString => 5,
|
86
|
+
Feature::MultiPolygon => 6,
|
87
|
+
Feature::GeometryCollection => 7,
|
88
88
|
}
|
89
89
|
# :startdoc:
|
90
90
|
|
@@ -170,7 +170,7 @@ module RGeo
|
|
170
170
|
type_ = obj_.geometry_type
|
171
171
|
type_code_ = TYPE_CODES[type_]
|
172
172
|
unless type_code_
|
173
|
-
raise
|
173
|
+
raise Error::ParseError, "Unrecognized Geometry Type: #{type_}"
|
174
174
|
end
|
175
175
|
emit_srid_ = false
|
176
176
|
if @type_format == :ewkb
|
@@ -186,11 +186,11 @@ module RGeo
|
|
186
186
|
end
|
187
187
|
_emit_integer(type_code_)
|
188
188
|
_emit_integer(obj_.srid) if emit_srid_
|
189
|
-
if type_ ==
|
189
|
+
if type_ == Feature::Point
|
190
190
|
_emit_doubles(_point_coords(obj_))
|
191
|
-
elsif type_.subtype_of?(
|
191
|
+
elsif type_.subtype_of?(Feature::LineString)
|
192
192
|
_emit_line_string_coords(obj_)
|
193
|
-
elsif type_ ==
|
193
|
+
elsif type_ == Feature::Polygon
|
194
194
|
exterior_ring_ = obj_.exterior_ring
|
195
195
|
if exterior_ring_.is_empty?
|
196
196
|
_emit_integer(0)
|
@@ -199,16 +199,16 @@ module RGeo
|
|
199
199
|
_emit_line_string_coords(exterior_ring_)
|
200
200
|
obj_.interior_rings.each{ |r_| _emit_line_string_coords(r_) }
|
201
201
|
end
|
202
|
-
elsif type_ ==
|
202
|
+
elsif type_ == Feature::GeometryCollection
|
203
203
|
_emit_integer(obj_.num_geometries)
|
204
204
|
obj_.each{ |g_| _generate_feature(g_) }
|
205
|
-
elsif type_ ==
|
205
|
+
elsif type_ == Feature::MultiPoint
|
206
206
|
_emit_integer(obj_.num_geometries)
|
207
207
|
obj_.each{ |g_| _generate_feature(g_) }
|
208
|
-
elsif type_ ==
|
208
|
+
elsif type_ == Feature::MultiLineString
|
209
209
|
_emit_integer(obj_.num_geometries)
|
210
210
|
obj_.each{ |g_| _generate_feature(g_) }
|
211
|
-
elsif type_ ==
|
211
|
+
elsif type_ == Feature::MultiPolygon
|
212
212
|
_emit_integer(obj_.num_geometries)
|
213
213
|
obj_.each{ |g_| _generate_feature(g_) }
|
214
214
|
end
|
@@ -61,7 +61,7 @@ module RGeo
|
|
61
61
|
# srid and dimension settings in the input. The factory generator
|
62
62
|
# should understand the configuration options <tt>:srid</tt>,
|
63
63
|
# <tt>:support_z_coordinate</tt>, and <tt>:support_m_coordinate</tt>.
|
64
|
-
# See RGeo::
|
64
|
+
# See RGeo::Feature::FactoryGenerator for more information.
|
65
65
|
# If no generator is provided, the <tt>:default_factory</tt> is
|
66
66
|
# used.
|
67
67
|
# <tt>:support_ewkb</tt>::
|
@@ -174,7 +174,7 @@ module RGeo
|
|
174
174
|
unless @ignore_extra_bytes
|
175
175
|
bytes_ = _bytes_remaining
|
176
176
|
if bytes_ > 0
|
177
|
-
raise
|
177
|
+
raise Error::ParseError, "Found #{bytes_} extra bytes at the end of the stream."
|
178
178
|
end
|
179
179
|
end
|
180
180
|
ensure
|
@@ -203,16 +203,16 @@ module RGeo
|
|
203
203
|
end
|
204
204
|
if contained_
|
205
205
|
if contained_ != true && contained_ != type_code_
|
206
|
-
raise
|
206
|
+
raise Error::ParseError, "Enclosed type=#{type_code_} is different from container constraint #{contained_}"
|
207
207
|
end
|
208
208
|
if has_z_ != @cur_has_z
|
209
|
-
raise
|
209
|
+
raise Error::ParseError, "Enclosed hasZ=#{has_z_} is different from toplevel hasZ=#{@cur_has_z}"
|
210
210
|
end
|
211
211
|
if has_m_ != @cur_has_m
|
212
|
-
raise
|
212
|
+
raise Error::ParseError, "Enclosed hasM=#{has_m_} is different from toplevel hasM=#{@cur_has_m}"
|
213
213
|
end
|
214
214
|
if srid_ && srid_ != @cur_srid
|
215
|
-
raise
|
215
|
+
raise Error::ParseError, "Enclosed SRID #{srid_} is different from toplevel srid #{@cur_srid || '(unspecified)'}"
|
216
216
|
end
|
217
217
|
else
|
218
218
|
@cur_has_z = has_z_
|
@@ -223,10 +223,10 @@ module RGeo
|
|
223
223
|
@cur_factory = @factory_generator.call(:srid => @cur_srid, :support_z_coordinate => has_z_, :support_m_coordinate => has_m_)
|
224
224
|
end
|
225
225
|
if @cur_has_z && !@cur_factory.has_capability?(:z_coordinate)
|
226
|
-
raise
|
226
|
+
raise Error::ParseError, "Data has Z coordinates but the factory doesn't have z_coordinate capability"
|
227
227
|
end
|
228
228
|
if @cur_has_m && !@cur_factory.has_capability?(:m_coordinate)
|
229
|
-
raise
|
229
|
+
raise Error::ParseError, "Data has M coordinates but the factory doesn't have m_coordinate capability"
|
230
230
|
end
|
231
231
|
end
|
232
232
|
case type_code_
|
@@ -248,7 +248,7 @@ module RGeo
|
|
248
248
|
when 7
|
249
249
|
@cur_factory.collection((1.._get_integer(little_endian_)).map{ _parse_object(true) })
|
250
250
|
else
|
251
|
-
raise
|
251
|
+
raise Error::ParseError, "Unknown type value: #{type_code_}."
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
@@ -279,7 +279,7 @@ module RGeo
|
|
279
279
|
|
280
280
|
def _get_byte # :nodoc:
|
281
281
|
if @_pos + 1 > @_len
|
282
|
-
raise
|
282
|
+
raise Error::ParseError, "Not enough bytes left to fulfill 1 byte"
|
283
283
|
end
|
284
284
|
str_ = @_data[@_pos, 1]
|
285
285
|
@_pos += 1
|
@@ -289,7 +289,7 @@ module RGeo
|
|
289
289
|
|
290
290
|
def _get_integer(little_endian_) # :nodoc:
|
291
291
|
if @_pos + 4 > @_len
|
292
|
-
raise
|
292
|
+
raise Error::ParseError, "Not enough bytes left to fulfill 1 integer"
|
293
293
|
end
|
294
294
|
str_ = @_data[@_pos, 4]
|
295
295
|
@_pos += 4
|
@@ -300,7 +300,7 @@ module RGeo
|
|
300
300
|
def _get_doubles(little_endian_, count_) # :nodoc:
|
301
301
|
len_ = 8 * count_
|
302
302
|
if @_pos + len_ > @_len
|
303
|
-
raise
|
303
|
+
raise Error::ParseError, "Not enough bytes left to fulfill #{count_} doubles"
|
304
304
|
end
|
305
305
|
str_ = @_data[@_pos, len_]
|
306
306
|
@_pos += len_
|