rgeo 2.3.1 → 3.0.1
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.
- checksums.yaml +4 -4
- data/.yardopts +6 -0
- data/README.md +23 -14
- data/ext/geos_c_impl/analysis.c +30 -25
- data/ext/geos_c_impl/analysis.h +8 -7
- data/ext/geos_c_impl/coordinates.c +27 -21
- data/ext/geos_c_impl/coordinates.h +5 -2
- data/ext/geos_c_impl/errors.c +19 -10
- data/ext/geos_c_impl/errors.h +11 -4
- data/ext/geos_c_impl/extconf.rb +42 -28
- data/ext/geos_c_impl/factory.c +540 -451
- data/ext/geos_c_impl/factory.h +105 -95
- data/ext/geos_c_impl/geometry.c +593 -387
- data/ext/geos_c_impl/geometry.h +10 -5
- data/ext/geos_c_impl/geometry_collection.c +306 -339
- data/ext/geos_c_impl/geometry_collection.h +6 -20
- data/ext/geos_c_impl/globals.c +169 -0
- data/ext/geos_c_impl/globals.h +46 -0
- data/ext/geos_c_impl/line_string.c +271 -231
- data/ext/geos_c_impl/line_string.h +5 -8
- data/ext/geos_c_impl/main.c +16 -16
- data/ext/geos_c_impl/point.c +65 -67
- data/ext/geos_c_impl/point.h +4 -7
- data/ext/geos_c_impl/polygon.c +137 -135
- data/ext/geos_c_impl/polygon.h +11 -11
- data/ext/geos_c_impl/preface.h +16 -10
- data/ext/geos_c_impl/ruby_more.c +67 -0
- data/ext/geos_c_impl/ruby_more.h +25 -0
- data/lib/rgeo/cartesian/analysis.rb +5 -3
- data/lib/rgeo/cartesian/bounding_box.rb +74 -79
- data/lib/rgeo/cartesian/calculations.rb +64 -33
- data/lib/rgeo/cartesian/factory.rb +57 -102
- data/lib/rgeo/cartesian/feature_classes.rb +68 -46
- data/lib/rgeo/cartesian/feature_methods.rb +67 -25
- data/lib/rgeo/cartesian/interface.rb +6 -41
- data/lib/rgeo/cartesian/planar_graph.rb +373 -0
- data/lib/rgeo/cartesian/sweepline_intersector.rb +147 -0
- data/lib/rgeo/cartesian/valid_op.rb +69 -0
- data/lib/rgeo/cartesian.rb +3 -0
- data/lib/rgeo/coord_sys/cs/entities.rb +303 -99
- data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +90 -42
- data/lib/rgeo/coord_sys.rb +1 -20
- data/lib/rgeo/error.rb +15 -0
- data/lib/rgeo/feature/curve.rb +0 -11
- data/lib/rgeo/feature/factory.rb +26 -36
- data/lib/rgeo/feature/factory_generator.rb +6 -14
- data/lib/rgeo/feature/geometry.rb +146 -66
- data/lib/rgeo/feature/geometry_collection.rb +16 -9
- data/lib/rgeo/feature/line_string.rb +4 -5
- data/lib/rgeo/feature/linear_ring.rb +0 -1
- data/lib/rgeo/feature/multi_curve.rb +0 -6
- data/lib/rgeo/feature/multi_surface.rb +3 -4
- data/lib/rgeo/feature/point.rb +4 -5
- data/lib/rgeo/feature/polygon.rb +1 -2
- data/lib/rgeo/feature/surface.rb +3 -4
- data/lib/rgeo/feature/types.rb +69 -85
- data/lib/rgeo/geographic/factory.rb +98 -125
- data/lib/rgeo/geographic/interface.rb +69 -166
- data/lib/rgeo/geographic/projected_feature_classes.rb +21 -9
- data/lib/rgeo/geographic/projected_feature_methods.rb +67 -42
- data/lib/rgeo/geographic/projected_window.rb +36 -22
- data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -5
- data/lib/rgeo/geographic/simple_mercator_projector.rb +26 -25
- data/lib/rgeo/geographic/spherical_feature_classes.rb +29 -9
- data/lib/rgeo/geographic/spherical_feature_methods.rb +86 -9
- data/lib/rgeo/geographic/spherical_math.rb +17 -20
- data/lib/rgeo/geographic.rb +1 -1
- data/lib/rgeo/geos/capi_factory.rb +87 -158
- data/lib/rgeo/geos/capi_feature_classes.rb +50 -36
- data/lib/rgeo/geos/ffi_factory.rb +105 -173
- data/lib/rgeo/geos/ffi_feature_classes.rb +34 -10
- data/lib/rgeo/geos/ffi_feature_methods.rb +105 -127
- data/lib/rgeo/geos/interface.rb +20 -59
- data/lib/rgeo/geos/utils.rb +5 -5
- data/lib/rgeo/geos/zm_factory.rb +53 -95
- data/lib/rgeo/geos/zm_feature_methods.rb +30 -33
- data/lib/rgeo/geos.rb +8 -8
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +9 -22
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +28 -56
- data/lib/rgeo/impl_helper/basic_point_methods.rb +2 -14
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +17 -26
- data/lib/rgeo/impl_helper/utils.rb +21 -0
- data/lib/rgeo/impl_helper/valid_op.rb +350 -0
- data/lib/rgeo/impl_helper/validity_check.rb +139 -0
- data/lib/rgeo/impl_helper.rb +1 -0
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep/wkb_generator.rb +73 -63
- data/lib/rgeo/wkrep/wkb_parser.rb +33 -31
- data/lib/rgeo/wkrep/wkt_generator.rb +52 -45
- data/lib/rgeo/wkrep/wkt_parser.rb +48 -35
- data/lib/rgeo.rb +1 -3
- metadata +50 -13
- data/lib/rgeo/coord_sys/srs_database/entry.rb +0 -107
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +0 -64
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +0 -65
@@ -6,79 +6,101 @@
|
|
6
6
|
#
|
7
7
|
# -----------------------------------------------------------------------------
|
8
8
|
|
9
|
+
require_relative "../impl_helper/validity_check"
|
10
|
+
|
9
11
|
module RGeo
|
10
12
|
module Cartesian
|
11
13
|
class PointImpl # :nodoc:
|
12
|
-
include
|
13
|
-
include
|
14
|
-
include
|
15
|
-
include
|
16
|
-
include
|
14
|
+
include Feature::Point
|
15
|
+
include ImplHelper::ValidityCheck
|
16
|
+
include ImplHelper::BasicGeometryMethods
|
17
|
+
include ImplHelper::BasicPointMethods
|
18
|
+
include ImplHelper::ValidOp
|
19
|
+
include GeometryMethods
|
20
|
+
include PointMethods
|
17
21
|
end
|
18
22
|
|
19
23
|
class LineStringImpl # :nodoc:
|
20
|
-
include
|
21
|
-
include
|
22
|
-
include
|
23
|
-
include
|
24
|
-
include
|
24
|
+
include Feature::LineString
|
25
|
+
include ImplHelper::ValidityCheck
|
26
|
+
include ImplHelper::BasicGeometryMethods
|
27
|
+
include ImplHelper::BasicLineStringMethods
|
28
|
+
include ImplHelper::ValidOp
|
29
|
+
include GeometryMethods
|
30
|
+
include LineStringMethods
|
25
31
|
end
|
26
32
|
|
27
33
|
class LineImpl # :nodoc:
|
28
|
-
include
|
29
|
-
include
|
30
|
-
include
|
31
|
-
include
|
32
|
-
include
|
33
|
-
include
|
34
|
+
include Feature::Line
|
35
|
+
include ImplHelper::ValidityCheck
|
36
|
+
include ImplHelper::BasicGeometryMethods
|
37
|
+
include ImplHelper::BasicLineStringMethods
|
38
|
+
include ImplHelper::BasicLineMethods
|
39
|
+
include ImplHelper::ValidOp
|
40
|
+
include GeometryMethods
|
41
|
+
include LineStringMethods
|
34
42
|
end
|
35
43
|
|
36
44
|
class LinearRingImpl # :nodoc:
|
37
|
-
include
|
38
|
-
include
|
39
|
-
include
|
40
|
-
include
|
41
|
-
include
|
42
|
-
include
|
45
|
+
include Feature::LinearRing
|
46
|
+
include ImplHelper::ValidityCheck
|
47
|
+
include ImplHelper::BasicGeometryMethods
|
48
|
+
include ImplHelper::BasicLineStringMethods
|
49
|
+
include ImplHelper::BasicLinearRingMethods
|
50
|
+
include ImplHelper::ValidOp
|
51
|
+
include GeometryMethods
|
52
|
+
include LineStringMethods
|
43
53
|
end
|
44
54
|
|
45
55
|
class PolygonImpl # :nodoc:
|
46
|
-
include
|
47
|
-
include
|
48
|
-
include
|
49
|
-
include
|
56
|
+
include Feature::Polygon
|
57
|
+
include ImplHelper::ValidityCheck
|
58
|
+
include ImplHelper::BasicGeometryMethods
|
59
|
+
include ImplHelper::BasicPolygonMethods
|
60
|
+
include ValidOp
|
61
|
+
include GeometryMethods
|
50
62
|
end
|
51
63
|
|
52
64
|
class GeometryCollectionImpl # :nodoc:
|
53
|
-
include
|
54
|
-
include
|
55
|
-
include
|
56
|
-
include
|
65
|
+
include Feature::GeometryCollection
|
66
|
+
include ImplHelper::ValidityCheck
|
67
|
+
include ImplHelper::BasicGeometryMethods
|
68
|
+
include ImplHelper::BasicGeometryCollectionMethods
|
69
|
+
include ImplHelper::ValidOp
|
70
|
+
include GeometryMethods
|
57
71
|
end
|
58
72
|
|
59
73
|
class MultiPointImpl # :nodoc:
|
60
|
-
include
|
61
|
-
include
|
62
|
-
include
|
63
|
-
include
|
64
|
-
include
|
74
|
+
include Feature::MultiPoint
|
75
|
+
include ImplHelper::ValidityCheck
|
76
|
+
include ImplHelper::BasicGeometryMethods
|
77
|
+
include ImplHelper::BasicGeometryCollectionMethods
|
78
|
+
include ImplHelper::BasicMultiPointMethods
|
79
|
+
include ImplHelper::ValidOp
|
80
|
+
include GeometryMethods
|
65
81
|
end
|
66
82
|
|
67
83
|
class MultiLineStringImpl # :nodoc:
|
68
|
-
include
|
69
|
-
include
|
70
|
-
include
|
71
|
-
include
|
72
|
-
include
|
73
|
-
include
|
84
|
+
include Feature::MultiLineString
|
85
|
+
include ImplHelper::ValidityCheck
|
86
|
+
include ImplHelper::BasicGeometryMethods
|
87
|
+
include ImplHelper::BasicGeometryCollectionMethods
|
88
|
+
include ImplHelper::BasicMultiLineStringMethods
|
89
|
+
include ImplHelper::ValidOp
|
90
|
+
include GeometryMethods
|
91
|
+
include MultiLineStringMethods
|
74
92
|
end
|
75
93
|
|
76
94
|
class MultiPolygonImpl # :nodoc:
|
77
|
-
include
|
78
|
-
include
|
79
|
-
include
|
80
|
-
include
|
81
|
-
include
|
95
|
+
include Feature::MultiPolygon
|
96
|
+
include ImplHelper::ValidityCheck
|
97
|
+
include ImplHelper::BasicGeometryMethods
|
98
|
+
include ImplHelper::BasicGeometryCollectionMethods
|
99
|
+
include ImplHelper::BasicMultiPolygonMethods
|
100
|
+
include ImplHelper::ValidOp
|
101
|
+
include GeometryMethods
|
82
102
|
end
|
103
|
+
|
104
|
+
ImplHelper::ValidityCheck.override_classes
|
83
105
|
end
|
84
106
|
end
|
@@ -16,6 +16,28 @@ module RGeo
|
|
16
16
|
def envelope
|
17
17
|
BoundingBox.new(factory).add(self).to_geometry
|
18
18
|
end
|
19
|
+
|
20
|
+
def coordinate_dimension
|
21
|
+
factory.coordinate_dimension
|
22
|
+
end
|
23
|
+
|
24
|
+
def spatial_dimension
|
25
|
+
factory.spatial_dimension
|
26
|
+
end
|
27
|
+
|
28
|
+
def is_3d?
|
29
|
+
factory.property(:has_z_coordinate)
|
30
|
+
end
|
31
|
+
|
32
|
+
def measured?
|
33
|
+
factory.property(:has_m_coordinate)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def graph
|
39
|
+
@graph ||= GeometryGraph.new(self)
|
40
|
+
end
|
19
41
|
end
|
20
42
|
|
21
43
|
module PointMethods # :nodoc:
|
@@ -50,36 +72,56 @@ module RGeo
|
|
50
72
|
end
|
51
73
|
|
52
74
|
def simple?
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
pindex = index - 1
|
62
|
-
pindex = nil if pindex < 0
|
63
|
-
return false if pindex && seg.contains_point?(segments[pindex].s)
|
64
|
-
next unless nindex
|
65
|
-
oindex = nindex + 1
|
66
|
-
while oindex < len
|
67
|
-
oseg = segments[oindex]
|
68
|
-
return false if !(index == 0 && oindex == len - 1 && seg.s == oseg.e) && seg.intersects_segment?(oseg)
|
69
|
-
oindex += 1
|
70
|
-
end
|
71
|
-
end
|
72
|
-
true
|
73
|
-
end
|
74
|
-
|
75
|
-
def is_simple?
|
76
|
-
warn "The is_simple? method is deprecated, please use the simple? counterpart, will be removed in v3" unless ENV["RGEO_SILENCE_DEPRECATION"]
|
77
|
-
simple?
|
75
|
+
# Use a SweeplineIntersector to determine if there are any self-intersections
|
76
|
+
# in the ring. The GeometryGraph of the ring could be used by comparing the
|
77
|
+
# edges to number of segments (graph.incident_edges.length == segments.length),
|
78
|
+
# but this adds computational and memory overhead if graph isn't already memoized.
|
79
|
+
# Since graph is not used elsewhere in LineStringMethods, we will just use the
|
80
|
+
# SweeplineIntersector for now.
|
81
|
+
li = SweeplineIntersector.new(segments)
|
82
|
+
li.proper_intersections.empty?
|
78
83
|
end
|
79
84
|
|
80
85
|
def length
|
81
86
|
segments.inject(0.0) { |sum, seg| sum + seg.length }
|
82
87
|
end
|
88
|
+
|
89
|
+
def crosses?(rhs)
|
90
|
+
case rhs
|
91
|
+
when Feature::LineString
|
92
|
+
crosses_line_string?(rhs)
|
93
|
+
else
|
94
|
+
super
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
# Determines if a cross occurs with another linestring.
|
101
|
+
# Process is to get the number of proper intersections in each geom
|
102
|
+
# then overlay and get the number of proper intersections from that.
|
103
|
+
# If the overlaid number is higher than the sum of individual self-ints
|
104
|
+
# then there is an intersection. Finally, we need to check the intersection
|
105
|
+
# to see that it is not a boundary point of either segment.
|
106
|
+
#
|
107
|
+
# @param rhs [Feature::LineString]
|
108
|
+
#
|
109
|
+
# @return [Boolean]
|
110
|
+
def crosses_line_string?(rhs)
|
111
|
+
self_ints = SweeplineIntersector.new(segments).proper_intersections
|
112
|
+
self_ints += SweeplineIntersector.new(rhs.segments).proper_intersections
|
113
|
+
overlay_ints = SweeplineIntersector.new(segments + rhs.segments).proper_intersections
|
114
|
+
|
115
|
+
(overlay_ints - self_ints).each do |int|
|
116
|
+
s1s = int.s1.s
|
117
|
+
s1e = int.s1.e
|
118
|
+
s2s = int.s2.s
|
119
|
+
s2e = int.s2.e
|
120
|
+
return true unless [s1s, s1e, s2s, s2e].include?(int.point)
|
121
|
+
end
|
122
|
+
|
123
|
+
false
|
124
|
+
end
|
83
125
|
end
|
84
126
|
|
85
127
|
module MultiLineStringMethods # :nodoc:
|
@@ -61,29 +61,19 @@ module RGeo
|
|
61
61
|
# [<tt>:srid</tt>]
|
62
62
|
# Set the SRID returned by geometries created by this factory.
|
63
63
|
# Default is 0.
|
64
|
-
# [<tt>:proj4</tt>]
|
65
|
-
# The coordinate system in Proj4 format, either as a
|
66
|
-
# CoordSys::Proj4 object or as a string or hash representing the
|
67
|
-
# proj4 format. Optional.
|
68
64
|
# [<tt>:coord_sys</tt>]
|
69
65
|
# The coordinate system in OGC form, either as a subclass of
|
70
66
|
# CoordSys::CS::CoordinateSystem, or as a string in WKT format.
|
71
|
-
# Optional.
|
72
|
-
#
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
67
|
+
# Optional. If no coord_sys is given, but an SRID is the factory
|
68
|
+
# will try to create one using the CoordSys::CONFIG.default_coord_sys_class
|
69
|
+
# or the given :coord_sys_class option.
|
70
|
+
# [<tt>:coord_sys_class</tt>]
|
71
|
+
# CoordSys::CS::CoordinateSystem implementation used to instansiate
|
72
|
+
# a coord_sys based on the :srid given.
|
77
73
|
# [<tt>:has_z_coordinate</tt>]
|
78
74
|
# Support a Z coordinate. Default is false.
|
79
75
|
# [<tt>:has_m_coordinate</tt>]
|
80
76
|
# Support an M coordinate. Default is false.
|
81
|
-
# [<tt>:uses_lenient_assertions</tt>]
|
82
|
-
# If set to true, assertion checking is disabled. This includes
|
83
|
-
# simplicity checking on LinearRing, and validity checks on
|
84
|
-
# Polygon and MultiPolygon. This may speed up creation of certain
|
85
|
-
# objects, at the expense of not doing the proper checking for
|
86
|
-
# OGC compliance. Default is false.
|
87
77
|
# [<tt>:wkt_parser</tt>]
|
88
78
|
# Configure the parser for WKT. The value is a hash of
|
89
79
|
# configuration parameters for WKRep::WKTParser.new. Default is
|
@@ -107,31 +97,6 @@ module RGeo
|
|
107
97
|
def simple_factory(opts = {})
|
108
98
|
Cartesian::Factory.new(opts)
|
109
99
|
end
|
110
|
-
|
111
|
-
# Returns a Feature::FactoryGenerator that creates preferred
|
112
|
-
# factories. The given options are used as the default options.
|
113
|
-
#
|
114
|
-
# A common case for this is to provide the <tt>:srs_database</tt>
|
115
|
-
# as a default. Then, the factory generator need only be passed
|
116
|
-
# an SRID and it will automatically fetch the appropriate Proj4
|
117
|
-
# and CoordSys objects.
|
118
|
-
|
119
|
-
def preferred_factory_generator(defaults = {})
|
120
|
-
proc { |c| preferred_factory(defaults.merge(c)) }
|
121
|
-
end
|
122
|
-
alias factory_generator preferred_factory_generator
|
123
|
-
|
124
|
-
# Returns a Feature::FactoryGenerator that creates simple factories.
|
125
|
-
# The given options are used as the default options.
|
126
|
-
#
|
127
|
-
# A common case for this is to provide the <tt>:srs_database</tt>
|
128
|
-
# as a default. Then, the factory generator need only be passed
|
129
|
-
# an SRID and it will automatically fetch the appropriate Proj4
|
130
|
-
# and CoordSys objects.
|
131
|
-
|
132
|
-
def simple_factory_generator(defaults = {})
|
133
|
-
proc { |c| simple_factory(defaults.merge(c)) }
|
134
|
-
end
|
135
100
|
end
|
136
101
|
end
|
137
102
|
end
|