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,10 +5,7 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module CoordSys
|
10
|
-
|
11
|
-
|
12
9
|
# This module contains an implementation of the CS (coordinate
|
13
10
|
# systems) package of the OGC Coordinate Transform spec. It provides
|
14
11
|
# classes for representing ellipsoids, datums, coordinate systems,
|
@@ -31,8 +28,6 @@ module RGeo
|
|
31
28
|
# implemented.
|
32
29
|
|
33
30
|
module CS
|
34
|
-
|
35
|
-
|
36
31
|
# A class implementing the CS_CoordinateSystemFactory interface.
|
37
32
|
# It provides methods for building up complex objects from simpler
|
38
33
|
# objects or values.
|
@@ -42,8 +37,6 @@ module RGeo
|
|
42
37
|
# values, use the create methods for the object classes themselves.
|
43
38
|
|
44
39
|
class CoordinateSystemFactory
|
45
|
-
|
46
|
-
|
47
40
|
# Create a CompoundCoordinateSystem from a name, and two
|
48
41
|
# constituent coordinate systems.
|
49
42
|
|
@@ -51,7 +44,6 @@ module RGeo
|
|
51
44
|
CompoundCoordinateSystem.create(name_, head_, tail_)
|
52
45
|
end
|
53
46
|
|
54
|
-
|
55
47
|
# Create an Ellipsoid from a name, semi-major axis, and semi-minor
|
56
48
|
# axis. You can also provide a LinearUnit, but this is optional
|
57
49
|
# and may be set to nil.
|
@@ -60,7 +52,6 @@ module RGeo
|
|
60
52
|
Ellipsoid.create_ellipsoid(name_, semi_major_axis_, semi_minor_axis_, linear_unit_)
|
61
53
|
end
|
62
54
|
|
63
|
-
|
64
55
|
# Create an Ellipsoid from a name, semi-major axis, and an inverse
|
65
56
|
# flattening factor. You can also provide a LinearUnit, but this
|
66
57
|
# is optional and may be set to nil.
|
@@ -69,7 +60,6 @@ module RGeo
|
|
69
60
|
Ellipsoid.create_flattened_sphere(name_, semi_major_axis_, inverse_flattening_, linear_unit_)
|
70
61
|
end
|
71
62
|
|
72
|
-
|
73
63
|
# Create any object given the OGC WKT format. Raises
|
74
64
|
# Error::ParseError if a syntax error is encounterred.
|
75
65
|
|
@@ -77,7 +67,6 @@ module RGeo
|
|
77
67
|
WKTParser.new(str_).parse
|
78
68
|
end
|
79
69
|
|
80
|
-
|
81
70
|
# Create a GeographicCoordinateSystem, given a name, an
|
82
71
|
# AngularUnit, a HorizontalDatum, a PrimeMeridian, and two
|
83
72
|
# AxisInfo objects. The AxisInfo objects are optional and may be
|
@@ -87,7 +76,6 @@ module RGeo
|
|
87
76
|
GeographicCoordinateSystem.create(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_)
|
88
77
|
end
|
89
78
|
|
90
|
-
|
91
79
|
# Create a HorizontalDatum given a name, a horizontal datum type
|
92
80
|
# code, an Ellipsoid, and a WGS84ConversionInfo. The
|
93
81
|
# WGS84ConversionInfo is optional and may be set to nil.
|
@@ -96,7 +84,6 @@ module RGeo
|
|
96
84
|
HorizontalDatum.create(name_, horizontal_datum_type_, ellipsoid_, to_wgs84_)
|
97
85
|
end
|
98
86
|
|
99
|
-
|
100
87
|
# Create a LocalCoordinateSystem given a name, a LocalDatum, a
|
101
88
|
# Unit, and an array of at least one AxisInfo.
|
102
89
|
|
@@ -104,22 +91,19 @@ module RGeo
|
|
104
91
|
LocalCoordinateSystem.create(name_, datum_, unit_, axes_)
|
105
92
|
end
|
106
93
|
|
107
|
-
|
108
94
|
# Create a LocalDatum given a name and a local datum type code.
|
109
95
|
|
110
|
-
def create_local_datum(
|
96
|
+
def create_local_datum(_name_, local_datum_type_)
|
111
97
|
LocalDatum.create(name, local_datum_type_)
|
112
98
|
end
|
113
99
|
|
114
|
-
|
115
100
|
# Create a PrimeMeridian given a name, an AngularUnit, and a
|
116
101
|
# longitude offset.
|
117
102
|
|
118
|
-
def create_prime_meridian(
|
103
|
+
def create_prime_meridian(_name_, angular_unit_, longitude_)
|
119
104
|
PrimeMeridian.create(name, angular_unit_, longitude_)
|
120
105
|
end
|
121
106
|
|
122
|
-
|
123
107
|
# Create a ProjectedCoordinateSystem given a name, a
|
124
108
|
# GeographicCoordinateSystem, and Projection, a LinearUnit, and
|
125
109
|
# two AxisInfo objects. The AxisInfo objects are optional and may
|
@@ -129,7 +113,6 @@ module RGeo
|
|
129
113
|
ProjectedCoordinateSystem.create(name_, gcs_, projection_, linear_unit_, axis0_, axis1_)
|
130
114
|
end
|
131
115
|
|
132
|
-
|
133
116
|
# Create a Projection given a name, a projection class, and an
|
134
117
|
# array of ProjectionParameter.
|
135
118
|
|
@@ -137,7 +120,6 @@ module RGeo
|
|
137
120
|
Projection.create(name_, wkt_projection_class_, parameters_)
|
138
121
|
end
|
139
122
|
|
140
|
-
|
141
123
|
# Create a VerticalCoordinateSystem given a name, a VerticalDatum,
|
142
124
|
# a VerticalUnit, and an AxisInfo. The AxisInfo is optional and
|
143
125
|
# may be nil.
|
@@ -146,33 +128,21 @@ module RGeo
|
|
146
128
|
VerticalCoordinateSystem.create(name_, vertical_datum_, vertical_unit_, axis_)
|
147
129
|
end
|
148
130
|
|
149
|
-
|
150
131
|
# Create a VerticalDatum given a name ane a datum type code.
|
151
132
|
|
152
133
|
def create_vertical_datum(name_, vertical_datum_type_)
|
153
134
|
VerticalDatum.create(name_, vertical_datum_type_)
|
154
135
|
end
|
155
|
-
|
156
|
-
|
157
136
|
end
|
158
137
|
|
159
|
-
|
160
138
|
class << self
|
161
|
-
|
162
|
-
|
163
139
|
# Parsees OGC WKT format and returns the object created. Raises
|
164
140
|
# Error::ParseError if a syntax error is encounterred.
|
165
141
|
|
166
142
|
def create_from_wkt(str_)
|
167
143
|
WKTParser.new(str_).parse
|
168
144
|
end
|
169
|
-
|
170
|
-
|
171
145
|
end
|
172
|
-
|
173
|
-
|
174
146
|
end
|
175
|
-
|
176
147
|
end
|
177
|
-
|
178
148
|
end
|
@@ -5,31 +5,23 @@
|
|
5
5
|
# -----------------------------------------------------------------------------
|
6
6
|
|
7
7
|
module RGeo
|
8
|
-
|
9
8
|
module CoordSys
|
10
|
-
|
11
|
-
|
12
9
|
module CS
|
13
|
-
|
14
|
-
|
15
|
-
class WKTParser # :nodoc:
|
16
|
-
|
10
|
+
class WKTParser # :nodoc:
|
17
11
|
def initialize(str_)
|
18
12
|
@scanner = ::StringScanner.new(str_)
|
19
13
|
next_token
|
20
14
|
end
|
21
15
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@cur_token.
|
26
|
-
(containing_type_ == 'AXIS' && @cur_token.kind_of?(TypeString))
|
27
|
-
then
|
16
|
+
def parse(containing_type_ = nil) # :nodoc:
|
17
|
+
if @cur_token.is_a?(QuotedString) ||
|
18
|
+
@cur_token.is_a?(::Numeric) ||
|
19
|
+
(containing_type_ == "AXIS" && @cur_token.is_a?(TypeString))
|
28
20
|
value_ = @cur_token
|
29
21
|
next_token
|
30
22
|
return value_
|
31
23
|
end
|
32
|
-
unless @cur_token.
|
24
|
+
unless @cur_token.is_a?(TypeString)
|
33
25
|
raise Error::ParseError("Found token #{@cur_token} when we expected a value")
|
34
26
|
end
|
35
27
|
type_ = @cur_token
|
@@ -45,49 +37,49 @@ module RGeo
|
|
45
37
|
consume_token_type(:end)
|
46
38
|
obj_ = nil
|
47
39
|
case type_
|
48
|
-
when
|
40
|
+
when "AUTHORITY"
|
49
41
|
obj_ = AuthorityClause.new(args_.shift(QuotedString), args_.shift(QuotedString))
|
50
|
-
when
|
42
|
+
when "EXTENSION"
|
51
43
|
obj_ = ExtensionClause.new(args_.shift(QuotedString), args_.shift(QuotedString))
|
52
|
-
when
|
44
|
+
when "AXIS"
|
53
45
|
obj_ = AxisInfo.create(args_.shift(QuotedString), args_.shift(TypeString))
|
54
|
-
when
|
46
|
+
when "TOWGS84"
|
55
47
|
bursa_wolf_params_ = args_.find_all(::Numeric)
|
56
48
|
unless bursa_wolf_params_.size == 7
|
57
49
|
raise Error::ParseError("Expected 7 Bursa Wolf parameters but found #{bursa_wolf_params_.size}")
|
58
50
|
end
|
59
51
|
obj_ = WGS84ConversionInfo.create(*bursa_wolf_params_)
|
60
|
-
when
|
52
|
+
when "UNIT"
|
61
53
|
case containing_type_
|
62
|
-
when
|
54
|
+
when "GEOCCS", "VERT_CS", "PROJCS", "SPHEROID"
|
63
55
|
klass_ = LinearUnit
|
64
|
-
when
|
56
|
+
when "GEOGCS"
|
65
57
|
klass_ = AngularUnit
|
66
58
|
else
|
67
59
|
klass_ = Unit
|
68
60
|
end
|
69
61
|
obj_ = klass_.create(args_.shift(QuotedString), args_.shift(::Numeric), *args_.create_optionals)
|
70
|
-
when
|
62
|
+
when "PARAMETER"
|
71
63
|
obj_ = ProjectionParameter.create(args_.shift(QuotedString), args_.shift(::Numeric))
|
72
|
-
when
|
64
|
+
when "PRIMEM"
|
73
65
|
obj_ = PrimeMeridian.create(args_.shift(QuotedString), nil, args_.shift(::Numeric), *args_.create_optionals)
|
74
|
-
when
|
66
|
+
when "SPHEROID"
|
75
67
|
obj_ = Ellipsoid.create_flattened_sphere(args_.shift(QuotedString), args_.shift(::Numeric), args_.shift(::Numeric), args_.find_first(LinearUnit), *args_.create_optionals)
|
76
|
-
when
|
68
|
+
when "PROJECTION"
|
77
69
|
name_ = args_.shift(QuotedString)
|
78
70
|
obj_ = Projection.create(name_, name_, args_.find_all(ProjectionParameter), *args_.create_optionals)
|
79
|
-
when
|
71
|
+
when "DATUM"
|
80
72
|
name_ = args_.shift(QuotedString)
|
81
73
|
ellipsoid_ = args_.find_first(Ellipsoid)
|
82
74
|
to_wgs84_ = args_.find_first(WGS84ConversionInfo)
|
83
75
|
obj_ = HorizontalDatum.create(name_, HD_GEOCENTRIC, ellipsoid_, to_wgs84_, *args_.create_optionals)
|
84
|
-
when
|
76
|
+
when "VERT_DATUM"
|
85
77
|
obj_ = VerticalDatum.create(args_.shift(QuotedString), args_.shift(::Numeric), *args_.create_optionals)
|
86
|
-
when
|
78
|
+
when "LOCAL_DATUM"
|
87
79
|
obj_ = LocalDatum.create(args_.shift(QuotedString), args_.shift(::Numeric), *args_.create_optionals)
|
88
|
-
when
|
80
|
+
when "COMPD_CS"
|
89
81
|
obj_ = CompoundCoordinateSystem.create(args_.shift(QuotedString), args_.shift(CoordinateSystem), args_.shift(CoordinateSystem), *args_.create_optionals)
|
90
|
-
when
|
82
|
+
when "LOCAL_CS"
|
91
83
|
name_ = args_.shift(QuotedString)
|
92
84
|
local_datum_ = args_.find_first(LocalDatum)
|
93
85
|
unit_ = args_.find_first(Unit)
|
@@ -96,7 +88,7 @@ module RGeo
|
|
96
88
|
raise Error::ParseError("Expected at least one AXIS in a LOCAL_CS")
|
97
89
|
end
|
98
90
|
obj_ = LocalCoordinateSystem.create(name_, local_datum_, unit_, axes_, *args_.create_optionals)
|
99
|
-
when
|
91
|
+
when "GEOCCS"
|
100
92
|
name_ = args_.shift(QuotedString)
|
101
93
|
horizontal_datum_ = args_.find_first(HorizontalDatum)
|
102
94
|
prime_meridian_ = args_.find_first(PrimeMeridian)
|
@@ -106,13 +98,13 @@ module RGeo
|
|
106
98
|
raise Error::ParseError("GEOCCS must contain either 0 or 3 AXIS parameters")
|
107
99
|
end
|
108
100
|
obj_ = GeocentricCoordinateSystem.create(name_, horizontal_datum_, prime_meridian_, linear_unit_, axes_[0], axes_[1], axes_[2], *args_.create_optionals)
|
109
|
-
when
|
101
|
+
when "VERT_CS"
|
110
102
|
name_ = args_.shift(QuotedString)
|
111
103
|
vertical_datum_ = args_.find_first(VerticalDatum)
|
112
104
|
linear_unit_ = args_.find_first(LinearUnit)
|
113
105
|
axis_ = args_.find_first(AxisInfo)
|
114
106
|
obj_ = VerticalCoordinateSystem.create(name_, vertical_datum_, linear_unit_, axis_, *args_.create_optionals)
|
115
|
-
when
|
107
|
+
when "GEOGCS"
|
116
108
|
name_ = args_.shift(QuotedString)
|
117
109
|
horizontal_datum_ = args_.find_first(HorizontalDatum)
|
118
110
|
prime_meridian_ = args_.find_first(PrimeMeridian)
|
@@ -122,7 +114,7 @@ module RGeo
|
|
122
114
|
raise Error::ParseError("GEOGCS must contain either 0 or 2 AXIS parameters")
|
123
115
|
end
|
124
116
|
obj_ = GeographicCoordinateSystem.create(name_, angular_unit_, horizontal_datum_, prime_meridian_, axes_[0], axes_[1], *args_.create_optionals)
|
125
|
-
when
|
117
|
+
when "PROJCS"
|
126
118
|
name_ = args_.shift(QuotedString)
|
127
119
|
geographic_coordinate_system_ = args_.find_first(GeographicCoordinateSystem)
|
128
120
|
projection_ = args_.find_first(Projection)
|
@@ -141,39 +133,38 @@ module RGeo
|
|
141
133
|
obj_
|
142
134
|
end
|
143
135
|
|
144
|
-
|
145
|
-
def consume_token_type(type_) # :nodoc:
|
136
|
+
def consume_token_type(type_) # :nodoc:
|
146
137
|
expect_token_type(type_)
|
147
138
|
tok_ = @cur_token
|
148
139
|
next_token
|
149
140
|
tok_
|
150
141
|
end
|
151
142
|
|
152
|
-
def expect_token_type(type_)
|
143
|
+
def expect_token_type(type_) # :nodoc:
|
153
144
|
unless type_ === @cur_token
|
154
145
|
raise Error::ParseError, "#{type_.inspect} expected but #{@cur_token.inspect} found."
|
155
146
|
end
|
156
147
|
end
|
157
148
|
|
158
|
-
def next_token
|
149
|
+
def next_token # :nodoc:
|
159
150
|
@scanner.skip(/\s+/)
|
160
151
|
case @scanner.peek(1)
|
161
152
|
when '"'
|
162
153
|
@scanner.getch
|
163
154
|
@cur_token = QuotedString.new(@scanner.scan(/[^"]*/))
|
164
155
|
@scanner.getch
|
165
|
-
when
|
156
|
+
when ","
|
166
157
|
@scanner.getch
|
167
158
|
@cur_token = :comma
|
168
|
-
when
|
159
|
+
when "(", "["
|
169
160
|
@scanner.getch
|
170
161
|
@cur_token = :begin
|
171
|
-
when
|
162
|
+
when "]", ")"
|
172
163
|
@scanner.getch
|
173
164
|
@cur_token = :end
|
174
165
|
when /[a-zA-Z]/
|
175
166
|
@cur_token = TypeString.new(@scanner.scan(/[a-zA-Z]\w*/))
|
176
|
-
when
|
167
|
+
when "", nil
|
177
168
|
@cur_token = nil
|
178
169
|
else
|
179
170
|
@scanner.scan_until(/[^\s\(\)\[\],"]+/)
|
@@ -187,47 +178,36 @@ module RGeo
|
|
187
178
|
@cur_token
|
188
179
|
end
|
189
180
|
|
190
|
-
|
191
|
-
@cur_token
|
192
|
-
end
|
193
|
-
|
181
|
+
attr_reader :cur_token
|
194
182
|
|
195
|
-
class QuotedString < ::String
|
183
|
+
class QuotedString < ::String # :nodoc:
|
196
184
|
end
|
197
185
|
|
198
|
-
class TypeString < ::String
|
186
|
+
class TypeString < ::String # :nodoc:
|
199
187
|
end
|
200
188
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
def initialize(name_, code_) # :nodoc:
|
189
|
+
class AuthorityClause # :nodoc:
|
190
|
+
def initialize(name_, code_) # :nodoc:
|
205
191
|
@name = name_
|
206
192
|
@code = code_
|
207
193
|
end
|
208
194
|
|
209
|
-
def to_a
|
195
|
+
def to_a # :nodoc:
|
210
196
|
[@name, @code]
|
211
197
|
end
|
212
|
-
|
213
198
|
end
|
214
199
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
def initialize(key_, value_) # :nodoc:
|
200
|
+
class ExtensionClause # :nodoc:
|
201
|
+
def initialize(key_, value_) # :nodoc:
|
219
202
|
@key = key_
|
220
203
|
@value = value_
|
221
204
|
end
|
222
205
|
|
223
|
-
attr_reader :key
|
224
|
-
attr_reader :value
|
225
|
-
|
206
|
+
attr_reader :key # :nodoc:
|
207
|
+
attr_reader :value # :nodoc:
|
226
208
|
end
|
227
209
|
|
228
|
-
|
229
|
-
class ArgumentList # :nodoc:
|
230
|
-
|
210
|
+
class ArgumentList # :nodoc:
|
231
211
|
def initialize # :nodoc:
|
232
212
|
@values = []
|
233
213
|
end
|
@@ -236,18 +216,18 @@ module RGeo
|
|
236
216
|
@values << value_
|
237
217
|
end
|
238
218
|
|
239
|
-
def assert_empty
|
219
|
+
def assert_empty # :nodoc:
|
240
220
|
if @values.size > 0
|
241
221
|
names_ = @values.map do |val_|
|
242
|
-
val_.
|
222
|
+
val_.is_a?(Base) ? val_._wkt_typename : val_.inspect
|
243
223
|
end
|
244
224
|
raise Error::ParseError, "#{@values.size} unexpected arguments: #{names_.join(', ')}"
|
245
225
|
end
|
246
226
|
end
|
247
227
|
|
248
|
-
def find_first(klass_)
|
228
|
+
def find_first(klass_) # :nodoc:
|
249
229
|
@values.each_with_index do |val_, index_|
|
250
|
-
if val_.
|
230
|
+
if val_.is_a?(klass_)
|
251
231
|
@values.slice!(index_)
|
252
232
|
return val_
|
253
233
|
end
|
@@ -259,7 +239,7 @@ module RGeo
|
|
259
239
|
results_ = []
|
260
240
|
nvalues_ = []
|
261
241
|
@values.each do |val_|
|
262
|
-
if val_.
|
242
|
+
if val_.is_a?(klass_)
|
263
243
|
results_ << val_
|
264
244
|
else
|
265
245
|
nvalues_ << val_
|
@@ -271,30 +251,22 @@ module RGeo
|
|
271
251
|
|
272
252
|
def create_optionals # :nodoc:
|
273
253
|
hash_ = {}
|
274
|
-
find_all(ExtensionClause).each{ |ec_| hash_[ec_.key] = ec_.value }
|
254
|
+
find_all(ExtensionClause).each { |ec_| hash_[ec_.key] = ec_.value }
|
275
255
|
(find_first(AuthorityClause) || [nil, nil]).to_a + [nil, nil, nil, hash_]
|
276
256
|
end
|
277
257
|
|
278
|
-
def shift(klass_=nil)
|
258
|
+
def shift(klass_ = nil) # :nodoc:
|
279
259
|
val_ = @values.shift
|
280
260
|
unless val_
|
281
261
|
raise Error::ParseError, "No arguments left... expected #{klass_}"
|
282
262
|
end
|
283
|
-
if klass_ && !val_.
|
263
|
+
if klass_ && !val_.is_a?(klass_)
|
284
264
|
raise Error::ParseError, "Expected #{klass_} but got #{val_.class}"
|
285
265
|
end
|
286
266
|
val_
|
287
267
|
end
|
288
|
-
|
289
268
|
end
|
290
|
-
|
291
|
-
|
292
269
|
end
|
293
|
-
|
294
|
-
|
295
270
|
end
|
296
|
-
|
297
|
-
|
298
271
|
end
|
299
|
-
|
300
272
|
end
|