schleyfox-rgeo 0.2.5
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 +199 -0
- data/README.rdoc +172 -0
- data/Spatial_Programming_With_RGeo.rdoc +440 -0
- data/Version +1 -0
- data/ext/geos_c_impl/extconf.rb +84 -0
- data/ext/geos_c_impl/factory.c +468 -0
- data/ext/geos_c_impl/factory.h +224 -0
- data/ext/geos_c_impl/geometry.c +705 -0
- data/ext/geos_c_impl/geometry.h +55 -0
- data/ext/geos_c_impl/geometry_collection.c +482 -0
- data/ext/geos_c_impl/geometry_collection.h +69 -0
- data/ext/geos_c_impl/line_string.c +509 -0
- data/ext/geos_c_impl/line_string.h +64 -0
- data/ext/geos_c_impl/main.c +70 -0
- data/ext/geos_c_impl/point.c +193 -0
- data/ext/geos_c_impl/point.h +62 -0
- data/ext/geos_c_impl/polygon.c +265 -0
- data/ext/geos_c_impl/polygon.h +66 -0
- data/ext/geos_c_impl/preface.h +50 -0
- data/ext/proj4_c_impl/extconf.rb +88 -0
- data/ext/proj4_c_impl/main.c +271 -0
- data/lib/rgeo.rb +124 -0
- data/lib/rgeo/cartesian.rb +60 -0
- data/lib/rgeo/cartesian/analysis.rb +118 -0
- data/lib/rgeo/cartesian/bounding_box.rb +337 -0
- data/lib/rgeo/cartesian/calculations.rb +161 -0
- data/lib/rgeo/cartesian/factory.rb +209 -0
- data/lib/rgeo/cartesian/feature_classes.rb +173 -0
- data/lib/rgeo/cartesian/feature_methods.rb +106 -0
- data/lib/rgeo/cartesian/interface.rb +150 -0
- data/lib/rgeo/coord_sys.rb +79 -0
- data/lib/rgeo/coord_sys/cs/entities.rb +1524 -0
- data/lib/rgeo/coord_sys/cs/factories.rb +208 -0
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +308 -0
- data/lib/rgeo/coord_sys/proj4.rb +312 -0
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +194 -0
- data/lib/rgeo/coord_sys/srs_database/interface.rb +165 -0
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +188 -0
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +108 -0
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +108 -0
- data/lib/rgeo/error.rb +63 -0
- data/lib/rgeo/feature.rb +88 -0
- data/lib/rgeo/feature/curve.rb +156 -0
- data/lib/rgeo/feature/factory.rb +332 -0
- data/lib/rgeo/feature/factory_generator.rb +138 -0
- data/lib/rgeo/feature/geometry.rb +614 -0
- data/lib/rgeo/feature/geometry_collection.rb +129 -0
- data/lib/rgeo/feature/line.rb +66 -0
- data/lib/rgeo/feature/line_string.rb +102 -0
- data/lib/rgeo/feature/linear_ring.rb +66 -0
- data/lib/rgeo/feature/multi_curve.rb +113 -0
- data/lib/rgeo/feature/multi_line_string.rb +66 -0
- data/lib/rgeo/feature/multi_point.rb +73 -0
- data/lib/rgeo/feature/multi_polygon.rb +97 -0
- data/lib/rgeo/feature/multi_surface.rb +116 -0
- data/lib/rgeo/feature/point.rb +120 -0
- data/lib/rgeo/feature/polygon.rb +141 -0
- data/lib/rgeo/feature/surface.rb +122 -0
- data/lib/rgeo/feature/types.rb +305 -0
- data/lib/rgeo/geographic.rb +75 -0
- data/lib/rgeo/geographic/factory.rb +287 -0
- data/lib/rgeo/geographic/interface.rb +410 -0
- data/lib/rgeo/geographic/proj4_projector.rb +98 -0
- data/lib/rgeo/geographic/projected_feature_classes.rb +213 -0
- data/lib/rgeo/geographic/projected_feature_methods.rb +228 -0
- data/lib/rgeo/geographic/projected_window.rb +467 -0
- data/lib/rgeo/geographic/simple_mercator_projector.rb +157 -0
- data/lib/rgeo/geographic/spherical_feature_classes.rb +212 -0
- data/lib/rgeo/geographic/spherical_feature_methods.rb +97 -0
- data/lib/rgeo/geographic/spherical_math.rb +206 -0
- data/lib/rgeo/geos.rb +72 -0
- data/lib/rgeo/geos/factory.rb +301 -0
- data/lib/rgeo/geos/impl_additions.rb +76 -0
- data/lib/rgeo/geos/interface.rb +139 -0
- data/lib/rgeo/geos/zm_factory.rb +275 -0
- data/lib/rgeo/geos/zm_impl.rb +432 -0
- data/lib/rgeo/impl_helper.rb +53 -0
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +235 -0
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +85 -0
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +197 -0
- data/lib/rgeo/impl_helper/basic_point_methods.rb +138 -0
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +121 -0
- data/lib/rgeo/impl_helper/math.rb +50 -0
- data/lib/rgeo/version.rb +52 -0
- data/lib/rgeo/wkrep.rb +72 -0
- data/lib/rgeo/wkrep/wkb_generator.rb +267 -0
- data/lib/rgeo/wkrep/wkb_parser.rb +315 -0
- data/lib/rgeo/wkrep/wkt_generator.rb +275 -0
- data/lib/rgeo/wkrep/wkt_parser.rb +496 -0
- data/test/common/geometry_collection_tests.rb +238 -0
- data/test/common/line_string_tests.rb +324 -0
- data/test/common/multi_line_string_tests.rb +209 -0
- data/test/common/multi_point_tests.rb +201 -0
- data/test/common/multi_polygon_tests.rb +208 -0
- data/test/common/point_tests.rb +331 -0
- data/test/common/polygon_tests.rb +232 -0
- data/test/coord_sys/tc_active_record_table.rb +102 -0
- data/test/coord_sys/tc_ogc_cs.rb +356 -0
- data/test/coord_sys/tc_proj4.rb +138 -0
- data/test/coord_sys/tc_proj4_srs_data.rb +76 -0
- data/test/coord_sys/tc_sr_org.rb +70 -0
- data/test/coord_sys/tc_url_reader.rb +82 -0
- data/test/geos/tc_factory.rb +91 -0
- data/test/geos/tc_geometry_collection.rb +62 -0
- data/test/geos/tc_line_string.rb +62 -0
- data/test/geos/tc_misc.rb +72 -0
- data/test/geos/tc_multi_line_string.rb +62 -0
- data/test/geos/tc_multi_point.rb +62 -0
- data/test/geos/tc_multi_polygon.rb +63 -0
- data/test/geos/tc_point.rb +86 -0
- data/test/geos/tc_polygon.rb +86 -0
- data/test/geos/tc_zmfactory.rb +85 -0
- data/test/projected_geographic/tc_geometry_collection.rb +62 -0
- data/test/projected_geographic/tc_line_string.rb +62 -0
- data/test/projected_geographic/tc_multi_line_string.rb +62 -0
- data/test/projected_geographic/tc_multi_point.rb +62 -0
- data/test/projected_geographic/tc_multi_polygon.rb +63 -0
- data/test/projected_geographic/tc_point.rb +93 -0
- data/test/projected_geographic/tc_polygon.rb +62 -0
- data/test/simple_cartesian/tc_calculations.rb +145 -0
- data/test/simple_cartesian/tc_geometry_collection.rb +69 -0
- data/test/simple_cartesian/tc_line_string.rb +70 -0
- data/test/simple_cartesian/tc_multi_line_string.rb +67 -0
- data/test/simple_cartesian/tc_multi_point.rb +67 -0
- data/test/simple_cartesian/tc_multi_polygon.rb +70 -0
- data/test/simple_cartesian/tc_point.rb +91 -0
- data/test/simple_cartesian/tc_polygon.rb +67 -0
- data/test/simple_mercator/tc_geometry_collection.rb +62 -0
- data/test/simple_mercator/tc_line_string.rb +62 -0
- data/test/simple_mercator/tc_multi_line_string.rb +62 -0
- data/test/simple_mercator/tc_multi_point.rb +62 -0
- data/test/simple_mercator/tc_multi_polygon.rb +63 -0
- data/test/simple_mercator/tc_point.rb +93 -0
- data/test/simple_mercator/tc_polygon.rb +62 -0
- data/test/simple_mercator/tc_window.rb +219 -0
- data/test/spherical_geographic/tc_calculations.rb +203 -0
- data/test/spherical_geographic/tc_geometry_collection.rb +70 -0
- data/test/spherical_geographic/tc_line_string.rb +70 -0
- data/test/spherical_geographic/tc_multi_line_string.rb +67 -0
- data/test/spherical_geographic/tc_multi_point.rb +67 -0
- data/test/spherical_geographic/tc_multi_polygon.rb +70 -0
- data/test/spherical_geographic/tc_point.rb +100 -0
- data/test/spherical_geographic/tc_polygon.rb +67 -0
- data/test/tc_cartesian_analysis.rb +107 -0
- data/test/tc_oneoff.rb +63 -0
- data/test/wkrep/tc_wkb_generator.rb +249 -0
- data/test/wkrep/tc_wkb_parser.rb +353 -0
- data/test/wkrep/tc_wkt_generator.rb +362 -0
- data/test/wkrep/tc_wkt_parser.rb +480 -0
- metadata +267 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Proj4 projection
|
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 Geographic
|
40
|
+
|
41
|
+
|
42
|
+
class Proj4Projector # :nodoc:
|
43
|
+
|
44
|
+
|
45
|
+
def initialize(geography_factory_, projection_factory_)
|
46
|
+
@geography_factory = geography_factory_
|
47
|
+
@projection_factory = projection_factory_
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def project(geometry_)
|
52
|
+
Feature.cast(geometry_, @projection_factory, :project)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def unproject(geometry_)
|
57
|
+
Feature.cast(geometry_, @geography_factory, :project)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
def projection_factory
|
62
|
+
@projection_factory
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def wraps?
|
67
|
+
false
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
def limits_window
|
72
|
+
nil
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
class << self
|
77
|
+
|
78
|
+
|
79
|
+
def create_from_existing_factory(geography_factory_, projection_factory_)
|
80
|
+
new(geography_factory_, projection_factory_)
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def create_from_proj4(geography_factory_, proj4_, opts_={})
|
85
|
+
projection_factory_ = Cartesian.preferred_factory(:proj4 => proj4_, :coord_sys => opts_[:coord_sys], :srid => opts_[:srid], :buffer_resolution => opts_[:buffer_resolution], :lenient_multi_polygon_assertions => opts_[:lenient_multi_polygon_assertions], :has_z_coordinate => opts_[:has_z_coordinate], :has_m_coordinate => opts_[:has_m_coordinate])
|
86
|
+
new(geography_factory_, projection_factory_)
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Projtected geographic 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 Geographic
|
40
|
+
|
41
|
+
|
42
|
+
class ProjectedPointImpl # :nodoc:
|
43
|
+
|
44
|
+
|
45
|
+
include Feature::Point
|
46
|
+
include ImplHelper::BasicGeometryMethods
|
47
|
+
include ImplHelper::BasicPointMethods
|
48
|
+
include ProjectedGeometryMethods
|
49
|
+
|
50
|
+
|
51
|
+
def _validate_geometry
|
52
|
+
@y = 85.0511287 if @y > 85.0511287
|
53
|
+
@y = -85.0511287 if @y < -85.0511287
|
54
|
+
super
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def canonical_x
|
59
|
+
x_ = @x % 360.0
|
60
|
+
x_ -= 360.0 if x_ >= 180.0
|
61
|
+
x_
|
62
|
+
end
|
63
|
+
alias_method :canonical_longitude, :canonical_x
|
64
|
+
alias_method :canonical_lon, :canonical_x
|
65
|
+
|
66
|
+
|
67
|
+
def canonical_point
|
68
|
+
if @x >= -180.0 && @x < 180.0
|
69
|
+
self
|
70
|
+
else
|
71
|
+
PointImpl.new(@factory, canonical_x, @y)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
alias_method :longitude, :x
|
77
|
+
alias_method :lon, :x
|
78
|
+
alias_method :latitude, :y
|
79
|
+
alias_method :lat, :y
|
80
|
+
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
class ProjectedLineStringImpl # :nodoc:
|
86
|
+
|
87
|
+
|
88
|
+
include Feature::LineString
|
89
|
+
include ImplHelper::BasicGeometryMethods
|
90
|
+
include ImplHelper::BasicLineStringMethods
|
91
|
+
include ProjectedGeometryMethods
|
92
|
+
include ProjectedNCurveMethods
|
93
|
+
include ProjectedLineStringMethods
|
94
|
+
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
class ProjectedLinearRingImpl # :nodoc:
|
100
|
+
|
101
|
+
|
102
|
+
include Feature::Line
|
103
|
+
include ImplHelper::BasicGeometryMethods
|
104
|
+
include ImplHelper::BasicLineStringMethods
|
105
|
+
include ImplHelper::BasicLinearRingMethods
|
106
|
+
include ProjectedGeometryMethods
|
107
|
+
include ProjectedNCurveMethods
|
108
|
+
include ProjectedLineStringMethods
|
109
|
+
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
class ProjectedLineImpl # :nodoc:
|
115
|
+
|
116
|
+
|
117
|
+
include Feature::Line
|
118
|
+
include ImplHelper::BasicGeometryMethods
|
119
|
+
include ImplHelper::BasicLineStringMethods
|
120
|
+
include ImplHelper::BasicLineMethods
|
121
|
+
include ProjectedGeometryMethods
|
122
|
+
include ProjectedNCurveMethods
|
123
|
+
include ProjectedLineStringMethods
|
124
|
+
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
class ProjectedPolygonImpl # :nodoc:
|
130
|
+
|
131
|
+
|
132
|
+
include Feature::Polygon
|
133
|
+
include ImplHelper::BasicGeometryMethods
|
134
|
+
include ImplHelper::BasicPolygonMethods
|
135
|
+
include ProjectedGeometryMethods
|
136
|
+
include ProjectedNSurfaceMethods
|
137
|
+
|
138
|
+
|
139
|
+
def _validate_geometry
|
140
|
+
super
|
141
|
+
unless projection
|
142
|
+
raise Error::InvalidGeometry, 'Polygon failed assertions'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
class ProjectedGeometryCollectionImpl # :nodoc:
|
151
|
+
|
152
|
+
|
153
|
+
include Feature::GeometryCollection
|
154
|
+
include ImplHelper::BasicGeometryMethods
|
155
|
+
include ImplHelper::BasicGeometryCollectionMethods
|
156
|
+
include ProjectedGeometryMethods
|
157
|
+
|
158
|
+
|
159
|
+
end
|
160
|
+
|
161
|
+
|
162
|
+
class ProjectedMultiPointImpl # :nodoc:
|
163
|
+
|
164
|
+
|
165
|
+
include Feature::GeometryCollection
|
166
|
+
include ImplHelper::BasicGeometryMethods
|
167
|
+
include ImplHelper::BasicGeometryCollectionMethods
|
168
|
+
include ImplHelper::BasicMultiPointMethods
|
169
|
+
include ProjectedGeometryMethods
|
170
|
+
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
class ProjectedMultiLineStringImpl # :nodoc:
|
176
|
+
|
177
|
+
|
178
|
+
include Feature::GeometryCollection
|
179
|
+
include ImplHelper::BasicGeometryMethods
|
180
|
+
include ImplHelper::BasicGeometryCollectionMethods
|
181
|
+
include ImplHelper::BasicMultiLineStringMethods
|
182
|
+
include ProjectedGeometryMethods
|
183
|
+
include ProjectedNCurveMethods
|
184
|
+
|
185
|
+
|
186
|
+
end
|
187
|
+
|
188
|
+
|
189
|
+
class ProjectedMultiPolygonImpl # :nodoc:
|
190
|
+
|
191
|
+
|
192
|
+
include Feature::GeometryCollection
|
193
|
+
include ImplHelper::BasicGeometryMethods
|
194
|
+
include ImplHelper::BasicGeometryCollectionMethods
|
195
|
+
include ImplHelper::BasicMultiPolygonMethods
|
196
|
+
include ProjectedGeometryMethods
|
197
|
+
include ProjectedNSurfaceMethods
|
198
|
+
|
199
|
+
|
200
|
+
def _validate_geometry
|
201
|
+
super
|
202
|
+
unless projection
|
203
|
+
raise Error::InvalidGeometry, 'MultiPolygon failed assertions'
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
end
|
@@ -0,0 +1,228 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Projected geographic 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 Geographic
|
40
|
+
|
41
|
+
|
42
|
+
module ProjectedGeometryMethods # :nodoc:
|
43
|
+
|
44
|
+
|
45
|
+
def srid
|
46
|
+
factory.srid
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def projection
|
51
|
+
unless defined?(@projection)
|
52
|
+
@projection = factory.project(self)
|
53
|
+
end
|
54
|
+
@projection
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def envelope
|
59
|
+
factory.unproject(projection.envelope)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
def is_empty?
|
64
|
+
projection.is_empty?
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def is_simple?
|
69
|
+
projection.is_simple?
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def boundary
|
74
|
+
factory.unproject(projection.boundary)
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def equals?(rhs_)
|
79
|
+
projection.equals?(Feature.cast(rhs_, factory).projection)
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
def disjoint?(rhs_)
|
84
|
+
projection.disjoint?(Feature.cast(rhs_, factory).projection)
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def intersects?(rhs_)
|
89
|
+
projection.intersects?(Feature.cast(rhs_, factory).projection)
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
def touches?(rhs_)
|
94
|
+
projection.touches?(Feature.cast(rhs_, factory).projection)
|
95
|
+
end
|
96
|
+
|
97
|
+
|
98
|
+
def crosses?(rhs_)
|
99
|
+
projection.crosses?(Feature.cast(rhs_, factory).projection)
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def within?(rhs_)
|
104
|
+
projection.within?(Feature.cast(rhs_, factory).projection)
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
def contains?(rhs_)
|
109
|
+
projection.contains?(Feature.cast(rhs_, factory).projection)
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
def overlaps?(rhs_)
|
114
|
+
projection.overlaps?(Feature.cast(rhs_, factory).projection)
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
def relate(rhs_, pattern_)
|
119
|
+
projection.relate(Feature.cast(rhs_, factory).projection, pattern_)
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
def distance(rhs_)
|
124
|
+
projection.distance(Feature.cast(rhs_, factory).projection)
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
def buffer(distance_)
|
129
|
+
factory.unproject(projection.buffer(distance_))
|
130
|
+
end
|
131
|
+
|
132
|
+
|
133
|
+
def convex_hull
|
134
|
+
factory.unproject(projection.convex_hull)
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
def intersection(rhs_)
|
139
|
+
factory.unproject(projection.intersection(Feature.cast(rhs_, factory).projection))
|
140
|
+
end
|
141
|
+
|
142
|
+
|
143
|
+
def union(rhs_)
|
144
|
+
factory.unproject(projection.union(Feature.cast(rhs_, factory).projection))
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
def difference(rhs_)
|
149
|
+
factory.unproject(projection.difference(Feature.cast(rhs_, factory).projection))
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
def sym_difference(rhs_)
|
154
|
+
factory.unproject(projection.sym_difference(Feature.cast(rhs_, factory).projection))
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
module ProjectedNCurveMethods # :nodoc:
|
162
|
+
|
163
|
+
|
164
|
+
def length
|
165
|
+
projection.length
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
|
172
|
+
module ProjectedLineStringMethods # :nodoc:
|
173
|
+
|
174
|
+
|
175
|
+
def _validate_geometry
|
176
|
+
size_ = @points.size
|
177
|
+
if size_ > 1
|
178
|
+
last_ = @points[0]
|
179
|
+
(1...size_).each do |i_|
|
180
|
+
p_ = @points[i_]
|
181
|
+
last_x_ = last_.x
|
182
|
+
p_x_ = p_.x
|
183
|
+
changed_ = true
|
184
|
+
if p_x_ < last_x_ - 180.0
|
185
|
+
p_x_ += 360.0 while p_x_ < last_x_ - 180.0
|
186
|
+
elsif p_x_ > last_x_ + 180.0
|
187
|
+
p_x_ +- 360.0 while p_x_ > last_x_ + 180.0
|
188
|
+
else
|
189
|
+
changed_ = false
|
190
|
+
end
|
191
|
+
if changed_
|
192
|
+
p_ = factory.point(p_x_, p_.y)
|
193
|
+
@points[i_] = p_
|
194
|
+
end
|
195
|
+
last_ = p_
|
196
|
+
end
|
197
|
+
end
|
198
|
+
super
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
module ProjectedNSurfaceMethods # :nodoc:
|
206
|
+
|
207
|
+
|
208
|
+
def area
|
209
|
+
projection.area
|
210
|
+
end
|
211
|
+
|
212
|
+
|
213
|
+
def centroid
|
214
|
+
factory.unproject(projection.centroid)
|
215
|
+
end
|
216
|
+
|
217
|
+
|
218
|
+
def point_on_surface
|
219
|
+
factory.unproject(projection.point_on_surface)
|
220
|
+
end
|
221
|
+
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|