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,13 +5,8 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Cartesian
|
10
|
-
|
11
|
-
|
12
|
-
class PointImpl # :nodoc:
|
13
|
-
|
14
|
-
|
9
|
+
class PointImpl # :nodoc:
|
15
10
|
include ::RGeo::Feature::Point
|
16
11
|
include ::RGeo::ImplHelper::BasicGeometryMethods
|
17
12
|
include ::RGeo::ImplHelper::BasicPointMethods
|
@@ -19,14 +14,9 @@ module RGeo
|
|
19
14
|
include ::RGeo::Cartesian::PointMethods
|
20
15
|
|
21
16
|
Feature::MixinCollection::GLOBAL.for_type(Feature::Point).include_in_class(self, true)
|
22
|
-
|
23
|
-
|
24
17
|
end
|
25
18
|
|
26
|
-
|
27
|
-
class LineStringImpl # :nodoc:
|
28
|
-
|
29
|
-
|
19
|
+
class LineStringImpl # :nodoc:
|
30
20
|
include ::RGeo::Feature::LineString
|
31
21
|
include ::RGeo::ImplHelper::BasicGeometryMethods
|
32
22
|
include ::RGeo::ImplHelper::BasicLineStringMethods
|
@@ -34,14 +24,9 @@ module RGeo
|
|
34
24
|
include ::RGeo::Cartesian::LineStringMethods
|
35
25
|
|
36
26
|
Feature::MixinCollection::GLOBAL.for_type(Feature::LineString).include_in_class(self, true)
|
37
|
-
|
38
|
-
|
39
27
|
end
|
40
28
|
|
41
|
-
|
42
|
-
class LineImpl # :nodoc:
|
43
|
-
|
44
|
-
|
29
|
+
class LineImpl # :nodoc:
|
45
30
|
include ::RGeo::Feature::Line
|
46
31
|
include ::RGeo::ImplHelper::BasicGeometryMethods
|
47
32
|
include ::RGeo::ImplHelper::BasicLineStringMethods
|
@@ -50,14 +35,9 @@ module RGeo
|
|
50
35
|
include ::RGeo::Cartesian::LineStringMethods
|
51
36
|
|
52
37
|
Feature::MixinCollection::GLOBAL.for_type(Feature::Line).include_in_class(self, true)
|
53
|
-
|
54
|
-
|
55
38
|
end
|
56
39
|
|
57
|
-
|
58
|
-
class LinearRingImpl # :nodoc:
|
59
|
-
|
60
|
-
|
40
|
+
class LinearRingImpl # :nodoc:
|
61
41
|
include ::RGeo::Feature::LinearRing
|
62
42
|
include ::RGeo::ImplHelper::BasicGeometryMethods
|
63
43
|
include ::RGeo::ImplHelper::BasicLineStringMethods
|
@@ -66,42 +46,27 @@ module RGeo
|
|
66
46
|
include ::RGeo::Cartesian::LineStringMethods
|
67
47
|
|
68
48
|
Feature::MixinCollection::GLOBAL.for_type(Feature::LinearRing).include_in_class(self, true)
|
69
|
-
|
70
|
-
|
71
49
|
end
|
72
50
|
|
73
|
-
|
74
|
-
class PolygonImpl # :nodoc:
|
75
|
-
|
76
|
-
|
51
|
+
class PolygonImpl # :nodoc:
|
77
52
|
include ::RGeo::Feature::Polygon
|
78
53
|
include ::RGeo::ImplHelper::BasicGeometryMethods
|
79
54
|
include ::RGeo::ImplHelper::BasicPolygonMethods
|
80
55
|
include ::RGeo::Cartesian::GeometryMethods
|
81
56
|
|
82
57
|
Feature::MixinCollection::GLOBAL.for_type(Feature::Polygon).include_in_class(self, true)
|
83
|
-
|
84
|
-
|
85
58
|
end
|
86
59
|
|
87
|
-
|
88
|
-
class GeometryCollectionImpl # :nodoc:
|
89
|
-
|
90
|
-
|
60
|
+
class GeometryCollectionImpl # :nodoc:
|
91
61
|
include ::RGeo::Feature::GeometryCollection
|
92
62
|
include ::RGeo::ImplHelper::BasicGeometryMethods
|
93
63
|
include ::RGeo::ImplHelper::BasicGeometryCollectionMethods
|
94
64
|
include ::RGeo::Cartesian::GeometryMethods
|
95
65
|
|
96
66
|
Feature::MixinCollection::GLOBAL.for_type(Feature::GeometryCollection).include_in_class(self, true)
|
97
|
-
|
98
|
-
|
99
67
|
end
|
100
68
|
|
101
|
-
|
102
|
-
class MultiPointImpl # :nodoc:
|
103
|
-
|
104
|
-
|
69
|
+
class MultiPointImpl # :nodoc:
|
105
70
|
include ::RGeo::Feature::MultiPoint
|
106
71
|
include ::RGeo::ImplHelper::BasicGeometryMethods
|
107
72
|
include ::RGeo::ImplHelper::BasicGeometryCollectionMethods
|
@@ -109,14 +74,9 @@ module RGeo
|
|
109
74
|
include ::RGeo::Cartesian::GeometryMethods
|
110
75
|
|
111
76
|
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPoint).include_in_class(self, true)
|
112
|
-
|
113
|
-
|
114
77
|
end
|
115
78
|
|
116
|
-
|
117
|
-
class MultiLineStringImpl # :nodoc:
|
118
|
-
|
119
|
-
|
79
|
+
class MultiLineStringImpl # :nodoc:
|
120
80
|
include ::RGeo::Feature::MultiLineString
|
121
81
|
include ::RGeo::ImplHelper::BasicGeometryMethods
|
122
82
|
include ::RGeo::ImplHelper::BasicGeometryCollectionMethods
|
@@ -125,14 +85,9 @@ module RGeo
|
|
125
85
|
include ::RGeo::Cartesian::MultiLineStringMethods
|
126
86
|
|
127
87
|
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiLineString).include_in_class(self, true)
|
128
|
-
|
129
|
-
|
130
88
|
end
|
131
89
|
|
132
|
-
|
133
|
-
class MultiPolygonImpl # :nodoc:
|
134
|
-
|
135
|
-
|
90
|
+
class MultiPolygonImpl # :nodoc:
|
136
91
|
include ::RGeo::Feature::MultiPolygon
|
137
92
|
include ::RGeo::ImplHelper::BasicGeometryMethods
|
138
93
|
include ::RGeo::ImplHelper::BasicGeometryCollectionMethods
|
@@ -140,11 +95,6 @@ module RGeo
|
|
140
95
|
include ::RGeo::Cartesian::GeometryMethods
|
141
96
|
|
142
97
|
Feature::MixinCollection::GLOBAL.for_type(Feature::MultiPolygon).include_in_class(self, true)
|
143
|
-
|
144
|
-
|
145
98
|
end
|
146
|
-
|
147
|
-
|
148
99
|
end
|
149
|
-
|
150
100
|
end
|
@@ -5,29 +5,18 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Cartesian
|
10
|
-
|
11
|
-
|
12
|
-
module GeometryMethods # :nodoc:
|
13
|
-
|
14
|
-
|
9
|
+
module GeometryMethods # :nodoc:
|
15
10
|
def srid
|
16
11
|
factory.srid
|
17
12
|
end
|
18
13
|
|
19
|
-
|
20
14
|
def envelope
|
21
15
|
BoundingBox.new(factory).add(self).to_geometry
|
22
16
|
end
|
23
|
-
|
24
|
-
|
25
17
|
end
|
26
18
|
|
27
|
-
|
28
|
-
module PointMethods # :nodoc:
|
29
|
-
|
30
|
-
|
19
|
+
module PointMethods # :nodoc:
|
31
20
|
def distance(rhs_)
|
32
21
|
rhs_ = ::RGeo::Feature.cast(rhs_, @factory)
|
33
22
|
case rhs_
|
@@ -40,7 +29,6 @@ module RGeo
|
|
40
29
|
end
|
41
30
|
end
|
42
31
|
|
43
|
-
|
44
32
|
def buffer(distance_)
|
45
33
|
point_count_ = factory.property(:buffer_resolution) * 4
|
46
34
|
angle_ = -::Math::PI * 2.0 / point_count_
|
@@ -50,28 +38,22 @@ module RGeo
|
|
50
38
|
end
|
51
39
|
factory.polygon(factory.linear_ring(points_))
|
52
40
|
end
|
53
|
-
|
54
|
-
|
55
41
|
end
|
56
42
|
|
57
|
-
|
58
|
-
module LineStringMethods # :nodoc:
|
59
|
-
|
60
|
-
|
43
|
+
module LineStringMethods # :nodoc:
|
61
44
|
def _segments
|
62
45
|
unless defined?(@segments)
|
63
|
-
@segments = (0..num_points-2).map do |i_|
|
64
|
-
Segment.new(point_n(i_), point_n(i_+1))
|
46
|
+
@segments = (0..num_points - 2).map do |i_|
|
47
|
+
Segment.new(point_n(i_), point_n(i_ + 1))
|
65
48
|
end
|
66
49
|
end
|
67
50
|
@segments
|
68
51
|
end
|
69
52
|
|
70
|
-
|
71
53
|
def is_simple?
|
72
54
|
segs_ = _segments
|
73
55
|
len_ = segs_.length
|
74
|
-
return false if segs_.any?
|
56
|
+
return false if segs_.any?(&:degenerate?)
|
75
57
|
return true if len_ == 1
|
76
58
|
return segs_[0].s != segs_[1].e if len_ == 2
|
77
59
|
segs_.each_with_index do |seg_, index_|
|
@@ -81,38 +63,26 @@ module RGeo
|
|
81
63
|
pindex_ = index_ - 1
|
82
64
|
pindex_ = nil if pindex_ < 0
|
83
65
|
return false if pindex_ && seg_.contains_point?(segs_[pindex_].s)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
66
|
+
next unless nindex_
|
67
|
+
oindex_ = nindex_ + 1
|
68
|
+
while oindex_ < len_
|
69
|
+
oseg_ = segs_[oindex_]
|
70
|
+
return false if !(index_ == 0 && oindex_ == len_ - 1 && seg_.s == oseg_.e) && seg_.intersects_segment?(oseg_)
|
71
|
+
oindex_ += 1
|
91
72
|
end
|
92
73
|
end
|
93
74
|
true
|
94
75
|
end
|
95
76
|
|
96
|
-
|
97
77
|
def length
|
98
|
-
_segments.inject(0.0){ |sum_, seg_| sum_ + seg_.length }
|
78
|
+
_segments.inject(0.0) { |sum_, seg_| sum_ + seg_.length }
|
99
79
|
end
|
100
|
-
|
101
|
-
|
102
80
|
end
|
103
81
|
|
104
|
-
|
105
|
-
module MultiLineStringMethods # :nodoc:
|
106
|
-
|
107
|
-
|
82
|
+
module MultiLineStringMethods # :nodoc:
|
108
83
|
def length
|
109
|
-
inject(0.0){ |sum_, geom_| sum_ + geom_.length }
|
84
|
+
inject(0.0) { |sum_, geom_| sum_ + geom_.length }
|
110
85
|
end
|
111
|
-
|
112
|
-
|
113
86
|
end
|
114
|
-
|
115
|
-
|
116
87
|
end
|
117
|
-
|
118
88
|
end
|
@@ -5,12 +5,8 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module Cartesian
|
10
|
-
|
11
9
|
class << self
|
12
|
-
|
13
|
-
|
14
10
|
# Creates and returns a cartesian factory of the preferred
|
15
11
|
# Cartesian implementation.
|
16
12
|
#
|
@@ -28,7 +24,7 @@ module RGeo
|
|
28
24
|
# RGeo::Cartesian.simple_factory for details. Unsupported options
|
29
25
|
# are ignored.
|
30
26
|
|
31
|
-
def preferred_factory(opts_={})
|
27
|
+
def preferred_factory(opts_ = {})
|
32
28
|
if ::RGeo::Geos.supported?
|
33
29
|
::RGeo::Geos.factory(opts_)
|
34
30
|
else
|
@@ -37,7 +33,6 @@ module RGeo
|
|
37
33
|
end
|
38
34
|
alias_method :factory, :preferred_factory
|
39
35
|
|
40
|
-
|
41
36
|
# Returns a factory for the simple Cartesian implementation. This
|
42
37
|
# implementation provides all SFS 1.1 types, and also allows Z and
|
43
38
|
# M coordinates. It does not depend on external libraries, and is
|
@@ -107,11 +102,10 @@ module RGeo
|
|
107
102
|
# Default is the empty hash, indicating the default configuration
|
108
103
|
# for WKRep::WKBGenerator.
|
109
104
|
|
110
|
-
def simple_factory(opts_={})
|
105
|
+
def simple_factory(opts_ = {})
|
111
106
|
Cartesian::Factory.new(opts_)
|
112
107
|
end
|
113
108
|
|
114
|
-
|
115
109
|
# Returns a Feature::FactoryGenerator that creates preferred
|
116
110
|
# factories. The given options are used as the default options.
|
117
111
|
#
|
@@ -120,12 +114,11 @@ module RGeo
|
|
120
114
|
# an SRID and it will automatically fetch the appropriate Proj4
|
121
115
|
# and CoordSys objects.
|
122
116
|
|
123
|
-
def preferred_factory_generator(defaults_={})
|
124
|
-
::Proc.new{ |c_| preferred_factory(defaults_.merge(c_)) }
|
117
|
+
def preferred_factory_generator(defaults_ = {})
|
118
|
+
::Proc.new { |c_| preferred_factory(defaults_.merge(c_)) }
|
125
119
|
end
|
126
120
|
alias_method :factory_generator, :preferred_factory_generator
|
127
121
|
|
128
|
-
|
129
122
|
# Returns a Feature::FactoryGenerator that creates simple factories.
|
130
123
|
# The given options are used as the default options.
|
131
124
|
#
|
@@ -134,13 +127,9 @@ module RGeo
|
|
134
127
|
# an SRID and it will automatically fetch the appropriate Proj4
|
135
128
|
# and CoordSys objects.
|
136
129
|
|
137
|
-
def simple_factory_generator(defaults_={})
|
138
|
-
::Proc.new{ |c_| simple_factory(defaults_.merge(c_)) }
|
130
|
+
def simple_factory_generator(defaults_ = {})
|
131
|
+
::Proc.new { |c_| simple_factory(defaults_.merge(c_)) }
|
139
132
|
end
|
140
|
-
|
141
|
-
|
142
133
|
end
|
143
|
-
|
144
134
|
end
|
145
|
-
|
146
135
|
end
|
data/lib/rgeo/coord_sys.rb
CHANGED
@@ -5,8 +5,6 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
|
-
|
10
8
|
# This module provides data structures and tools related to coordinate
|
11
9
|
# systems and coordinate transforms. It comprises the following parts:
|
12
10
|
#
|
@@ -29,21 +27,17 @@ module RGeo
|
|
29
27
|
|
30
28
|
module CoordSys
|
31
29
|
end
|
32
|
-
|
33
|
-
|
34
30
|
end
|
35
31
|
|
36
|
-
|
37
32
|
# Implementation files
|
38
33
|
begin
|
39
|
-
require
|
34
|
+
require "rgeo/coord_sys/proj4_c_impl"
|
40
35
|
rescue ::LoadError; end
|
41
|
-
require
|
42
|
-
require
|
43
|
-
require
|
44
|
-
require
|
45
|
-
require
|
46
|
-
require
|
47
|
-
require
|
48
|
-
require
|
49
|
-
require 'rgeo/coord_sys/srs_database/sr_org.rb'
|
36
|
+
require "rgeo/coord_sys/proj4"
|
37
|
+
require "rgeo/coord_sys/cs/factories"
|
38
|
+
require "rgeo/coord_sys/cs/entities"
|
39
|
+
require "rgeo/coord_sys/cs/wkt_parser"
|
40
|
+
require "rgeo/coord_sys/srs_database/interface.rb"
|
41
|
+
require "rgeo/coord_sys/srs_database/proj4_data.rb"
|
42
|
+
require "rgeo/coord_sys/srs_database/url_reader.rb"
|
43
|
+
require "rgeo/coord_sys/srs_database/sr_org.rb"
|
@@ -5,13 +5,8 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module CoordSys
|
10
|
-
|
11
|
-
|
12
9
|
module CS
|
13
|
-
|
14
|
-
|
15
10
|
# An axis orientation constant for AxisInfo.
|
16
11
|
# Unknown or unspecified axis orientation. This can be used for
|
17
12
|
# local or fitted coordinate systems.
|
@@ -45,7 +40,6 @@ module RGeo
|
|
45
40
|
# coordinate systems.
|
46
41
|
AO_DOWN = 6
|
47
42
|
|
48
|
-
|
49
43
|
# A datum type constant for HorizontalDatum.
|
50
44
|
# Lowest possible value for horizontal datum types.
|
51
45
|
HD_MIN = 1000
|
@@ -132,12 +126,11 @@ module RGeo
|
|
132
126
|
|
133
127
|
# A datum type constant for LocalDatum.
|
134
128
|
# Lowest possible value for local datum types.
|
135
|
-
LD_MIN =
|
129
|
+
LD_MIN = 10_000
|
136
130
|
|
137
131
|
# A datum type constant for LocalDatum.
|
138
132
|
# Highest possible value for local datum types.
|
139
|
-
LD_MAX =
|
140
|
-
|
133
|
+
LD_MAX = 32_767
|
141
134
|
|
142
135
|
# This is a base class for all OGC coordinate system objects.
|
143
136
|
# This includes both interfaces and data types from the OGC
|
@@ -146,128 +139,112 @@ module RGeo
|
|
146
139
|
# This is a non-instantiable abstract class.
|
147
140
|
|
148
141
|
class Base
|
149
|
-
|
150
|
-
|
151
142
|
# Standard object inspection output
|
152
143
|
|
153
144
|
def inspect
|
154
145
|
"#<#{self.class}:0x#{object_id.to_s(16)} #{to_wkt}>"
|
155
146
|
end
|
156
147
|
|
157
|
-
|
158
148
|
# Tests for equality. Two objects are defined as equal if they
|
159
149
|
# have the same type (class) and the same WKT representation.
|
160
150
|
|
161
151
|
def eql?(rhs_)
|
162
|
-
rhs_.class == self.class && rhs_.to_wkt ==
|
152
|
+
rhs_.class == self.class && rhs_.to_wkt == to_wkt
|
163
153
|
end
|
164
154
|
alias_method :==, :eql?
|
165
155
|
|
166
|
-
|
167
156
|
# Standard hash code
|
168
157
|
|
169
158
|
def hash
|
170
|
-
@hash ||=
|
159
|
+
@hash ||= to_wkt.hash
|
171
160
|
end
|
172
161
|
|
173
|
-
|
174
162
|
# Returns the default WKT representation.
|
175
163
|
|
176
164
|
def to_s
|
177
165
|
to_wkt
|
178
166
|
end
|
179
167
|
|
180
|
-
|
181
168
|
# Computes the WKT representation. Options include:
|
182
169
|
#
|
183
170
|
# [<tt>:standard_brackets</tt>]
|
184
171
|
# If set to true, outputs parentheses rather than square
|
185
172
|
# brackets. Default is false.
|
186
173
|
|
187
|
-
def to_wkt(opts_={})
|
174
|
+
def to_wkt(opts_ = {})
|
188
175
|
if opts_[:standard_brackets]
|
189
|
-
@standard_wkt ||= _to_wkt(
|
176
|
+
@standard_wkt ||= _to_wkt("(", ")")
|
190
177
|
else
|
191
|
-
@square_wkt ||= _to_wkt(
|
178
|
+
@square_wkt ||= _to_wkt("[", "]")
|
192
179
|
end
|
193
180
|
end
|
194
181
|
|
195
|
-
|
196
|
-
|
197
|
-
content_ = _wkt_content(open_, close_).map{ |obj_| ",#{obj_}" }.join
|
182
|
+
def _to_wkt(open_, close_) # :nodoc:
|
183
|
+
content_ = _wkt_content(open_, close_).map { |obj_| ",#{obj_}" }.join
|
198
184
|
if defined?(@authority) && @authority
|
199
185
|
authority_ = ",AUTHORITY#{open_}#{@authority.inspect},#{@authority_code.inspect}#{close_}"
|
200
186
|
else
|
201
|
-
authority_ =
|
187
|
+
authority_ = ""
|
202
188
|
end
|
203
189
|
if defined?(@extensions) && @extensions
|
204
|
-
extensions_ = @extensions.map{ |k_, v_| ",EXTENSION#{open_}#{k_.inspect},#{v_.inspect}#{close_}" }.join
|
190
|
+
extensions_ = @extensions.map { |k_, v_| ",EXTENSION#{open_}#{k_.inspect},#{v_.inspect}#{close_}" }.join
|
205
191
|
else
|
206
|
-
extensions_ =
|
192
|
+
extensions_ = ""
|
207
193
|
end
|
208
194
|
"#{_wkt_typename}#{open_}#{@name.inspect}#{content_}#{extensions_}#{authority_}#{close_}"
|
209
195
|
end
|
210
196
|
|
211
|
-
|
212
197
|
# Marshal support
|
213
198
|
|
214
|
-
def marshal_dump
|
199
|
+
def marshal_dump # :nodoc:
|
215
200
|
to_wkt
|
216
201
|
end
|
217
202
|
|
218
|
-
def marshal_load(data_)
|
219
|
-
data_ = data_[
|
203
|
+
def marshal_load(data_) # :nodoc:
|
204
|
+
data_ = data_["wkt"] if data_.is_a?(::Hash)
|
220
205
|
temp_ = CS.create_from_wkt(data_)
|
221
206
|
if temp_.class == self.class
|
222
207
|
temp_.instance_variables.each do |iv_|
|
223
208
|
instance_variable_set(iv_, temp_.instance_variable_get(iv_))
|
224
209
|
end
|
225
210
|
else
|
226
|
-
raise ::TypeError,
|
211
|
+
raise ::TypeError, "Bad Marshal data"
|
227
212
|
end
|
228
213
|
end
|
229
214
|
|
230
|
-
|
231
215
|
# Psych support
|
232
216
|
|
233
|
-
def encode_with(coder_)
|
234
|
-
coder_[
|
217
|
+
def encode_with(coder_) # :nodoc:
|
218
|
+
coder_["wkt"] = to_wkt
|
235
219
|
end
|
236
220
|
|
237
|
-
def init_with(coder_)
|
238
|
-
temp_ = CS.create_from_wkt(coder_.type == :scalar ? coder_.scalar : coder_[
|
221
|
+
def init_with(coder_) # :nodoc:
|
222
|
+
temp_ = CS.create_from_wkt(coder_.type == :scalar ? coder_.scalar : coder_["wkt"])
|
239
223
|
if temp_.class == self.class
|
240
224
|
temp_.instance_variables.each do |iv_|
|
241
225
|
instance_variable_set(iv_, temp_.instance_variable_get(iv_))
|
242
226
|
end
|
243
227
|
else
|
244
|
-
raise ::TypeError,
|
228
|
+
raise ::TypeError, "Bad YAML data"
|
245
229
|
end
|
246
230
|
end
|
247
231
|
|
248
|
-
|
249
232
|
class << self
|
250
|
-
|
251
233
|
private :new
|
252
|
-
|
253
234
|
end
|
254
|
-
|
255
|
-
|
256
235
|
end
|
257
236
|
|
258
|
-
|
259
237
|
# == OGC spec description
|
260
238
|
#
|
261
239
|
# Details of axis. This is used to label axes, and indicate the
|
262
240
|
# orientation.
|
263
241
|
|
264
242
|
class AxisInfo < Base
|
265
|
-
|
266
243
|
# :stopdoc:
|
267
|
-
NAMES_BY_VALUE =
|
244
|
+
NAMES_BY_VALUE = %w(OTHER NORTH SOUTH EAST WEST UP DOWN)
|
268
245
|
# :startdoc:
|
269
246
|
|
270
|
-
def initialize(name_, orientation_)
|
247
|
+
def initialize(name_, orientation_) # :nodoc:
|
271
248
|
@name = name_
|
272
249
|
case orientation_
|
273
250
|
when ::String, ::Symbol
|
@@ -277,7 +254,6 @@ module RGeo
|
|
277
254
|
end
|
278
255
|
end
|
279
256
|
|
280
|
-
|
281
257
|
# Human readable name for axis. Possible values are "X", "Y",
|
282
258
|
# "Long", "Lat" or any other short string.
|
283
259
|
attr_reader :name
|
@@ -285,19 +261,15 @@ module RGeo
|
|
285
261
|
# Gets enumerated value for orientation.
|
286
262
|
attr_reader :orientation
|
287
263
|
|
288
|
-
|
289
|
-
def _wkt_typename # :nodoc:
|
264
|
+
def _wkt_typename # :nodoc:
|
290
265
|
"AXIS"
|
291
266
|
end
|
292
267
|
|
293
|
-
def _wkt_content(
|
268
|
+
def _wkt_content(_open_, _close_) # :nodoc:
|
294
269
|
[NAMES_BY_VALUE[@orientation]]
|
295
270
|
end
|
296
271
|
|
297
|
-
|
298
272
|
class << self
|
299
|
-
|
300
|
-
|
301
273
|
# Creates an AxisInfo. you must pass the human readable name for
|
302
274
|
# the axis (e.g. "X", "Y", "Long", "Lat", or other short string)
|
303
275
|
# and either an integer orientation code or a string. Possible
|
@@ -309,13 +281,9 @@ module RGeo
|
|
309
281
|
def create(name_, orientation_)
|
310
282
|
new(name_, orientation_)
|
311
283
|
end
|
312
|
-
|
313
|
-
|
314
284
|
end
|
315
|
-
|
316
285
|
end
|
317
286
|
|
318
|
-
|
319
287
|
# == OGC spec description
|
320
288
|
#
|
321
289
|
# A named projection parameter value. The linear units of
|
@@ -325,44 +293,34 @@ module RGeo
|
|
325
293
|
# system that the projected coordinate system is based on.
|
326
294
|
|
327
295
|
class ProjectionParameter < Base
|
328
|
-
|
329
|
-
def initialize(name_, value_) # :nodoc:
|
296
|
+
def initialize(name_, value_) # :nodoc:
|
330
297
|
@name = name_
|
331
298
|
@value = value_.to_f
|
332
299
|
end
|
333
300
|
|
334
|
-
|
335
301
|
# The parameter name.
|
336
302
|
attr_reader :name
|
337
303
|
|
338
304
|
# The parameter value.
|
339
305
|
attr_reader :value
|
340
306
|
|
341
|
-
|
342
|
-
def _wkt_typename # :nodoc:
|
307
|
+
def _wkt_typename # :nodoc:
|
343
308
|
"PARAMETER"
|
344
309
|
end
|
345
310
|
|
346
|
-
def _wkt_content(
|
311
|
+
def _wkt_content(_open_, _close_) # :nodoc:
|
347
312
|
[@value]
|
348
313
|
end
|
349
314
|
|
350
|
-
|
351
315
|
class << self
|
352
|
-
|
353
|
-
|
354
316
|
# Create a parameter given the name and value.
|
355
317
|
|
356
318
|
def create(name_, value_)
|
357
319
|
new(name_, value_)
|
358
320
|
end
|
359
|
-
|
360
|
-
|
361
321
|
end
|
362
|
-
|
363
322
|
end
|
364
323
|
|
365
|
-
|
366
324
|
# == OGC spec description
|
367
325
|
#
|
368
326
|
# Parameters for a geographic transformation into WGS84. The Bursa
|
@@ -371,8 +329,7 @@ module RGeo
|
|
371
329
|
# points East, and the Z axis points North.
|
372
330
|
|
373
331
|
class WGS84ConversionInfo < Base
|
374
|
-
|
375
|
-
def initialize(dx_, dy_, dz_, ex_, ey_, ez_, ppm_) # :nodoc:
|
332
|
+
def initialize(dx_, dy_, dz_, ex_, ey_, ez_, ppm_) # :nodoc:
|
376
333
|
@dx = dx_.to_f
|
377
334
|
@dy = dy_.to_f
|
378
335
|
@dz = dz_.to_f
|
@@ -382,7 +339,6 @@ module RGeo
|
|
382
339
|
@ppm = ppm_.to_f
|
383
340
|
end
|
384
341
|
|
385
|
-
|
386
342
|
# Bursa Wolf shift in meters.
|
387
343
|
attr_reader :dx
|
388
344
|
|
@@ -404,15 +360,11 @@ module RGeo
|
|
404
360
|
# Bursa Wolf scaling in in parts per million.
|
405
361
|
attr_reader :ppm
|
406
362
|
|
407
|
-
|
408
|
-
def _to_wkt(open_, close_) # :nodoc:
|
363
|
+
def _to_wkt(open_, close_) # :nodoc:
|
409
364
|
"TOWGS84#{open_}#{@dx},#{@dy},#{@dz},#{@ex},#{@ey},#{@ez},#{@ppm}#{close_}"
|
410
365
|
end
|
411
366
|
|
412
|
-
|
413
367
|
class << self
|
414
|
-
|
415
|
-
|
416
368
|
# Create the horizontal datum shift transformation into WGS84,
|
417
369
|
# given the seven Bursa Wolf parameters.
|
418
370
|
# The Bursa Wolf shift should be in meters, the rotation in arc
|
@@ -421,13 +373,9 @@ module RGeo
|
|
421
373
|
def create(dx_, dy_, dz_, ex_, ey_, ez_, ppm_)
|
422
374
|
new(dx_, dy_, dz_, ex_, ey_, ez_, ppm_)
|
423
375
|
end
|
424
|
-
|
425
|
-
|
426
376
|
end
|
427
|
-
|
428
377
|
end
|
429
378
|
|
430
|
-
|
431
379
|
# == OGC spec description
|
432
380
|
#
|
433
381
|
# A base interface for metadata applicable to coordinate system
|
@@ -468,8 +416,7 @@ module RGeo
|
|
468
416
|
# * <b>extensions</b>: a hash of extension keys and values
|
469
417
|
|
470
418
|
class Info < Base
|
471
|
-
|
472
|
-
def initialize(name_, authority_=nil, authority_code_=nil, abbreviation_=nil, alias_=nil, remarks_=nil, extensions_=nil) # :nodoc:
|
419
|
+
def initialize(name_, authority_ = nil, authority_code_ = nil, abbreviation_ = nil, alias_ = nil, remarks_ = nil, extensions_ = nil) # :nodoc:
|
473
420
|
@name = name_
|
474
421
|
@authority = authority_ ? authority_.to_s : nil
|
475
422
|
@authority_code = authority_code_ ? authority_code_.to_s : nil
|
@@ -478,11 +425,10 @@ module RGeo
|
|
478
425
|
@remarks = remarks_ ? remarks_.to_s : nil
|
479
426
|
@extensions = {}
|
480
427
|
if extensions_
|
481
|
-
extensions_.each{ |k_, v_| @extensions[k_.to_s] = v_.to_s }
|
428
|
+
extensions_.each { |k_, v_| @extensions[k_.to_s] = v_.to_s }
|
482
429
|
end
|
483
430
|
end
|
484
431
|
|
485
|
-
|
486
432
|
# Gets the abbreviation.
|
487
433
|
attr_reader :abbreviation
|
488
434
|
|
@@ -520,11 +466,8 @@ module RGeo
|
|
520
466
|
def extension(key_)
|
521
467
|
@extensions[key_.to_s]
|
522
468
|
end
|
523
|
-
|
524
|
-
|
525
469
|
end
|
526
470
|
|
527
|
-
|
528
471
|
# == OGC spec description
|
529
472
|
#
|
530
473
|
# Base interface for defining units.
|
@@ -536,31 +479,25 @@ module RGeo
|
|
536
479
|
# not clear whether the data refers to a LinearUnit or AngularUnit.
|
537
480
|
|
538
481
|
class Unit < Info
|
539
|
-
|
540
|
-
def initialize(name_, conversion_factor_, *optional_) # :nodoc:
|
482
|
+
def initialize(name_, conversion_factor_, *optional_) # :nodoc:
|
541
483
|
super(name_, *optional_)
|
542
484
|
@conversion_factor = conversion_factor_.to_f
|
543
485
|
end
|
544
486
|
|
545
|
-
|
546
487
|
# This field is not part of the OGC CT spec, but is part of the
|
547
488
|
# SFS. It is an alias of the appropriate field in the subclass,
|
548
489
|
# i.e. LinearUnit#meters_per_unit or AngularUnit#radians_per_unit.
|
549
490
|
attr_reader :conversion_factor
|
550
491
|
|
551
|
-
|
552
|
-
def _wkt_typename # :nodoc:
|
492
|
+
def _wkt_typename # :nodoc:
|
553
493
|
"UNIT"
|
554
494
|
end
|
555
495
|
|
556
|
-
def _wkt_content(
|
496
|
+
def _wkt_content(_open_, _close_) # :nodoc:
|
557
497
|
[@conversion_factor]
|
558
498
|
end
|
559
499
|
|
560
|
-
|
561
500
|
class << self
|
562
|
-
|
563
|
-
|
564
501
|
# Create a bare Unit that does not specify whether it is a
|
565
502
|
# LinearUnit or an AngularUnit, given a unit name and a
|
566
503
|
# conversion factor. You may also provide the optional
|
@@ -569,20 +506,14 @@ module RGeo
|
|
569
506
|
def create(name_, conversion_factor_, *optional_)
|
570
507
|
new(name_, conversion_factor_, *optional_)
|
571
508
|
end
|
572
|
-
|
573
|
-
|
574
509
|
end
|
575
|
-
|
576
510
|
end
|
577
511
|
|
578
|
-
|
579
512
|
# == OGC spec description
|
580
513
|
#
|
581
514
|
# Definition of linear units.
|
582
515
|
|
583
516
|
class LinearUnit < Unit
|
584
|
-
|
585
|
-
|
586
517
|
# Returns the number of meters per LinearUnit.
|
587
518
|
# Also available as Unit#conversion_factor.
|
588
519
|
|
@@ -590,10 +521,7 @@ module RGeo
|
|
590
521
|
@conversion_factor
|
591
522
|
end
|
592
523
|
|
593
|
-
|
594
524
|
class << self
|
595
|
-
|
596
|
-
|
597
525
|
# Create a LinearUnit given a unit name and a conversion factor
|
598
526
|
# in meters per unit. You may also provide the optional
|
599
527
|
# parameters specified by the Info interface.
|
@@ -601,20 +529,14 @@ module RGeo
|
|
601
529
|
def create(name_, meters_per_unit_, *optional_)
|
602
530
|
new(name_, meters_per_unit_, *optional_)
|
603
531
|
end
|
604
|
-
|
605
|
-
|
606
532
|
end
|
607
|
-
|
608
533
|
end
|
609
534
|
|
610
|
-
|
611
535
|
# == OGC spec description
|
612
536
|
#
|
613
537
|
# Definition of angular units.
|
614
538
|
|
615
539
|
class AngularUnit < Unit
|
616
|
-
|
617
|
-
|
618
540
|
# Returns the number of radians per AngularUnit.
|
619
541
|
# Also available as Unit#conversion_factor.
|
620
542
|
|
@@ -622,10 +544,7 @@ module RGeo
|
|
622
544
|
@conversion_factor
|
623
545
|
end
|
624
546
|
|
625
|
-
|
626
547
|
class << self
|
627
|
-
|
628
|
-
|
629
548
|
# Create an AngularUnit given a unit name and a conversion
|
630
549
|
# factor in radians per unit. You may also provide the optional
|
631
550
|
# parameters specified by the Info interface.
|
@@ -633,26 +552,20 @@ module RGeo
|
|
633
552
|
def create(name_, radians_per_unit_, *optional_)
|
634
553
|
new(name_, radians_per_unit_, *optional_)
|
635
554
|
end
|
636
|
-
|
637
|
-
|
638
555
|
end
|
639
|
-
|
640
556
|
end
|
641
557
|
|
642
|
-
|
643
558
|
# == OGC spec description
|
644
559
|
#
|
645
560
|
# A meridian used to take longitude measurements from.
|
646
561
|
|
647
562
|
class PrimeMeridian < Info
|
648
|
-
|
649
|
-
def initialize(name_, angular_unit_, longitude_, *optional_) # :nodoc:
|
563
|
+
def initialize(name_, angular_unit_, longitude_, *optional_) # :nodoc:
|
650
564
|
super(name_, *optional_)
|
651
565
|
@angular_unit = angular_unit_
|
652
566
|
@longitude = longitude_.to_f
|
653
567
|
end
|
654
568
|
|
655
|
-
|
656
569
|
# Returns the AngularUnits.
|
657
570
|
attr_reader :angular_unit
|
658
571
|
|
@@ -660,19 +573,15 @@ module RGeo
|
|
660
573
|
# The longitude is expressed in this objects angular units.
|
661
574
|
attr_reader :longitude
|
662
575
|
|
663
|
-
|
664
|
-
def _wkt_typename # :nodoc:
|
576
|
+
def _wkt_typename # :nodoc:
|
665
577
|
"PRIMEM"
|
666
578
|
end
|
667
579
|
|
668
|
-
def _wkt_content(
|
580
|
+
def _wkt_content(_open_, _close_) # :nodoc:
|
669
581
|
[@longitude]
|
670
582
|
end
|
671
583
|
|
672
|
-
|
673
584
|
class << self
|
674
|
-
|
675
|
-
|
676
585
|
# Create a PrimeMeridian given a name, AngularUnits, and the
|
677
586
|
# longitude relative to the Greenwich Meridian, expressed in
|
678
587
|
# the AngularUnits. You may also provide the optional parameters
|
@@ -681,21 +590,15 @@ module RGeo
|
|
681
590
|
def create(name_, angular_unit_, longitude_, *optional_)
|
682
591
|
new(name_, angular_unit_, longitude_, *optional_)
|
683
592
|
end
|
684
|
-
|
685
|
-
|
686
593
|
end
|
687
|
-
|
688
|
-
|
689
594
|
end
|
690
595
|
|
691
|
-
|
692
596
|
# == OGC spec description
|
693
597
|
#
|
694
598
|
# An approximation of the Earth's surface as a squashed sphere.
|
695
599
|
|
696
600
|
class Ellipsoid < Info
|
697
|
-
|
698
|
-
def initialize(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_) # :nodoc:
|
601
|
+
def initialize(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_) # :nodoc:
|
699
602
|
super(name_, *optional_)
|
700
603
|
@semi_major_axis = semi_major_axis_.to_f
|
701
604
|
@semi_minor_axis = semi_minor_axis_.to_f
|
@@ -704,7 +607,6 @@ module RGeo
|
|
704
607
|
@linear_unit = linear_unit_
|
705
608
|
end
|
706
609
|
|
707
|
-
|
708
610
|
# Gets the equatorial radius. The returned length is expressed in
|
709
611
|
# this object's axis units.
|
710
612
|
attr_reader :semi_major_axis
|
@@ -730,19 +632,15 @@ module RGeo
|
|
730
632
|
# semi-minor axis values.
|
731
633
|
attr_reader :axis_unit
|
732
634
|
|
733
|
-
|
734
|
-
def _wkt_typename # :nodoc:
|
635
|
+
def _wkt_typename # :nodoc:
|
735
636
|
"SPHEROID"
|
736
637
|
end
|
737
638
|
|
738
|
-
def _wkt_content(
|
639
|
+
def _wkt_content(_open_, _close_) # :nodoc:
|
739
640
|
[@semi_major_axis, @inverse_flattening]
|
740
641
|
end
|
741
642
|
|
742
|
-
|
743
643
|
class << self
|
744
|
-
|
745
|
-
|
746
644
|
# Create an Ellipsoid given a name, semi-major and semi-minor
|
747
645
|
# axes, the inverse flattening, a boolean indicating whether
|
748
646
|
# the inverse flattening is definitive, and the LinearUnit
|
@@ -754,7 +652,6 @@ module RGeo
|
|
754
652
|
new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_)
|
755
653
|
end
|
756
654
|
|
757
|
-
|
758
655
|
# Create an Ellipsoid given a name, semi-major and semi-minor
|
759
656
|
# axes, and the LinearUnit indicating the axis units. In the
|
760
657
|
# resulting ellipsoid, the inverse flattening is not definitive.
|
@@ -769,7 +666,6 @@ module RGeo
|
|
769
666
|
new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, false, linear_unit_, *optional_)
|
770
667
|
end
|
771
668
|
|
772
|
-
|
773
669
|
# Create an Ellipsoid given a name, semi-major axis, inverse
|
774
670
|
# flattening, and the LinearUnit indicating the axis units. In
|
775
671
|
# the resulting ellipsoid, the inverse flattening is definitive.
|
@@ -783,13 +679,9 @@ module RGeo
|
|
783
679
|
semi_minor_axis_ = semi_major_axis_ if semi_minor_axis_.infinite?
|
784
680
|
new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, true, linear_unit_, *optional_)
|
785
681
|
end
|
786
|
-
|
787
|
-
|
788
682
|
end
|
789
|
-
|
790
683
|
end
|
791
684
|
|
792
|
-
|
793
685
|
# == OGC spec description
|
794
686
|
#
|
795
687
|
# A set of quantities from which other quantities are calculated.
|
@@ -811,42 +703,33 @@ module RGeo
|
|
811
703
|
# LocalDatum.
|
812
704
|
|
813
705
|
class Datum < Info
|
814
|
-
|
815
|
-
def initialize(name_, datum_type_, *optional_) # :nodoc:
|
706
|
+
def initialize(name_, datum_type_, *optional_) # :nodoc:
|
816
707
|
super(name_, *optional_)
|
817
708
|
@datum_type = datum_type_.to_i
|
818
709
|
end
|
819
710
|
|
820
|
-
|
821
711
|
# Gets the type of the datum as an enumerated code.
|
822
712
|
attr_reader :datum_type
|
823
713
|
|
824
|
-
|
825
|
-
def _wkt_content(open_, close_) # :nodoc:
|
714
|
+
def _wkt_content(_open_, _close_) # :nodoc:
|
826
715
|
[]
|
827
716
|
end
|
828
|
-
|
829
|
-
|
830
717
|
end
|
831
718
|
|
832
|
-
|
833
719
|
# == OGC spec description
|
834
720
|
#
|
835
721
|
# Procedure used to measure vertical distances.
|
836
722
|
|
837
723
|
class VerticalDatum < Datum
|
838
|
-
|
839
|
-
def _wkt_typename # :nodoc:
|
724
|
+
def _wkt_typename # :nodoc:
|
840
725
|
"VERT_DATUM"
|
841
726
|
end
|
842
727
|
|
843
|
-
def _wkt_content(
|
728
|
+
def _wkt_content(_open_, _close_) # :nodoc:
|
844
729
|
[@datum_type]
|
845
730
|
end
|
846
731
|
|
847
732
|
class << self
|
848
|
-
|
849
|
-
|
850
733
|
# Create a VerticalDatum given a name and a datum type code.
|
851
734
|
# You may also provide the optional parameters specified by the
|
852
735
|
# Info interface.
|
@@ -854,13 +737,9 @@ module RGeo
|
|
854
737
|
def create(name_, datum_type_, *optional_)
|
855
738
|
new(name_, datum_type_, *optional_)
|
856
739
|
end
|
857
|
-
|
858
|
-
|
859
740
|
end
|
860
|
-
|
861
741
|
end
|
862
742
|
|
863
|
-
|
864
743
|
# == OGC spec description
|
865
744
|
#
|
866
745
|
# Local datum. If two local datum objects have the same datum type
|
@@ -870,18 +749,15 @@ module RGeo
|
|
870
749
|
# datum.
|
871
750
|
|
872
751
|
class LocalDatum < Datum
|
873
|
-
|
874
|
-
def _wkt_typename # :nodoc:
|
752
|
+
def _wkt_typename # :nodoc:
|
875
753
|
"LOCAL_DATUM"
|
876
754
|
end
|
877
755
|
|
878
|
-
def _wkt_content(
|
756
|
+
def _wkt_content(_open_, _close_) # :nodoc:
|
879
757
|
[@datum_type]
|
880
758
|
end
|
881
759
|
|
882
760
|
class << self
|
883
|
-
|
884
|
-
|
885
761
|
# Create a LocalDatum given a name and a datum type code. You
|
886
762
|
# may also provide the optional parameters specified by the
|
887
763
|
# Info interface.
|
@@ -889,26 +765,20 @@ module RGeo
|
|
889
765
|
def create(name_, datum_type_, *optional_)
|
890
766
|
new(name_, datum_type_, *optional_)
|
891
767
|
end
|
892
|
-
|
893
|
-
|
894
768
|
end
|
895
|
-
|
896
769
|
end
|
897
770
|
|
898
|
-
|
899
771
|
# == OGC spec description
|
900
772
|
#
|
901
773
|
# Procedure used to measure positions on the surface of the Earth.
|
902
774
|
|
903
775
|
class HorizontalDatum < Datum
|
904
|
-
|
905
|
-
def initialize(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_) # :nodoc:
|
776
|
+
def initialize(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_) # :nodoc:
|
906
777
|
super(name_, datum_type_, *optional_)
|
907
778
|
@ellipsoid = ellipsoid_
|
908
779
|
@wgs84_parameters = wgs84_parameters_
|
909
780
|
end
|
910
781
|
|
911
|
-
|
912
782
|
# Returns the Ellipsoid.
|
913
783
|
attr_reader :ellipsoid
|
914
784
|
|
@@ -917,21 +787,17 @@ module RGeo
|
|
917
787
|
# (ex,ey,ez) in arc-seconds, and scaling in parts-per-million.
|
918
788
|
attr_reader :wgs84_parameters
|
919
789
|
|
920
|
-
|
921
|
-
def _wkt_typename # :nodoc:
|
790
|
+
def _wkt_typename # :nodoc:
|
922
791
|
"DATUM"
|
923
792
|
end
|
924
793
|
|
925
|
-
def _wkt_content(open_, close_)
|
794
|
+
def _wkt_content(open_, close_) # :nodoc:
|
926
795
|
array_ = [@ellipsoid._to_wkt(open_, close_)]
|
927
796
|
array_ << @wgs84_parameters._to_wkt(open_, close_) if @wgs84_parameters
|
928
797
|
array_
|
929
798
|
end
|
930
799
|
|
931
|
-
|
932
800
|
class << self
|
933
|
-
|
934
|
-
|
935
801
|
# Create a HorizontalDatum given a name, datum type code,
|
936
802
|
# Ellipsoid, and WGS84ConversionInfo. The WGS84ConversionInfo
|
937
803
|
# is optional and may be set to nil. You may also provide the
|
@@ -940,64 +806,51 @@ module RGeo
|
|
940
806
|
def create(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_)
|
941
807
|
new(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_)
|
942
808
|
end
|
943
|
-
|
944
|
-
|
945
809
|
end
|
946
|
-
|
947
810
|
end
|
948
811
|
|
949
|
-
|
950
812
|
# == OGC spec description
|
951
813
|
#
|
952
814
|
# A projection from geographic coordinates to projected coordinates.
|
953
815
|
|
954
816
|
class Projection < Info
|
955
|
-
|
956
|
-
def initialize(name_, class_name_, parameters_, *optional_) # :nodoc:
|
817
|
+
def initialize(name_, class_name_, parameters_, *optional_) # :nodoc:
|
957
818
|
super(name_, *optional_)
|
958
819
|
@class_name = class_name_.to_s
|
959
820
|
@parameters = parameters_ ? parameters_.dup : []
|
960
821
|
end
|
961
822
|
|
962
|
-
|
963
823
|
# Gets the projection classification name
|
964
824
|
# (e.g. "Transverse_Mercator").
|
965
825
|
attr_reader :class_name
|
966
826
|
|
967
|
-
|
968
827
|
# Gets number of parameters of the projection.
|
969
828
|
|
970
829
|
def num_parameters
|
971
830
|
@parameters.size
|
972
831
|
end
|
973
832
|
|
974
|
-
|
975
833
|
# Gets an inexed parameter of the projection.
|
976
834
|
|
977
835
|
def get_parameter(index_)
|
978
836
|
@parameters[index_]
|
979
837
|
end
|
980
838
|
|
981
|
-
|
982
839
|
# Iterates over the parameters of the projection.
|
983
840
|
|
984
841
|
def each_parameter(&block_)
|
985
842
|
@parameters.each(&block_)
|
986
843
|
end
|
987
844
|
|
988
|
-
|
989
|
-
def _wkt_typename # :nodoc:
|
845
|
+
def _wkt_typename # :nodoc:
|
990
846
|
"PROJECTION"
|
991
847
|
end
|
992
848
|
|
993
|
-
def _wkt_content(
|
849
|
+
def _wkt_content(_open_, _close_) # :nodoc:
|
994
850
|
[]
|
995
851
|
end
|
996
852
|
|
997
|
-
|
998
853
|
class << self
|
999
|
-
|
1000
|
-
|
1001
854
|
# Create a Projection given a name, a projection class, and an
|
1002
855
|
# array of ProjectionParameter. You may also provide the
|
1003
856
|
# optional parameters specified by the Info interface.
|
@@ -1005,13 +858,9 @@ module RGeo
|
|
1005
858
|
def create(name_, class_name_, parameters_, *optional_)
|
1006
859
|
new(name_, class_name_, parameters_, *optional_)
|
1007
860
|
end
|
1008
|
-
|
1009
|
-
|
1010
861
|
end
|
1011
|
-
|
1012
862
|
end
|
1013
863
|
|
1014
|
-
|
1015
864
|
# == OGC spec description
|
1016
865
|
#
|
1017
866
|
# Base interface for all coordinate systems.
|
@@ -1042,36 +891,29 @@ module RGeo
|
|
1042
891
|
# CompoundCoordinateSystem.
|
1043
892
|
|
1044
893
|
class CoordinateSystem < Info
|
1045
|
-
|
1046
|
-
def initialize(name_, dimension_, *optional_) # :nodoc:
|
894
|
+
def initialize(name_, dimension_, *optional_) # :nodoc:
|
1047
895
|
super(name_, *optional_)
|
1048
896
|
@dimension = dimension_.to_i
|
1049
897
|
end
|
1050
898
|
|
1051
|
-
|
1052
899
|
# Dimension of the coordinate system
|
1053
900
|
attr_reader :dimension
|
1054
901
|
|
1055
|
-
|
1056
902
|
# Gets axis details for dimension within coordinate system. Each
|
1057
903
|
# dimension in the coordinate system has a corresponding axis.
|
1058
904
|
|
1059
|
-
def get_axis(
|
905
|
+
def get_axis(_dimension_)
|
1060
906
|
nil
|
1061
907
|
end
|
1062
908
|
|
1063
|
-
|
1064
909
|
# Gets units for dimension within coordinate system. Each
|
1065
910
|
# dimension in the coordinate system has corresponding units.
|
1066
911
|
|
1067
|
-
def get_units(
|
912
|
+
def get_units(_dimension_)
|
1068
913
|
nil
|
1069
914
|
end
|
1070
|
-
|
1071
|
-
|
1072
915
|
end
|
1073
916
|
|
1074
|
-
|
1075
917
|
# == OGC spec description
|
1076
918
|
#
|
1077
919
|
# An aggregate of two coordinate systems (CRS). One of these is
|
@@ -1081,21 +923,18 @@ module RGeo
|
|
1081
923
|
# coordinate system with a vertical datum.
|
1082
924
|
|
1083
925
|
class CompoundCoordinateSystem < CoordinateSystem
|
1084
|
-
|
1085
|
-
def initialize(name_, head_, tail_, *optional_) # :nodoc:
|
926
|
+
def initialize(name_, head_, tail_, *optional_) # :nodoc:
|
1086
927
|
super(name_, head_.dimension + tail_.dimension, *optional_)
|
1087
928
|
@head = head_
|
1088
929
|
@tail = tail_
|
1089
930
|
end
|
1090
931
|
|
1091
|
-
|
1092
932
|
# Gets first sub-coordinate system.
|
1093
933
|
attr_reader :head
|
1094
934
|
|
1095
935
|
# Gets second sub-coordinate system.
|
1096
936
|
attr_reader :tail
|
1097
937
|
|
1098
|
-
|
1099
938
|
# Implements CoordinateSystem#get_axis
|
1100
939
|
|
1101
940
|
def get_axis(index_)
|
@@ -1103,7 +942,6 @@ module RGeo
|
|
1103
942
|
index_ < hd_ ? @head.get_axis(index_) : @tail.get_axis(index_ - hd_)
|
1104
943
|
end
|
1105
944
|
|
1106
|
-
|
1107
945
|
# Implements CoordinateSystem#get_units
|
1108
946
|
|
1109
947
|
def get_units(index_)
|
@@ -1111,19 +949,15 @@ module RGeo
|
|
1111
949
|
index_ < hd_ ? @head.get_units(index_) : @tail.get_units(index_ - hd_)
|
1112
950
|
end
|
1113
951
|
|
1114
|
-
|
1115
|
-
def _wkt_typename # :nodoc:
|
952
|
+
def _wkt_typename # :nodoc:
|
1116
953
|
"COMPD_CS"
|
1117
954
|
end
|
1118
955
|
|
1119
|
-
def _wkt_content(open_, close_)
|
956
|
+
def _wkt_content(open_, close_) # :nodoc:
|
1120
957
|
[@head._to_wkt(open_, close_), @tail._to_wkt(open_, close_)]
|
1121
958
|
end
|
1122
959
|
|
1123
|
-
|
1124
960
|
class << self
|
1125
|
-
|
1126
|
-
|
1127
961
|
# Create a CompoundCoordinateSystem given two sub-coordinate
|
1128
962
|
# systems. You may also provide the optional parameters
|
1129
963
|
# specified by the Info interface.
|
@@ -1131,14 +965,9 @@ module RGeo
|
|
1131
965
|
def create(name_, head_, tail_, *optional_)
|
1132
966
|
new(name_, head_, tail_, *optional_)
|
1133
967
|
end
|
1134
|
-
|
1135
|
-
|
1136
968
|
end
|
1137
|
-
|
1138
|
-
|
1139
969
|
end
|
1140
970
|
|
1141
|
-
|
1142
971
|
# == OGC spec description
|
1143
972
|
#
|
1144
973
|
# A local coordinate system, with uncertain relationship to the
|
@@ -1159,45 +988,37 @@ module RGeo
|
|
1159
988
|
# Transformation (CT) package.
|
1160
989
|
|
1161
990
|
class LocalCoordinateSystem < CoordinateSystem
|
1162
|
-
|
1163
|
-
def initialize(name_, local_datum_, unit_, axes_, *optional_) # :nodoc:
|
991
|
+
def initialize(name_, local_datum_, unit_, axes_, *optional_) # :nodoc:
|
1164
992
|
super(name_, axes_.size, *optional_)
|
1165
993
|
@local_datum = local_datum_
|
1166
994
|
@unit = unit_
|
1167
995
|
@axes = axes_.dup
|
1168
996
|
end
|
1169
997
|
|
1170
|
-
|
1171
998
|
# Gets the local datum.
|
1172
999
|
attr_reader :local_datum
|
1173
1000
|
|
1174
|
-
|
1175
1001
|
# Implements CoordinateSystem#get_axis
|
1176
1002
|
|
1177
1003
|
def get_axis(index_)
|
1178
1004
|
@axes[index_]
|
1179
1005
|
end
|
1180
1006
|
|
1181
|
-
|
1182
1007
|
# Implements CoordinateSystem#get_units
|
1183
1008
|
|
1184
|
-
def get_units(
|
1009
|
+
def get_units(_index_)
|
1185
1010
|
@unit
|
1186
1011
|
end
|
1187
1012
|
|
1188
|
-
|
1189
|
-
def _wkt_typename # :nodoc:
|
1013
|
+
def _wkt_typename # :nodoc:
|
1190
1014
|
"LOCAL_CS"
|
1191
1015
|
end
|
1192
1016
|
|
1193
|
-
def _wkt_content(open_, close_)
|
1194
|
-
[@local_datum._to_wkt(open_, close_), @unit._to_wkt(open_, close_)] + @axes.map{ |ax_| ax_._to_wkt(open_, close_) }
|
1017
|
+
def _wkt_content(open_, close_) # :nodoc:
|
1018
|
+
[@local_datum._to_wkt(open_, close_), @unit._to_wkt(open_, close_)] + @axes.map { |ax_| ax_._to_wkt(open_, close_) }
|
1195
1019
|
end
|
1196
1020
|
|
1197
|
-
|
1198
1021
|
class << self
|
1199
|
-
|
1200
|
-
|
1201
1022
|
# Create a LocalCoordinateSystem given a name, a LocalDatum, a
|
1202
1023
|
# Unit, and an array of at least one AxisInfo. You may also
|
1203
1024
|
# provide the optional parameters specified by the Info
|
@@ -1206,13 +1027,9 @@ module RGeo
|
|
1206
1027
|
def create(name_, local_datum_, unit_, axes_, *optional_)
|
1207
1028
|
new(name_, local_datum_, unit_, axes_, *optional_)
|
1208
1029
|
end
|
1209
|
-
|
1210
|
-
|
1211
1030
|
end
|
1212
|
-
|
1213
1031
|
end
|
1214
1032
|
|
1215
|
-
|
1216
1033
|
# == OGC spec description
|
1217
1034
|
#
|
1218
1035
|
# A 3D coordinate system, with its origin at the centre of the
|
@@ -1223,8 +1040,7 @@ module RGeo
|
|
1223
1040
|
# non-default values.
|
1224
1041
|
|
1225
1042
|
class GeocentricCoordinateSystem < CoordinateSystem
|
1226
|
-
|
1227
|
-
def initialize(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_) # :nodoc:
|
1043
|
+
def initialize(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_) # :nodoc:
|
1228
1044
|
super(name_, 3, *optional_)
|
1229
1045
|
@horizontal_datum = horizontal_datum_
|
1230
1046
|
@prime_meridian = prime_meridian_
|
@@ -1234,7 +1050,6 @@ module RGeo
|
|
1234
1050
|
@axis2 = axis2_
|
1235
1051
|
end
|
1236
1052
|
|
1237
|
-
|
1238
1053
|
# Returns the HorizontalDatum. The horizontal datum is used to
|
1239
1054
|
# determine where the centre of the Earth is considered to be.
|
1240
1055
|
# All coordinate points will be measured from the centre of the
|
@@ -1247,26 +1062,23 @@ module RGeo
|
|
1247
1062
|
# Gets the units used along all the axes.
|
1248
1063
|
attr_reader :linear_unit
|
1249
1064
|
|
1250
|
-
|
1251
1065
|
# Implements CoordinateSystem#get_units
|
1252
1066
|
|
1253
|
-
def get_units(
|
1067
|
+
def get_units(_index_)
|
1254
1068
|
@linear_unit
|
1255
1069
|
end
|
1256
1070
|
|
1257
|
-
|
1258
1071
|
# Implements CoordinateSystem#get_axis
|
1259
1072
|
|
1260
1073
|
def get_axis(index_)
|
1261
1074
|
[@axis0, @axis1, @axis2][index_]
|
1262
1075
|
end
|
1263
1076
|
|
1264
|
-
|
1265
|
-
def _wkt_typename # :nodoc:
|
1077
|
+
def _wkt_typename # :nodoc:
|
1266
1078
|
"GEOCCS"
|
1267
1079
|
end
|
1268
1080
|
|
1269
|
-
def _wkt_content(open_, close_)
|
1081
|
+
def _wkt_content(open_, close_) # :nodoc:
|
1270
1082
|
arr_ = [@horizontal_datum._to_wkt(open_, close_), @prime_meridian._to_wkt(open_, close_), @linear_unit._to_wkt(open_, close_)]
|
1271
1083
|
arr_ << @axis0._to_wkt(open_, close_) if @axis0
|
1272
1084
|
arr_ << @axis1._to_wkt(open_, close_) if @axis1
|
@@ -1274,10 +1086,7 @@ module RGeo
|
|
1274
1086
|
arr_
|
1275
1087
|
end
|
1276
1088
|
|
1277
|
-
|
1278
1089
|
class << self
|
1279
|
-
|
1280
|
-
|
1281
1090
|
# Create a GeocentricCoordinateSystem given a name, a
|
1282
1091
|
# HorizontalDatum, a PrimeMeridian, a LinearUnit, and three
|
1283
1092
|
# AxisInfo objects. The AxisInfo are optional and may be nil.
|
@@ -1287,29 +1096,22 @@ module RGeo
|
|
1287
1096
|
def create(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_)
|
1288
1097
|
new(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_)
|
1289
1098
|
end
|
1290
|
-
|
1291
|
-
|
1292
1099
|
end
|
1293
|
-
|
1294
|
-
|
1295
1100
|
end
|
1296
1101
|
|
1297
|
-
|
1298
1102
|
# == OGC spec description
|
1299
1103
|
#
|
1300
1104
|
# A one-dimensional coordinate system suitable for vertical
|
1301
1105
|
# measurements.
|
1302
1106
|
|
1303
1107
|
class VerticalCoordinateSystem < CoordinateSystem
|
1304
|
-
|
1305
|
-
def initialize(name_, vertical_datum_, vertical_unit_, axis_, *optional_) # :nodoc:
|
1108
|
+
def initialize(name_, vertical_datum_, vertical_unit_, axis_, *optional_) # :nodoc:
|
1306
1109
|
super(name_, 1, *optional_)
|
1307
1110
|
@vertical_datum = vertical_datum_
|
1308
1111
|
@vertical_unit = vertical_unit_
|
1309
1112
|
@axis = axis_
|
1310
1113
|
end
|
1311
1114
|
|
1312
|
-
|
1313
1115
|
# Gets the vertical datum, which indicates the measurement method.
|
1314
1116
|
attr_reader :vertical_datum
|
1315
1117
|
|
@@ -1317,35 +1119,29 @@ module RGeo
|
|
1317
1119
|
# must be the same as the CS_CoordinateSystem units.
|
1318
1120
|
attr_reader :vertical_unit
|
1319
1121
|
|
1320
|
-
|
1321
1122
|
# Implements CoordinateSystem#get_units
|
1322
1123
|
|
1323
|
-
def get_units(
|
1124
|
+
def get_units(_index_)
|
1324
1125
|
@vertical_unit
|
1325
1126
|
end
|
1326
1127
|
|
1327
|
-
|
1328
1128
|
# Implements CoordinateSystem#get_axis
|
1329
1129
|
|
1330
|
-
def get_axis(
|
1130
|
+
def get_axis(_index_)
|
1331
1131
|
@axis
|
1332
1132
|
end
|
1333
1133
|
|
1334
|
-
|
1335
|
-
def _wkt_typename # :nodoc:
|
1134
|
+
def _wkt_typename # :nodoc:
|
1336
1135
|
"VERT_CS"
|
1337
1136
|
end
|
1338
1137
|
|
1339
|
-
def _wkt_content(open_, close_)
|
1138
|
+
def _wkt_content(open_, close_) # :nodoc:
|
1340
1139
|
arr_ = [@vertical_datum._to_wkt(open_, close_), @vertical_unit._to_wkt(open_, close_)]
|
1341
1140
|
arr_ << @axis._to_wkt(open_, close_) if @axis
|
1342
1141
|
arr_
|
1343
1142
|
end
|
1344
1143
|
|
1345
|
-
|
1346
1144
|
class << self
|
1347
|
-
|
1348
|
-
|
1349
1145
|
# Create a VerticalCoordinateSystem given a name, a
|
1350
1146
|
# VerticalDatum, a LinearUnit, and an AxisInfo. The AxisInfo is
|
1351
1147
|
# optional and may be nil. You may also provide the optional
|
@@ -1354,14 +1150,9 @@ module RGeo
|
|
1354
1150
|
def create(name_, vertical_datum_, vertical_unit_, axis_, *optional_)
|
1355
1151
|
new(name_, vertical_datum_, vertical_unit_, axis_, *optional_)
|
1356
1152
|
end
|
1357
|
-
|
1358
|
-
|
1359
1153
|
end
|
1360
|
-
|
1361
|
-
|
1362
1154
|
end
|
1363
1155
|
|
1364
|
-
|
1365
1156
|
# == OGC spec description
|
1366
1157
|
#
|
1367
1158
|
# A 2D coordinate system suitable for positions on the Earth's surface.
|
@@ -1373,20 +1164,15 @@ module RGeo
|
|
1373
1164
|
# ProjectedCoordinateSystem.
|
1374
1165
|
|
1375
1166
|
class HorizontalCoordinateSystem < CoordinateSystem
|
1376
|
-
|
1377
|
-
def initialize(name_, horizontal_datum_, *optional_) # :nodoc:
|
1167
|
+
def initialize(name_, horizontal_datum_, *optional_) # :nodoc:
|
1378
1168
|
super(name_, 2, *optional_)
|
1379
1169
|
@horizontal_datum = horizontal_datum_
|
1380
1170
|
end
|
1381
1171
|
|
1382
|
-
|
1383
1172
|
# Returns the HorizontalDatum.
|
1384
1173
|
attr_reader :horizontal_datum
|
1385
|
-
|
1386
|
-
|
1387
1174
|
end
|
1388
1175
|
|
1389
|
-
|
1390
1176
|
# == OGC spec description
|
1391
1177
|
#
|
1392
1178
|
# A coordinate system based on latitude and longitude. Some
|
@@ -1396,8 +1182,7 @@ module RGeo
|
|
1396
1182
|
# systems use degrees.
|
1397
1183
|
|
1398
1184
|
class GeographicCoordinateSystem < HorizontalCoordinateSystem
|
1399
|
-
|
1400
|
-
def initialize(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_) # :nodoc:
|
1185
|
+
def initialize(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_) # :nodoc:
|
1401
1186
|
super(name_, horizontal_datum_, *optional_)
|
1402
1187
|
@prime_meridian = prime_meridian_
|
1403
1188
|
@angular_unit = angular_unit_
|
@@ -1405,7 +1190,6 @@ module RGeo
|
|
1405
1190
|
@axis1 = axis1_
|
1406
1191
|
end
|
1407
1192
|
|
1408
|
-
|
1409
1193
|
# Returns the PrimeMeridian.
|
1410
1194
|
attr_reader :prime_meridian
|
1411
1195
|
|
@@ -1413,54 +1197,46 @@ module RGeo
|
|
1413
1197
|
# the CS_CoordinateSystem units.
|
1414
1198
|
attr_reader :angular_unit
|
1415
1199
|
|
1416
|
-
|
1417
1200
|
# Implements CoordinateSystem#get_units
|
1418
1201
|
|
1419
|
-
def get_units(
|
1202
|
+
def get_units(_index_)
|
1420
1203
|
@angular_unit
|
1421
1204
|
end
|
1422
1205
|
|
1423
|
-
|
1424
1206
|
# Implements CoordinateSystem#get_axis
|
1425
1207
|
|
1426
1208
|
def get_axis(index_)
|
1427
1209
|
index_ == 1 ? @axis1 : @axis0
|
1428
1210
|
end
|
1429
1211
|
|
1430
|
-
|
1431
1212
|
# Gets the number of available conversions to WGS84 coordinates.
|
1432
1213
|
|
1433
1214
|
def num_conversion_to_wgs84
|
1434
1215
|
@horizontal_datum.wgs84_parameters ? 1 : 0
|
1435
1216
|
end
|
1436
1217
|
|
1437
|
-
|
1438
1218
|
# Gets details on a conversion to WGS84. Some geographic
|
1439
1219
|
# coordinate systems provide several transformations into WGS84,
|
1440
1220
|
# which are designed to provide good accuracy in different areas
|
1441
1221
|
# of interest. The first conversion (with index=0) should provide
|
1442
1222
|
# acceptable accuracy over the largest possible area of interest.
|
1443
1223
|
|
1444
|
-
def get_wgs84_conversion_info(
|
1224
|
+
def get_wgs84_conversion_info(_index_)
|
1445
1225
|
@horizontal_datum.wgs84_parameters
|
1446
1226
|
end
|
1447
1227
|
|
1448
|
-
|
1449
|
-
def _wkt_typename # :nodoc:
|
1228
|
+
def _wkt_typename # :nodoc:
|
1450
1229
|
"GEOGCS"
|
1451
1230
|
end
|
1452
1231
|
|
1453
|
-
def _wkt_content(open_, close_)
|
1232
|
+
def _wkt_content(open_, close_) # :nodoc:
|
1454
1233
|
arr_ = [@horizontal_datum._to_wkt(open_, close_), @prime_meridian._to_wkt(open_, close_), @angular_unit._to_wkt(open_, close_)]
|
1455
1234
|
arr_ << @axis0._to_wkt(open_, close_) if @axis0
|
1456
1235
|
arr_ << @axis1._to_wkt(open_, close_) if @axis1
|
1457
1236
|
arr_
|
1458
1237
|
end
|
1459
1238
|
|
1460
|
-
|
1461
1239
|
class << self
|
1462
|
-
|
1463
|
-
|
1464
1240
|
# Create a GeographicCoordinateSystem, given a name, an
|
1465
1241
|
# AngularUnit, a HorizontalDatum, a PrimeMeridian, and two
|
1466
1242
|
# AxisInfo objects. The AxisInfo objects are optional and may
|
@@ -1470,21 +1246,15 @@ module RGeo
|
|
1470
1246
|
def create(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_)
|
1471
1247
|
new(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_)
|
1472
1248
|
end
|
1473
|
-
|
1474
|
-
|
1475
1249
|
end
|
1476
|
-
|
1477
|
-
|
1478
1250
|
end
|
1479
1251
|
|
1480
|
-
|
1481
1252
|
# == OGC spec description
|
1482
1253
|
#
|
1483
1254
|
# A 2D cartographic coordinate system.
|
1484
1255
|
|
1485
1256
|
class ProjectedCoordinateSystem < HorizontalCoordinateSystem
|
1486
|
-
|
1487
|
-
def initialize(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_) # :nodoc:
|
1257
|
+
def initialize(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_) # :nodoc:
|
1488
1258
|
super(name_, geographic_coordinate_system_.horizontal_datum, *optional_)
|
1489
1259
|
@geographic_coordinate_system = geographic_coordinate_system_
|
1490
1260
|
@projection = projection_
|
@@ -1493,7 +1263,6 @@ module RGeo
|
|
1493
1263
|
@axis1 = axis1_
|
1494
1264
|
end
|
1495
1265
|
|
1496
|
-
|
1497
1266
|
# Returns the GeographicCoordinateSystem.
|
1498
1267
|
attr_reader :geographic_coordinate_system
|
1499
1268
|
|
@@ -1504,38 +1273,32 @@ module RGeo
|
|
1504
1273
|
# the CS_CoordinateSystem units.
|
1505
1274
|
attr_reader :linear_unit
|
1506
1275
|
|
1507
|
-
|
1508
1276
|
# Implements CoordinateSystem#get_units
|
1509
1277
|
|
1510
|
-
def get_units(
|
1278
|
+
def get_units(_index_)
|
1511
1279
|
@linear_unit
|
1512
1280
|
end
|
1513
1281
|
|
1514
|
-
|
1515
1282
|
# Implements CoordinateSystem#get_axis
|
1516
1283
|
|
1517
1284
|
def get_axis(index_)
|
1518
1285
|
index_ == 1 ? @axis1 : @axis0
|
1519
1286
|
end
|
1520
1287
|
|
1521
|
-
|
1522
|
-
def _wkt_typename # :nodoc:
|
1288
|
+
def _wkt_typename # :nodoc:
|
1523
1289
|
"PROJCS"
|
1524
1290
|
end
|
1525
1291
|
|
1526
|
-
def _wkt_content(open_, close_)
|
1292
|
+
def _wkt_content(open_, close_) # :nodoc:
|
1527
1293
|
arr_ = [@geographic_coordinate_system._to_wkt(open_, close_), @projection._to_wkt(open_, close_)]
|
1528
|
-
@projection.each_parameter{ |param_| arr_ << param_._to_wkt(open_, close_) }
|
1294
|
+
@projection.each_parameter { |param_| arr_ << param_._to_wkt(open_, close_) }
|
1529
1295
|
arr_ << @linear_unit._to_wkt(open_, close_)
|
1530
1296
|
arr_ << @axis0._to_wkt(open_, close_) if @axis0
|
1531
1297
|
arr_ << @axis1._to_wkt(open_, close_) if @axis1
|
1532
1298
|
arr_
|
1533
1299
|
end
|
1534
1300
|
|
1535
|
-
|
1536
1301
|
class << self
|
1537
|
-
|
1538
|
-
|
1539
1302
|
# Create a ProjectedCoordinateSystem given a name, a
|
1540
1303
|
# GeographicCoordinateSystem, and Projection, a LinearUnit, and
|
1541
1304
|
# two AxisInfo objects. The AxisInfo objects are optional and
|
@@ -1545,17 +1308,8 @@ module RGeo
|
|
1545
1308
|
def create(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_)
|
1546
1309
|
new(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_)
|
1547
1310
|
end
|
1548
|
-
|
1549
|
-
|
1550
1311
|
end
|
1551
|
-
|
1552
|
-
|
1553
1312
|
end
|
1554
|
-
|
1555
|
-
|
1556
1313
|
end
|
1557
|
-
|
1558
|
-
|
1559
1314
|
end
|
1560
|
-
|
1561
1315
|
end
|