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
@@ -5,38 +5,28 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Geographic
|
9
|
+
class SimpleMercatorProjector # :nodoc:
|
10
|
+
EQUATORIAL_RADIUS = 6_378_137.0
|
10
11
|
|
11
|
-
|
12
|
-
class SimpleMercatorProjector # :nodoc:
|
13
|
-
|
14
|
-
EQUATORIAL_RADIUS = 6378137.0
|
15
|
-
|
16
|
-
|
17
|
-
def initialize(geography_factory_, opts_={})
|
12
|
+
def initialize(geography_factory_, opts_ = {})
|
18
13
|
@geography_factory = geography_factory_
|
19
|
-
@projection_factory = Cartesian.preferred_factory(:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
@projection_factory = Cartesian.preferred_factory(srid: 3857,
|
15
|
+
proj4: SimpleMercatorProjector._proj4_3857,
|
16
|
+
coord_sys: SimpleMercatorProjector._coordsys_3857,
|
17
|
+
buffer_resolution: opts_[:buffer_resolution],
|
18
|
+
lenient_multi_polygon_assertions: opts_[:lenient_multi_polygon_assertions],
|
19
|
+
uses_lenient_assertions: opts_[:uses_lenient_assertions],
|
20
|
+
has_z_coordinate: opts_[:has_z_coordinate],
|
21
|
+
has_m_coordinate: opts_[:has_m_coordinate])
|
27
22
|
end
|
28
23
|
|
29
|
-
|
30
|
-
def _set_factories(geography_factory_, projection_factory_) # :nodoc:
|
24
|
+
def _set_factories(geography_factory_, projection_factory_) # :nodoc:
|
31
25
|
@geography_factory = geography_factory_
|
32
26
|
@projection_factory = projection_factory_
|
33
27
|
end
|
34
28
|
|
35
|
-
|
36
|
-
def projection_factory
|
37
|
-
@projection_factory
|
38
|
-
end
|
39
|
-
|
29
|
+
attr_reader :projection_factory
|
40
30
|
|
41
31
|
def project(geometry_)
|
42
32
|
case geometry_
|
@@ -48,26 +38,23 @@ module RGeo
|
|
48
38
|
when Feature::Line
|
49
39
|
@projection_factory.line(project(geometry_.start_point), project(geometry_.end_point))
|
50
40
|
when Feature::LinearRing
|
51
|
-
@projection_factory.linear_ring(geometry_.points.map{ |p_| project(p_) })
|
41
|
+
@projection_factory.linear_ring(geometry_.points.map { |p_| project(p_) })
|
52
42
|
when Feature::LineString
|
53
|
-
@projection_factory.line_string(geometry_.points.map{ |p_| project(p_) })
|
43
|
+
@projection_factory.line_string(geometry_.points.map { |p_| project(p_) })
|
54
44
|
when Feature::Polygon
|
55
45
|
@projection_factory.polygon(project(geometry_.exterior_ring),
|
56
|
-
geometry_.interior_rings.map{ |p_| project(p_) })
|
46
|
+
geometry_.interior_rings.map { |p_| project(p_) })
|
57
47
|
when Feature::MultiPoint
|
58
|
-
@projection_factory.multi_point(geometry_.map{ |p_| project(p_) })
|
48
|
+
@projection_factory.multi_point(geometry_.map { |p_| project(p_) })
|
59
49
|
when Feature::MultiLineString
|
60
|
-
@projection_factory.multi_line_string(geometry_.map{ |p_| project(p_) })
|
50
|
+
@projection_factory.multi_line_string(geometry_.map { |p_| project(p_) })
|
61
51
|
when Feature::MultiPolygon
|
62
|
-
@projection_factory.multi_polygon(geometry_.map{ |p_| project(p_) })
|
52
|
+
@projection_factory.multi_polygon(geometry_.map { |p_| project(p_) })
|
63
53
|
when Feature::GeometryCollection
|
64
|
-
@projection_factory.collection(geometry_.map{ |p_| project(p_) })
|
65
|
-
else
|
66
|
-
nil
|
54
|
+
@projection_factory.collection(geometry_.map { |p_| project(p_) })
|
67
55
|
end
|
68
56
|
end
|
69
57
|
|
70
|
-
|
71
58
|
def unproject(geometry_)
|
72
59
|
case geometry_
|
73
60
|
when Feature::Point
|
@@ -78,57 +65,46 @@ module RGeo
|
|
78
65
|
when Feature::Line
|
79
66
|
@geography_factory.line(unproject(geometry_.start_point), unproject(geometry_.end_point))
|
80
67
|
when Feature::LinearRing
|
81
|
-
@geography_factory.linear_ring(geometry_.points.map{ |p_| unproject(p_) })
|
68
|
+
@geography_factory.linear_ring(geometry_.points.map { |p_| unproject(p_) })
|
82
69
|
when Feature::LineString
|
83
|
-
@geography_factory.line_string(geometry_.points.map{ |p_| unproject(p_) })
|
70
|
+
@geography_factory.line_string(geometry_.points.map { |p_| unproject(p_) })
|
84
71
|
when Feature::Polygon
|
85
72
|
@geography_factory.polygon(unproject(geometry_.exterior_ring),
|
86
|
-
geometry_.interior_rings.map{ |p_| unproject(p_) })
|
73
|
+
geometry_.interior_rings.map { |p_| unproject(p_) })
|
87
74
|
when Feature::MultiPoint
|
88
|
-
@geography_factory.multi_point(geometry_.map{ |p_| unproject(p_) })
|
75
|
+
@geography_factory.multi_point(geometry_.map { |p_| unproject(p_) })
|
89
76
|
when Feature::MultiLineString
|
90
|
-
@geography_factory.multi_line_string(geometry_.map{ |p_| unproject(p_) })
|
77
|
+
@geography_factory.multi_line_string(geometry_.map { |p_| unproject(p_) })
|
91
78
|
when Feature::MultiPolygon
|
92
|
-
@geography_factory.multi_polygon(geometry_.map{ |p_| unproject(p_) })
|
79
|
+
@geography_factory.multi_polygon(geometry_.map { |p_| unproject(p_) })
|
93
80
|
when Feature::GeometryCollection
|
94
|
-
@geography_factory.collection(geometry_.map{ |p_| unproject(p_) })
|
95
|
-
else
|
96
|
-
nil
|
81
|
+
@geography_factory.collection(geometry_.map { |p_| unproject(p_) })
|
97
82
|
end
|
98
83
|
end
|
99
84
|
|
100
|
-
|
101
85
|
def wraps?
|
102
86
|
true
|
103
87
|
end
|
104
88
|
|
105
|
-
|
106
89
|
def limits_window
|
107
90
|
@limits_window ||= ProjectedWindow.new(@geography_factory,
|
108
|
-
-
|
109
|
-
:
|
91
|
+
-20_037_508.342789, -20_037_508.342789, 20_037_508.342789, 20_037_508.342789,
|
92
|
+
is_limits: true)
|
110
93
|
end
|
111
94
|
|
112
|
-
|
113
|
-
def self._proj4_3857 # :nodoc:
|
95
|
+
def self._proj4_3857 # :nodoc:
|
114
96
|
unless defined?(@proj4_3857)
|
115
|
-
@proj4_3857 = CoordSys::Proj4.create(
|
97
|
+
@proj4_3857 = CoordSys::Proj4.create("+proj=merc +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs")
|
116
98
|
end
|
117
99
|
@proj4_3857
|
118
100
|
end
|
119
101
|
|
120
|
-
|
121
|
-
def self._coordsys_3857 # :nodoc:
|
102
|
+
def self._coordsys_3857 # :nodoc:
|
122
103
|
unless defined?(@coordsys_3857)
|
123
104
|
@coordsys_3857 = CoordSys::CS.create_from_wkt('PROJCS["Popular Visualisation CRS / Mercator",GEOGCS["Popular Visualisation CRS",DATUM["Popular_Visualisation_Datum",SPHEROID["Popular Visualisation Sphere",6378137,0,AUTHORITY["EPSG","7059"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY["EPSG","6055"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4055"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],AUTHORITY["EPSG","3785"],AXIS["X",EAST],AXIS["Y",NORTH]]')
|
124
105
|
end
|
125
106
|
@coordsys_3857
|
126
107
|
end
|
127
|
-
|
128
|
-
|
129
108
|
end
|
130
|
-
|
131
|
-
|
132
109
|
end
|
133
|
-
|
134
110
|
end
|
@@ -5,45 +5,28 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Geographic
|
10
|
-
|
11
|
-
|
12
|
-
class SphericalPointImpl # :nodoc:
|
13
|
-
|
14
|
-
|
9
|
+
class SphericalPointImpl # :nodoc:
|
15
10
|
include Feature::Point
|
16
11
|
include ImplHelper::BasicGeometryMethods
|
17
12
|
include ImplHelper::BasicPointMethods
|
18
13
|
include SphericalGeometryMethods
|
19
14
|
include SphericalPointMethods
|
20
15
|
|
21
|
-
|
22
16
|
Feature::MixinCollection::GLOBAL.for_type(Feature::Point).include_in_class(self, true)
|
23
|
-
|
24
|
-
|
25
17
|
end
|
26
18
|
|
27
|
-
|
28
|
-
class SphericalLineStringImpl # :nodoc:
|
29
|
-
|
30
|
-
|
19
|
+
class SphericalLineStringImpl # :nodoc:
|
31
20
|
include Feature::LineString
|
32
21
|
include ImplHelper::BasicGeometryMethods
|
33
22
|
include ImplHelper::BasicLineStringMethods
|
34
23
|
include SphericalGeometryMethods
|
35
24
|
include SphericalLineStringMethods
|
36
25
|
|
37
|
-
|
38
26
|
Feature::MixinCollection::GLOBAL.for_type(Feature::LineString).include_in_class(self, true)
|
39
|
-
|
40
|
-
|
41
27
|
end
|
42
28
|
|
43
|
-
|
44
|
-
class SphericalLineImpl # :nodoc:
|
45
|
-
|
46
|
-
|
29
|
+
class SphericalLineImpl # :nodoc:
|
47
30
|
include Feature::Line
|
48
31
|
include ImplHelper::BasicGeometryMethods
|
49
32
|
include ImplHelper::BasicLineStringMethods
|
@@ -51,16 +34,10 @@ module RGeo
|
|
51
34
|
include SphericalGeometryMethods
|
52
35
|
include SphericalLineStringMethods
|
53
36
|
|
54
|
-
|
55
37
|
Feature::MixinCollection::GLOBAL.for_type(Feature::Line).include_in_class(self, true)
|
56
|
-
|
57
|
-
|
58
38
|
end
|
59
39
|
|
60
|
-
|
61
|
-
class SphericalLinearRingImpl # :nodoc:
|
62
|
-
|
63
|
-
|
40
|
+
class SphericalLinearRingImpl # :nodoc:
|
64
41
|
include Feature::LinearRing
|
65
42
|
include ImplHelper::BasicGeometryMethods
|
66
43
|
include ImplHelper::BasicLineStringMethods
|
@@ -68,62 +45,38 @@ module RGeo
|
|
68
45
|
include SphericalGeometryMethods
|
69
46
|
include SphericalLineStringMethods
|
70
47
|
|
71
|
-
|
72
48
|
Feature::MixinCollection::GLOBAL.for_type(Feature::LinearRing).include_in_class(self, true)
|
73
|
-
|
74
|
-
|
75
49
|
end
|
76
50
|
|
77
|
-
|
78
|
-
class SphericalPolygonImpl # :nodoc:
|
79
|
-
|
80
|
-
|
51
|
+
class SphericalPolygonImpl # :nodoc:
|
81
52
|
include Feature::Polygon
|
82
53
|
include ImplHelper::BasicGeometryMethods
|
83
54
|
include ImplHelper::BasicPolygonMethods
|
84
55
|
include SphericalGeometryMethods
|
85
56
|
|
86
|
-
|
87
57
|
Feature::MixinCollection::GLOBAL.for_type(Feature::Polygon).include_in_class(self, true)
|
88
|
-
|
89
|
-
|
90
58
|
end
|
91
59
|
|
92
|
-
|
93
|
-
class SphericalGeometryCollectionImpl # :nodoc:
|
94
|
-
|
95
|
-
|
60
|
+
class SphericalGeometryCollectionImpl # :nodoc:
|
96
61
|
include Feature::GeometryCollection
|
97
62
|
include ImplHelper::BasicGeometryMethods
|
98
63
|
include ImplHelper::BasicGeometryCollectionMethods
|
99
64
|
include SphericalGeometryMethods
|
100
65
|
|
101
|
-
|
102
66
|
Feature::MixinCollection::GLOBAL.for_type(Feature::GeometryCollection).include_in_class(self, true)
|
103
|
-
|
104
|
-
|
105
67
|
end
|
106
68
|
|
107
|
-
|
108
|
-
class SphericalMultiPointImpl # :nodoc:
|
109
|
-
|
110
|
-
|
69
|
+
class SphericalMultiPointImpl # :nodoc:
|
111
70
|
include Feature::MultiPoint
|
112
71
|
include ImplHelper::BasicGeometryMethods
|
113
72
|
include ImplHelper::BasicGeometryCollectionMethods
|
114
73
|
include ImplHelper::BasicMultiPointMethods
|
115
74
|
include SphericalGeometryMethods
|
116
75
|
|
117
|
-
|
118
76
|
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPoint).include_in_class(self, true)
|
119
|
-
|
120
|
-
|
121
77
|
end
|
122
78
|
|
123
|
-
|
124
|
-
class SphericalMultiLineStringImpl # :nodoc:
|
125
|
-
|
126
|
-
|
79
|
+
class SphericalMultiLineStringImpl # :nodoc:
|
127
80
|
include Feature::MultiLineString
|
128
81
|
include ImplHelper::BasicGeometryMethods
|
129
82
|
include ImplHelper::BasicGeometryCollectionMethods
|
@@ -131,29 +84,17 @@ module RGeo
|
|
131
84
|
include SphericalGeometryMethods
|
132
85
|
include SphericalMultiLineStringMethods
|
133
86
|
|
134
|
-
|
135
87
|
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiLineString).include_in_class(self, true)
|
136
|
-
|
137
|
-
|
138
88
|
end
|
139
89
|
|
140
|
-
|
141
|
-
class SphericalMultiPolygonImpl # :nodoc:
|
142
|
-
|
143
|
-
|
90
|
+
class SphericalMultiPolygonImpl # :nodoc:
|
144
91
|
include Feature::MultiPolygon
|
145
92
|
include ImplHelper::BasicGeometryMethods
|
146
93
|
include ImplHelper::BasicGeometryCollectionMethods
|
147
94
|
include ImplHelper::BasicMultiPolygonMethods
|
148
95
|
include SphericalGeometryMethods
|
149
96
|
|
150
|
-
|
151
97
|
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPolygon).include_in_class(self, true)
|
152
|
-
|
153
|
-
|
154
98
|
end
|
155
|
-
|
156
|
-
|
157
99
|
end
|
158
|
-
|
159
100
|
end
|
@@ -5,24 +5,14 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Geographic
|
10
|
-
|
11
|
-
|
12
|
-
module SphericalGeometryMethods # :nodoc:
|
13
|
-
|
14
|
-
|
9
|
+
module SphericalGeometryMethods # :nodoc:
|
15
10
|
def srid
|
16
11
|
factory.srid
|
17
12
|
end
|
18
|
-
|
19
|
-
|
20
13
|
end
|
21
14
|
|
22
|
-
|
23
|
-
module SphericalPointMethods # :nodoc:
|
24
|
-
|
25
|
-
|
15
|
+
module SphericalPointMethods # :nodoc:
|
26
16
|
def _validate_geometry
|
27
17
|
if @x < -180.0 || @x > 180.0
|
28
18
|
@x = @x % 360.0
|
@@ -33,12 +23,10 @@ module RGeo
|
|
33
23
|
super
|
34
24
|
end
|
35
25
|
|
36
|
-
|
37
26
|
def _xyz
|
38
27
|
@xyz ||= SphericalMath::PointXYZ.from_latlon(@y, @x)
|
39
28
|
end
|
40
29
|
|
41
|
-
|
42
30
|
def distance(rhs_)
|
43
31
|
rhs_ = Feature.cast(rhs_, @factory)
|
44
32
|
case rhs_
|
@@ -49,9 +37,8 @@ module RGeo
|
|
49
37
|
end
|
50
38
|
end
|
51
39
|
|
52
|
-
|
53
40
|
def equals?(rhs_)
|
54
|
-
return false unless rhs_.is_a?(self.class) && rhs_.factory ==
|
41
|
+
return false unless rhs_.is_a?(self.class) && rhs_.factory == factory
|
55
42
|
case rhs_
|
56
43
|
when Feature::Point
|
57
44
|
if @y == 90
|
@@ -62,15 +49,14 @@ module RGeo
|
|
62
49
|
rhs_.x == @x && rhs_.y == @y
|
63
50
|
end
|
64
51
|
when Feature::LineString
|
65
|
-
rhs_.num_points > 0 && rhs_.points.all?{ |elem_| equals?(elem_) }
|
52
|
+
rhs_.num_points > 0 && rhs_.points.all? { |elem_| equals?(elem_) }
|
66
53
|
when Feature::GeometryCollection
|
67
|
-
rhs_.num_geometries > 0 && rhs_.all?{ |elem_| equals?(elem_) }
|
54
|
+
rhs_.num_geometries > 0 && rhs_.all? { |elem_| equals?(elem_) }
|
68
55
|
else
|
69
56
|
false
|
70
57
|
end
|
71
58
|
end
|
72
59
|
|
73
|
-
|
74
60
|
def buffer(distance_)
|
75
61
|
radius_ = distance_ / SphericalMath::RADIUS
|
76
62
|
radius_ = 1.5 if radius_ > 1.5
|
@@ -90,7 +76,6 @@ module RGeo
|
|
90
76
|
factory.polygon(factory.linear_ring(points_))
|
91
77
|
end
|
92
78
|
|
93
|
-
|
94
79
|
def self.included(klass_)
|
95
80
|
klass_.module_eval do
|
96
81
|
alias_method :longitude, :x
|
@@ -99,28 +84,22 @@ module RGeo
|
|
99
84
|
alias_method :lat, :y
|
100
85
|
end
|
101
86
|
end
|
102
|
-
|
103
|
-
|
104
87
|
end
|
105
88
|
|
106
|
-
|
107
|
-
module SphericalLineStringMethods # :nodoc:
|
108
|
-
|
109
|
-
|
89
|
+
module SphericalLineStringMethods # :nodoc:
|
110
90
|
def _arcs
|
111
91
|
unless defined?(@arcs)
|
112
|
-
@arcs = (0..num_points-2).map do |i_|
|
113
|
-
SphericalMath::ArcXYZ.new(point_n(i_)._xyz, point_n(i_+1)._xyz)
|
92
|
+
@arcs = (0..num_points - 2).map do |i_|
|
93
|
+
SphericalMath::ArcXYZ.new(point_n(i_)._xyz, point_n(i_ + 1)._xyz)
|
114
94
|
end
|
115
95
|
end
|
116
96
|
@arcs
|
117
97
|
end
|
118
98
|
|
119
|
-
|
120
99
|
def is_simple?
|
121
100
|
arcs_ = _arcs
|
122
101
|
len_ = arcs_.length
|
123
|
-
return false if arcs_.any?
|
102
|
+
return false if arcs_.any?(&:degenerate?)
|
124
103
|
return true if len_ == 1
|
125
104
|
return arcs_[0].s != arcs_[1].e if len_ == 2
|
126
105
|
arcs_.each_with_index do |arc_, index_|
|
@@ -130,38 +109,26 @@ module RGeo
|
|
130
109
|
pindex_ = index_ - 1
|
131
110
|
pindex_ = nil if pindex_ < 0
|
132
111
|
return false if pindex_ && arc_.contains_point?(arcs_[pindex_].s)
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
end
|
112
|
+
next unless nindex_
|
113
|
+
oindex_ = nindex_ + 1
|
114
|
+
while oindex_ < len_
|
115
|
+
oarc_ = arcs_[oindex_]
|
116
|
+
return false if !(index_ == 0 && oindex_ == len_ - 1 && arc_.s == oarc_.e) && arc_.intersects_arc?(oarc_)
|
117
|
+
oindex_ += 1
|
140
118
|
end
|
141
119
|
end
|
142
120
|
true
|
143
121
|
end
|
144
122
|
|
145
|
-
|
146
123
|
def length
|
147
|
-
_arcs.inject(0.0){ |sum_, arc_| sum_ + arc_.length } * SphericalMath::RADIUS
|
124
|
+
_arcs.inject(0.0) { |sum_, arc_| sum_ + arc_.length } * SphericalMath::RADIUS
|
148
125
|
end
|
149
|
-
|
150
|
-
|
151
126
|
end
|
152
127
|
|
153
|
-
|
154
|
-
module SphericalMultiLineStringMethods # :nodoc:
|
155
|
-
|
156
|
-
|
128
|
+
module SphericalMultiLineStringMethods # :nodoc:
|
157
129
|
def length
|
158
|
-
inject(0.0){ |sum_, geom_| sum_ + geom_.length }
|
130
|
+
inject(0.0) { |sum_, geom_| sum_ + geom_.length }
|
159
131
|
end
|
160
|
-
|
161
|
-
|
162
132
|
end
|
163
|
-
|
164
|
-
|
165
133
|
end
|
166
|
-
|
167
134
|
end
|