rgeo 2.1.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +160 -0
- data/ext/geos_c_impl/analysis.c +78 -0
- data/ext/geos_c_impl/analysis.h +42 -0
- data/ext/geos_c_impl/errors.c +35 -0
- data/ext/geos_c_impl/errors.h +22 -0
- data/ext/geos_c_impl/extconf.rb +1 -0
- data/ext/geos_c_impl/factory.c +15 -7
- data/ext/geos_c_impl/factory.h +5 -1
- data/ext/geos_c_impl/geometry.c +9 -8
- data/ext/geos_c_impl/geometry_collection.c +1 -1
- data/ext/geos_c_impl/line_string.c +2 -2
- data/ext/geos_c_impl/main.c +5 -2
- data/ext/geos_c_impl/preface.h +3 -0
- data/lib/rgeo/cartesian/analysis.rb +22 -0
- data/lib/rgeo/cartesian/feature_methods.rb +6 -1
- data/lib/rgeo/cartesian.rb +7 -7
- data/lib/rgeo/coord_sys.rb +6 -6
- data/lib/rgeo/error.rb +4 -0
- data/lib/rgeo/feature/curve.rb +12 -2
- data/lib/rgeo/feature/geometry.rb +12 -2
- data/lib/rgeo/feature/linear_ring.rb +10 -0
- data/lib/rgeo/feature/multi_curve.rb +6 -1
- data/lib/rgeo/feature.rb +17 -17
- data/lib/rgeo/geographic/interface.rb +2 -1
- data/lib/rgeo/geographic/projected_feature_methods.rb +12 -2
- data/lib/rgeo/geographic/spherical_feature_classes.rb +1 -0
- data/lib/rgeo/geographic/spherical_feature_methods.rb +29 -1
- data/lib/rgeo/geographic.rb +10 -10
- data/lib/rgeo/geos/capi_factory.rb +5 -1
- data/lib/rgeo/geos/capi_feature_classes.rb +33 -0
- data/lib/rgeo/geos/ffi_feature_methods.rb +34 -5
- data/lib/rgeo/geos/interface.rb +18 -4
- data/lib/rgeo/geos/zm_feature_methods.rb +30 -5
- data/lib/rgeo/geos.rb +11 -11
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +33 -5
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +62 -8
- data/lib/rgeo/impl_helper/basic_point_methods.rb +12 -2
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +45 -3
- data/lib/rgeo/impl_helper.rb +7 -7
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep/wkb_generator.rb +1 -1
- data/lib/rgeo/wkrep/wkt_generator.rb +6 -6
- data/lib/rgeo/wkrep.rb +4 -4
- data/lib/rgeo.rb +9 -9
- metadata +21 -11
@@ -39,13 +39,18 @@ module RGeo
|
|
39
39
|
Feature::LineString
|
40
40
|
end
|
41
41
|
|
42
|
-
def
|
42
|
+
def empty?
|
43
43
|
@points.size == 0
|
44
44
|
end
|
45
45
|
|
46
|
+
def is_empty?
|
47
|
+
warn "The is_empty? method is deprecated, please use the empty? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
48
|
+
empty?
|
49
|
+
end
|
50
|
+
|
46
51
|
def boundary
|
47
52
|
array = []
|
48
|
-
array << @points.first << @points.last if !
|
53
|
+
array << @points.first << @points.last if !empty? && !closed?
|
49
54
|
factory.multipoint([array])
|
50
55
|
end
|
51
56
|
|
@@ -57,15 +62,25 @@ module RGeo
|
|
57
62
|
@points.last
|
58
63
|
end
|
59
64
|
|
60
|
-
def
|
61
|
-
unless defined?(@
|
62
|
-
@
|
65
|
+
def closed?
|
66
|
+
unless defined?(@closed)
|
67
|
+
@closed = @points.size > 2 && @points.first == @points.last
|
63
68
|
end
|
64
|
-
@
|
69
|
+
@closed
|
70
|
+
end
|
71
|
+
|
72
|
+
def is_closed?
|
73
|
+
warn "The is_closed? method is deprecated, please use the closed? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
74
|
+
closed?
|
75
|
+
end
|
76
|
+
|
77
|
+
def ring?
|
78
|
+
closed? && simple?
|
65
79
|
end
|
66
80
|
|
67
81
|
def is_ring?
|
68
|
-
|
82
|
+
warn "The is_ring? method is deprecated, please use the ring? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
83
|
+
ring?
|
69
84
|
end
|
70
85
|
|
71
86
|
def rep_equals?(rhs)
|
@@ -87,8 +102,43 @@ module RGeo
|
|
87
102
|
@points.map(&:coordinates)
|
88
103
|
end
|
89
104
|
|
105
|
+
def contains?(rhs)
|
106
|
+
if Feature::Point === rhs
|
107
|
+
contains_point?(rhs)
|
108
|
+
else
|
109
|
+
raise(Error::UnsupportedOperation,
|
110
|
+
"Method LineString#contains? is only defined for Point")
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
90
114
|
private
|
91
115
|
|
116
|
+
def contains_point?(point)
|
117
|
+
@points.each_cons(2) do |start_point, end_point|
|
118
|
+
return true if point_intersect_segment?(point, start_point, end_point)
|
119
|
+
end
|
120
|
+
false
|
121
|
+
end
|
122
|
+
|
123
|
+
def point_intersect_segment?(point, start_point, end_point)
|
124
|
+
return false unless point_collinear?(point, start_point, end_point)
|
125
|
+
|
126
|
+
if start_point.x != end_point.x
|
127
|
+
between_coordinate?(point.x, start_point.x, end_point.x)
|
128
|
+
else
|
129
|
+
between_coordinate?(point.y, start_point.y, end_point.y)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def point_collinear?(a, b, c)
|
134
|
+
(b.x - a.x) * (c.y - a.y) == (c.x - a.x) * (b.y - a.y)
|
135
|
+
end
|
136
|
+
|
137
|
+
def between_coordinate?(coord, start_coord, end_coord)
|
138
|
+
end_coord >= coord && coord >= start_coord ||
|
139
|
+
start_coord >= coord && coord >= end_coord
|
140
|
+
end
|
141
|
+
|
92
142
|
def copy_state_from(obj)
|
93
143
|
super
|
94
144
|
@points = obj.points
|
@@ -137,6 +187,10 @@ module RGeo
|
|
137
187
|
Feature::LinearRing
|
138
188
|
end
|
139
189
|
|
190
|
+
def ccw?
|
191
|
+
RGeo::Cartesian::Analysis.ccw?(self)
|
192
|
+
end
|
193
|
+
|
140
194
|
private
|
141
195
|
|
142
196
|
def validate_geometry
|
@@ -144,7 +198,7 @@ module RGeo
|
|
144
198
|
if @points.size > 0
|
145
199
|
@points << @points.first if @points.first != @points.last
|
146
200
|
@points = @points.chunk { |x| x }.map(&:first)
|
147
|
-
if !@factory.property(:uses_lenient_assertions) && !
|
201
|
+
if !@factory.property(:uses_lenient_assertions) && !ring?
|
148
202
|
raise Error::InvalidGeometry, "LinearRing failed ring test"
|
149
203
|
end
|
150
204
|
end
|
@@ -45,14 +45,24 @@ module RGeo
|
|
45
45
|
Feature::Point
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
48
|
+
def empty?
|
49
49
|
false
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
52
|
+
def is_empty?
|
53
|
+
warn "The is_empty? method is deprecated, please use the empty? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
54
|
+
empty?
|
55
|
+
end
|
56
|
+
|
57
|
+
def simple?
|
53
58
|
true
|
54
59
|
end
|
55
60
|
|
61
|
+
def is_simple?
|
62
|
+
warn "The is_simple? method is deprecated, please use the simple? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
63
|
+
simple?
|
64
|
+
end
|
65
|
+
|
56
66
|
def envelope
|
57
67
|
self
|
58
68
|
end
|
@@ -49,15 +49,20 @@ module RGeo
|
|
49
49
|
Feature::Polygon
|
50
50
|
end
|
51
51
|
|
52
|
+
def empty?
|
53
|
+
@exterior_ring.empty?
|
54
|
+
end
|
55
|
+
|
52
56
|
def is_empty?
|
53
|
-
|
57
|
+
warn "The is_empty? method is deprecated, please use the empty? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
58
|
+
empty?
|
54
59
|
end
|
55
60
|
|
56
61
|
def boundary
|
57
62
|
array = []
|
58
|
-
array << @exterior_ring unless @exterior_ring.
|
63
|
+
array << @exterior_ring unless @exterior_ring.empty?
|
59
64
|
array.concat(@interior_rings)
|
60
|
-
factory.
|
65
|
+
factory.multi_line_string(array)
|
61
66
|
end
|
62
67
|
|
63
68
|
def rep_equals?(rhs)
|
@@ -79,8 +84,45 @@ module RGeo
|
|
79
84
|
([@exterior_ring] + @interior_rings).map(&:coordinates)
|
80
85
|
end
|
81
86
|
|
87
|
+
def contains?(rhs)
|
88
|
+
if Feature::Point === rhs
|
89
|
+
contains_point?(rhs)
|
90
|
+
else
|
91
|
+
raise(Error::UnsupportedOperation,
|
92
|
+
"Method Polygon#contains? is only defined for Point"
|
93
|
+
)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
82
97
|
private
|
83
98
|
|
99
|
+
def contains_point?(point)
|
100
|
+
ring_encloses_point?(@exterior_ring, point) &&
|
101
|
+
!@interior_rings.any? do |exclusion|
|
102
|
+
ring_encloses_point?(exclusion, point, on_border_return: true)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def ring_encloses_point?(ring, point, on_border_return: false)
|
107
|
+
# This is an implementation of the ray casting algorithm, greatly inspired
|
108
|
+
# by https://wrf.ecse.rpi.edu/Research/Short_Notes/pnpoly.html
|
109
|
+
# Since this algorithm does not handle point on edge, we check first if
|
110
|
+
# the ring is on the border.
|
111
|
+
# on_border_return is used for exclusion ring
|
112
|
+
return on_border_return if ring.contains?(point)
|
113
|
+
encloses_point = false
|
114
|
+
ring.points.each_cons(2) do |start_point, end_point|
|
115
|
+
next unless (point.y < end_point.y) != (point.y < start_point.y)
|
116
|
+
|
117
|
+
if point.x < (end_point.x - start_point.x) * (point.y - start_point.y) /
|
118
|
+
(end_point.y - start_point.y) + start_point.x
|
119
|
+
encloses_point = !encloses_point
|
120
|
+
end
|
121
|
+
end
|
122
|
+
encloses_point
|
123
|
+
end
|
124
|
+
|
125
|
+
|
84
126
|
def copy_state_from(obj)
|
85
127
|
super
|
86
128
|
@exterior_ring = obj.exterior_ring
|
data/lib/rgeo/impl_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
require_relative "impl_helper/utils"
|
4
|
+
require_relative "impl_helper/math"
|
5
|
+
require_relative "impl_helper/basic_geometry_methods"
|
6
|
+
require_relative "impl_helper/basic_geometry_collection_methods"
|
7
|
+
require_relative "impl_helper/basic_point_methods"
|
8
|
+
require_relative "impl_helper/basic_line_string_methods"
|
9
|
+
require_relative "impl_helper/basic_polygon_methods"
|
data/lib/rgeo/version.rb
CHANGED
@@ -160,7 +160,7 @@ module RGeo
|
|
160
160
|
end
|
161
161
|
|
162
162
|
def generate_line_string(obj)
|
163
|
-
if obj.
|
163
|
+
if obj.empty?
|
164
164
|
"EMPTY"
|
165
165
|
else
|
166
166
|
"#{@begin_bracket}#{obj.points.map { |p| generate_coords(p) }.join(', ')}#{@end_bracket}"
|
@@ -168,7 +168,7 @@ module RGeo
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def generate_polygon(obj)
|
171
|
-
if obj.
|
171
|
+
if obj.empty?
|
172
172
|
"EMPTY"
|
173
173
|
else
|
174
174
|
"#{@begin_bracket}#{([generate_line_string(obj.exterior_ring)] + obj.interior_rings.map { |r| generate_line_string(r) }).join(', ')}#{@end_bracket}"
|
@@ -176,7 +176,7 @@ module RGeo
|
|
176
176
|
end
|
177
177
|
|
178
178
|
def generate_geometry_collection(obj)
|
179
|
-
if obj.
|
179
|
+
if obj.empty?
|
180
180
|
"EMPTY"
|
181
181
|
else
|
182
182
|
"#{@begin_bracket}#{obj.map { |f| generate_feature(f) }.join(', ')}#{@end_bracket}"
|
@@ -184,7 +184,7 @@ module RGeo
|
|
184
184
|
end
|
185
185
|
|
186
186
|
def generate_multi_point(obj)
|
187
|
-
if obj.
|
187
|
+
if obj.empty?
|
188
188
|
"EMPTY"
|
189
189
|
else
|
190
190
|
"#{@begin_bracket}#{obj.map { |f| generate_point(f) }.join(', ')}#{@end_bracket}"
|
@@ -192,7 +192,7 @@ module RGeo
|
|
192
192
|
end
|
193
193
|
|
194
194
|
def generate_multi_line_string(obj)
|
195
|
-
if obj.
|
195
|
+
if obj.empty?
|
196
196
|
"EMPTY"
|
197
197
|
else
|
198
198
|
"#{@begin_bracket}#{obj.map { |f| generate_line_string(f) }.join(', ')}#{@end_bracket}"
|
@@ -200,7 +200,7 @@ module RGeo
|
|
200
200
|
end
|
201
201
|
|
202
202
|
def generate_multi_polygon(obj)
|
203
|
-
if obj.
|
203
|
+
if obj.empty?
|
204
204
|
"EMPTY"
|
205
205
|
else
|
206
206
|
"#{@begin_bracket}#{obj.map { |f| generate_polygon(f) }.join(', ')}#{@end_bracket}"
|
data/lib/rgeo/wkrep.rb
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
# To parse a byte string in WKB (well-known binary) format back into a
|
22
22
|
# geometry object, use the WKRep::WKBParser class.
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
require_relative "wkrep/wkt_parser"
|
25
|
+
require_relative "wkrep/wkt_generator"
|
26
|
+
require_relative "wkrep/wkb_parser"
|
27
|
+
require_relative "wkrep/wkb_generator"
|
data/lib/rgeo.rb
CHANGED
@@ -75,12 +75,12 @@
|
|
75
75
|
# database, and based on the postgresql adapter. Available as the
|
76
76
|
# activerecord-postgis-adapter gem.
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
78
|
+
require_relative "rgeo/version"
|
79
|
+
require_relative "rgeo/error"
|
80
|
+
require_relative "rgeo/feature"
|
81
|
+
require_relative "rgeo/coord_sys"
|
82
|
+
require_relative "rgeo/impl_helper"
|
83
|
+
require_relative "rgeo/wkrep"
|
84
|
+
require_relative "rgeo/geos"
|
85
|
+
require_relative "rgeo/cartesian"
|
86
|
+
require_relative "rgeo/geographic"
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgeo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1
|
4
|
+
version: 2.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Daniel Azuma
|
7
|
+
- Daniel Azuma
|
8
|
+
- Tee Parham
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2021-11-30 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: ffi-geos
|
@@ -44,14 +45,14 @@ dependencies:
|
|
44
45
|
requirements:
|
45
46
|
- - "~>"
|
46
47
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
48
|
+
version: '13.0'
|
48
49
|
type: :development
|
49
50
|
prerelease: false
|
50
51
|
version_requirements: !ruby/object:Gem::Requirement
|
51
52
|
requirements:
|
52
53
|
- - "~>"
|
53
54
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
55
|
+
version: '13.0'
|
55
56
|
- !ruby/object:Gem::Dependency
|
56
57
|
name: rake-compiler
|
57
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +73,36 @@ dependencies:
|
|
72
73
|
requirements:
|
73
74
|
- - "~>"
|
74
75
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
76
|
+
version: 1.8.1
|
76
77
|
type: :development
|
77
78
|
prerelease: false
|
78
79
|
version_requirements: !ruby/object:Gem::Requirement
|
79
80
|
requirements:
|
80
81
|
- - "~>"
|
81
82
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
83
|
+
version: 1.8.1
|
83
84
|
description: RGeo is a geospatial data library for Ruby. It provides an implementation
|
84
85
|
of the Open Geospatial Consortium's Simple Features Specification, used by most
|
85
86
|
standard spatial/geographic data storage systems such as PostGIS. A number of add-on
|
86
87
|
modules are also available to help with writing location-based applications using
|
87
88
|
Ruby-based frameworks such as Ruby On Rails.
|
88
|
-
email:
|
89
|
+
email:
|
90
|
+
- dazuma@gmail.com
|
91
|
+
- parhameter@gmail.com
|
92
|
+
- kfdoggett@gmail.com
|
89
93
|
executables: []
|
90
94
|
extensions:
|
91
95
|
- ext/geos_c_impl/extconf.rb
|
92
96
|
extra_rdoc_files: []
|
93
97
|
files:
|
94
98
|
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- ext/geos_c_impl/analysis.c
|
101
|
+
- ext/geos_c_impl/analysis.h
|
95
102
|
- ext/geos_c_impl/coordinates.c
|
96
103
|
- ext/geos_c_impl/coordinates.h
|
104
|
+
- ext/geos_c_impl/errors.c
|
105
|
+
- ext/geos_c_impl/errors.h
|
97
106
|
- ext/geos_c_impl/extconf.rb
|
98
107
|
- ext/geos_c_impl/factory.c
|
99
108
|
- ext/geos_c_impl/factory.h
|
@@ -181,7 +190,8 @@ files:
|
|
181
190
|
- lib/rgeo/wkrep/wkt_generator.rb
|
182
191
|
- lib/rgeo/wkrep/wkt_parser.rb
|
183
192
|
homepage: https://github.com/rgeo/rgeo
|
184
|
-
licenses:
|
193
|
+
licenses:
|
194
|
+
- BSD-3-Clause
|
185
195
|
metadata: {}
|
186
196
|
post_install_message:
|
187
197
|
rdoc_options: []
|
@@ -191,14 +201,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
191
201
|
requirements:
|
192
202
|
- - ">="
|
193
203
|
- !ruby/object:Gem::Version
|
194
|
-
version: 2.
|
204
|
+
version: 2.5.0
|
195
205
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
196
206
|
requirements:
|
197
207
|
- - ">="
|
198
208
|
- !ruby/object:Gem::Version
|
199
209
|
version: '0'
|
200
210
|
requirements: []
|
201
|
-
rubygems_version: 3.
|
211
|
+
rubygems_version: 3.1.4
|
202
212
|
signing_key:
|
203
213
|
specification_version: 4
|
204
214
|
summary: RGeo is a geospatial data library for Ruby.
|