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/lib/rgeo/yaml.rb
CHANGED
@@ -5,25 +5,19 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
begin
|
8
|
-
require
|
8
|
+
require "psych"
|
9
9
|
rescue ::LoadError
|
10
10
|
end
|
11
11
|
|
12
|
-
|
13
12
|
module RGeo
|
14
|
-
|
15
|
-
|
16
13
|
# :stopdoc:
|
17
14
|
PSYCH_AVAILABLE = defined?(::Psych)
|
18
15
|
# :startdoc:
|
19
16
|
|
20
|
-
|
21
17
|
# Returns true if YAML serialization and deserialization is supported.
|
22
18
|
# YAML support requires the Psych library/gem.
|
23
19
|
|
24
20
|
def self.yaml_supported?
|
25
21
|
PSYCH_AVAILABLE
|
26
22
|
end
|
27
|
-
|
28
|
-
|
29
23
|
end
|
@@ -4,21 +4,16 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
|
7
|
+
require "rgeo"
|
9
8
|
|
10
9
|
module RGeo
|
11
|
-
module Tests
|
12
|
-
module Common
|
13
|
-
|
14
|
-
module FactoryTests # :nodoc:
|
15
|
-
|
16
|
-
|
10
|
+
module Tests # :nodoc:
|
11
|
+
module Common # :nodoc:
|
12
|
+
module FactoryTests # :nodoc:
|
17
13
|
def _srid
|
18
14
|
defined?(@srid) ? @srid : 0
|
19
15
|
end
|
20
16
|
|
21
|
-
|
22
17
|
def test_srid_preserved_through_factory
|
23
18
|
geom_ = @factory.point(-10, 20)
|
24
19
|
assert_equal(_srid, geom_.srid)
|
@@ -28,7 +23,6 @@ module RGeo
|
|
28
23
|
assert_equal(_srid, geom2_.srid)
|
29
24
|
end
|
30
25
|
|
31
|
-
|
32
26
|
def test_srid_preserved_through_geom_operations
|
33
27
|
geom1_ = @factory.point(-10, 20)
|
34
28
|
geom2_ = @factory.point(-20, 25)
|
@@ -38,34 +32,29 @@ module RGeo
|
|
38
32
|
assert_equal(_srid, geom3_.geometry_n(1).srid)
|
39
33
|
end
|
40
34
|
|
41
|
-
|
42
35
|
def test_srid_preserved_through_geom_functions
|
43
36
|
geom1_ = @factory.point(-10, 20)
|
44
37
|
geom2_ = geom1_.boundary
|
45
38
|
assert_equal(_srid, geom2_.srid)
|
46
39
|
end
|
47
40
|
|
48
|
-
|
49
41
|
def test_srid_preserved_through_geometry_dup
|
50
42
|
geom1_ = @factory.point(-10, 20)
|
51
43
|
geom2_ = geom1_.clone
|
52
44
|
assert_equal(_srid, geom2_.srid)
|
53
45
|
end
|
54
46
|
|
55
|
-
|
56
47
|
def test_dup_factory_results_in_equal_factories
|
57
48
|
dup_factory_ = @factory.dup
|
58
49
|
assert_equal(@factory, dup_factory_)
|
59
50
|
assert_equal(_srid, dup_factory_.srid)
|
60
51
|
end
|
61
52
|
|
62
|
-
|
63
53
|
def test_dup_factory_results_in_equal_hashes
|
64
54
|
dup_factory_ = @factory.dup
|
65
55
|
assert_equal(@factory.hash, dup_factory_.hash)
|
66
56
|
end
|
67
57
|
|
68
|
-
|
69
58
|
def test_marshal_dump_load_factory
|
70
59
|
data_ = ::Marshal.dump(@factory)
|
71
60
|
factory2_ = ::Marshal.load(data_)
|
@@ -73,7 +62,6 @@ module RGeo
|
|
73
62
|
assert_equal(_srid, factory2_.srid)
|
74
63
|
end
|
75
64
|
|
76
|
-
|
77
65
|
if ::RGeo.yaml_supported?
|
78
66
|
|
79
67
|
def test_psych_dump_load_factory
|
@@ -84,10 +72,7 @@ module RGeo
|
|
84
72
|
end
|
85
73
|
|
86
74
|
end
|
87
|
-
|
88
|
-
|
89
75
|
end
|
90
|
-
|
91
76
|
end
|
92
77
|
end
|
93
78
|
end
|
@@ -4,16 +4,12 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
|
7
|
+
require "rgeo"
|
9
8
|
|
10
9
|
module RGeo
|
11
|
-
module Tests
|
12
|
-
module Common
|
13
|
-
|
14
|
-
module GeometryCollectionTests # :nodoc:
|
15
|
-
|
16
|
-
|
10
|
+
module Tests # :nodoc:
|
11
|
+
module Common # :nodoc:
|
12
|
+
module GeometryCollectionTests # :nodoc:
|
17
13
|
def setup
|
18
14
|
@factory = create_factory
|
19
15
|
@point1 = @factory.point(0, 0)
|
@@ -25,7 +21,6 @@ module RGeo
|
|
25
21
|
@line3 = @factory.line(@point3, @point4)
|
26
22
|
end
|
27
23
|
|
28
|
-
|
29
24
|
def test_creation_simple
|
30
25
|
geom_ = @factory.collection([@point1, @line1])
|
31
26
|
assert_not_nil(geom_)
|
@@ -36,7 +31,6 @@ module RGeo
|
|
36
31
|
assert(@line1.eql?(geom_[1]))
|
37
32
|
end
|
38
33
|
|
39
|
-
|
40
34
|
def test_creation_empty
|
41
35
|
geom_ = @factory.collection([])
|
42
36
|
assert_not_nil(geom_)
|
@@ -46,7 +40,6 @@ module RGeo
|
|
46
40
|
assert_equal([], geom_.to_a)
|
47
41
|
end
|
48
42
|
|
49
|
-
|
50
43
|
def test_bounds_check
|
51
44
|
geom_ = @factory.collection([@point1, @line1])
|
52
45
|
assert_nil(geom_.geometry_n(200))
|
@@ -54,7 +47,6 @@ module RGeo
|
|
54
47
|
assert(@line1.eql?(geom_[-1]))
|
55
48
|
end
|
56
49
|
|
57
|
-
|
58
50
|
def test_creation_save_klass
|
59
51
|
geom_ = @factory.collection([@point1, @line3])
|
60
52
|
assert_not_nil(geom_)
|
@@ -64,7 +56,6 @@ module RGeo
|
|
64
56
|
assert(geom_[1].eql?(@line3))
|
65
57
|
end
|
66
58
|
|
67
|
-
|
68
59
|
def test_creation_compound
|
69
60
|
geom1_ = @factory.collection([@point1, @line1])
|
70
61
|
geom2_ = @factory.collection([@point2, geom1_])
|
@@ -75,7 +66,6 @@ module RGeo
|
|
75
66
|
assert(geom2_[1].eql?(geom1_))
|
76
67
|
end
|
77
68
|
|
78
|
-
|
79
69
|
def test_creation_compound_save_klass
|
80
70
|
geom1_ = @factory.collection([@point1, @line3])
|
81
71
|
geom2_ = @factory.collection([@point2, geom1_])
|
@@ -87,7 +77,6 @@ module RGeo
|
|
87
77
|
assert_equal(::RGeo::Feature::Line, geom2_[1][1].geometry_type)
|
88
78
|
end
|
89
79
|
|
90
|
-
|
91
80
|
def test_required_equivalences
|
92
81
|
geom1_ = @factory.collection([@point1, @line1])
|
93
82
|
geom2_ = @factory.collection([@point1, @line1])
|
@@ -95,7 +84,6 @@ module RGeo
|
|
95
84
|
assert(geom1_ == geom2_)
|
96
85
|
end
|
97
86
|
|
98
|
-
|
99
87
|
def test_fully_equal
|
100
88
|
geom1_ = @factory.collection([@point1, @line1])
|
101
89
|
geom2_ = @factory.collection([@point1, @line1])
|
@@ -103,7 +91,6 @@ module RGeo
|
|
103
91
|
assert(geom1_.equals?(geom2_))
|
104
92
|
end
|
105
93
|
|
106
|
-
|
107
94
|
def test_geometrically_equal
|
108
95
|
geom1_ = @factory.collection([@point2, @line2])
|
109
96
|
geom2_ = @factory.collection([@point2, @line1, @line2])
|
@@ -111,7 +98,6 @@ module RGeo
|
|
111
98
|
assert(geom1_.equals?(geom2_))
|
112
99
|
end
|
113
100
|
|
114
|
-
|
115
101
|
def test_empty_equal
|
116
102
|
geom1_ = @factory.collection([])
|
117
103
|
geom2_ = @factory.collection([])
|
@@ -119,7 +105,6 @@ module RGeo
|
|
119
105
|
assert(geom1_.equals?(geom2_))
|
120
106
|
end
|
121
107
|
|
122
|
-
|
123
108
|
def test_not_equal
|
124
109
|
geom1_ = @factory.collection([@point1, @line1])
|
125
110
|
geom2_ = @factory.collection([@point2, @line1])
|
@@ -127,14 +112,12 @@ module RGeo
|
|
127
112
|
assert(!geom1_.equals?(geom2_))
|
128
113
|
end
|
129
114
|
|
130
|
-
|
131
115
|
def test_hashes_equal_for_representationally_equivalent_objects
|
132
116
|
geom1_ = @factory.collection([@point1, @line1])
|
133
117
|
geom2_ = @factory.collection([@point1, @line1])
|
134
118
|
assert_equal(geom1_.hash, geom2_.hash)
|
135
119
|
end
|
136
120
|
|
137
|
-
|
138
121
|
def test_nested_equality
|
139
122
|
geom1_ = @factory.collection([@line1, @factory.collection([@point1, @point2])])
|
140
123
|
geom2_ = @factory.collection([@line1, @factory.collection([@point1, @point2])])
|
@@ -142,7 +125,6 @@ module RGeo
|
|
142
125
|
assert_equal(geom1_.hash, geom2_.hash)
|
143
126
|
end
|
144
127
|
|
145
|
-
|
146
128
|
def test_out_of_order_is_not_equal
|
147
129
|
geom1_ = @factory.collection([@line1, @point2])
|
148
130
|
geom2_ = @factory.collection([@point2, @line1])
|
@@ -150,21 +132,18 @@ module RGeo
|
|
150
132
|
assert_not_equal(geom1_.hash, geom2_.hash)
|
151
133
|
end
|
152
134
|
|
153
|
-
|
154
135
|
def test_wkt_creation_simple
|
155
|
-
parsed_geom_ = @factory.parse_wkt(
|
136
|
+
parsed_geom_ = @factory.parse_wkt("GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(-4 2, -5 3))")
|
156
137
|
built_geom_ = @factory.collection([@point1, @line1])
|
157
138
|
assert(built_geom_.eql?(parsed_geom_))
|
158
139
|
end
|
159
140
|
|
160
|
-
|
161
141
|
def test_wkt_creation_empty
|
162
|
-
parsed_geom_ = @factory.parse_wkt(
|
142
|
+
parsed_geom_ = @factory.parse_wkt("GEOMETRYCOLLECTION EMPTY")
|
163
143
|
assert_equal(0, parsed_geom_.num_geometries)
|
164
144
|
assert_equal([], parsed_geom_.to_a)
|
165
145
|
end
|
166
146
|
|
167
|
-
|
168
147
|
def test_clone
|
169
148
|
geom1_ = @factory.collection([@point1, @line1])
|
170
149
|
geom2_ = geom1_.clone
|
@@ -175,7 +154,6 @@ module RGeo
|
|
175
154
|
assert(@line1.eql?(geom2_[1]))
|
176
155
|
end
|
177
156
|
|
178
|
-
|
179
157
|
def test_type_check
|
180
158
|
geom1_ = @factory.collection([@point1, @line1])
|
181
159
|
assert(::RGeo::Feature::Geometry.check_type(geom1_))
|
@@ -189,7 +167,6 @@ module RGeo
|
|
189
167
|
assert(!::RGeo::Feature::MultiPoint.check_type(geom2_))
|
190
168
|
end
|
191
169
|
|
192
|
-
|
193
170
|
def test_as_text_wkt_round_trip
|
194
171
|
geom1_ = @factory.collection([@point1, @line1])
|
195
172
|
text_ = geom1_.as_text
|
@@ -197,7 +174,6 @@ module RGeo
|
|
197
174
|
assert(geom1_.eql?(geom2_))
|
198
175
|
end
|
199
176
|
|
200
|
-
|
201
177
|
def test_as_binary_wkb_round_trip
|
202
178
|
geom1_ = @factory.collection([@point1, @line1])
|
203
179
|
binary_ = geom1_.as_binary
|
@@ -205,7 +181,6 @@ module RGeo
|
|
205
181
|
assert(geom1_.eql?(geom2_))
|
206
182
|
end
|
207
183
|
|
208
|
-
|
209
184
|
def test_dimension
|
210
185
|
geom1_ = @factory.collection([@point1, @line1])
|
211
186
|
assert_equal(1, geom1_.dimension)
|
@@ -215,7 +190,6 @@ module RGeo
|
|
215
190
|
assert_equal(-1, geom3_.dimension)
|
216
191
|
end
|
217
192
|
|
218
|
-
|
219
193
|
def test_is_empty
|
220
194
|
geom1_ = @factory.collection([@point1, @line1])
|
221
195
|
assert(!geom1_.is_empty?)
|
@@ -223,7 +197,6 @@ module RGeo
|
|
223
197
|
assert(geom2_.is_empty?)
|
224
198
|
end
|
225
199
|
|
226
|
-
|
227
200
|
def test_empty_collection_envelope
|
228
201
|
empty_ = @factory.collection([])
|
229
202
|
envelope_ = empty_.envelope
|
@@ -231,13 +204,11 @@ module RGeo
|
|
231
204
|
assert_equal(0, envelope_.num_geometries)
|
232
205
|
end
|
233
206
|
|
234
|
-
|
235
207
|
def test_empty_collection_boundary
|
236
208
|
empty_ = @factory.collection([])
|
237
209
|
assert_nil(empty_.boundary)
|
238
210
|
end
|
239
211
|
|
240
|
-
|
241
212
|
def test_each_block
|
242
213
|
geom1_ = @factory.collection([@point1, @line1])
|
243
214
|
i_ = 0
|
@@ -251,7 +222,6 @@ module RGeo
|
|
251
222
|
end
|
252
223
|
end
|
253
224
|
|
254
|
-
|
255
225
|
def test_each_enumerator
|
256
226
|
geom1_ = @factory.collection([@point1, @line1])
|
257
227
|
enum_ = geom1_.each
|
@@ -261,10 +231,7 @@ module RGeo
|
|
261
231
|
enum_.next
|
262
232
|
end
|
263
233
|
end
|
264
|
-
|
265
|
-
|
266
234
|
end
|
267
|
-
|
268
235
|
end
|
269
236
|
end
|
270
237
|
end
|
@@ -4,16 +4,12 @@
|
|
4
4
|
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
|
-
require
|
8
|
-
|
7
|
+
require "rgeo"
|
9
8
|
|
10
9
|
module RGeo
|
11
|
-
module Tests
|
12
|
-
module Common
|
13
|
-
|
14
|
-
module LineStringTests # :nodoc:
|
15
|
-
|
16
|
-
|
10
|
+
module Tests # :nodoc:
|
11
|
+
module Common # :nodoc:
|
12
|
+
module LineStringTests # :nodoc:
|
17
13
|
def test_creation_points2
|
18
14
|
point1_ = @factory.point(0, 0)
|
19
15
|
point2_ = @factory.point(0, 1)
|
@@ -29,7 +25,6 @@ module RGeo
|
|
29
25
|
assert_equal(point2_, line1_.end_point)
|
30
26
|
end
|
31
27
|
|
32
|
-
|
33
28
|
def test_creation_points3
|
34
29
|
point1_ = @factory.point(0, 0)
|
35
30
|
point2_ = @factory.point(0, 1)
|
@@ -46,7 +41,6 @@ module RGeo
|
|
46
41
|
assert_equal(point3_, line2_.end_point)
|
47
42
|
end
|
48
43
|
|
49
|
-
|
50
44
|
def test_creation_points2_degenerate
|
51
45
|
point1_ = @factory.point(0, 0)
|
52
46
|
line3_ = @factory.line_string([point1_, point1_])
|
@@ -59,7 +53,6 @@ module RGeo
|
|
59
53
|
assert_equal(point1_, line3_.end_point)
|
60
54
|
end
|
61
55
|
|
62
|
-
|
63
56
|
def test_creation_points_empty
|
64
57
|
line4_ = @factory.line_string([])
|
65
58
|
assert_not_nil(line4_)
|
@@ -69,7 +62,6 @@ module RGeo
|
|
69
62
|
assert_nil(line4_.end_point)
|
70
63
|
end
|
71
64
|
|
72
|
-
|
73
65
|
def test_creation_line_string
|
74
66
|
point1_ = @factory.point(0, 0)
|
75
67
|
point2_ = @factory.point(0, 1)
|
@@ -82,7 +74,6 @@ module RGeo
|
|
82
74
|
assert_equal(::RGeo::Feature::LineString, line1_.geometry_type)
|
83
75
|
end
|
84
76
|
|
85
|
-
|
86
77
|
def test_creation_linear_ring
|
87
78
|
point1_ = @factory.point(0, 0)
|
88
79
|
point2_ = @factory.point(0, 1)
|
@@ -100,7 +91,6 @@ module RGeo
|
|
100
91
|
assert_equal(::RGeo::Feature::LinearRing, line2_.geometry_type)
|
101
92
|
end
|
102
93
|
|
103
|
-
|
104
94
|
def test_creation_line
|
105
95
|
point1_ = @factory.point(0, 0)
|
106
96
|
point2_ = @factory.point(0, 1)
|
@@ -110,7 +100,6 @@ module RGeo
|
|
110
100
|
assert_equal(::RGeo::Feature::Line, line1_.geometry_type)
|
111
101
|
end
|
112
102
|
|
113
|
-
|
114
103
|
def test_creation_errors
|
115
104
|
point1_ = @factory.point(0, 0)
|
116
105
|
collection_ = point1_.boundary
|
@@ -120,7 +109,6 @@ module RGeo
|
|
120
109
|
assert_nil(line2_)
|
121
110
|
end
|
122
111
|
|
123
|
-
|
124
112
|
def test_required_equivalences
|
125
113
|
point1_ = @factory.point(0, 0)
|
126
114
|
point2_ = @factory.point(0, 1)
|
@@ -134,7 +122,6 @@ module RGeo
|
|
134
122
|
assert(line1_ == line2_)
|
135
123
|
end
|
136
124
|
|
137
|
-
|
138
125
|
def test_fully_equal
|
139
126
|
point1_ = @factory.point(0, 0)
|
140
127
|
point2_ = @factory.point(0, 1)
|
@@ -148,7 +135,6 @@ module RGeo
|
|
148
135
|
assert(line1_.equals?(line2_))
|
149
136
|
end
|
150
137
|
|
151
|
-
|
152
138
|
def test_geometrically_equal_but_different_type
|
153
139
|
point1_ = @factory.point(0, 0)
|
154
140
|
point2_ = @factory.point(0, 1)
|
@@ -160,7 +146,6 @@ module RGeo
|
|
160
146
|
assert(line1_.equals?(line2_))
|
161
147
|
end
|
162
148
|
|
163
|
-
|
164
149
|
def test_geometrically_equal_but_different_type2
|
165
150
|
point1_ = @factory.point(0, 0)
|
166
151
|
point2_ = @factory.point(0, 1)
|
@@ -174,7 +159,6 @@ module RGeo
|
|
174
159
|
assert(line1_.equals?(line2_))
|
175
160
|
end
|
176
161
|
|
177
|
-
|
178
162
|
def test_geometrically_equal_but_different_overlap
|
179
163
|
point1_ = @factory.point(0, 0)
|
180
164
|
point2_ = @factory.point(0, 1)
|
@@ -188,7 +172,6 @@ module RGeo
|
|
188
172
|
assert(line1_.equals?(line2_))
|
189
173
|
end
|
190
174
|
|
191
|
-
|
192
175
|
def test_empty_equal
|
193
176
|
line1_ = @factory.line_string([])
|
194
177
|
line2_ = @factory.line_string([])
|
@@ -196,7 +179,6 @@ module RGeo
|
|
196
179
|
assert(line1_.equals?(line2_))
|
197
180
|
end
|
198
181
|
|
199
|
-
|
200
182
|
def test_not_equal
|
201
183
|
point1_ = @factory.point(0, 0)
|
202
184
|
point2_ = @factory.point(0, 1)
|
@@ -209,7 +191,6 @@ module RGeo
|
|
209
191
|
assert(!line1_.equals?(line2_))
|
210
192
|
end
|
211
193
|
|
212
|
-
|
213
194
|
def test_hashes_equal_for_representationally_equivalent_objects
|
214
195
|
point1_ = @factory.point(0, 0)
|
215
196
|
point2_ = @factory.point(0, 1)
|
@@ -222,7 +203,6 @@ module RGeo
|
|
222
203
|
assert_equal(line1_.hash, line2_.hash)
|
223
204
|
end
|
224
205
|
|
225
|
-
|
226
206
|
def test_out_of_order_is_not_equal
|
227
207
|
point1_ = @factory.point(0, 0)
|
228
208
|
point2_ = @factory.point(0, 1)
|
@@ -234,13 +214,12 @@ module RGeo
|
|
234
214
|
assert_not_equal(line1_.hash, line2_.hash)
|
235
215
|
end
|
236
216
|
|
237
|
-
|
238
217
|
def test_wkt_creation
|
239
|
-
line1_ = @factory.parse_wkt(
|
218
|
+
line1_ = @factory.parse_wkt("LINESTRING(21 22, 11 12)")
|
240
219
|
assert_equal(@factory.point(21, 22), line1_.point_n(0))
|
241
220
|
assert_equal(@factory.point(11, 12), line1_.point_n(1))
|
242
221
|
assert_equal(2, line1_.num_points)
|
243
|
-
line2_ = @factory.parse_wkt(
|
222
|
+
line2_ = @factory.parse_wkt("LINESTRING(-1 -1, 21 22, 11 12, -1 -1)")
|
244
223
|
assert_equal(@factory.point(-1, -1), line2_.point_n(0))
|
245
224
|
assert_equal(@factory.point(21, 22), line2_.point_n(1))
|
246
225
|
assert_equal(@factory.point(11, 12), line2_.point_n(2))
|
@@ -248,7 +227,6 @@ module RGeo
|
|
248
227
|
assert_equal(4, line2_.num_points)
|
249
228
|
end
|
250
229
|
|
251
|
-
|
252
230
|
def test_clone
|
253
231
|
point1_ = @factory.point(0, 0)
|
254
232
|
point2_ = @factory.point(0, 1)
|
@@ -260,7 +238,6 @@ module RGeo
|
|
260
238
|
assert(point2_.eql?(line2_.point_n(1)))
|
261
239
|
end
|
262
240
|
|
263
|
-
|
264
241
|
def test_type_check
|
265
242
|
point1_ = @factory.point(0, 0)
|
266
243
|
point2_ = @factory.point(0, 1)
|
@@ -273,7 +250,6 @@ module RGeo
|
|
273
250
|
assert(!::RGeo::Feature::LinearRing.check_type(line_))
|
274
251
|
end
|
275
252
|
|
276
|
-
|
277
253
|
def test_as_text_wkt_round_trip
|
278
254
|
point1_ = @factory.point(0, 0)
|
279
255
|
point2_ = @factory.point(0, 1)
|
@@ -283,7 +259,6 @@ module RGeo
|
|
283
259
|
assert(line2_.eql?(line1_))
|
284
260
|
end
|
285
261
|
|
286
|
-
|
287
262
|
def test_as_binary_wkb_round_trip
|
288
263
|
point1_ = @factory.point(-42, 0)
|
289
264
|
point2_ = @factory.point(0, 193)
|
@@ -293,7 +268,6 @@ module RGeo
|
|
293
268
|
assert(line2_.eql?(line1_))
|
294
269
|
end
|
295
270
|
|
296
|
-
|
297
271
|
def test_empty_as_text_wkt_round_trip
|
298
272
|
line1_ = @factory.line_string([])
|
299
273
|
text_ = line1_.as_text
|
@@ -301,7 +275,6 @@ module RGeo
|
|
301
275
|
assert(line2_.is_empty?)
|
302
276
|
end
|
303
277
|
|
304
|
-
|
305
278
|
def test_empty_as_binary_wkb_round_trip
|
306
279
|
line1_ = @factory.line_string([])
|
307
280
|
binary_ = line1_.as_binary
|
@@ -309,7 +282,6 @@ module RGeo
|
|
309
282
|
assert(line2_.is_empty?)
|
310
283
|
end
|
311
284
|
|
312
|
-
|
313
285
|
def test_dimension
|
314
286
|
point1_ = @factory.point(-42, 0)
|
315
287
|
point2_ = @factory.point(0, 193)
|
@@ -317,7 +289,6 @@ module RGeo
|
|
317
289
|
assert_equal(1, line1_.dimension)
|
318
290
|
end
|
319
291
|
|
320
|
-
|
321
292
|
def test_is_empty
|
322
293
|
point1_ = @factory.point(-42, 0)
|
323
294
|
point2_ = @factory.point(0, 193)
|
@@ -327,7 +298,6 @@ module RGeo
|
|
327
298
|
assert(line2_.is_empty?)
|
328
299
|
end
|
329
300
|
|
330
|
-
|
331
301
|
def test_marshal_roundtrip
|
332
302
|
point1_ = @factory.point(0, 0)
|
333
303
|
point2_ = @factory.point(0, 1)
|
@@ -337,6 +307,10 @@ module RGeo
|
|
337
307
|
assert_equal(line1_, line2_)
|
338
308
|
end
|
339
309
|
|
310
|
+
def test_linestring_coordinates
|
311
|
+
line = @factory.line_string([@factory.point(0.0, 1.0), @factory.point(2.0, 3.0)])
|
312
|
+
assert_equal(line.coordinates, [[0.0, 1.0], [2.0, 3.0]])
|
313
|
+
end
|
340
314
|
|
341
315
|
if ::RGeo.yaml_supported?
|
342
316
|
|
@@ -350,10 +324,7 @@ module RGeo
|
|
350
324
|
end
|
351
325
|
|
352
326
|
end
|
353
|
-
|
354
|
-
|
355
327
|
end
|
356
|
-
|
357
328
|
end
|
358
329
|
end
|
359
330
|
end
|