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
@@ -1,279 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Mercator geography feature classes
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
8
|
-
# All rights reserved.
|
9
|
-
#
|
10
|
-
# Redistribution and use in source and binary forms, with or without
|
11
|
-
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
13
|
-
# * Redistributions of source code must retain the above copyright notice,
|
14
|
-
# this list of conditions and the following disclaimer.
|
15
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
-
# this list of conditions and the following disclaimer in the documentation
|
17
|
-
# and/or other materials provided with the distribution.
|
18
|
-
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
-
# contributors to this software, may be used to endorse or promote products
|
20
|
-
# derived from this software without specific prior written permission.
|
21
|
-
#
|
22
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
-
# -----------------------------------------------------------------------------
|
34
|
-
;
|
35
|
-
|
36
|
-
|
37
|
-
module RGeo
|
38
|
-
|
39
|
-
module Geography
|
40
|
-
|
41
|
-
module SimpleMercator # :nodoc:
|
42
|
-
|
43
|
-
|
44
|
-
class PointImpl # :nodoc:
|
45
|
-
|
46
|
-
|
47
|
-
include ::RGeo::Features::Point
|
48
|
-
include ::RGeo::ImplHelpers::BasicGeometryMethods
|
49
|
-
include ::RGeo::ImplHelpers::BasicPointMethods
|
50
|
-
include ::RGeo::Geography::SimpleMercator::GeometryMethods
|
51
|
-
|
52
|
-
|
53
|
-
def _validate_geometry
|
54
|
-
@y = 85.0511287 if @y > 85.0511287
|
55
|
-
@y = -85.0511287 if @y < -85.0511287
|
56
|
-
super
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
def _make_projection(projection_factory_) # :nodoc:
|
61
|
-
rpd_ = ::RGeo::ImplHelpers::Math::RADIANS_PER_DEGREE
|
62
|
-
mpr_ = EQUATORIAL_RADIUS
|
63
|
-
projection_factory_.point(@x * rpd_ * mpr_,
|
64
|
-
::Math.log(::Math.tan(::Math::PI / 4.0 + @y * rpd_ / 2.0)) * mpr_)
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
def scaling_factor
|
69
|
-
1.0 / ::Math.cos(::RGeo::ImplHelpers::Math::RADIANS_PER_DEGREE * @y)
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
def canonical_x
|
74
|
-
x_ = @x % 360.0
|
75
|
-
x_ -= 360.0 if x_ >= 180.0
|
76
|
-
x_
|
77
|
-
end
|
78
|
-
alias_method :canonical_longitude, :canonical_x
|
79
|
-
alias_method :canonical_lon, :canonical_x
|
80
|
-
|
81
|
-
|
82
|
-
def canonical_point
|
83
|
-
if @x >= -180.0 && @x < 180.0
|
84
|
-
self
|
85
|
-
else
|
86
|
-
PointImpl.new(@factory, canonical_x, @y)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
alias_method :longitude, :x
|
92
|
-
alias_method :lon, :x
|
93
|
-
alias_method :latitude, :y
|
94
|
-
alias_method :lat, :y
|
95
|
-
|
96
|
-
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
class LineStringImpl # :nodoc:
|
101
|
-
|
102
|
-
|
103
|
-
include ::RGeo::Features::LineString
|
104
|
-
include ::RGeo::ImplHelpers::BasicGeometryMethods
|
105
|
-
include ::RGeo::ImplHelpers::BasicLineStringMethods
|
106
|
-
include ::RGeo::Geography::SimpleMercator::GeometryMethods
|
107
|
-
include ::RGeo::Geography::SimpleMercator::NCurveMethods
|
108
|
-
include ::RGeo::Geography::SimpleMercator::CurveMethods
|
109
|
-
include ::RGeo::Geography::SimpleMercator::LineStringMethods
|
110
|
-
|
111
|
-
|
112
|
-
def _make_projection(projection_factory_) # :nodoc:
|
113
|
-
projection_factory_.line_string(@points.map{ |p_| p_.projection })
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
class LinearRingImpl # :nodoc:
|
121
|
-
|
122
|
-
|
123
|
-
include ::RGeo::Features::Line
|
124
|
-
include ::RGeo::ImplHelpers::BasicGeometryMethods
|
125
|
-
include ::RGeo::ImplHelpers::BasicLineStringMethods
|
126
|
-
include ::RGeo::ImplHelpers::BasicLinearRingMethods
|
127
|
-
include ::RGeo::Geography::SimpleMercator::GeometryMethods
|
128
|
-
include ::RGeo::Geography::SimpleMercator::NCurveMethods
|
129
|
-
include ::RGeo::Geography::SimpleMercator::CurveMethods
|
130
|
-
include ::RGeo::Geography::SimpleMercator::LineStringMethods
|
131
|
-
|
132
|
-
|
133
|
-
def _make_projection(projection_factory_) # :nodoc:
|
134
|
-
projection_factory_.linear_ring(@points.map{ |p_| p_.projection })
|
135
|
-
end
|
136
|
-
|
137
|
-
|
138
|
-
end
|
139
|
-
|
140
|
-
|
141
|
-
class LineImpl # :nodoc:
|
142
|
-
|
143
|
-
|
144
|
-
include ::RGeo::Features::Line
|
145
|
-
include ::RGeo::ImplHelpers::BasicGeometryMethods
|
146
|
-
include ::RGeo::ImplHelpers::BasicLineStringMethods
|
147
|
-
include ::RGeo::ImplHelpers::BasicLineMethods
|
148
|
-
include ::RGeo::Geography::SimpleMercator::GeometryMethods
|
149
|
-
include ::RGeo::Geography::SimpleMercator::NCurveMethods
|
150
|
-
include ::RGeo::Geography::SimpleMercator::CurveMethods
|
151
|
-
include ::RGeo::Geography::SimpleMercator::LineStringMethods
|
152
|
-
|
153
|
-
|
154
|
-
def _make_projection(projection_factory_) # :nodoc:
|
155
|
-
projection_factory_.line(start_point.projection, end_point.projection)
|
156
|
-
end
|
157
|
-
|
158
|
-
|
159
|
-
end
|
160
|
-
|
161
|
-
|
162
|
-
class PolygonImpl # :nodoc:
|
163
|
-
|
164
|
-
|
165
|
-
include ::RGeo::Features::Polygon
|
166
|
-
include ::RGeo::ImplHelpers::BasicGeometryMethods
|
167
|
-
include ::RGeo::ImplHelpers::BasicPolygonMethods
|
168
|
-
include ::RGeo::Geography::SimpleMercator::GeometryMethods
|
169
|
-
include ::RGeo::Geography::SimpleMercator::NSurfaceMethods
|
170
|
-
include ::RGeo::Geography::SimpleMercator::SurfaceMethods
|
171
|
-
|
172
|
-
|
173
|
-
def _validate_geometry
|
174
|
-
super
|
175
|
-
unless projection
|
176
|
-
raise ::RGeo::Errors::InvalidGeometry, 'Polygon failed assertions'
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
|
181
|
-
def _make_projection(projection_factory_) # :nodoc:
|
182
|
-
projection_factory_.polygon(@exterior_ring.projection,
|
183
|
-
@interior_rings.map{ |p_| p_.projection })
|
184
|
-
end
|
185
|
-
|
186
|
-
|
187
|
-
end
|
188
|
-
|
189
|
-
|
190
|
-
class GeometryCollectionImpl # :nodoc:
|
191
|
-
|
192
|
-
|
193
|
-
include ::RGeo::Features::GeometryCollection
|
194
|
-
include ::RGeo::ImplHelpers::BasicGeometryMethods
|
195
|
-
include ::RGeo::ImplHelpers::BasicGeometryCollectionMethods
|
196
|
-
include ::RGeo::Geography::SimpleMercator::GeometryMethods
|
197
|
-
include ::RGeo::Geography::SimpleMercator::GeometryCollectionMethods
|
198
|
-
|
199
|
-
|
200
|
-
def _make_projection(projection_factory_) # :nodoc:
|
201
|
-
projection_factory_.collection(@elements.map{ |p_| p_.projection })
|
202
|
-
end
|
203
|
-
|
204
|
-
|
205
|
-
end
|
206
|
-
|
207
|
-
|
208
|
-
class MultiPointImpl # :nodoc:
|
209
|
-
|
210
|
-
|
211
|
-
include ::RGeo::Features::GeometryCollection
|
212
|
-
include ::RGeo::ImplHelpers::BasicGeometryMethods
|
213
|
-
include ::RGeo::ImplHelpers::BasicGeometryCollectionMethods
|
214
|
-
include ::RGeo::ImplHelpers::BasicMultiPointMethods
|
215
|
-
include ::RGeo::Geography::SimpleMercator::GeometryMethods
|
216
|
-
include ::RGeo::Geography::SimpleMercator::GeometryCollectionMethods
|
217
|
-
|
218
|
-
|
219
|
-
def _make_projection(projection_factory_) # :nodoc:
|
220
|
-
projection_factory_.multi_point(@elements.map{ |p_| p_.projection })
|
221
|
-
end
|
222
|
-
|
223
|
-
|
224
|
-
end
|
225
|
-
|
226
|
-
|
227
|
-
class MultiLineStringImpl # :nodoc:
|
228
|
-
|
229
|
-
|
230
|
-
include ::RGeo::Features::GeometryCollection
|
231
|
-
include ::RGeo::ImplHelpers::BasicGeometryMethods
|
232
|
-
include ::RGeo::ImplHelpers::BasicGeometryCollectionMethods
|
233
|
-
include ::RGeo::ImplHelpers::BasicMultiLineStringMethods
|
234
|
-
include ::RGeo::Geography::SimpleMercator::GeometryMethods
|
235
|
-
include ::RGeo::Geography::SimpleMercator::NCurveMethods
|
236
|
-
include ::RGeo::Geography::SimpleMercator::GeometryCollectionMethods
|
237
|
-
|
238
|
-
|
239
|
-
def _make_projection(projection_factory_) # :nodoc:
|
240
|
-
projection_factory_.multi_line_string(@elements.map{ |p_| p_.projection })
|
241
|
-
end
|
242
|
-
|
243
|
-
|
244
|
-
end
|
245
|
-
|
246
|
-
|
247
|
-
class MultiPolygonImpl # :nodoc:
|
248
|
-
|
249
|
-
|
250
|
-
include ::RGeo::Features::GeometryCollection
|
251
|
-
include ::RGeo::ImplHelpers::BasicGeometryMethods
|
252
|
-
include ::RGeo::ImplHelpers::BasicGeometryCollectionMethods
|
253
|
-
include ::RGeo::ImplHelpers::BasicMultiPolygonMethods
|
254
|
-
include ::RGeo::Geography::SimpleMercator::GeometryMethods
|
255
|
-
include ::RGeo::Geography::SimpleMercator::NSurfaceMethods
|
256
|
-
include ::RGeo::Geography::SimpleMercator::GeometryCollectionMethods
|
257
|
-
|
258
|
-
|
259
|
-
def _validate_geometry
|
260
|
-
super
|
261
|
-
unless projection
|
262
|
-
raise ::RGeo::Errors::InvalidGeometry, 'MultiPolygon failed assertions'
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
|
267
|
-
def _make_projection(projection_factory_) # :nodoc:
|
268
|
-
projection_factory_.multi_polygon(@elements.map{ |p_| p_.projection })
|
269
|
-
end
|
270
|
-
|
271
|
-
|
272
|
-
end
|
273
|
-
|
274
|
-
|
275
|
-
end
|
276
|
-
|
277
|
-
end
|
278
|
-
|
279
|
-
end
|
@@ -1,278 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Mercator geography common method definitions
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
8
|
-
# All rights reserved.
|
9
|
-
#
|
10
|
-
# Redistribution and use in source and binary forms, with or without
|
11
|
-
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
13
|
-
# * Redistributions of source code must retain the above copyright notice,
|
14
|
-
# this list of conditions and the following disclaimer.
|
15
|
-
# * Redistributions in binary form must reproduce the above copyright notice,
|
16
|
-
# this list of conditions and the following disclaimer in the documentation
|
17
|
-
# and/or other materials provided with the distribution.
|
18
|
-
# * Neither the name of the copyright holder, nor the names of any other
|
19
|
-
# contributors to this software, may be used to endorse or promote products
|
20
|
-
# derived from this software without specific prior written permission.
|
21
|
-
#
|
22
|
-
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
|
-
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
-
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
-
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
-
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
-
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
-
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
-
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
-
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
-
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
-
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
-
# -----------------------------------------------------------------------------
|
34
|
-
;
|
35
|
-
|
36
|
-
|
37
|
-
module RGeo
|
38
|
-
|
39
|
-
module Geography
|
40
|
-
|
41
|
-
module SimpleMercator # :nodoc:
|
42
|
-
|
43
|
-
|
44
|
-
module GeometryMethods # :nodoc:
|
45
|
-
|
46
|
-
|
47
|
-
def srid
|
48
|
-
4326
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
def projection
|
53
|
-
if @projection.nil?
|
54
|
-
projection_factory_ = @factory.projection_factory
|
55
|
-
@projection = projection_factory_ ? _make_projection(projection_factory_) : nil
|
56
|
-
@projection = false unless @projection
|
57
|
-
end
|
58
|
-
@projection ? @projection : nil
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
def _make_projection(projection_factory_) # :nodoc:
|
63
|
-
nil
|
64
|
-
end
|
65
|
-
|
66
|
-
|
67
|
-
def scaling_factor
|
68
|
-
1.0
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
def envelope
|
73
|
-
factory.unproject(projection.envelope)
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
|
-
def is_empty?
|
78
|
-
projection.is_empty?
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
def is_simple?
|
83
|
-
projection.is_simple?
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
def boundary
|
88
|
-
factory.unproject(projection.boundary)
|
89
|
-
end
|
90
|
-
|
91
|
-
|
92
|
-
def equals?(rhs_)
|
93
|
-
projection.equals?(Features.cast(rhs_, factory).projection)
|
94
|
-
end
|
95
|
-
|
96
|
-
|
97
|
-
def disjoint?(rhs_)
|
98
|
-
projection.disjoint?(Features.cast(rhs_, factory).projection)
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
def intersects?(rhs_)
|
103
|
-
projection.intersects?(Features.cast(rhs_, factory).projection)
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
def touches?(rhs_)
|
108
|
-
projection.touches?(Features.cast(rhs_, factory).projection)
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
def crosses?(rhs_)
|
113
|
-
projection.crosses?(Features.cast(rhs_, factory).projection)
|
114
|
-
end
|
115
|
-
|
116
|
-
|
117
|
-
def within?(rhs_)
|
118
|
-
projection.within?(Features.cast(rhs_, factory).projection)
|
119
|
-
end
|
120
|
-
|
121
|
-
|
122
|
-
def contains?(rhs_)
|
123
|
-
projection.contains?(Features.cast(rhs_, factory).projection)
|
124
|
-
end
|
125
|
-
|
126
|
-
|
127
|
-
def overlaps?(rhs_)
|
128
|
-
projection.overlaps?(Features.cast(rhs_, factory).projection)
|
129
|
-
end
|
130
|
-
|
131
|
-
|
132
|
-
def relate(rhs_, pattern_)
|
133
|
-
projection.relate(Features.cast(rhs_, factory).projection, pattern_)
|
134
|
-
end
|
135
|
-
|
136
|
-
|
137
|
-
def distance(rhs_)
|
138
|
-
projection.distance(Features.cast(rhs_, factory).projection) / scaling_factor
|
139
|
-
end
|
140
|
-
|
141
|
-
|
142
|
-
def buffer(distance_)
|
143
|
-
factory.unproject(projection.buffer(distance_ * scaling_factor))
|
144
|
-
end
|
145
|
-
|
146
|
-
|
147
|
-
def convex_hull
|
148
|
-
factory.unproject(projection.convex_hull)
|
149
|
-
end
|
150
|
-
|
151
|
-
|
152
|
-
def intersection(rhs_)
|
153
|
-
factory.unproject(projection.intersection(Features.cast(rhs_, factory).projection))
|
154
|
-
end
|
155
|
-
|
156
|
-
|
157
|
-
def union(rhs_)
|
158
|
-
factory.unproject(projection.union(Features.cast(rhs_, factory).projection))
|
159
|
-
end
|
160
|
-
|
161
|
-
|
162
|
-
def difference(rhs_)
|
163
|
-
factory.unproject(projection.difference(Features.cast(rhs_, factory).projection))
|
164
|
-
end
|
165
|
-
|
166
|
-
|
167
|
-
def sym_difference(rhs_)
|
168
|
-
factory.unproject(projection.sym_difference(Features.cast(rhs_, factory).projection))
|
169
|
-
end
|
170
|
-
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
|
175
|
-
module GeometryCollectionMethods # :nodoc:
|
176
|
-
|
177
|
-
|
178
|
-
def scaling_factor
|
179
|
-
is_empty? ? 1.0 : geometry_n(0).scaling_factor
|
180
|
-
end
|
181
|
-
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
|
186
|
-
module NCurveMethods # :nodoc:
|
187
|
-
|
188
|
-
|
189
|
-
def length
|
190
|
-
projection.length / scaling_factor
|
191
|
-
end
|
192
|
-
|
193
|
-
|
194
|
-
end
|
195
|
-
|
196
|
-
|
197
|
-
module CurveMethods # :nodoc:
|
198
|
-
|
199
|
-
|
200
|
-
def scaling_factor
|
201
|
-
is_empty? ? 1.0 : start_point.scaling_factor
|
202
|
-
end
|
203
|
-
|
204
|
-
|
205
|
-
end
|
206
|
-
|
207
|
-
|
208
|
-
module LineStringMethods # :nodoc:
|
209
|
-
|
210
|
-
|
211
|
-
def _validate_geometry
|
212
|
-
size_ = @points.size
|
213
|
-
if size_ > 1
|
214
|
-
last_ = @points[0]
|
215
|
-
(1...size_).each do |i_|
|
216
|
-
p_ = @points[i_]
|
217
|
-
last_x_ = last_.x
|
218
|
-
p_x_ = p_.x
|
219
|
-
changed_ = true
|
220
|
-
if p_x_ < last_x_ - 180.0
|
221
|
-
p_x_ += 360.0 while p_x_ < last_x_ - 180.0
|
222
|
-
elsif p_x_ > last_x_ + 180.0
|
223
|
-
p_x_ +- 360.0 while p_x_ > last_x_ + 180.0
|
224
|
-
else
|
225
|
-
changed_ = false
|
226
|
-
end
|
227
|
-
if changed_
|
228
|
-
p_ = factory.point(p_x_, p_.y)
|
229
|
-
@points[i_] = p_
|
230
|
-
end
|
231
|
-
last_ = p_
|
232
|
-
end
|
233
|
-
end
|
234
|
-
super
|
235
|
-
end
|
236
|
-
|
237
|
-
|
238
|
-
end
|
239
|
-
|
240
|
-
|
241
|
-
module NSurfaceMethods # :nodoc:
|
242
|
-
|
243
|
-
|
244
|
-
def area
|
245
|
-
factor_ = scaling_factor
|
246
|
-
projection.area / (factor_ * factor_)
|
247
|
-
end
|
248
|
-
|
249
|
-
|
250
|
-
def centroid
|
251
|
-
factory.unproject(projection.centroid)
|
252
|
-
end
|
253
|
-
|
254
|
-
|
255
|
-
def point_on_surface
|
256
|
-
factory.unproject(projection.point_on_surface)
|
257
|
-
end
|
258
|
-
|
259
|
-
|
260
|
-
end
|
261
|
-
|
262
|
-
|
263
|
-
module SurfaceMethods # :nodoc:
|
264
|
-
|
265
|
-
|
266
|
-
def scaling_factor
|
267
|
-
is_empty? ? 1.0 : point_on_surface.scaling_factor
|
268
|
-
end
|
269
|
-
|
270
|
-
|
271
|
-
end
|
272
|
-
|
273
|
-
|
274
|
-
end
|
275
|
-
|
276
|
-
end
|
277
|
-
|
278
|
-
end
|