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,24 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for the GEOS multi line string implementation
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
require ::File.expand_path("../common/multi_line_string_tests.rb", ::File.dirname(__FILE__))
|
11
|
-
|
12
|
-
module RGeo
|
13
|
-
module Tests # :nodoc:
|
14
|
-
module GeosCAPI # :nodoc:
|
15
|
-
class TestMultiLineString < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
def create_factory
|
17
|
-
::RGeo::Geos.factory
|
18
|
-
end
|
19
|
-
|
20
|
-
include ::RGeo::Tests::Common::MultiLineStringTests
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end if ::RGeo::Geos.capi_supported?
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for the GEOS multi point implementation
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
require ::File.expand_path("../common/multi_point_tests.rb", ::File.dirname(__FILE__))
|
11
|
-
|
12
|
-
module RGeo
|
13
|
-
module Tests # :nodoc:
|
14
|
-
module GeosCAPI # :nodoc:
|
15
|
-
class TestMultiPoint < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
def create_factory(opts_ = {})
|
17
|
-
::RGeo::Geos.factory(opts_)
|
18
|
-
end
|
19
|
-
|
20
|
-
include ::RGeo::Tests::Common::MultiPointTests
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end if ::RGeo::Geos.capi_supported?
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for the GEOS multi polygon implementation
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
require ::File.expand_path("../common/multi_polygon_tests.rb", ::File.dirname(__FILE__))
|
11
|
-
|
12
|
-
module RGeo
|
13
|
-
module Tests # :nodoc:
|
14
|
-
module GeosCAPI # :nodoc:
|
15
|
-
class TestMultiPolygon < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
def create_factories
|
17
|
-
@factory = ::RGeo::Geos.factory
|
18
|
-
@lenient_factory = ::RGeo::Geos.factory(lenient_multi_polygon_assertions: true)
|
19
|
-
end
|
20
|
-
|
21
|
-
include ::RGeo::Tests::Common::MultiPolygonTests
|
22
|
-
|
23
|
-
# Centroid of an empty should return an empty collection rather than crash
|
24
|
-
|
25
|
-
def test_empty_centroid
|
26
|
-
assert_equal(@factory.collection([]), @factory.multi_polygon([]).centroid)
|
27
|
-
end
|
28
|
-
|
29
|
-
def _test_geos_bug_582
|
30
|
-
f_ = ::RGeo::Geos.factory(buffer_resolution: 2)
|
31
|
-
p1_ = f_.polygon(f_.linear_ring([]))
|
32
|
-
p2_ = f_.polygon(f_.linear_ring([f_.point(0, 0), f_.point(0, 1), f_.point(1, 1), f_.point(1, 0)]))
|
33
|
-
mp_ = f_.multi_polygon([p2_, p1_])
|
34
|
-
mp_.centroid.as_text
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end if ::RGeo::Geos.capi_supported?
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for the GEOS point implementation
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
module RGeo
|
11
|
-
module Tests # :nodoc:
|
12
|
-
module GeosCAPI # :nodoc:
|
13
|
-
class TestParsingUnparsing < ::Test::Unit::TestCase # :nodoc:
|
14
|
-
def test_wkt_generator_default_floating_point
|
15
|
-
# Bug report GH-4
|
16
|
-
factory_ = ::RGeo::Geos.factory
|
17
|
-
point_ = factory_.point(111.99, -40.37)
|
18
|
-
assert_equal("POINT (111.99 -40.37)", point_.as_text)
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_wkt_generator_downcase
|
22
|
-
factory_ = ::RGeo::Geos.factory(wkt_generator: { convert_case: :lower })
|
23
|
-
point_ = factory_.point(1, 1)
|
24
|
-
assert_equal("point (1.0 1.0)", point_.as_text)
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_wkt_generator_geos
|
28
|
-
factory_ = ::RGeo::Geos.factory(wkt_generator: :geos)
|
29
|
-
point_ = factory_.point(1, 1)
|
30
|
-
assert_equal("POINT (1.0000000000000000 1.0000000000000000)", point_.as_text)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_wkt_parser_default_with_non_geosable_input
|
34
|
-
factory_ = ::RGeo::Geos.factory
|
35
|
-
assert_not_nil(factory_.parse_wkt("Point (1 1)"))
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end if ::RGeo::Geos.capi_supported?
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for the GEOS point implementation
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require "test/unit"
|
8
|
-
require "rgeo"
|
9
|
-
|
10
|
-
require ::File.expand_path("../common/point_tests.rb", ::File.dirname(__FILE__))
|
11
|
-
|
12
|
-
module RGeo
|
13
|
-
module Tests # :nodoc:
|
14
|
-
module GeosCAPI # :nodoc:
|
15
|
-
class TestPoint < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
def setup
|
17
|
-
@factory = ::RGeo::Geos.factory(buffer_resolution: 8)
|
18
|
-
@zfactory = ::RGeo::Geos.factory(has_z_coordinate: true)
|
19
|
-
@mfactory = ::RGeo::Geos.factory(has_m_coordinate: true)
|
20
|
-
@zmfactory = ::RGeo::Geos.factory(has_z_coordinate: true, has_m_coordinate: true)
|
21
|
-
end
|
22
|
-
|
23
|
-
include ::RGeo::Tests::Common::PointTests
|
24
|
-
|
25
|
-
def test_is_geos
|
26
|
-
point_ = @factory.point(21, -22)
|
27
|
-
assert_equal(true, ::RGeo::Geos.is_geos?(point_))
|
28
|
-
assert_equal(true, ::RGeo::Geos.is_capi_geos?(point_))
|
29
|
-
assert_equal(false, ::RGeo::Geos.is_ffi_geos?(point_))
|
30
|
-
point2_ = @zmfactory.point(21, -22, 0, 0)
|
31
|
-
assert_equal(true, ::RGeo::Geos.is_geos?(point2_))
|
32
|
-
assert_equal(true, ::RGeo::Geos.is_capi_geos?(point2_))
|
33
|
-
assert_equal(false, ::RGeo::Geos.is_ffi_geos?(point2_))
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_has_no_projection
|
37
|
-
point_ = @factory.point(21, -22)
|
38
|
-
assert(!point_.respond_to?(:projection))
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_srid
|
42
|
-
point_ = @factory.point(11, 12)
|
43
|
-
assert_equal(0, point_.srid)
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_distance
|
47
|
-
point1_ = @factory.point(11, 12)
|
48
|
-
point2_ = @factory.point(11, 12)
|
49
|
-
point3_ = @factory.point(13, 12)
|
50
|
-
assert_equal(0, point1_.distance(point2_))
|
51
|
-
assert_equal(2, point1_.distance(point3_))
|
52
|
-
end
|
53
|
-
|
54
|
-
if defined?(::Encoding)
|
55
|
-
|
56
|
-
def test_as_text_encoding
|
57
|
-
factory_ = ::RGeo::Geos.factory(wkt_generator: :geos)
|
58
|
-
point_ = factory_.point(11, 12)
|
59
|
-
assert_equal(::Encoding::US_ASCII, point_.as_text.encoding)
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_as_binary_encoding
|
63
|
-
factory_ = ::RGeo::Geos.factory(wkb_generator: :geos)
|
64
|
-
point_ = factory_.point(11, 12)
|
65
|
-
assert_equal(::Encoding::ASCII_8BIT, point_.as_binary.encoding)
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end if ::RGeo::Geos.capi_supported?
|
@@ -1,154 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for the GEOS polygon implementation
|
4
|
-
#
|
5
|
-
# -----------------------------------------------------------------------------
|
6
|
-
|
7
|
-
require 'test/unit'
|
8
|
-
require 'rgeo'
|
9
|
-
|
10
|
-
require ::File.expand_path('../common/polygon_tests.rb', ::File.dirname(__FILE__))
|
11
|
-
|
12
|
-
module RGeo
|
13
|
-
module Tests # :nodoc:
|
14
|
-
module GeosCAPI # :nodoc:
|
15
|
-
class TestPolygon < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
def setup
|
17
|
-
@factory = ::RGeo::Geos.factory
|
18
|
-
end
|
19
|
-
|
20
|
-
include ::RGeo::Tests::Common::PolygonTests
|
21
|
-
|
22
|
-
def test_intersection
|
23
|
-
point1_ = @factory.point(0, 0)
|
24
|
-
point2_ = @factory.point(0, 2)
|
25
|
-
point3_ = @factory.point(2, 2)
|
26
|
-
point4_ = @factory.point(2, 0)
|
27
|
-
poly1_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point3_, point4_]))
|
28
|
-
poly2_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point4_]))
|
29
|
-
poly3_ = poly1_.intersection(poly2_)
|
30
|
-
assert_equal(poly2_, poly3_)
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_union
|
34
|
-
point1_ = @factory.point(0, 0)
|
35
|
-
point2_ = @factory.point(0, 2)
|
36
|
-
point3_ = @factory.point(2, 2)
|
37
|
-
point4_ = @factory.point(2, 0)
|
38
|
-
poly1_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point3_, point4_]))
|
39
|
-
poly2_ = @factory.polygon(@factory.linear_ring([point1_, point2_, point4_]))
|
40
|
-
poly3_ = poly1_.union(poly2_)
|
41
|
-
assert_equal(poly1_, poly3_)
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_simplify
|
45
|
-
xys = [[0, 0], [5, 0], [10, 0], [10, 10], [5, 10.2], [0, 10], [0, 0]]
|
46
|
-
points = xys.collect { |x, y| @factory.point(x, y) }
|
47
|
-
poly = @factory.polygon(@factory.linear_ring(points))
|
48
|
-
simplified = poly.simplify(0.3)
|
49
|
-
new_points = simplified.exterior_ring.points
|
50
|
-
extra = new_points.reject { |p| [0, 10].include?(p.x) and [0, 10].include?(p.y) }
|
51
|
-
assert_equal 5, new_points.length, "Closed ring of the square should have 5 points"
|
52
|
-
assert_equal 0, extra.length, "Should only have x/y's on 0 and 10"
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_buffer
|
56
|
-
polygon_coordinates = [[0.5527864045000421, 3.776393202250021],
|
57
|
-
[0.7763932022500211, 4.447213595499958],
|
58
|
-
[1.4472135954999579, 4.223606797749979],
|
59
|
-
[2.447213595499958, 2.223606797749979],
|
60
|
-
[2.223606797749979, 1.5527864045000421],
|
61
|
-
[1.5527864045000421, 1.776393202250021],
|
62
|
-
[0.5527864045000421, 3.776393202250021]]
|
63
|
-
|
64
|
-
points_arr = polygon_coordinates.map { |v| @factory.point(v[0], v[1]) }
|
65
|
-
outer_ring = @factory.linear_ring(points_arr)
|
66
|
-
polygon = @factory.polygon(outer_ring)
|
67
|
-
|
68
|
-
point1 = @factory.point(2, 2)
|
69
|
-
point2 = @factory.point(1, 4)
|
70
|
-
line_string = @factory.line_string([point1, point2])
|
71
|
-
polygon2 = line_string.buffer(0.5)
|
72
|
-
|
73
|
-
assert_equal polygon, polygon2
|
74
|
-
end
|
75
|
-
|
76
|
-
def test_simplify_preserve_topology()
|
77
|
-
xys1 = [[0.0, 0.0], [5.0, 0.0], [10.0, 0.0], [10.0, 10.0], [5.0, 12.0], [0.0, 10.0], [0.0, 0.0]]
|
78
|
-
xys2 = [[0.1, 0.1], [0.1, 0.6], [0.3, 0.8], [0.5, 0.5], [0.7, 0.3], [0.3, 0.1], [0.1, 0.1]]
|
79
|
-
|
80
|
-
points1 = xys1.collect { |x,y| @factory.point(x, y) }
|
81
|
-
points2 = xys2.collect { |x,y| @factory.point(x, y) }
|
82
|
-
|
83
|
-
ln1 = @factory.line_string(points1)
|
84
|
-
ln2 = @factory.line_string(points2)
|
85
|
-
|
86
|
-
poly = @factory.polygon(ln1,[ln2])
|
87
|
-
|
88
|
-
simplified = poly.simplify_preserve_topology(1)
|
89
|
-
interior_points = simplified.interior_rings[0].points
|
90
|
-
|
91
|
-
assert_equal 5, interior_points.length
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_buffer_with_style
|
95
|
-
polygon_coordinates = [[0.7316718427000253, 3.865835921350013],
|
96
|
-
[1.0, 4.3], [6.0, 4.3], [6.3, 4.3],
|
97
|
-
[6.3, 3.7], [1.4854101966249682, 3.7],
|
98
|
-
[2.2683281572999747, 2.134164078649987],
|
99
|
-
[2.4024922359499623, 1.8658359213500124],
|
100
|
-
[1.8658359213500126, 1.597507764050038],
|
101
|
-
[0.7316718427000253, 3.865835921350013]]
|
102
|
-
|
103
|
-
points_arr = polygon_coordinates.map { |v| @factory.point(v[0], v[1]) }
|
104
|
-
outer_ring = @factory.linear_ring(points_arr)
|
105
|
-
polygon = @factory.polygon(outer_ring)
|
106
|
-
|
107
|
-
point1 = @factory.point(2, 2)
|
108
|
-
point2 = @factory.point(1, 4)
|
109
|
-
point3 = @factory.point(6, 4)
|
110
|
-
line_string = @factory.line_string([point1, point2, point3])
|
111
|
-
buffered_line_string = line_string.buffer_with_style(0.3,
|
112
|
-
RGeo::Geos::CAP_FLAT,
|
113
|
-
RGeo::Geos::JOIN_ROUND,
|
114
|
-
0.0)
|
115
|
-
|
116
|
-
assert_equal polygon, buffered_line_string
|
117
|
-
end
|
118
|
-
|
119
|
-
def test_is_valid_polygon
|
120
|
-
polygon_coordinates = [[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]]
|
121
|
-
points_arr = polygon_coordinates.map{|v| @factory.point(v[0],v[1])}
|
122
|
-
outer_ring = @factory.linear_ring(points_arr)
|
123
|
-
polygon = @factory.polygon(outer_ring)
|
124
|
-
|
125
|
-
assert_equal(polygon.valid?, true)
|
126
|
-
|
127
|
-
polygon_coordinates = [[-1, -1], [-1, 0], [1, 0], [1, 1], [0, 1], [0, -1], [-1, -1]]
|
128
|
-
points_arr = polygon_coordinates.map{|v| @factory.point(v[0],v[1])}
|
129
|
-
outer_ring = @factory.linear_ring(points_arr)
|
130
|
-
polygon = @factory.polygon(outer_ring)
|
131
|
-
|
132
|
-
assert_equal(polygon.valid?, false)
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_invalid_reason
|
136
|
-
polygon_coordinates = [[-1, -1], [-1, 0], [1, 0], [1, 1], [0, 1], [0, -1], [-1, -1]]
|
137
|
-
points_arr = polygon_coordinates.map{|v| @factory.point(v[0],v[1])}
|
138
|
-
outer_ring = @factory.linear_ring(points_arr)
|
139
|
-
polygon = @factory.polygon(outer_ring)
|
140
|
-
|
141
|
-
assert_equal(polygon.invalid_reason, "Self-intersection[0 0 0]")
|
142
|
-
end
|
143
|
-
|
144
|
-
def test_invalid_reason_with_valid_polygon
|
145
|
-
polygon_coordinates = [[0, 0], [0, 5], [5, 5], [5, 0], [0, 0]]
|
146
|
-
points_arr = polygon_coordinates.map{|v| @factory.point(v[0],v[1])}
|
147
|
-
outer_ring = @factory.linear_ring(points_arr)
|
148
|
-
polygon = @factory.polygon(outer_ring)
|
149
|
-
polygon.invalid_reason
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end if ::RGeo::Geos.capi_supported?
|
@@ -1,57 +0,0 @@
|
|
1
|
-
# -----------------------------------------------------------------------------
|
2
|
-
#
|
3
|
-
# Tests for the GEOS point implementation
|
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 TestZMFactory < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
def setup
|
17
|
-
@factory = ::RGeo::Geos.factory(has_z_coordinate: true, has_m_coordinate: true, srid: 1000, buffer_resolution: 2)
|
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
|
-
|
29
|
-
def test_factory_parts
|
30
|
-
assert_equal(1000, @factory.srid)
|
31
|
-
assert_equal(1000, @factory.z_factory.srid)
|
32
|
-
assert_equal(1000, @factory.m_factory.srid)
|
33
|
-
assert_equal(2, @factory.buffer_resolution)
|
34
|
-
assert_equal(2, @factory.z_factory.buffer_resolution)
|
35
|
-
assert_equal(2, @factory.m_factory.buffer_resolution)
|
36
|
-
assert(@factory.property(:has_z_coordinate))
|
37
|
-
assert(@factory.property(:has_m_coordinate))
|
38
|
-
assert(@factory.z_factory.property(:has_z_coordinate))
|
39
|
-
assert(!@factory.z_factory.property(:has_m_coordinate))
|
40
|
-
assert(!@factory.m_factory.property(:has_z_coordinate))
|
41
|
-
assert(@factory.m_factory.property(:has_m_coordinate))
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_4d_point
|
45
|
-
point_ = @factory.point(1, 2, 3, 4)
|
46
|
-
assert_equal(Feature::Point, point_.geometry_type)
|
47
|
-
assert_equal(3, point_.z)
|
48
|
-
assert_equal(4, point_.m)
|
49
|
-
assert_equal(3, point_.z_geometry.z)
|
50
|
-
assert_nil(point_.z_geometry.m)
|
51
|
-
assert_nil(point_.m_geometry.z)
|
52
|
-
assert_equal(4, point_.m_geometry.m)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end if ::RGeo::Geos.capi_supported?
|
@@ -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 GeosFFI # :nodoc:
|
15
|
-
class TestFactory < ::Test::Unit::TestCase # :nodoc:
|
16
|
-
def setup
|
17
|
-
@factory = ::RGeo::Geos.factory(srid: 1000, native_interface: :ffi)
|
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(false, ::RGeo::Geos.is_capi_geos?(@factory))
|
26
|
-
assert_equal(true, ::RGeo::Geos.is_ffi_geos?(@factory))
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end if ::RGeo::Geos.ffi_supported?
|