rgeo 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/geos_c_impl/extconf.rb +1 -0
- data/ext/geos_c_impl/factory.c +10 -1
- data/ext/geos_c_impl/geometry.c +25 -3
- data/ext/geos_c_impl/line_string.c +1 -12
- data/ext/geos_c_impl/polygon.c +0 -3
- data/ext/geos_c_impl/preface.h +3 -0
- data/lib/rgeo.rb +0 -1
- data/lib/rgeo/feature/geometry.rb +17 -0
- data/lib/rgeo/feature/types.rb +4 -4
- data/lib/rgeo/geographic/projected_feature_methods.rb +1 -22
- data/lib/rgeo/geos/ffi_feature_methods.rb +5 -0
- data/lib/rgeo/geos/utils.rb +2 -0
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +1 -0
- data/lib/rgeo/version.rb +1 -1
- metadata +11 -171
- data/lib/rgeo/yaml.rb +0 -23
- data/test/cartesian_analysis_test.rb +0 -65
- data/test/cartesian_bbox_test.rb +0 -123
- data/test/common/factory_tests.rb +0 -78
- data/test/common/geometry_collection_tests.rb +0 -237
- data/test/common/line_string_tests.rb +0 -330
- data/test/common/multi_line_string_tests.rb +0 -182
- data/test/common/multi_point_tests.rb +0 -200
- data/test/common/multi_polygon_tests.rb +0 -191
- data/test/common/point_tests.rb +0 -370
- data/test/common/polygon_tests.rb +0 -228
- data/test/coord_sys/ogc_cs_test.rb +0 -342
- data/test/coord_sys/proj4_srs_data_test.rb +0 -41
- data/test/coord_sys/proj4_test.rb +0 -150
- data/test/coord_sys/sr_org_test.rb +0 -32
- data/test/coord_sys/url_reader_test.rb +0 -42
- data/test/geos_capi/factory_test.rb +0 -31
- data/test/geos_capi/geometry_collection_test.rb +0 -24
- data/test/geos_capi/line_string_test.rb +0 -24
- data/test/geos_capi/misc_test.rb +0 -116
- data/test/geos_capi/multi_line_string_test.rb +0 -24
- data/test/geos_capi/multi_point_test.rb +0 -24
- data/test/geos_capi/multi_polygon_test.rb +0 -39
- data/test/geos_capi/parsing_unparsing_test.rb +0 -40
- data/test/geos_capi/point_test.rb +0 -72
- data/test/geos_capi/polygon_test.rb +0 -154
- data/test/geos_capi/zmfactory_test.rb +0 -57
- data/test/geos_ffi/factory_test.rb +0 -31
- data/test/geos_ffi/geometry_collection_test.rb +0 -24
- data/test/geos_ffi/line_string_test.rb +0 -24
- data/test/geos_ffi/misc_test.rb +0 -63
- data/test/geos_ffi/multi_line_string_test.rb +0 -24
- data/test/geos_ffi/multi_point_test.rb +0 -24
- data/test/geos_ffi/multi_polygon_test.rb +0 -33
- data/test/geos_ffi/parsing_unparsing_test.rb +0 -41
- data/test/geos_ffi/point_test.rb +0 -77
- data/test/geos_ffi/polygon_test.rb +0 -46
- data/test/geos_ffi/zmfactory_test.rb +0 -58
- data/test/mixins_test.rb +0 -141
- data/test/oneoff_test.rb +0 -26
- data/test/projected_geographic/factory_test.rb +0 -25
- data/test/projected_geographic/geometry_collection_test.rb +0 -24
- data/test/projected_geographic/line_string_test.rb +0 -24
- data/test/projected_geographic/multi_line_string_test.rb +0 -26
- data/test/projected_geographic/multi_point_test.rb +0 -30
- data/test/projected_geographic/multi_polygon_test.rb +0 -25
- data/test/projected_geographic/point_test.rb +0 -51
- data/test/projected_geographic/polygon_test.rb +0 -24
- data/test/simple_cartesian/calculations_test.rb +0 -99
- data/test/simple_cartesian/factory_test.rb +0 -27
- data/test/simple_cartesian/geometry_collection_test.rb +0 -30
- data/test/simple_cartesian/line_string_test.rb +0 -31
- data/test/simple_cartesian/multi_line_string_test.rb +0 -28
- data/test/simple_cartesian/multi_point_test.rb +0 -31
- data/test/simple_cartesian/multi_polygon_test.rb +0 -31
- data/test/simple_cartesian/point_test.rb +0 -50
- data/test/simple_cartesian/polygon_test.rb +0 -28
- data/test/simple_mercator/factory_test.rb +0 -25
- data/test/simple_mercator/geometry_collection_test.rb +0 -24
- data/test/simple_mercator/line_string_test.rb +0 -24
- data/test/simple_mercator/multi_line_string_test.rb +0 -26
- data/test/simple_mercator/multi_point_test.rb +0 -29
- data/test/simple_mercator/multi_polygon_test.rb +0 -25
- data/test/simple_mercator/point_test.rb +0 -55
- data/test/simple_mercator/polygon_test.rb +0 -24
- data/test/simple_mercator/window_test.rb +0 -173
- data/test/spherical_geographic/calculations_test.rb +0 -167
- data/test/spherical_geographic/factory_test.rb +0 -27
- data/test/spherical_geographic/geometry_collection_test.rb +0 -31
- data/test/spherical_geographic/line_string_test.rb +0 -31
- data/test/spherical_geographic/multi_line_string_test.rb +0 -29
- data/test/spherical_geographic/multi_point_test.rb +0 -31
- data/test/spherical_geographic/multi_polygon_test.rb +0 -31
- data/test/spherical_geographic/point_test.rb +0 -78
- data/test/spherical_geographic/polygon_test.rb +0 -28
- data/test/types_test.rb +0 -42
- data/test/wkrep/wkb_generator_test.rb +0 -185
- data/test/wkrep/wkb_parser_test.rb +0 -293
- data/test/wkrep/wkt_generator_test.rb +0 -294
- data/test/wkrep/wkt_parser_test.rb +0 -412
@@ -1,41 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for OGC CS classes
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
module RGeo
|
11
|
-
module Tests # :nodoc:
|
12
|
-
module CoordSys # :nodoc:
|
13
|
-
class TestProj4SRSData < ::Test::Unit::TestCase # :nodoc:
|
14
|
-
def test_epsg_4326
|
15
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new("epsg")
|
16
|
-
entry_ = db_.get(4326)
|
17
|
-
allowed_vals_ = [
|
18
|
-
"+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs", # Proj 4.7
|
19
|
-
"+proj=longlat +datum=WGS84 +no_defs" # Proj 4.8
|
20
|
-
]
|
21
|
-
assert(allowed_vals_.include?(entry_.proj4.original_str))
|
22
|
-
assert_equal("WGS 84", entry_.name)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_epsg_3857
|
26
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new("epsg")
|
27
|
-
entry_ = db_.get(3857)
|
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)
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_nad83_4601
|
33
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::Proj4Data.new("nad83")
|
34
|
-
entry_ = db_.get(4601)
|
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)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end if ::RGeo::CoordSys::Proj4.supported?
|
@@ -1,150 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for proj4 wrapper
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
module RGeo
|
11
|
-
module Tests # :nodoc:
|
12
|
-
module CoordSys # :nodoc:
|
13
|
-
class TestProj4 < ::Test::Unit::TestCase # :nodoc:
|
14
|
-
def test_proj4_version
|
15
|
-
assert_match(/^\d+\.\d+(\.\d+)?$/, ::RGeo::CoordSys::Proj4.version)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_create_wgs84
|
19
|
-
proj_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
20
|
-
assert_equal(true, proj_.geographic?)
|
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)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_get_wgs84_geographic
|
26
|
-
proj_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
27
|
-
proj2_ = proj_.get_geographic
|
28
|
-
assert_nil(proj2_.original_str)
|
29
|
-
assert_equal(true, proj2_.geographic?)
|
30
|
-
coords_ = ::RGeo::CoordSys::Proj4.transform_coords(proj_, proj2_, 1, 2, 0)
|
31
|
-
assert_equal([1, 2, 0], coords_)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_identity_transform
|
35
|
-
proj_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
36
|
-
assert_equal([1, 2, 0], ::RGeo::CoordSys::Proj4.transform_coords(proj_, proj_, 1, 2, 0))
|
37
|
-
assert_equal([1, 2], ::RGeo::CoordSys::Proj4.transform_coords(proj_, proj_, 1, 2, nil))
|
38
|
-
end
|
39
|
-
|
40
|
-
def _project_merc(x_, y_)
|
41
|
-
[x_ * 6_378_137.0, ::Math.log(::Math.tan(::Math::PI / 4.0 + y_ / 2.0)) * 6_378_137.0]
|
42
|
-
end
|
43
|
-
|
44
|
-
def _unproject_merc(x_, y_)
|
45
|
-
[x_ / 6_378_137.0, (2.0 * ::Math.atan(::Math.exp(y_ / 6_378_137.0)) - ::Math::PI / 2.0)]
|
46
|
-
end
|
47
|
-
|
48
|
-
def _assert_close_enough(a_, b_)
|
49
|
-
delta_ = ::Math.sqrt(a_ * a_ + b_ * b_) * 0.00000001
|
50
|
-
delta_ = 0.000000000001 if delta_ < 0.000000000001
|
51
|
-
assert_in_delta(a_, b_, delta_)
|
52
|
-
end
|
53
|
-
|
54
|
-
def _assert_xy_close(xy1_, xy2_)
|
55
|
-
_assert_close_enough(xy1_[0], xy2_[0])
|
56
|
-
_assert_close_enough(xy1_[1], xy2_[1])
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_simple_mercator_transform
|
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")
|
62
|
-
_assert_xy_close(_project_merc(0, 0), ::RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, 0, 0, nil))
|
63
|
-
_assert_xy_close(_project_merc(0.01, 0.01), ::RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, 0.01, 0.01, nil))
|
64
|
-
_assert_xy_close(_project_merc(1, 1), ::RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, 1, 1, nil))
|
65
|
-
_assert_xy_close(_project_merc(-1, -1), ::RGeo::CoordSys::Proj4.transform_coords(geography_, projection_, -1, -1, nil))
|
66
|
-
_assert_xy_close(_unproject_merc(0, 0), ::RGeo::CoordSys::Proj4.transform_coords(projection_, geography_, 0, 0, nil))
|
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))
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_equivalence
|
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")
|
74
|
-
assert_equal(proj1_, proj2_)
|
75
|
-
end
|
76
|
-
|
77
|
-
def test_hashes_equal_for_equivalent_objects
|
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")
|
80
|
-
assert_equal(proj1_.hash, proj2_.hash)
|
81
|
-
end
|
82
|
-
|
83
|
-
def test_point_projection_cast
|
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_)
|
88
|
-
_assert_close_enough(-0.9393598527244420, geo_point_.x)
|
89
|
-
_assert_close_enough(51.5740106527552697, geo_point_.y)
|
90
|
-
end
|
91
|
-
|
92
|
-
def test_point_transform_lowlevel
|
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)")
|
96
|
-
geo_point_ = ::RGeo::CoordSys::Proj4.transform(projection_.proj4, proj_point_, geography_.proj4, geography_)
|
97
|
-
_assert_close_enough(-0.9393598527244420, geo_point_.x)
|
98
|
-
_assert_close_enough(51.5740106527552697, geo_point_.y)
|
99
|
-
end
|
100
|
-
|
101
|
-
def test_geocentric
|
102
|
-
obj1_ = ::RGeo::CoordSys::Proj4.create("+proj=geocent +ellps=WGS84")
|
103
|
-
assert_equal(true, obj1_.geocentric?)
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_get_geographic
|
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")
|
108
|
-
geographic_ = projection_.get_geographic
|
109
|
-
expected_ = ::RGeo::CoordSys::Proj4.create("+proj=latlong +a=6378137 +b=6378137 +nadgrids=@null")
|
110
|
-
assert_equal(expected_, geographic_)
|
111
|
-
end
|
112
|
-
|
113
|
-
def test_marshal_roundtrip
|
114
|
-
obj1_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
115
|
-
dump_ = ::Marshal.dump(obj1_)
|
116
|
-
obj2_ = ::Marshal.load(dump_)
|
117
|
-
assert_equal(obj1_, obj2_)
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_dup
|
121
|
-
obj1_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
122
|
-
obj2_ = obj1_.dup
|
123
|
-
assert_equal(obj1_, obj2_)
|
124
|
-
end
|
125
|
-
|
126
|
-
def test_dup_of_get_geographic
|
127
|
-
obj1_ = ::RGeo::CoordSys::Proj4.create("+proj=latlong +datum=WGS84 +ellps=WGS84")
|
128
|
-
obj2_ = obj1_.get_geographic
|
129
|
-
obj3_ = obj2_.dup
|
130
|
-
assert_equal(obj1_, obj3_)
|
131
|
-
end
|
132
|
-
|
133
|
-
if ::RGeo.yaml_supported?
|
134
|
-
|
135
|
-
def test_yaml_roundtrip
|
136
|
-
obj1_ = ::RGeo::CoordSys::Proj4.create("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
|
137
|
-
dump_ = ::Psych.dump(obj1_)
|
138
|
-
obj2_ = ::Psych.load(dump_)
|
139
|
-
assert_equal(obj1_, obj2_)
|
140
|
-
end
|
141
|
-
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end if ::RGeo::CoordSys::Proj4.supported?
|
147
|
-
|
148
|
-
unless ::RGeo::CoordSys::Proj4.supported?
|
149
|
-
puts "WARNING: Proj4 support not available. Related tests skipped."
|
150
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for OGC CS classes
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
module RGeo
|
11
|
-
module Tests # :nodoc:
|
12
|
-
module CoordSys # :nodoc:
|
13
|
-
class TestSrOrg < ::Test::Unit::TestCase # :nodoc:
|
14
|
-
def test_epsg_4326
|
15
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::SrOrg.new("epsg")
|
16
|
-
entry_ = db_.get(4326)
|
17
|
-
assert_equal("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs", entry_.proj4.original_str)
|
18
|
-
assert_kind_of(::RGeo::CoordSys::CS::GeographicCoordinateSystem, entry_.coord_sys)
|
19
|
-
assert_equal("WGS 84", entry_.name)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_epsg_3857
|
23
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::SrOrg.new("epsg")
|
24
|
-
entry_ = db_.get(3857)
|
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)
|
26
|
-
assert_kind_of(::RGeo::CoordSys::CS::ProjectedCoordinateSystem, entry_.coord_sys)
|
27
|
-
assert_equal("Popular Visualisation CRS / Mercator", entry_.name)
|
28
|
-
end
|
29
|
-
end if false
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for OGC CS classes
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
module RGeo
|
11
|
-
module Tests # :nodoc:
|
12
|
-
module CoordSys # :nodoc:
|
13
|
-
class TestUrlReader < ::Test::Unit::TestCase # :nodoc:
|
14
|
-
def test_sr_org_epsg_4326_ogcwkt
|
15
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
|
16
|
-
entry_ = db_.get("http://spatialreference.org/ref/epsg/4326/ogcwkt/")
|
17
|
-
assert_kind_of(::RGeo::CoordSys::CS::GeographicCoordinateSystem, entry_.coord_sys)
|
18
|
-
assert_equal("WGS 84", entry_.name)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_sr_org_epsg_4326_proj4
|
22
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
|
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)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_sr_org_epsg_3857_ogcwkt
|
28
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
|
29
|
-
entry_ = db_.get("http://spatialreference.org/ref/epsg/3857/ogcwkt/")
|
30
|
-
assert_kind_of(::RGeo::CoordSys::CS::ProjectedCoordinateSystem, entry_.coord_sys)
|
31
|
-
assert_equal("Popular Visualisation CRS / Mercator", entry_.name)
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_sr_org_epsg_3857_proj4
|
35
|
-
db_ = ::RGeo::CoordSys::SRSDatabase::UrlReader.new
|
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)
|
38
|
-
end
|
39
|
-
end if false
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for the GEOS factory
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
require ::File.expand_path("../common/factory_tests.rb", ::File.dirname(__FILE__))
|
11
|
-
|
12
|
-
module RGeo
|
13
|
-
module Tests # :nodoc:
|
14
|
-
module GeosCAPI # :nodoc:
|
15
|
-
class TestFactory < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
def setup
|
17
|
-
@factory = ::RGeo::Geos.factory(srid: 1000)
|
18
|
-
@srid = 1000
|
19
|
-
end
|
20
|
-
|
21
|
-
include ::RGeo::Tests::Common::FactoryTests
|
22
|
-
|
23
|
-
def test_is_geos_factory
|
24
|
-
assert_equal(true, ::RGeo::Geos.is_geos?(@factory))
|
25
|
-
assert_equal(true, ::RGeo::Geos.is_capi_geos?(@factory))
|
26
|
-
assert_equal(false, ::RGeo::Geos.is_ffi_geos?(@factory))
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end if ::RGeo::Geos.capi_supported?
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for the GEOS geometry collection implementation
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
require ::File.expand_path("../common/geometry_collection_tests.rb", ::File.dirname(__FILE__))
|
11
|
-
|
12
|
-
module RGeo
|
13
|
-
module Tests # :nodoc:
|
14
|
-
module GeosCAPI # :nodoc:
|
15
|
-
class TestGeometryCollection < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
def create_factory
|
17
|
-
::RGeo::Geos.factory
|
18
|
-
end
|
19
|
-
|
20
|
-
include ::RGeo::Tests::Common::GeometryCollectionTests
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end if ::RGeo::Geos.capi_supported?
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for the GEOS line string implementation
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
require ::File.expand_path("../common/line_string_tests.rb", ::File.dirname(__FILE__))
|
11
|
-
|
12
|
-
module RGeo
|
13
|
-
module Tests # :nodoc:
|
14
|
-
module GeosCAPI # :nodoc:
|
15
|
-
class TestLineString < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
include ::RGeo::Tests::Common::LineStringTests
|
17
|
-
|
18
|
-
def setup
|
19
|
-
@factory = ::RGeo::Geos.factory
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end if ::RGeo::Geos.capi_supported?
|
data/test/geos_capi/misc_test.rb
DELETED
@@ -1,116 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for miscellaneous GEOS stuff
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
module RGeo
|
11
|
-
module Tests # :nodoc:
|
12
|
-
module GeosCAPI # :nodoc:
|
13
|
-
class TestMisc < ::Test::Unit::TestCase # :nodoc:
|
14
|
-
def setup
|
15
|
-
@factory = ::RGeo::Geos.factory(srid: 4326)
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_marshal_dump_with_geos
|
19
|
-
@factory = ::RGeo::Geos.factory(
|
20
|
-
srid: 4326,
|
21
|
-
wkt_generator: :geos,
|
22
|
-
wkb_generator: :geos,
|
23
|
-
wkt_parser: :geos,
|
24
|
-
wkb_parser: :geos
|
25
|
-
)
|
26
|
-
|
27
|
-
dump = nil
|
28
|
-
assert_nothing_raised { dump = @factory.marshal_dump }
|
29
|
-
assert_equal({}, dump["wktg"])
|
30
|
-
assert_equal({}, dump["wkbg"])
|
31
|
-
assert_equal({}, dump["wktp"])
|
32
|
-
assert_equal({}, dump["wkbp"])
|
33
|
-
end
|
34
|
-
|
35
|
-
def test_encode_with_geos
|
36
|
-
@factory = ::RGeo::Geos.factory(
|
37
|
-
srid: 4326,
|
38
|
-
wkt_generator: :geos,
|
39
|
-
wkb_generator: :geos,
|
40
|
-
wkt_parser: :geos,
|
41
|
-
wkb_parser: :geos
|
42
|
-
)
|
43
|
-
coder = Psych::Coder.new("test")
|
44
|
-
|
45
|
-
assert_nothing_raised { @factory.encode_with(coder) }
|
46
|
-
assert_equal({}, coder["wkt_generator"])
|
47
|
-
assert_equal({}, coder["wkb_generator"])
|
48
|
-
assert_equal({}, coder["wkt_parser"])
|
49
|
-
assert_equal({}, coder["wkb_parser"])
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_uninitialized
|
53
|
-
geom_ = ::RGeo::Geos::CAPIGeometryImpl.new
|
54
|
-
assert_equal(false, geom_.initialized?)
|
55
|
-
assert_nil(geom_.geometry_type)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_empty_geometries_equal
|
59
|
-
geom1_ = @factory.collection([])
|
60
|
-
geom2_ = @factory.line_string([])
|
61
|
-
assert(!geom1_.eql?(geom2_))
|
62
|
-
assert(geom1_.equals?(geom2_))
|
63
|
-
end
|
64
|
-
|
65
|
-
def test_prepare
|
66
|
-
p1_ = @factory.point(1, 2)
|
67
|
-
p2_ = @factory.point(3, 4)
|
68
|
-
p3_ = @factory.point(5, 2)
|
69
|
-
polygon_ = @factory.polygon(@factory.linear_ring([p1_, p2_, p3_, p1_]))
|
70
|
-
assert_equal(false, polygon_.prepared?)
|
71
|
-
polygon_.prepare!
|
72
|
-
assert_equal(true, polygon_.prepared?)
|
73
|
-
end
|
74
|
-
|
75
|
-
def test_auto_prepare
|
76
|
-
p1_ = @factory.point(1, 2)
|
77
|
-
p2_ = @factory.point(3, 4)
|
78
|
-
p3_ = @factory.point(5, 2)
|
79
|
-
polygon_ = @factory.polygon(@factory.linear_ring([p1_, p2_, p3_, p1_]))
|
80
|
-
assert_equal(false, polygon_.prepared?)
|
81
|
-
polygon_.intersects?(p1_)
|
82
|
-
assert_equal(false, polygon_.prepared?)
|
83
|
-
polygon_.intersects?(p2_)
|
84
|
-
assert_equal(true, polygon_.prepared?)
|
85
|
-
|
86
|
-
factory_no_auto_prepare_ = ::RGeo::Geos.factory(srid: 4326, auto_prepare: :disabled)
|
87
|
-
polygon2_ = factory_no_auto_prepare_.polygon(
|
88
|
-
factory_no_auto_prepare_.linear_ring([p1_, p2_, p3_, p1_]))
|
89
|
-
assert_equal(false, polygon2_.prepared?)
|
90
|
-
polygon2_.intersects?(p1_)
|
91
|
-
assert_equal(false, polygon2_.prepared?)
|
92
|
-
polygon2_.intersects?(p2_)
|
93
|
-
assert_equal(false, polygon2_.prepared?)
|
94
|
-
end
|
95
|
-
|
96
|
-
def test_gh_21
|
97
|
-
# Test for GH-21 (seg fault in rgeo_convert_to_geos_geometry)
|
98
|
-
# This seemed to fail under Ruby 1.8.7 only.
|
99
|
-
f_ = RGeo::Geographic.simple_mercator_factory
|
100
|
-
loc_ = f_.line_string([f_.point(-123, 37), f_.point(-122, 38)])
|
101
|
-
f2_ = f_.projection_factory
|
102
|
-
loc2_ = f2_.line_string([f2_.point(-123, 37), f2_.point(-122, 38)])
|
103
|
-
loc2_.intersection(loc_)
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_geos_version
|
107
|
-
assert_match(/^\d+\.\d+(\.\d+)?$/, ::RGeo::Geos.version)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end if ::RGeo::Geos.capi_supported?
|
113
|
-
|
114
|
-
unless ::RGeo::Geos.capi_supported?
|
115
|
-
puts "WARNING: GEOS CAPI support not available. Related tests skipped."
|
116
|
-
end
|