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
@@ -71,8 +71,8 @@ module RGeo
|
|
71
71
|
def test_creation_simple
|
72
72
|
geom_ = @factory.multi_polygon([@poly1, @poly2])
|
73
73
|
assert_not_nil(geom_)
|
74
|
-
assert(::RGeo::
|
75
|
-
assert_equal(::RGeo::
|
74
|
+
assert(::RGeo::Feature::MultiPolygon === geom_)
|
75
|
+
assert_equal(::RGeo::Feature::MultiPolygon, geom_.geometry_type)
|
76
76
|
assert_equal(2, geom_.num_geometries)
|
77
77
|
assert(@poly1.eql?(geom_[0]))
|
78
78
|
assert(@poly2.eql?(geom_[1]))
|
@@ -82,8 +82,8 @@ module RGeo
|
|
82
82
|
def test_creation_empty
|
83
83
|
geom_ = @factory.multi_polygon([])
|
84
84
|
assert_not_nil(geom_)
|
85
|
-
assert(::RGeo::
|
86
|
-
assert_equal(::RGeo::
|
85
|
+
assert(::RGeo::Feature::MultiPolygon === geom_)
|
86
|
+
assert_equal(::RGeo::Feature::MultiPolygon, geom_.geometry_type)
|
87
87
|
assert_equal(0, geom_.num_geometries)
|
88
88
|
assert_equal([], geom_.to_a)
|
89
89
|
end
|
@@ -136,7 +136,7 @@ module RGeo
|
|
136
136
|
|
137
137
|
def test_wkt_creation_empty
|
138
138
|
parsed_geom_ = @factory.parse_wkt('MULTIPOLYGON EMPTY')
|
139
|
-
assert_equal(::RGeo::
|
139
|
+
assert_equal(::RGeo::Feature::MultiPolygon, parsed_geom_.geometry_type)
|
140
140
|
assert_equal(0, parsed_geom_.num_geometries)
|
141
141
|
assert_equal([], parsed_geom_.to_a)
|
142
142
|
end
|
@@ -146,7 +146,7 @@ module RGeo
|
|
146
146
|
geom1_ = @factory.multi_polygon([@poly1, @poly2])
|
147
147
|
geom2_ = geom1_.clone
|
148
148
|
assert(geom1_.eql?(geom2_))
|
149
|
-
assert_equal(::RGeo::
|
149
|
+
assert_equal(::RGeo::Feature::MultiPolygon, geom2_.geometry_type)
|
150
150
|
assert_equal(2, geom2_.num_geometries)
|
151
151
|
assert(@poly1.eql?(geom2_[0]))
|
152
152
|
assert(@poly2.eql?(geom2_[1]))
|
@@ -155,17 +155,17 @@ module RGeo
|
|
155
155
|
|
156
156
|
def test_type_check
|
157
157
|
geom1_ = @factory.multi_polygon([@poly1, @poly2])
|
158
|
-
assert(::RGeo::
|
159
|
-
assert(!::RGeo::
|
160
|
-
assert(::RGeo::
|
161
|
-
assert(!::RGeo::
|
162
|
-
assert(::RGeo::
|
158
|
+
assert(::RGeo::Feature::Geometry.check_type(geom1_))
|
159
|
+
assert(!::RGeo::Feature::Polygon.check_type(geom1_))
|
160
|
+
assert(::RGeo::Feature::GeometryCollection.check_type(geom1_))
|
161
|
+
assert(!::RGeo::Feature::MultiPoint.check_type(geom1_))
|
162
|
+
assert(::RGeo::Feature::MultiPolygon.check_type(geom1_))
|
163
163
|
geom2_ = @factory.multi_polygon([])
|
164
|
-
assert(::RGeo::
|
165
|
-
assert(!::RGeo::
|
166
|
-
assert(::RGeo::
|
167
|
-
assert(!::RGeo::
|
168
|
-
assert(::RGeo::
|
164
|
+
assert(::RGeo::Feature::Geometry.check_type(geom2_))
|
165
|
+
assert(!::RGeo::Feature::Polygon.check_type(geom2_))
|
166
|
+
assert(::RGeo::Feature::GeometryCollection.check_type(geom2_))
|
167
|
+
assert(!::RGeo::Feature::MultiPoint.check_type(geom2_))
|
168
|
+
assert(::RGeo::Feature::MultiPolygon.check_type(geom2_))
|
169
169
|
end
|
170
170
|
|
171
171
|
|
@@ -81,16 +81,16 @@ module RGeo
|
|
81
81
|
|
82
82
|
def test_type_check
|
83
83
|
point_ = @factory.point(21, 22)
|
84
|
-
assert(::RGeo::
|
85
|
-
assert(::RGeo::
|
86
|
-
assert(!::RGeo::
|
87
|
-
assert(!::RGeo::
|
84
|
+
assert(::RGeo::Feature::Geometry.check_type(point_))
|
85
|
+
assert(::RGeo::Feature::Point.check_type(point_))
|
86
|
+
assert(!::RGeo::Feature::GeometryCollection.check_type(point_))
|
87
|
+
assert(!::RGeo::Feature::Curve.check_type(point_))
|
88
88
|
end
|
89
89
|
|
90
90
|
|
91
91
|
def test_geometry_type
|
92
92
|
point_ = @factory.point(11, 12)
|
93
|
-
assert_equal(::RGeo::
|
93
|
+
assert_equal(::RGeo::Feature::Point, point_.geometry_type)
|
94
94
|
end
|
95
95
|
|
96
96
|
|
@@ -240,7 +240,7 @@ module RGeo
|
|
240
240
|
union12_ = point1_.union(point2_)
|
241
241
|
union13_ = point1_.union(point3_)
|
242
242
|
assert_close_enough(point1_, union12_)
|
243
|
-
assert_equal(::RGeo::
|
243
|
+
assert_equal(::RGeo::Feature::MultiPoint, union13_.geometry_type)
|
244
244
|
assert_contains_approx(point1_, union13_)
|
245
245
|
assert_contains_approx(point3_, union13_)
|
246
246
|
end
|
@@ -252,7 +252,7 @@ module RGeo
|
|
252
252
|
point3_ = @factory.point(12, 12)
|
253
253
|
diff12_ = point1_.difference(point2_)
|
254
254
|
diff13_ = point1_.difference(point3_)
|
255
|
-
assert_equal(::RGeo::
|
255
|
+
assert_equal(::RGeo::Feature::GeometryCollection, diff12_.geometry_type)
|
256
256
|
assert(diff12_.is_empty?)
|
257
257
|
assert_close_enough(point1_, diff13_)
|
258
258
|
end
|
@@ -264,9 +264,9 @@ module RGeo
|
|
264
264
|
point3_ = @factory.point(12, 12)
|
265
265
|
diff12_ = point1_.sym_difference(point2_)
|
266
266
|
diff13_ = point1_.sym_difference(point3_)
|
267
|
-
assert_equal(::RGeo::
|
267
|
+
assert_equal(::RGeo::Feature::GeometryCollection, diff12_.geometry_type)
|
268
268
|
assert(diff12_.is_empty?)
|
269
|
-
assert_equal(::RGeo::
|
269
|
+
assert_equal(::RGeo::Feature::MultiPoint, diff13_.geometry_type)
|
270
270
|
assert_contains_approx(point1_, diff13_)
|
271
271
|
assert_contains_approx(point3_, diff13_)
|
272
272
|
end
|
@@ -51,8 +51,8 @@ module RGeo
|
|
51
51
|
exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
|
52
52
|
polygon_ = @factory.polygon(exterior_)
|
53
53
|
assert_not_nil(polygon_)
|
54
|
-
assert(::RGeo::
|
55
|
-
assert_equal(::RGeo::
|
54
|
+
assert(::RGeo::Feature::Polygon === polygon_)
|
55
|
+
assert_equal(::RGeo::Feature::Polygon, polygon_.geometry_type)
|
56
56
|
assert(exterior_.eql?(polygon_.exterior_ring))
|
57
57
|
assert_equal(0, polygon_.num_interior_rings)
|
58
58
|
end
|
@@ -70,8 +70,8 @@ module RGeo
|
|
70
70
|
interior_ = @factory.linear_ring([point5_, point6_, point7_, point5_])
|
71
71
|
polygon_ = @factory.polygon(exterior_, [interior_])
|
72
72
|
assert_not_nil(polygon_)
|
73
|
-
assert(::RGeo::
|
74
|
-
assert_equal(::RGeo::
|
73
|
+
assert(::RGeo::Feature::Polygon === polygon_)
|
74
|
+
assert_equal(::RGeo::Feature::Polygon, polygon_.geometry_type)
|
75
75
|
assert(exterior_.eql?(polygon_.exterior_ring))
|
76
76
|
assert_equal(1, polygon_.num_interior_rings)
|
77
77
|
assert(interior_.eql?(polygon_.interior_ring_n(0)))
|
@@ -166,11 +166,11 @@ module RGeo
|
|
166
166
|
point3_ = @factory.point(1, 0)
|
167
167
|
exterior_ = @factory.linear_ring([point1_, point2_, point3_, point1_])
|
168
168
|
poly_ = @factory.polygon(exterior_)
|
169
|
-
assert(::RGeo::
|
170
|
-
assert(!::RGeo::
|
171
|
-
assert(!::RGeo::
|
172
|
-
assert(::RGeo::
|
173
|
-
assert(::RGeo::
|
169
|
+
assert(::RGeo::Feature::Geometry.check_type(poly_))
|
170
|
+
assert(!::RGeo::Feature::Point.check_type(poly_))
|
171
|
+
assert(!::RGeo::Feature::GeometryCollection.check_type(poly_))
|
172
|
+
assert(::RGeo::Feature::Surface.check_type(poly_))
|
173
|
+
assert(::RGeo::Feature::Polygon.check_type(poly_))
|
174
174
|
end
|
175
175
|
|
176
176
|
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# A container file for one-off tests
|
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
|
+
require 'test/unit'
|
38
|
+
require 'rgeo'
|
39
|
+
|
40
|
+
|
41
|
+
module RGeo
|
42
|
+
module Tests # :nodoc:
|
43
|
+
module CoordSys # :nodoc:
|
44
|
+
|
45
|
+
class TestProj4 < ::Test::Unit::TestCase # :nodoc:
|
46
|
+
|
47
|
+
|
48
|
+
def test_create_wgs84
|
49
|
+
proj_ = RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
50
|
+
assert_equal(true, proj_.geographic?)
|
51
|
+
assert_equal('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs', proj_.original_str)
|
52
|
+
assert_equal(' +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0', proj_.canonical_str)
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def test_get_wgs84_geographic
|
57
|
+
proj_ = RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
58
|
+
proj2_ = proj_.get_geographic
|
59
|
+
assert_nil(proj2_.original_str)
|
60
|
+
assert_equal(true, proj2_.geographic?)
|
61
|
+
coords_ = RGeo::CoordSys::Proj4.transform_coords(proj_, proj2_, 1, 2, 0)
|
62
|
+
assert_equal([1, 2, 0], coords_)
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def test_identity_transform
|
67
|
+
proj_ = RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
68
|
+
assert_equal([1, 2, 0], RGeo::CoordSys::Proj4.transform_coords(proj_, proj_, 1, 2, 0))
|
69
|
+
assert_equal([1, 2], RGeo::CoordSys::Proj4.transform_coords(proj_, proj_, 1, 2, nil))
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
def _project_merc(x_, y_)
|
74
|
+
[x_ * 6378137.0, ::Math.log(::Math.tan(::Math::PI / 4.0 + y_ / 2.0)) * 6378137.0]
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
def _unproject_merc(x_, y_)
|
79
|
+
[x_ / 6378137.0, (2.0 * ::Math.atan(::Math.exp(y_ / 6378137.0)) - ::Math::PI / 2.0)]
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
def _assert_close_enough(a_, b_)
|
84
|
+
assert_in_delta(a_, b_, ::Math.sqrt(a_*a_+b_*b_)*0.00000001)
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
def _assert_xy_close(xy1_, xy2_)
|
89
|
+
_assert_close_enough(xy1_[0], xy2_[0])
|
90
|
+
_assert_close_enough(xy1_[1], xy2_[1])
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
def test_simple_mercator_transform
|
95
|
+
geography_ = RGeo::CoordSys::Proj4.create('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
|
96
|
+
projection_ = RGeo::CoordSys::Proj4.create('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs')
|
97
|
+
assert_equal(_project_merc(0, 0), RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, 0, 0, nil, :radians => true))
|
98
|
+
assert_equal(_project_merc(0.01, 0.01), RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, 0.01, 0.01, nil, :radians => true))
|
99
|
+
assert_equal(_project_merc(1, 1), RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, 1, 1, nil, :radians => true))
|
100
|
+
assert_equal(_project_merc(-1, -1), RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, -1, -1, nil, :radians => true))
|
101
|
+
_assert_xy_close(_unproject_merc(0, 0), RGeo::CoordSys::Proj4.transform_coords(projection_, geography_, 0, 0, nil, :radians => true))
|
102
|
+
_assert_xy_close(_unproject_merc(10000, 10000), RGeo::CoordSys::Proj4.transform_coords(projection_, geography_, 10000, 10000, nil, :radians => true))
|
103
|
+
_assert_xy_close(_unproject_merc(-20000000, -20000000), RGeo::CoordSys::Proj4.transform_coords(projection_, geography_, -20000000, -20000000, nil, :radians => true))
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
File without changes
|
File without changes
|
@@ -40,7 +40,7 @@ require 'rgeo'
|
|
40
40
|
|
41
41
|
module RGeo
|
42
42
|
module Tests # :nodoc:
|
43
|
-
module Geos
|
43
|
+
module Geos # :nodoc:
|
44
44
|
|
45
45
|
class TestZMFactory < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
@@ -68,7 +68,7 @@ module RGeo
|
|
68
68
|
|
69
69
|
def test_4d_point
|
70
70
|
point_ = @factory.point(1, 2, 3, 4)
|
71
|
-
assert_equal(
|
71
|
+
assert_equal(Feature::Point, point_.geometry_type)
|
72
72
|
assert_equal(3, point_.z)
|
73
73
|
assert_equal(4, point_.m)
|
74
74
|
assert_equal(3, point_.z_geometry.z)
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple mercator geometry collection implementation
|
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
|
+
require 'test/unit'
|
38
|
+
require 'rgeo'
|
39
|
+
|
40
|
+
require ::File.expand_path('../common/geometry_collection_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module ProjectedGeography # :nodoc:
|
46
|
+
|
47
|
+
class TestGeometryCollection < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def create_factory
|
51
|
+
::RGeo::Geography.projected(:projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857)
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
include ::RGeo::Tests::Common::GeometryCollectionTests
|
56
|
+
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Tests for the simple mercator line string implementation
|
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
|
+
require 'test/unit'
|
38
|
+
require 'rgeo'
|
39
|
+
|
40
|
+
require ::File.expand_path('../common/line_string_tests.rb', ::File.dirname(__FILE__))
|
41
|
+
|
42
|
+
|
43
|
+
module RGeo
|
44
|
+
module Tests # :nodoc:
|
45
|
+
module ProjectedGeography # :nodoc:
|
46
|
+
|
47
|
+
class TestLineString < ::Test::Unit::TestCase # :nodoc:
|
48
|
+
|
49
|
+
|
50
|
+
def setup
|
51
|
+
@factory = ::RGeo::Geography.projected(:projection_proj4 => '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs', :projection_srid => 3857)
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
include ::RGeo::Tests::Common::LineStringTests
|
56
|
+
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|