rgeo 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +29 -0
- data/ext/geos_c_impl/Makefile_2.2.3 +260 -0
- data/ext/geos_c_impl/coordinates.c +65 -0
- data/ext/geos_c_impl/coordinates.h +2 -0
- data/ext/geos_c_impl/extconf.rb +19 -43
- data/ext/geos_c_impl/geometry.c +24 -0
- data/ext/geos_c_impl/geometry_collection.c +99 -1
- data/ext/geos_c_impl/geos_c_impl_2.2.3.bundle +0 -0
- data/ext/geos_c_impl/line_string.c +38 -0
- data/ext/geos_c_impl/mkmf.log +123 -0
- data/ext/geos_c_impl/point.c +27 -0
- data/ext/geos_c_impl/polygon.c +26 -0
- data/ext/proj4_c_impl/Makefile_2.2.3 +260 -0
- data/ext/proj4_c_impl/extconf.rb +32 -32
- data/ext/proj4_c_impl/mkmf.log +47 -0
- data/ext/proj4_c_impl/proj4_c_impl_2.2.3.bundle +0 -0
- data/lib/rgeo.rb +10 -11
- data/lib/rgeo/cartesian.rb +7 -12
- data/lib/rgeo/cartesian/analysis.rb +13 -26
- data/lib/rgeo/cartesian/bounding_box.rb +45 -114
- data/lib/rgeo/cartesian/calculations.rb +3 -21
- data/lib/rgeo/cartesian/factory.rb +101 -122
- data/lib/rgeo/cartesian/feature_classes.rb +9 -59
- data/lib/rgeo/cartesian/feature_methods.rb +15 -45
- data/lib/rgeo/cartesian/interface.rb +6 -17
- data/lib/rgeo/coord_sys.rb +9 -15
- data/lib/rgeo/coord_sys/cs/entities.rb +84 -330
- data/lib/rgeo/coord_sys/cs/factories.rb +2 -32
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +52 -80
- data/lib/rgeo/coord_sys/proj4.rb +28 -67
- data/lib/rgeo/coord_sys/proj4_c_impl.bundle +0 -0
- data/lib/rgeo/coord_sys/srs_database/interface.rb +4 -24
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +20 -38
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +6 -22
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +6 -21
- data/lib/rgeo/error.rb +0 -6
- data/lib/rgeo/feature.rb +18 -23
- data/lib/rgeo/feature/curve.rb +0 -14
- data/lib/rgeo/feature/factory.rb +13 -38
- data/lib/rgeo/feature/factory_generator.rb +4 -16
- data/lib/rgeo/feature/geometry.rb +18 -60
- data/lib/rgeo/feature/geometry_collection.rb +3 -17
- data/lib/rgeo/feature/line.rb +0 -10
- data/lib/rgeo/feature/line_string.rb +1 -13
- data/lib/rgeo/feature/linear_ring.rb +0 -9
- data/lib/rgeo/feature/mixins.rb +11 -36
- data/lib/rgeo/feature/multi_curve.rb +0 -11
- data/lib/rgeo/feature/multi_line_string.rb +0 -9
- data/lib/rgeo/feature/multi_point.rb +0 -9
- data/lib/rgeo/feature/multi_polygon.rb +0 -9
- data/lib/rgeo/feature/multi_surface.rb +0 -12
- data/lib/rgeo/feature/point.rb +0 -13
- data/lib/rgeo/feature/polygon.rb +1 -14
- data/lib/rgeo/feature/surface.rb +0 -12
- data/lib/rgeo/feature/types.rb +19 -61
- data/lib/rgeo/geographic.rb +10 -15
- data/lib/rgeo/geographic/factory.rb +126 -147
- data/lib/rgeo/geographic/interface.rb +67 -81
- data/lib/rgeo/geographic/proj4_projector.rb +13 -37
- data/lib/rgeo/geographic/projected_feature_classes.rb +7 -66
- data/lib/rgeo/geographic/projected_feature_methods.rb +15 -80
- data/lib/rgeo/geographic/projected_window.rb +15 -67
- data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -56
- data/lib/rgeo/geographic/spherical_feature_classes.rb +9 -68
- data/lib/rgeo/geographic/spherical_feature_methods.rb +18 -51
- data/lib/rgeo/geographic/spherical_math.rb +26 -51
- data/lib/rgeo/geos.rb +23 -20
- data/lib/rgeo/geos/capi_factory.rb +125 -131
- data/lib/rgeo/geos/capi_feature_classes.rb +21 -88
- data/lib/rgeo/geos/ffi_factory.rb +90 -143
- data/lib/rgeo/geos/ffi_feature_classes.rb +8 -63
- data/lib/rgeo/geos/ffi_feature_methods.rb +46 -162
- data/lib/rgeo/geos/geos_c_impl.bundle +0 -0
- data/lib/rgeo/geos/interface.rb +4 -23
- data/lib/rgeo/geos/utils.rb +4 -19
- data/lib/rgeo/geos/zm_factory.rb +82 -131
- data/lib/rgeo/geos/zm_feature_classes.rb +8 -63
- data/lib/rgeo/geos/zm_feature_methods.rb +34 -107
- data/lib/rgeo/impl_helper.rb +8 -13
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +27 -71
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +10 -28
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +21 -57
- data/lib/rgeo/impl_helper/basic_point_methods.rb +12 -30
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +9 -28
- data/lib/rgeo/impl_helper/math.rb +4 -10
- data/lib/rgeo/impl_helper/utils.rb +2 -10
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep.rb +4 -9
- data/lib/rgeo/wkrep/wkb_generator.rb +22 -46
- data/lib/rgeo/wkrep/wkb_parser.rb +25 -52
- data/lib/rgeo/wkrep/wkt_generator.rb +39 -69
- data/lib/rgeo/wkrep/wkt_parser.rb +52 -89
- data/lib/rgeo/yaml.rb +1 -7
- data/test/common/factory_tests.rb +4 -19
- data/test/common/geometry_collection_tests.rb +6 -39
- data/test/common/line_string_tests.rb +10 -39
- data/test/common/multi_line_string_tests.rb +10 -30
- data/test/common/multi_point_tests.rb +15 -34
- data/test/common/multi_polygon_tests.rb +26 -28
- data/test/common/point_tests.rb +37 -59
- data/test/common/polygon_tests.rb +16 -25
- data/test/coord_sys/tc_ogc_cs.rb +151 -186
- data/test/coord_sys/tc_proj4.rb +35 -60
- data/test/coord_sys/tc_proj4_srs_data.rb +15 -24
- data/test/coord_sys/tc_sr_org.rb +11 -19
- data/test/coord_sys/tc_url_reader.rb +13 -23
- data/test/geos_capi/tc_factory.rb +7 -16
- data/test/geos_capi/tc_geometry_collection.rb +6 -14
- data/test/geos_capi/tc_line_string.rb +7 -15
- data/test/geos_capi/tc_misc.rb +26 -41
- data/test/geos_capi/tc_multi_line_string.rb +6 -14
- data/test/geos_capi/tc_multi_point.rb +7 -15
- data/test/geos_capi/tc_multi_polygon.rb +8 -18
- data/test/geos_capi/tc_parsing_unparsing.rb +11 -21
- data/test/geos_capi/tc_point.rb +12 -26
- data/test/geos_capi/tc_polygon.rb +52 -17
- data/test/geos_capi/tc_zmfactory.rb +7 -18
- data/test/geos_ffi/tc_factory.rb +7 -16
- data/test/geos_ffi/tc_geometry_collection.rb +7 -15
- data/test/geos_ffi/tc_line_string.rb +7 -15
- data/test/geos_ffi/tc_misc.rb +8 -18
- data/test/geos_ffi/tc_multi_line_string.rb +7 -15
- data/test/geos_ffi/tc_multi_point.rb +8 -16
- data/test/geos_ffi/tc_multi_polygon.rb +9 -18
- data/test/geos_ffi/tc_parsing_unparsing.rb +14 -24
- data/test/geos_ffi/tc_point.rb +13 -28
- data/test/geos_ffi/tc_polygon.rb +7 -17
- data/test/geos_ffi/tc_zmfactory.rb +8 -19
- data/test/projected_geographic/tc_factory.rb +7 -15
- data/test/projected_geographic/tc_geometry_collection.rb +7 -15
- data/test/projected_geographic/tc_line_string.rb +7 -15
- data/test/projected_geographic/tc_multi_line_string.rb +7 -16
- data/test/projected_geographic/tc_multi_point.rb +8 -17
- data/test/projected_geographic/tc_multi_polygon.rb +8 -16
- data/test/projected_geographic/tc_point.rb +11 -23
- data/test/projected_geographic/tc_polygon.rb +7 -15
- data/test/simple_cartesian/tc_calculations.rb +6 -22
- data/test/simple_cartesian/tc_factory.rb +7 -16
- data/test/simple_cartesian/tc_geometry_collection.rb +6 -15
- data/test/simple_cartesian/tc_line_string.rb +6 -15
- data/test/simple_cartesian/tc_multi_line_string.rb +6 -15
- data/test/simple_cartesian/tc_multi_point.rb +7 -16
- data/test/simple_cartesian/tc_multi_polygon.rb +7 -16
- data/test/simple_cartesian/tc_point.rb +10 -21
- data/test/simple_cartesian/tc_polygon.rb +6 -15
- data/test/simple_mercator/tc_factory.rb +6 -14
- data/test/simple_mercator/tc_geometry_collection.rb +6 -14
- data/test/simple_mercator/tc_line_string.rb +6 -14
- data/test/simple_mercator/tc_multi_line_string.rb +6 -15
- data/test/simple_mercator/tc_multi_point.rb +7 -16
- data/test/simple_mercator/tc_multi_polygon.rb +7 -15
- data/test/simple_mercator/tc_point.rb +11 -24
- data/test/simple_mercator/tc_polygon.rb +6 -14
- data/test/simple_mercator/tc_window.rb +10 -34
- data/test/spherical_geographic/tc_calculations.rb +5 -32
- data/test/spherical_geographic/tc_factory.rb +6 -15
- data/test/spherical_geographic/tc_geometry_collection.rb +6 -15
- data/test/spherical_geographic/tc_line_string.rb +6 -15
- data/test/spherical_geographic/tc_multi_line_string.rb +6 -15
- data/test/spherical_geographic/tc_multi_point.rb +7 -16
- data/test/spherical_geographic/tc_multi_polygon.rb +7 -16
- data/test/spherical_geographic/tc_point.rb +10 -22
- data/test/spherical_geographic/tc_polygon.rb +6 -15
- data/test/tc_cartesian_analysis.rb +4 -16
- data/test/tc_cartesian_bbox.rb +7 -21
- data/test/tc_mixins.rb +8 -25
- data/test/tc_oneoff.rb +5 -13
- data/test/tc_types.rb +7 -16
- data/test/wkrep/tc_wkb_generator.rb +63 -97
- data/test/wkrep/tc_wkb_parser.rb +63 -100
- data/test/wkrep/tc_wkt_generator.rb +54 -92
- data/test/wkrep/tc_wkt_parser.rb +84 -133
- metadata +39 -9
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +0 -166
- data/test/coord_sys/tc_active_record_table.rb +0 -79
data/test/coord_sys/tc_proj4.rb
CHANGED
@@ -4,32 +4,26 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
10
9
|
|
11
10
|
module RGeo
|
12
|
-
module Tests
|
13
|
-
module CoordSys
|
14
|
-
|
15
|
-
class TestProj4 < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
|
17
|
-
|
11
|
+
module Tests # :nodoc:
|
12
|
+
module CoordSys # :nodoc:
|
13
|
+
class TestProj4 < ::Test::Unit::TestCase # :nodoc:
|
18
14
|
def test_proj4_version
|
19
15
|
assert_match(/^\d+\.\d+(\.\d+)?$/, ::RGeo::CoordSys::Proj4.version)
|
20
16
|
end
|
21
17
|
|
22
|
-
|
23
18
|
def test_create_wgs84
|
24
|
-
proj_ = ::RGeo::CoordSys::Proj4.create(
|
19
|
+
proj_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
25
20
|
assert_equal(true, proj_.geographic?)
|
26
|
-
assert_equal(
|
27
|
-
assert_equal(
|
21
|
+
assert_equal("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs", proj_.original_str)
|
22
|
+
assert_equal(" +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0", proj_.canonical_str)
|
28
23
|
end
|
29
24
|
|
30
|
-
|
31
25
|
def test_get_wgs84_geographic
|
32
|
-
proj_ = ::RGeo::CoordSys::Proj4.create(
|
26
|
+
proj_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
33
27
|
proj2_ = proj_.get_geographic
|
34
28
|
assert_nil(proj2_.original_str)
|
35
29
|
assert_equal(true, proj2_.geographic?)
|
@@ -37,135 +31,116 @@ module RGeo
|
|
37
31
|
assert_equal([1, 2, 0], coords_)
|
38
32
|
end
|
39
33
|
|
40
|
-
|
41
34
|
def test_identity_transform
|
42
|
-
proj_ = ::RGeo::CoordSys::Proj4.create(
|
35
|
+
proj_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
43
36
|
assert_equal([1, 2, 0], ::RGeo::CoordSys::Proj4.transform_coords(proj_, proj_, 1, 2, 0))
|
44
37
|
assert_equal([1, 2], ::RGeo::CoordSys::Proj4.transform_coords(proj_, proj_, 1, 2, nil))
|
45
38
|
end
|
46
39
|
|
47
|
-
|
48
40
|
def _project_merc(x_, y_)
|
49
|
-
[x_ *
|
41
|
+
[x_ * 6_378_137.0, ::Math.log(::Math.tan(::Math::PI / 4.0 + y_ / 2.0)) * 6_378_137.0]
|
50
42
|
end
|
51
43
|
|
52
|
-
|
53
44
|
def _unproject_merc(x_, y_)
|
54
|
-
[x_ /
|
45
|
+
[x_ / 6_378_137.0, (2.0 * ::Math.atan(::Math.exp(y_ / 6_378_137.0)) - ::Math::PI / 2.0)]
|
55
46
|
end
|
56
47
|
|
57
|
-
|
58
48
|
def _assert_close_enough(a_, b_)
|
59
|
-
delta_ = ::Math.sqrt(a_*a_+b_*b_)*0.00000001
|
49
|
+
delta_ = ::Math.sqrt(a_ * a_ + b_ * b_) * 0.00000001
|
60
50
|
delta_ = 0.000000000001 if delta_ < 0.000000000001
|
61
51
|
assert_in_delta(a_, b_, delta_)
|
62
52
|
end
|
63
53
|
|
64
|
-
|
65
54
|
def _assert_xy_close(xy1_, xy2_)
|
66
55
|
_assert_close_enough(xy1_[0], xy2_[0])
|
67
56
|
_assert_close_enough(xy1_[1], xy2_[1])
|
68
57
|
end
|
69
58
|
|
70
|
-
|
71
59
|
def test_simple_mercator_transform
|
72
|
-
geography_ = ::RGeo::CoordSys::Proj4.create(
|
73
|
-
projection_ = ::RGeo::CoordSys::Proj4.create(
|
60
|
+
geography_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs", radians: true)
|
61
|
+
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")
|
74
62
|
_assert_xy_close(_project_merc(0, 0), ::RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, 0, 0, nil))
|
75
63
|
_assert_xy_close(_project_merc(0.01, 0.01), ::RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, 0.01, 0.01, nil))
|
76
64
|
_assert_xy_close(_project_merc(1, 1), ::RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, 1, 1, nil))
|
77
65
|
_assert_xy_close(_project_merc(-1, -1), ::RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, -1, -1, nil))
|
78
66
|
_assert_xy_close(_unproject_merc(0, 0), ::RGeo::CoordSys::Proj4.transform_coords(projection_, geography_, 0, 0, nil))
|
79
|
-
_assert_xy_close(_unproject_merc(
|
80
|
-
_assert_xy_close(_unproject_merc(-
|
67
|
+
_assert_xy_close(_unproject_merc(10_000, 10_000), ::RGeo::CoordSys::Proj4.transform_coords(projection_, geography_, 10_000, 10_000, nil))
|
68
|
+
_assert_xy_close(_unproject_merc(-20_000_000, -20_000_000), ::RGeo::CoordSys::Proj4.transform_coords(projection_, geography_, -20_000_000, -20_000_000, nil))
|
81
69
|
end
|
82
70
|
|
83
|
-
|
84
71
|
def test_equivalence
|
85
|
-
proj1_ = ::RGeo::CoordSys::Proj4.create(
|
86
|
-
proj2_ = ::RGeo::CoordSys::Proj4.create(
|
72
|
+
proj1_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
73
|
+
proj2_ = ::RGeo::CoordSys::Proj4.create(" +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
87
74
|
assert_equal(proj1_, proj2_)
|
88
75
|
end
|
89
76
|
|
90
|
-
|
91
77
|
def test_hashes_equal_for_equivalent_objects
|
92
|
-
proj1_ = ::RGeo::CoordSys::Proj4.create(
|
93
|
-
proj2_ = ::RGeo::CoordSys::Proj4.create(
|
78
|
+
proj1_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
79
|
+
proj2_ = ::RGeo::CoordSys::Proj4.create(" +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
94
80
|
assert_equal(proj1_.hash, proj2_.hash)
|
95
81
|
end
|
96
82
|
|
97
|
-
|
98
83
|
def test_point_projection_cast
|
99
|
-
geography_ = ::RGeo::Geos.factory(:
|
100
|
-
projection_ = ::RGeo::Geos.factory(:
|
101
|
-
proj_point_ = projection_.parse_wkt(
|
102
|
-
geo_point_ = ::RGeo::Feature.cast(proj_point_, :
|
84
|
+
geography_ = ::RGeo::Geos.factory(proj4: "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs", srid: 4326)
|
85
|
+
projection_ = ::RGeo::Geos.factory(proj4: "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs", srid: 27_700)
|
86
|
+
proj_point_ = projection_.parse_wkt("POINT(473600.5000000000000000 186659.7999999999883585)")
|
87
|
+
geo_point_ = ::RGeo::Feature.cast(proj_point_, project: true, factory: geography_)
|
103
88
|
_assert_close_enough(-0.9393598527244420, geo_point_.x)
|
104
89
|
_assert_close_enough(51.5740106527552697, geo_point_.y)
|
105
90
|
end
|
106
91
|
|
107
|
-
|
108
92
|
def test_point_transform_lowlevel
|
109
|
-
geography_ = ::RGeo::Geos.factory(:
|
110
|
-
projection_ = ::RGeo::Geos.factory(:
|
111
|
-
proj_point_ = projection_.parse_wkt(
|
93
|
+
geography_ = ::RGeo::Geos.factory(proj4: "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs", srid: 4326)
|
94
|
+
projection_ = ::RGeo::Geos.factory(proj4: "+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs", srid: 27_700)
|
95
|
+
proj_point_ = projection_.parse_wkt("POINT(473600.5000000000000000 186659.7999999999883585)")
|
112
96
|
geo_point_ = ::RGeo::CoordSys::Proj4.transform(projection_.proj4, proj_point_, geography_.proj4, geography_)
|
113
97
|
_assert_close_enough(-0.9393598527244420, geo_point_.x)
|
114
98
|
_assert_close_enough(51.5740106527552697, geo_point_.y)
|
115
99
|
end
|
116
100
|
|
117
|
-
|
118
101
|
def test_geocentric
|
119
|
-
obj1_ = ::RGeo::CoordSys::Proj4.create(
|
102
|
+
obj1_ = ::RGeo::CoordSys::Proj4.create("+proj=geocent +ellps=WGS84")
|
120
103
|
assert_equal(true, obj1_.geocentric?)
|
121
104
|
end
|
122
105
|
|
123
|
-
|
124
106
|
def test_get_geographic
|
125
|
-
projection_ = ::RGeo::CoordSys::Proj4.create(
|
107
|
+
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")
|
126
108
|
geographic_ = projection_.get_geographic
|
127
|
-
expected_ = ::RGeo::CoordSys::Proj4.create(
|
109
|
+
expected_ = ::RGeo::CoordSys::Proj4.create("+proj=latlong +a=6378137 +b=6378137 +nadgrids=@null")
|
128
110
|
assert_equal(expected_, geographic_)
|
129
111
|
end
|
130
112
|
|
131
|
-
|
132
113
|
def test_marshal_roundtrip
|
133
|
-
obj1_ = ::RGeo::CoordSys::Proj4.create(
|
114
|
+
obj1_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
134
115
|
dump_ = ::Marshal.dump(obj1_)
|
135
116
|
obj2_ = ::Marshal.load(dump_)
|
136
117
|
assert_equal(obj1_, obj2_)
|
137
118
|
end
|
138
119
|
|
139
|
-
|
140
120
|
def test_dup
|
141
|
-
obj1_ = ::RGeo::CoordSys::Proj4.create(
|
121
|
+
obj1_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
142
122
|
obj2_ = obj1_.dup
|
143
123
|
assert_equal(obj1_, obj2_)
|
144
124
|
end
|
145
125
|
|
146
|
-
|
147
126
|
def test_dup_of_get_geographic
|
148
|
-
obj1_ = ::RGeo::CoordSys::Proj4.create(
|
127
|
+
obj1_ = ::RGeo::CoordSys::Proj4.create("+proj=latlong +datum=WGS84 +ellps=WGS84")
|
149
128
|
obj2_ = obj1_.get_geographic
|
150
129
|
obj3_ = obj2_.dup
|
151
130
|
assert_equal(obj1_, obj3_)
|
152
131
|
end
|
153
132
|
|
154
|
-
|
155
133
|
if ::RGeo.yaml_supported?
|
156
134
|
|
157
135
|
def test_yaml_roundtrip
|
158
|
-
obj1_ = ::RGeo::CoordSys::Proj4.create(
|
136
|
+
obj1_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
159
137
|
dump_ = ::Psych.dump(obj1_)
|
160
138
|
obj2_ = ::Psych.load(dump_)
|
161
139
|
assert_equal(obj1_, obj2_)
|
162
140
|
end
|
163
141
|
|
164
142
|
end
|
165
|
-
|
166
|
-
|
167
143
|
end
|
168
|
-
|
169
144
|
end
|
170
145
|
end
|
171
146
|
end if ::RGeo::CoordSys::Proj4.supported?
|
@@ -4,47 +4,38 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
10
9
|
|
11
10
|
module RGeo
|
12
|
-
module Tests
|
13
|
-
module CoordSys
|
14
|
-
|
15
|
-
class TestProj4SRSData < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
|
17
|
-
|
11
|
+
module Tests # :nodoc:
|
12
|
+
module CoordSys # :nodoc:
|
13
|
+
class TestProj4SRSData < ::Test::Unit::TestCase # :nodoc:
|
18
14
|
def test_epsg_4326
|
19
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new(
|
15
|
+
db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new("epsg")
|
20
16
|
entry_ = db_.get(4326)
|
21
17
|
allowed_vals_ = [
|
22
|
-
|
23
|
-
|
18
|
+
"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs", # Proj 4.7
|
19
|
+
"+proj=longlat +datum=WGS84 +no_defs" # Proj 4.8
|
24
20
|
]
|
25
21
|
assert(allowed_vals_.include?(entry_.proj4.original_str))
|
26
|
-
assert_equal(
|
22
|
+
assert_equal("WGS 84", entry_.name)
|
27
23
|
end
|
28
24
|
|
29
|
-
|
30
25
|
def test_epsg_3857
|
31
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new(
|
26
|
+
db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new("epsg")
|
32
27
|
entry_ = db_.get(3857)
|
33
|
-
assert_equal(
|
34
|
-
assert_equal(
|
28
|
+
assert_equal("+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", entry_.proj4.original_str)
|
29
|
+
assert_equal("WGS 84 / Pseudo-Mercator", entry_.name)
|
35
30
|
end
|
36
31
|
|
37
|
-
|
38
32
|
def test_nad83_4601
|
39
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new(
|
33
|
+
db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new("nad83")
|
40
34
|
entry_ = db_.get(4601)
|
41
|
-
assert_equal(
|
42
|
-
assert_equal(
|
35
|
+
assert_equal("+proj=lcc +datum=NAD83 +lon_0=-120d50 +lat_1=48d44 +lat_2=47d30 +lat_0=47 +x_0=500000 +y_0=0 +no_defs", entry_.proj4.original_str)
|
36
|
+
assert_equal("4601: washington north: nad83", entry_.name)
|
43
37
|
end
|
44
|
-
|
45
|
-
|
46
38
|
end
|
47
|
-
|
48
39
|
end
|
49
40
|
end
|
50
41
|
end if ::RGeo::CoordSys::Proj4.supported?
|
data/test/coord_sys/tc_sr_org.rb
CHANGED
@@ -4,37 +4,29 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
10
9
|
|
11
10
|
module RGeo
|
12
|
-
module Tests
|
13
|
-
module CoordSys
|
14
|
-
|
15
|
-
class TestSrOrg < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
|
17
|
-
|
11
|
+
module Tests # :nodoc:
|
12
|
+
module CoordSys # :nodoc:
|
13
|
+
class TestSrOrg < ::Test::Unit::TestCase # :nodoc:
|
18
14
|
def test_epsg_4326
|
19
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::SrOrg.new(
|
15
|
+
db_ = ::RGeo::CoordSys::SRSDatabase::SrOrg.new("epsg")
|
20
16
|
entry_ = db_.get(4326)
|
21
|
-
assert_equal(
|
17
|
+
assert_equal("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs", entry_.proj4.original_str)
|
22
18
|
assert_kind_of(::RGeo::CoordSys::CS::GeographicCoordinateSystem, entry_.coord_sys)
|
23
|
-
assert_equal(
|
19
|
+
assert_equal("WGS 84", entry_.name)
|
24
20
|
end
|
25
21
|
|
26
|
-
|
27
22
|
def test_epsg_3857
|
28
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::SrOrg.new(
|
23
|
+
db_ = ::RGeo::CoordSys::SRSDatabase::SrOrg.new("epsg")
|
29
24
|
entry_ = db_.get(3857)
|
30
|
-
assert_equal(
|
25
|
+
assert_equal("+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs", entry_.proj4.original_str)
|
31
26
|
assert_kind_of(::RGeo::CoordSys::CS::ProjectedCoordinateSystem, entry_.coord_sys)
|
32
|
-
assert_equal(
|
27
|
+
assert_equal("Popular Visualisation CRS / Mercator", entry_.name)
|
33
28
|
end
|
34
|
-
|
35
|
-
|
36
29
|
end if false
|
37
|
-
|
38
30
|
end
|
39
31
|
end
|
40
32
|
end
|
@@ -4,49 +4,39 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
10
9
|
|
11
10
|
module RGeo
|
12
|
-
module Tests
|
13
|
-
module CoordSys
|
14
|
-
|
15
|
-
class TestUrlReader < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
|
17
|
-
|
11
|
+
module Tests # :nodoc:
|
12
|
+
module CoordSys # :nodoc:
|
13
|
+
class TestUrlReader < ::Test::Unit::TestCase # :nodoc:
|
18
14
|
def test_sr_org_epsg_4326_ogcwkt
|
19
15
|
db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
|
20
|
-
entry_ = db_.get(
|
16
|
+
entry_ = db_.get("http://spatialreference.org/ref/epsg/4326/ogcwkt/")
|
21
17
|
assert_kind_of(::RGeo::CoordSys::CS::GeographicCoordinateSystem, entry_.coord_sys)
|
22
|
-
assert_equal(
|
18
|
+
assert_equal("WGS 84", entry_.name)
|
23
19
|
end
|
24
20
|
|
25
|
-
|
26
21
|
def test_sr_org_epsg_4326_proj4
|
27
22
|
db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
|
28
|
-
entry_ = db_.get(
|
29
|
-
assert_equal(
|
23
|
+
entry_ = db_.get("http://spatialreference.org/ref/epsg/4326/proj4/")
|
24
|
+
assert_equal("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs", entry_.proj4.original_str)
|
30
25
|
end
|
31
26
|
|
32
|
-
|
33
27
|
def test_sr_org_epsg_3857_ogcwkt
|
34
28
|
db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
|
35
|
-
entry_ = db_.get(
|
29
|
+
entry_ = db_.get("http://spatialreference.org/ref/epsg/3857/ogcwkt/")
|
36
30
|
assert_kind_of(::RGeo::CoordSys::CS::ProjectedCoordinateSystem, entry_.coord_sys)
|
37
|
-
assert_equal(
|
31
|
+
assert_equal("Popular Visualisation CRS / Mercator", entry_.name)
|
38
32
|
end
|
39
33
|
|
40
|
-
|
41
34
|
def test_sr_org_epsg_3857_proj4
|
42
35
|
db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
|
43
|
-
entry_ = db_.get(
|
44
|
-
assert_equal(
|
36
|
+
entry_ = db_.get("http://spatialreference.org/ref/epsg/3857/proj4/")
|
37
|
+
assert_equal("+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs", entry_.proj4.original_str)
|
45
38
|
end
|
46
|
-
|
47
|
-
|
48
39
|
end if false
|
49
|
-
|
50
40
|
end
|
51
41
|
end
|
52
42
|
end
|
@@ -4,37 +4,28 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
10
|
-
require ::File.expand_path('../common/factory_tests.rb', ::File.dirname(__FILE__))
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
11
9
|
|
10
|
+
require ::File.expand_path("../common/factory_tests.rb", ::File.dirname(__FILE__))
|
12
11
|
|
13
12
|
module RGeo
|
14
|
-
module Tests
|
15
|
-
module GeosCAPI
|
16
|
-
|
17
|
-
class TestFactory < ::Test::Unit::TestCase # :nodoc:
|
18
|
-
|
19
|
-
|
13
|
+
module Tests # :nodoc:
|
14
|
+
module GeosCAPI # :nodoc:
|
15
|
+
class TestFactory < ::Test::Unit::TestCase # :nodoc:
|
20
16
|
def setup
|
21
|
-
@factory = ::RGeo::Geos.factory(:
|
17
|
+
@factory = ::RGeo::Geos.factory(srid: 1000)
|
22
18
|
@srid = 1000
|
23
19
|
end
|
24
20
|
|
25
|
-
|
26
21
|
include ::RGeo::Tests::Common::FactoryTests
|
27
22
|
|
28
|
-
|
29
23
|
def test_is_geos_factory
|
30
24
|
assert_equal(true, ::RGeo::Geos.is_geos?(@factory))
|
31
25
|
assert_equal(true, ::RGeo::Geos.is_capi_geos?(@factory))
|
32
26
|
assert_equal(false, ::RGeo::Geos.is_ffi_geos?(@factory))
|
33
27
|
end
|
34
|
-
|
35
|
-
|
36
28
|
end
|
37
|
-
|
38
29
|
end
|
39
30
|
end
|
40
31
|
end if ::RGeo::Geos.capi_supported?
|
@@ -4,29 +4,21 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
require
|
9
|
-
|
10
|
-
require ::File.expand_path('../common/geometry_collection_tests.rb', ::File.dirname(__FILE__))
|
7
|
+
require "test/unit"
|
8
|
+
require "rgeo"
|
11
9
|
|
10
|
+
require ::File.expand_path("../common/geometry_collection_tests.rb", ::File.dirname(__FILE__))
|
12
11
|
|
13
12
|
module RGeo
|
14
|
-
module Tests
|
15
|
-
module GeosCAPI
|
16
|
-
|
17
|
-
class TestGeometryCollection < ::Test::Unit::TestCase # :nodoc:
|
18
|
-
|
19
|
-
|
13
|
+
module Tests # :nodoc:
|
14
|
+
module GeosCAPI # :nodoc:
|
15
|
+
class TestGeometryCollection < ::Test::Unit::TestCase # :nodoc:
|
20
16
|
def create_factory
|
21
17
|
::RGeo::Geos.factory
|
22
18
|
end
|
23
19
|
|
24
|
-
|
25
20
|
include ::RGeo::Tests::Common::GeometryCollectionTests
|
26
|
-
|
27
|
-
|
28
21
|
end
|
29
|
-
|
30
22
|
end
|
31
23
|
end
|
32
24
|
end if ::RGeo::Geos.capi_supported?
|