rgeo 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.rdoc +6 -0
- data/README.rdoc +1 -1
- data/Version +1 -1
- data/ext/geos_c_impl/extconf.rb +13 -13
- data/ext/geos_c_impl/factory.c +30 -18
- data/ext/geos_c_impl/factory.h +18 -12
- data/ext/geos_c_impl/geometry.c +11 -11
- data/ext/geos_c_impl/geometry.h +7 -7
- data/ext/geos_c_impl/geometry_collection.c +15 -15
- data/ext/geos_c_impl/geometry_collection.h +8 -8
- data/ext/geos_c_impl/line_string.c +14 -14
- data/ext/geos_c_impl/line_string.h +7 -7
- data/ext/geos_c_impl/main.c +7 -7
- data/ext/geos_c_impl/point.c +9 -9
- data/ext/geos_c_impl/point.h +7 -7
- data/ext/geos_c_impl/polygon.c +9 -9
- data/ext/geos_c_impl/polygon.h +7 -7
- data/ext/geos_c_impl/preface.h +7 -7
- data/ext/proj4_c_impl/extconf.rb +13 -13
- data/ext/proj4_c_impl/main.c +12 -12
- data/lib/rgeo.rb +26 -26
- data/lib/rgeo/cartesian.rb +12 -12
- data/lib/rgeo/cartesian/analysis.rb +26 -26
- data/lib/rgeo/cartesian/bounding_box.rb +83 -83
- data/lib/rgeo/cartesian/calculations.rb +36 -36
- data/lib/rgeo/cartesian/factory.rb +78 -78
- data/lib/rgeo/cartesian/feature_classes.rb +74 -74
- data/lib/rgeo/cartesian/feature_methods.rb +34 -34
- data/lib/rgeo/cartesian/interface.rb +33 -33
- data/lib/rgeo/coord_sys.rb +15 -15
- data/lib/rgeo/coord_sys/cs/entities.rb +533 -534
- data/lib/rgeo/coord_sys/cs/factories.rb +69 -69
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +44 -44
- data/lib/rgeo/coord_sys/proj4.rb +85 -85
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/interface.rb +44 -44
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +31 -31
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +29 -29
- data/lib/rgeo/error.rb +17 -17
- data/lib/rgeo/feature.rb +15 -15
- data/lib/rgeo/feature/curve.rb +58 -58
- data/lib/rgeo/feature/factory.rb +84 -84
- data/lib/rgeo/feature/factory_generator.rb +32 -32
- data/lib/rgeo/feature/geometry.rb +215 -215
- data/lib/rgeo/feature/geometry_collection.rb +46 -46
- data/lib/rgeo/feature/line.rb +21 -21
- data/lib/rgeo/feature/line_string.rb +35 -35
- data/lib/rgeo/feature/linear_ring.rb +20 -20
- data/lib/rgeo/feature/mixins.rb +61 -61
- data/lib/rgeo/feature/multi_curve.rb +37 -37
- data/lib/rgeo/feature/multi_line_string.rb +20 -20
- data/lib/rgeo/feature/multi_point.rb +22 -22
- data/lib/rgeo/feature/multi_polygon.rb +28 -28
- data/lib/rgeo/feature/multi_surface.rb +39 -39
- data/lib/rgeo/feature/point.rb +42 -42
- data/lib/rgeo/feature/polygon.rb +50 -50
- data/lib/rgeo/feature/surface.rb +42 -42
- data/lib/rgeo/feature/types.rb +58 -58
- data/lib/rgeo/geographic.rb +14 -14
- data/lib/rgeo/geographic/factory.rb +87 -87
- data/lib/rgeo/geographic/interface.rb +55 -55
- data/lib/rgeo/geographic/proj4_projector.rb +35 -35
- data/lib/rgeo/geographic/projected_feature_classes.rb +95 -95
- data/lib/rgeo/geographic/projected_feature_methods.rb +81 -81
- data/lib/rgeo/geographic/projected_window.rb +103 -103
- data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -32
- data/lib/rgeo/geographic/spherical_feature_classes.rb +93 -93
- data/lib/rgeo/geographic/spherical_feature_methods.rb +25 -25
- data/lib/rgeo/geographic/spherical_math.rb +58 -58
- data/lib/rgeo/geos.rb +22 -17
- data/lib/rgeo/geos/factory.rb +93 -93
- data/lib/rgeo/geos/ffi_classes.rb +306 -231
- data/lib/rgeo/geos/ffi_factory.rb +100 -96
- data/lib/rgeo/geos/impl_additions.rb +22 -22
- data/lib/rgeo/geos/interface.rb +45 -45
- data/lib/rgeo/geos/zm_factory.rb +90 -90
- data/lib/rgeo/geos/zm_impl.rb +167 -167
- data/lib/rgeo/impl_helper.rb +11 -11
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +71 -71
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +29 -29
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +61 -61
- data/lib/rgeo/impl_helper/basic_point_methods.rb +43 -43
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +35 -35
- data/lib/rgeo/impl_helper/math.rb +13 -13
- data/lib/rgeo/version.rb +10 -10
- data/lib/rgeo/wkrep.rb +16 -16
- data/lib/rgeo/wkrep/wkb_generator.rb +51 -51
- data/lib/rgeo/wkrep/wkb_parser.rb +52 -52
- data/lib/rgeo/wkrep/wkt_generator.rb +51 -51
- data/lib/rgeo/wkrep/wkt_parser.rb +66 -66
- data/lib/rgeo/yaml.rb +14 -14
- data/test/common/geometry_collection_tests.rb +53 -53
- data/test/common/line_string_tests.rb +57 -57
- data/test/common/multi_line_string_tests.rb +43 -43
- data/test/common/multi_point_tests.rb +43 -43
- data/test/common/multi_polygon_tests.rb +43 -43
- data/test/common/point_tests.rb +75 -75
- data/test/common/polygon_tests.rb +37 -37
- data/test/coord_sys/tc_active_record_table.rb +25 -25
- data/test/coord_sys/tc_ogc_cs.rb +72 -72
- data/test/coord_sys/tc_proj4.rb +51 -51
- data/test/coord_sys/tc_proj4_srs_data.rb +17 -17
- data/test/coord_sys/tc_sr_org.rb +15 -15
- data/test/coord_sys/tc_url_reader.rb +19 -19
- data/test/geos_capi/tc_factory.rb +21 -21
- data/test/geos_capi/tc_geometry_collection.rb +15 -15
- data/test/geos_capi/tc_line_string.rb +15 -15
- data/test/geos_capi/tc_misc.rb +33 -22
- data/test/geos_capi/tc_multi_line_string.rb +15 -15
- data/test/geos_capi/tc_multi_point.rb +15 -15
- data/test/geos_capi/tc_multi_polygon.rb +15 -15
- data/test/geos_capi/tc_parsing_unparsing.rb +19 -19
- data/test/geos_capi/tc_point.rb +21 -21
- data/test/geos_capi/tc_polygon.rb +19 -19
- data/test/geos_capi/tc_zmfactory.rb +17 -17
- data/test/geos_ffi/tc_factory.rb +21 -21
- data/test/geos_ffi/tc_geometry_collection.rb +15 -15
- data/test/geos_ffi/tc_line_string.rb +15 -15
- data/test/geos_ffi/tc_misc.rb +49 -15
- data/test/geos_ffi/tc_multi_line_string.rb +15 -15
- data/test/geos_ffi/tc_multi_point.rb +15 -15
- data/test/geos_ffi/tc_multi_polygon.rb +15 -15
- data/test/geos_ffi/tc_parsing_unparsing.rb +19 -19
- data/test/geos_ffi/tc_point.rb +21 -21
- data/test/geos_ffi/tc_polygon.rb +19 -19
- data/test/geos_ffi/tc_zmfactory.rb +17 -17
- data/test/projected_geographic/tc_geometry_collection.rb +15 -15
- data/test/projected_geographic/tc_line_string.rb +15 -15
- data/test/projected_geographic/tc_multi_line_string.rb +15 -15
- data/test/projected_geographic/tc_multi_point.rb +15 -15
- data/test/projected_geographic/tc_multi_polygon.rb +15 -15
- data/test/projected_geographic/tc_point.rb +23 -23
- data/test/projected_geographic/tc_polygon.rb +15 -15
- data/test/simple_cartesian/tc_calculations.rb +31 -31
- data/test/simple_cartesian/tc_geometry_collection.rb +17 -17
- data/test/simple_cartesian/tc_line_string.rb +17 -17
- data/test/simple_cartesian/tc_multi_line_string.rb +17 -17
- data/test/simple_cartesian/tc_multi_point.rb +17 -17
- data/test/simple_cartesian/tc_multi_polygon.rb +17 -17
- data/test/simple_cartesian/tc_point.rb +21 -21
- data/test/simple_cartesian/tc_polygon.rb +17 -17
- data/test/simple_mercator/tc_geometry_collection.rb +15 -15
- data/test/simple_mercator/tc_line_string.rb +15 -15
- data/test/simple_mercator/tc_multi_line_string.rb +15 -15
- data/test/simple_mercator/tc_multi_point.rb +15 -15
- data/test/simple_mercator/tc_multi_polygon.rb +15 -15
- data/test/simple_mercator/tc_point.rb +23 -23
- data/test/simple_mercator/tc_polygon.rb +15 -15
- data/test/simple_mercator/tc_window.rb +50 -50
- data/test/spherical_geographic/tc_calculations.rb +47 -47
- data/test/spherical_geographic/tc_geometry_collection.rb +17 -17
- data/test/spherical_geographic/tc_line_string.rb +17 -17
- data/test/spherical_geographic/tc_multi_line_string.rb +17 -17
- data/test/spherical_geographic/tc_multi_point.rb +17 -17
- data/test/spherical_geographic/tc_multi_polygon.rb +17 -17
- data/test/spherical_geographic/tc_point.rb +23 -23
- data/test/spherical_geographic/tc_polygon.rb +17 -17
- data/test/tc_cartesian_analysis.rb +23 -23
- data/test/tc_mixins.rb +39 -39
- data/test/tc_oneoff.rb +15 -15
- data/test/tc_types.rb +17 -17
- data/test/wkrep/tc_wkb_generator.rb +67 -67
- data/test/wkrep/tc_wkb_parser.rb +73 -73
- data/test/wkrep/tc_wkt_generator.rb +75 -75
- data/test/wkrep/tc_wkt_parser.rb +97 -97
- metadata +3 -3
data/lib/rgeo/impl_helper.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Implementation helpers namespace for RGeo
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -35,12 +35,12 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module RGeo
|
38
|
-
|
39
|
-
|
38
|
+
|
39
|
+
|
40
40
|
module ImplHelper # :nodoc:
|
41
41
|
end
|
42
|
-
|
43
|
-
|
42
|
+
|
43
|
+
|
44
44
|
end
|
45
45
|
|
46
46
|
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Common methods for GeometryCollection features
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -35,13 +35,13 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module RGeo
|
38
|
-
|
38
|
+
|
39
39
|
module ImplHelper # :nodoc:
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
module BasicGeometryCollectionMethods # :nodoc:
|
43
|
-
|
44
|
-
|
43
|
+
|
44
|
+
|
45
45
|
def initialize(factory_, elements_)
|
46
46
|
_set_factory(factory_)
|
47
47
|
@elements = elements_.map do |elem_|
|
@@ -53,8 +53,8 @@ module RGeo
|
|
53
53
|
end
|
54
54
|
_validate_geometry
|
55
55
|
end
|
56
|
-
|
57
|
-
|
56
|
+
|
57
|
+
|
58
58
|
def eql?(rhs_)
|
59
59
|
if rhs_.is_a?(self.class) && rhs_.factory.eql?(@factory) && @elements.size == rhs_.num_geometries
|
60
60
|
rhs_.each_with_index{ |p_, i_| return false unless @elements[i_].eql?(p_) }
|
@@ -62,28 +62,28 @@ module RGeo
|
|
62
62
|
false
|
63
63
|
end
|
64
64
|
end
|
65
|
-
|
66
|
-
|
65
|
+
|
66
|
+
|
67
67
|
def num_geometries
|
68
68
|
@elements.size
|
69
69
|
end
|
70
|
-
|
71
|
-
|
70
|
+
|
71
|
+
|
72
72
|
def geometry_n(n_)
|
73
73
|
n_ < 0 ? nil : @elements[n_]
|
74
74
|
end
|
75
|
-
|
76
|
-
|
75
|
+
|
76
|
+
|
77
77
|
def [](n_)
|
78
78
|
@elements[n_]
|
79
79
|
end
|
80
|
-
|
81
|
-
|
80
|
+
|
81
|
+
|
82
82
|
def each(&block_)
|
83
83
|
@elements.each(&block_)
|
84
84
|
end
|
85
|
-
|
86
|
-
|
85
|
+
|
86
|
+
|
87
87
|
def dimension
|
88
88
|
unless @dimension
|
89
89
|
@dimension = -1
|
@@ -94,24 +94,24 @@ module RGeo
|
|
94
94
|
end
|
95
95
|
@dimension
|
96
96
|
end
|
97
|
-
|
98
|
-
|
97
|
+
|
98
|
+
|
99
99
|
def geometry_type
|
100
100
|
Feature::GeometryCollection
|
101
101
|
end
|
102
|
-
|
103
|
-
|
102
|
+
|
103
|
+
|
104
104
|
def is_empty?
|
105
105
|
@elements.size == 0
|
106
106
|
end
|
107
|
-
|
108
|
-
|
107
|
+
|
108
|
+
|
109
109
|
end
|
110
|
-
|
111
|
-
|
110
|
+
|
111
|
+
|
112
112
|
module BasicMultiLineStringMethods # :nodoc:
|
113
|
-
|
114
|
-
|
113
|
+
|
114
|
+
|
115
115
|
def initialize(factory_, elements_)
|
116
116
|
_set_factory(factory_)
|
117
117
|
@elements = elements_.map do |elem_|
|
@@ -123,29 +123,29 @@ module RGeo
|
|
123
123
|
end
|
124
124
|
_validate_geometry
|
125
125
|
end
|
126
|
-
|
127
|
-
|
126
|
+
|
127
|
+
|
128
128
|
def geometry_type
|
129
129
|
Feature::MultiLineString
|
130
130
|
end
|
131
|
-
|
132
|
-
|
131
|
+
|
132
|
+
|
133
133
|
def is_closed?
|
134
134
|
all?{ |elem_| elem_.is_closed? }
|
135
135
|
end
|
136
|
-
|
137
|
-
|
136
|
+
|
137
|
+
|
138
138
|
def length
|
139
139
|
@elements.inject(0.0){ |sum_, obj_| sum_ + obj_.length }
|
140
140
|
end
|
141
|
-
|
142
|
-
|
141
|
+
|
142
|
+
|
143
143
|
def _add_boundary(hash_, point_) # :nodoc:
|
144
144
|
hval_ = [point_.x, point_.y].hash
|
145
145
|
(hash_[hval_] ||= [point_, 0])[1] += 1
|
146
146
|
end
|
147
|
-
|
148
|
-
|
147
|
+
|
148
|
+
|
149
149
|
def boundary
|
150
150
|
hash_ = {}
|
151
151
|
@elements.each do |line_|
|
@@ -160,14 +160,14 @@ module RGeo
|
|
160
160
|
end
|
161
161
|
factory.multi_point([array_])
|
162
162
|
end
|
163
|
-
|
164
|
-
|
163
|
+
|
164
|
+
|
165
165
|
end
|
166
|
-
|
167
|
-
|
166
|
+
|
167
|
+
|
168
168
|
module BasicMultiPointMethods # :nodoc:
|
169
|
-
|
170
|
-
|
169
|
+
|
170
|
+
|
171
171
|
def initialize(factory_, elements_)
|
172
172
|
_set_factory(factory_)
|
173
173
|
@elements = elements_.map do |elem_|
|
@@ -179,24 +179,24 @@ module RGeo
|
|
179
179
|
end
|
180
180
|
_validate_geometry
|
181
181
|
end
|
182
|
-
|
183
|
-
|
182
|
+
|
183
|
+
|
184
184
|
def geometry_type
|
185
185
|
Feature::MultiPoint
|
186
186
|
end
|
187
|
-
|
188
|
-
|
187
|
+
|
188
|
+
|
189
189
|
def boundary
|
190
190
|
factory.collection([])
|
191
191
|
end
|
192
|
-
|
193
|
-
|
192
|
+
|
193
|
+
|
194
194
|
end
|
195
|
-
|
196
|
-
|
195
|
+
|
196
|
+
|
197
197
|
module BasicMultiPolygonMethods # :nodoc:
|
198
|
-
|
199
|
-
|
198
|
+
|
199
|
+
|
200
200
|
def initialize(factory_, elements_)
|
201
201
|
_set_factory(factory_)
|
202
202
|
@elements = elements_.map do |elem_|
|
@@ -208,18 +208,18 @@ module RGeo
|
|
208
208
|
end
|
209
209
|
_validate_geometry
|
210
210
|
end
|
211
|
-
|
212
|
-
|
211
|
+
|
212
|
+
|
213
213
|
def geometry_type
|
214
214
|
Feature::MultiPolygon
|
215
215
|
end
|
216
|
-
|
217
|
-
|
216
|
+
|
217
|
+
|
218
218
|
def area
|
219
219
|
@elements.inject(0.0){ |sum_, obj_| sum_ + obj_.area }
|
220
220
|
end
|
221
|
-
|
222
|
-
|
221
|
+
|
222
|
+
|
223
223
|
def boundary
|
224
224
|
array_ = []
|
225
225
|
@elements.each do |poly_|
|
@@ -230,11 +230,11 @@ module RGeo
|
|
230
230
|
end
|
231
231
|
factory.multi_line_string(array_)
|
232
232
|
end
|
233
|
-
|
234
|
-
|
233
|
+
|
234
|
+
|
235
235
|
end
|
236
|
-
|
237
|
-
|
236
|
+
|
237
|
+
|
238
238
|
end
|
239
|
-
|
239
|
+
|
240
240
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Basic methods used by geometry objects
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -35,51 +35,51 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module RGeo
|
38
|
-
|
38
|
+
|
39
39
|
module ImplHelper # :nodoc:
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
module BasicGeometryMethods # :nodoc:
|
43
|
-
|
43
|
+
|
44
44
|
include Feature::Instance
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
|
47
47
|
def inspect # :nodoc:
|
48
48
|
"#<#{self.class}:0x#{object_id.to_s(16)} #{as_text.inspect}>"
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
def to_s # :nodoc:
|
52
52
|
as_text
|
53
53
|
end
|
54
|
-
|
55
|
-
|
54
|
+
|
55
|
+
|
56
56
|
def _validate_geometry # :nodoc:
|
57
57
|
end
|
58
|
-
|
59
|
-
|
58
|
+
|
59
|
+
|
60
60
|
def _set_factory(factory_) # :nodoc:
|
61
61
|
@factory = factory_
|
62
62
|
end
|
63
|
-
|
64
|
-
|
63
|
+
|
64
|
+
|
65
65
|
def factory
|
66
66
|
@factory
|
67
67
|
end
|
68
|
-
|
69
|
-
|
68
|
+
|
69
|
+
|
70
70
|
def as_text
|
71
71
|
@factory.instance_variable_get(:@wkt_generator).generate(self)
|
72
72
|
end
|
73
|
-
|
74
|
-
|
73
|
+
|
74
|
+
|
75
75
|
def as_binary
|
76
76
|
@factory.instance_variable_get(:@wkb_generator).generate(self)
|
77
77
|
end
|
78
|
-
|
79
|
-
|
78
|
+
|
79
|
+
|
80
80
|
end
|
81
|
-
|
82
|
-
|
81
|
+
|
82
|
+
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
# -----------------------------------------------------------------------------
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Common methods for LineString features
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# -----------------------------------------------------------------------------
|
6
|
-
# Copyright 2010 Daniel Azuma
|
7
|
-
#
|
6
|
+
# Copyright 2010-2012 Daniel Azuma
|
7
|
+
#
|
8
8
|
# All rights reserved.
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# Redistribution and use in source and binary forms, with or without
|
11
11
|
# modification, are permitted provided that the following conditions are met:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# * Redistributions of source code must retain the above copyright notice,
|
14
14
|
# this list of conditions and the following disclaimer.
|
15
15
|
# * Redistributions in binary form must reproduce the above copyright notice,
|
@@ -18,7 +18,7 @@
|
|
18
18
|
# * Neither the name of the copyright holder, nor the names of any other
|
19
19
|
# contributors to this software, may be used to endorse or promote products
|
20
20
|
# derived from this software without specific prior written permission.
|
21
|
-
#
|
21
|
+
#
|
22
22
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
23
23
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
24
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -35,13 +35,13 @@
|
|
35
35
|
|
36
36
|
|
37
37
|
module RGeo
|
38
|
-
|
38
|
+
|
39
39
|
module ImplHelper # :nodoc:
|
40
|
-
|
41
|
-
|
40
|
+
|
41
|
+
|
42
42
|
module BasicLineStringMethods # :nodoc:
|
43
|
-
|
44
|
-
|
43
|
+
|
44
|
+
|
45
45
|
def initialize(factory_, points_)
|
46
46
|
_set_factory(factory_)
|
47
47
|
@points = points_.map do |elem_|
|
@@ -53,15 +53,15 @@ module RGeo
|
|
53
53
|
end
|
54
54
|
_validate_geometry
|
55
55
|
end
|
56
|
-
|
57
|
-
|
56
|
+
|
57
|
+
|
58
58
|
def _validate_geometry
|
59
59
|
if @points.size == 1
|
60
60
|
raise Error::InvalidGeometry, 'LineString cannot have 1 point'
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
64
|
-
|
63
|
+
|
64
|
+
|
65
65
|
def eql?(rhs_)
|
66
66
|
if rhs_.is_a?(self.class) && rhs_.factory.eql?(@factory) && @points.size == rhs_.num_points
|
67
67
|
rhs_.points.each_with_index{ |p_, i_| return false unless @points[i_].eql?(p_) }
|
@@ -69,38 +69,38 @@ module RGeo
|
|
69
69
|
false
|
70
70
|
end
|
71
71
|
end
|
72
|
-
|
73
|
-
|
72
|
+
|
73
|
+
|
74
74
|
def num_points
|
75
75
|
@points.size
|
76
76
|
end
|
77
|
-
|
78
|
-
|
77
|
+
|
78
|
+
|
79
79
|
def point_n(n_)
|
80
80
|
n_ < 0 ? nil : @points[n_]
|
81
81
|
end
|
82
|
-
|
83
|
-
|
82
|
+
|
83
|
+
|
84
84
|
def points
|
85
85
|
@points.dup
|
86
86
|
end
|
87
|
-
|
88
|
-
|
87
|
+
|
88
|
+
|
89
89
|
def dimension
|
90
90
|
1
|
91
91
|
end
|
92
|
-
|
93
|
-
|
92
|
+
|
93
|
+
|
94
94
|
def geometry_type
|
95
95
|
Feature::LineString
|
96
96
|
end
|
97
|
-
|
98
|
-
|
97
|
+
|
98
|
+
|
99
99
|
def is_empty?
|
100
100
|
@points.size == 0
|
101
101
|
end
|
102
|
-
|
103
|
-
|
102
|
+
|
103
|
+
|
104
104
|
def boundary
|
105
105
|
array_ = []
|
106
106
|
if !is_empty? && !is_closed?
|
@@ -108,37 +108,37 @@ module RGeo
|
|
108
108
|
end
|
109
109
|
factory.multi_point([array_])
|
110
110
|
end
|
111
|
-
|
112
|
-
|
111
|
+
|
112
|
+
|
113
113
|
def start_point
|
114
114
|
@points.first
|
115
115
|
end
|
116
|
-
|
117
|
-
|
116
|
+
|
117
|
+
|
118
118
|
def end_point
|
119
119
|
@points.last
|
120
120
|
end
|
121
|
-
|
122
|
-
|
121
|
+
|
122
|
+
|
123
123
|
def is_closed?
|
124
124
|
unless defined?(@is_closed)
|
125
125
|
@is_closed = @points.size > 2 && @points.first == @points.last
|
126
126
|
end
|
127
127
|
@is_closed
|
128
128
|
end
|
129
|
-
|
130
|
-
|
129
|
+
|
130
|
+
|
131
131
|
def is_ring?
|
132
132
|
is_closed? && is_simple?
|
133
133
|
end
|
134
|
-
|
135
|
-
|
134
|
+
|
135
|
+
|
136
136
|
end
|
137
|
-
|
138
|
-
|
137
|
+
|
138
|
+
|
139
139
|
module BasicLineMethods # :nodoc:
|
140
|
-
|
141
|
-
|
140
|
+
|
141
|
+
|
142
142
|
def initialize(factory_, start_, end_)
|
143
143
|
_set_factory(factory_)
|
144
144
|
cstart_ = Feature.cast(start_, factory_, Feature::Point)
|
@@ -152,27 +152,27 @@ module RGeo
|
|
152
152
|
@points = [cstart_, cend_]
|
153
153
|
_validate_geometry
|
154
154
|
end
|
155
|
-
|
156
|
-
|
155
|
+
|
156
|
+
|
157
157
|
def _validate_geometry # :nodoc:
|
158
158
|
super
|
159
159
|
if @points.size > 2
|
160
160
|
raise Error::InvalidGeometry, 'Line must have 0 or 2 points'
|
161
161
|
end
|
162
162
|
end
|
163
|
-
|
164
|
-
|
163
|
+
|
164
|
+
|
165
165
|
def geometry_type
|
166
166
|
Feature::Line
|
167
167
|
end
|
168
|
-
|
169
|
-
|
168
|
+
|
169
|
+
|
170
170
|
end
|
171
|
-
|
172
|
-
|
171
|
+
|
172
|
+
|
173
173
|
module BasicLinearRingMethods # :nodoc:
|
174
|
-
|
175
|
-
|
174
|
+
|
175
|
+
|
176
176
|
def _validate_geometry # :nodoc:
|
177
177
|
super
|
178
178
|
if @points.size > 0
|
@@ -182,16 +182,16 @@ module RGeo
|
|
182
182
|
end
|
183
183
|
end
|
184
184
|
end
|
185
|
-
|
186
|
-
|
185
|
+
|
186
|
+
|
187
187
|
def geometry_type
|
188
188
|
Feature::LinearRing
|
189
189
|
end
|
190
|
-
|
191
|
-
|
190
|
+
|
191
|
+
|
192
192
|
end
|
193
|
-
|
194
|
-
|
193
|
+
|
194
|
+
|
195
195
|
end
|
196
|
-
|
196
|
+
|
197
197
|
end
|