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
@@ -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 Geography
|
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_, :srid => opts_[:srid], :buffer_resolution => opts_[:buffer_resolution], :lenient_multi_polygon_assertions => opts_[:lenient_multi_polygon_assertions], :support_z_coordinate => opts_[:support_z_coordinate], :support_m_coordinate => opts_[:support_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
|
+
# 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
|
+
|
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
|
+
# 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
|
+
|
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
|