rgeo 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. data/History.rdoc +6 -0
  2. data/README.rdoc +1 -1
  3. data/Version +1 -1
  4. data/ext/geos_c_impl/extconf.rb +13 -13
  5. data/ext/geos_c_impl/factory.c +30 -18
  6. data/ext/geos_c_impl/factory.h +18 -12
  7. data/ext/geos_c_impl/geometry.c +11 -11
  8. data/ext/geos_c_impl/geometry.h +7 -7
  9. data/ext/geos_c_impl/geometry_collection.c +15 -15
  10. data/ext/geos_c_impl/geometry_collection.h +8 -8
  11. data/ext/geos_c_impl/line_string.c +14 -14
  12. data/ext/geos_c_impl/line_string.h +7 -7
  13. data/ext/geos_c_impl/main.c +7 -7
  14. data/ext/geos_c_impl/point.c +9 -9
  15. data/ext/geos_c_impl/point.h +7 -7
  16. data/ext/geos_c_impl/polygon.c +9 -9
  17. data/ext/geos_c_impl/polygon.h +7 -7
  18. data/ext/geos_c_impl/preface.h +7 -7
  19. data/ext/proj4_c_impl/extconf.rb +13 -13
  20. data/ext/proj4_c_impl/main.c +12 -12
  21. data/lib/rgeo.rb +26 -26
  22. data/lib/rgeo/cartesian.rb +12 -12
  23. data/lib/rgeo/cartesian/analysis.rb +26 -26
  24. data/lib/rgeo/cartesian/bounding_box.rb +83 -83
  25. data/lib/rgeo/cartesian/calculations.rb +36 -36
  26. data/lib/rgeo/cartesian/factory.rb +78 -78
  27. data/lib/rgeo/cartesian/feature_classes.rb +74 -74
  28. data/lib/rgeo/cartesian/feature_methods.rb +34 -34
  29. data/lib/rgeo/cartesian/interface.rb +33 -33
  30. data/lib/rgeo/coord_sys.rb +15 -15
  31. data/lib/rgeo/coord_sys/cs/entities.rb +533 -534
  32. data/lib/rgeo/coord_sys/cs/factories.rb +69 -69
  33. data/lib/rgeo/coord_sys/cs/wkt_parser.rb +44 -44
  34. data/lib/rgeo/coord_sys/proj4.rb +85 -85
  35. data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +31 -31
  36. data/lib/rgeo/coord_sys/srs_database/interface.rb +44 -44
  37. data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +31 -31
  38. data/lib/rgeo/coord_sys/srs_database/sr_org.rb +31 -31
  39. data/lib/rgeo/coord_sys/srs_database/url_reader.rb +29 -29
  40. data/lib/rgeo/error.rb +17 -17
  41. data/lib/rgeo/feature.rb +15 -15
  42. data/lib/rgeo/feature/curve.rb +58 -58
  43. data/lib/rgeo/feature/factory.rb +84 -84
  44. data/lib/rgeo/feature/factory_generator.rb +32 -32
  45. data/lib/rgeo/feature/geometry.rb +215 -215
  46. data/lib/rgeo/feature/geometry_collection.rb +46 -46
  47. data/lib/rgeo/feature/line.rb +21 -21
  48. data/lib/rgeo/feature/line_string.rb +35 -35
  49. data/lib/rgeo/feature/linear_ring.rb +20 -20
  50. data/lib/rgeo/feature/mixins.rb +61 -61
  51. data/lib/rgeo/feature/multi_curve.rb +37 -37
  52. data/lib/rgeo/feature/multi_line_string.rb +20 -20
  53. data/lib/rgeo/feature/multi_point.rb +22 -22
  54. data/lib/rgeo/feature/multi_polygon.rb +28 -28
  55. data/lib/rgeo/feature/multi_surface.rb +39 -39
  56. data/lib/rgeo/feature/point.rb +42 -42
  57. data/lib/rgeo/feature/polygon.rb +50 -50
  58. data/lib/rgeo/feature/surface.rb +42 -42
  59. data/lib/rgeo/feature/types.rb +58 -58
  60. data/lib/rgeo/geographic.rb +14 -14
  61. data/lib/rgeo/geographic/factory.rb +87 -87
  62. data/lib/rgeo/geographic/interface.rb +55 -55
  63. data/lib/rgeo/geographic/proj4_projector.rb +35 -35
  64. data/lib/rgeo/geographic/projected_feature_classes.rb +95 -95
  65. data/lib/rgeo/geographic/projected_feature_methods.rb +81 -81
  66. data/lib/rgeo/geographic/projected_window.rb +103 -103
  67. data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -32
  68. data/lib/rgeo/geographic/spherical_feature_classes.rb +93 -93
  69. data/lib/rgeo/geographic/spherical_feature_methods.rb +25 -25
  70. data/lib/rgeo/geographic/spherical_math.rb +58 -58
  71. data/lib/rgeo/geos.rb +22 -17
  72. data/lib/rgeo/geos/factory.rb +93 -93
  73. data/lib/rgeo/geos/ffi_classes.rb +306 -231
  74. data/lib/rgeo/geos/ffi_factory.rb +100 -96
  75. data/lib/rgeo/geos/impl_additions.rb +22 -22
  76. data/lib/rgeo/geos/interface.rb +45 -45
  77. data/lib/rgeo/geos/zm_factory.rb +90 -90
  78. data/lib/rgeo/geos/zm_impl.rb +167 -167
  79. data/lib/rgeo/impl_helper.rb +11 -11
  80. data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +71 -71
  81. data/lib/rgeo/impl_helper/basic_geometry_methods.rb +29 -29
  82. data/lib/rgeo/impl_helper/basic_line_string_methods.rb +61 -61
  83. data/lib/rgeo/impl_helper/basic_point_methods.rb +43 -43
  84. data/lib/rgeo/impl_helper/basic_polygon_methods.rb +35 -35
  85. data/lib/rgeo/impl_helper/math.rb +13 -13
  86. data/lib/rgeo/version.rb +10 -10
  87. data/lib/rgeo/wkrep.rb +16 -16
  88. data/lib/rgeo/wkrep/wkb_generator.rb +51 -51
  89. data/lib/rgeo/wkrep/wkb_parser.rb +52 -52
  90. data/lib/rgeo/wkrep/wkt_generator.rb +51 -51
  91. data/lib/rgeo/wkrep/wkt_parser.rb +66 -66
  92. data/lib/rgeo/yaml.rb +14 -14
  93. data/test/common/geometry_collection_tests.rb +53 -53
  94. data/test/common/line_string_tests.rb +57 -57
  95. data/test/common/multi_line_string_tests.rb +43 -43
  96. data/test/common/multi_point_tests.rb +43 -43
  97. data/test/common/multi_polygon_tests.rb +43 -43
  98. data/test/common/point_tests.rb +75 -75
  99. data/test/common/polygon_tests.rb +37 -37
  100. data/test/coord_sys/tc_active_record_table.rb +25 -25
  101. data/test/coord_sys/tc_ogc_cs.rb +72 -72
  102. data/test/coord_sys/tc_proj4.rb +51 -51
  103. data/test/coord_sys/tc_proj4_srs_data.rb +17 -17
  104. data/test/coord_sys/tc_sr_org.rb +15 -15
  105. data/test/coord_sys/tc_url_reader.rb +19 -19
  106. data/test/geos_capi/tc_factory.rb +21 -21
  107. data/test/geos_capi/tc_geometry_collection.rb +15 -15
  108. data/test/geos_capi/tc_line_string.rb +15 -15
  109. data/test/geos_capi/tc_misc.rb +33 -22
  110. data/test/geos_capi/tc_multi_line_string.rb +15 -15
  111. data/test/geos_capi/tc_multi_point.rb +15 -15
  112. data/test/geos_capi/tc_multi_polygon.rb +15 -15
  113. data/test/geos_capi/tc_parsing_unparsing.rb +19 -19
  114. data/test/geos_capi/tc_point.rb +21 -21
  115. data/test/geos_capi/tc_polygon.rb +19 -19
  116. data/test/geos_capi/tc_zmfactory.rb +17 -17
  117. data/test/geos_ffi/tc_factory.rb +21 -21
  118. data/test/geos_ffi/tc_geometry_collection.rb +15 -15
  119. data/test/geos_ffi/tc_line_string.rb +15 -15
  120. data/test/geos_ffi/tc_misc.rb +49 -15
  121. data/test/geos_ffi/tc_multi_line_string.rb +15 -15
  122. data/test/geos_ffi/tc_multi_point.rb +15 -15
  123. data/test/geos_ffi/tc_multi_polygon.rb +15 -15
  124. data/test/geos_ffi/tc_parsing_unparsing.rb +19 -19
  125. data/test/geos_ffi/tc_point.rb +21 -21
  126. data/test/geos_ffi/tc_polygon.rb +19 -19
  127. data/test/geos_ffi/tc_zmfactory.rb +17 -17
  128. data/test/projected_geographic/tc_geometry_collection.rb +15 -15
  129. data/test/projected_geographic/tc_line_string.rb +15 -15
  130. data/test/projected_geographic/tc_multi_line_string.rb +15 -15
  131. data/test/projected_geographic/tc_multi_point.rb +15 -15
  132. data/test/projected_geographic/tc_multi_polygon.rb +15 -15
  133. data/test/projected_geographic/tc_point.rb +23 -23
  134. data/test/projected_geographic/tc_polygon.rb +15 -15
  135. data/test/simple_cartesian/tc_calculations.rb +31 -31
  136. data/test/simple_cartesian/tc_geometry_collection.rb +17 -17
  137. data/test/simple_cartesian/tc_line_string.rb +17 -17
  138. data/test/simple_cartesian/tc_multi_line_string.rb +17 -17
  139. data/test/simple_cartesian/tc_multi_point.rb +17 -17
  140. data/test/simple_cartesian/tc_multi_polygon.rb +17 -17
  141. data/test/simple_cartesian/tc_point.rb +21 -21
  142. data/test/simple_cartesian/tc_polygon.rb +17 -17
  143. data/test/simple_mercator/tc_geometry_collection.rb +15 -15
  144. data/test/simple_mercator/tc_line_string.rb +15 -15
  145. data/test/simple_mercator/tc_multi_line_string.rb +15 -15
  146. data/test/simple_mercator/tc_multi_point.rb +15 -15
  147. data/test/simple_mercator/tc_multi_polygon.rb +15 -15
  148. data/test/simple_mercator/tc_point.rb +23 -23
  149. data/test/simple_mercator/tc_polygon.rb +15 -15
  150. data/test/simple_mercator/tc_window.rb +50 -50
  151. data/test/spherical_geographic/tc_calculations.rb +47 -47
  152. data/test/spherical_geographic/tc_geometry_collection.rb +17 -17
  153. data/test/spherical_geographic/tc_line_string.rb +17 -17
  154. data/test/spherical_geographic/tc_multi_line_string.rb +17 -17
  155. data/test/spherical_geographic/tc_multi_point.rb +17 -17
  156. data/test/spherical_geographic/tc_multi_polygon.rb +17 -17
  157. data/test/spherical_geographic/tc_point.rb +23 -23
  158. data/test/spherical_geographic/tc_polygon.rb +17 -17
  159. data/test/tc_cartesian_analysis.rb +23 -23
  160. data/test/tc_mixins.rb +39 -39
  161. data/test/tc_oneoff.rb +15 -15
  162. data/test/tc_types.rb +17 -17
  163. data/test/wkrep/tc_wkb_generator.rb +67 -67
  164. data/test/wkrep/tc_wkb_parser.rb +73 -73
  165. data/test/wkrep/tc_wkt_generator.rb +75 -75
  166. data/test/wkrep/tc_wkt_parser.rb +97 -97
  167. metadata +3 -3
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Cartesian common methods
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,29 +35,29 @@
35
35
 
36
36
 
37
37
  module RGeo
38
-
38
+
39
39
  module Cartesian
40
-
41
-
40
+
41
+
42
42
  module GeometryMethods # :nodoc:
43
-
44
-
43
+
44
+
45
45
  def srid
46
46
  factory.srid
47
47
  end
48
-
49
-
48
+
49
+
50
50
  def envelope
51
51
  BoundingBox.new(factory).add(self).to_geometry
52
52
  end
53
-
54
-
53
+
54
+
55
55
  end
56
-
57
-
56
+
57
+
58
58
  module PointMethods # :nodoc:
59
-
60
-
59
+
60
+
61
61
  def distance(rhs_)
62
62
  rhs_ = ::RGeo::Feature.cast(rhs_, @factory)
63
63
  case rhs_
@@ -69,14 +69,14 @@ module RGeo
69
69
  super
70
70
  end
71
71
  end
72
-
73
-
72
+
73
+
74
74
  end
75
-
76
-
75
+
76
+
77
77
  module LineStringMethods # :nodoc:
78
-
79
-
78
+
79
+
80
80
  def _segments
81
81
  unless @segments
82
82
  @segments = (0..num_points-2).map do |i_|
@@ -85,8 +85,8 @@ module RGeo
85
85
  end
86
86
  @segments
87
87
  end
88
-
89
-
88
+
89
+
90
90
  def is_simple?
91
91
  segs_ = _segments
92
92
  len_ = segs_.length
@@ -111,15 +111,15 @@ module RGeo
111
111
  end
112
112
  true
113
113
  end
114
-
115
-
114
+
115
+
116
116
  def length
117
117
  @segments.inject(0.0){ |sum_, seg_| sum_ + seg_.length }
118
118
  end
119
-
120
-
119
+
120
+
121
121
  end
122
-
122
+
123
123
  end
124
-
124
+
125
125
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Cartesian toplevel interface
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,15 +35,15 @@
35
35
 
36
36
 
37
37
  module RGeo
38
-
38
+
39
39
  module Cartesian
40
-
40
+
41
41
  class << self
42
-
43
-
42
+
43
+
44
44
  # Creates and returns a cartesian factory of the preferred
45
45
  # Cartesian implementation.
46
- #
46
+ #
47
47
  # The actual implementation returned depends on which ruby
48
48
  # interpreter is running and what libraries are available.
49
49
  # RGeo will try to provide a fully-functional and performant
@@ -51,13 +51,13 @@ module RGeo
51
51
  # implementation will be returned.
52
52
  # In practice, this means it returns a Geos implementation if
53
53
  # available; otherwise it falls back to the simple implementation.
54
- #
54
+ #
55
55
  # The given options are passed to the factory's constructor.
56
56
  # What options are available depends on the particular
57
57
  # implementation. See RGeo::Geos.factory and
58
58
  # RGeo::Cartesian.simple_factory for details. Unsupported options
59
59
  # are ignored.
60
-
60
+
61
61
  def preferred_factory(opts_={})
62
62
  if ::RGeo::Geos.supported?
63
63
  ::RGeo::Geos.factory(opts_)
@@ -66,14 +66,14 @@ module RGeo
66
66
  end
67
67
  end
68
68
  alias_method :factory, :preferred_factory
69
-
70
-
69
+
70
+
71
71
  # Returns a factory for the simple Cartesian implementation. This
72
72
  # implementation provides all SFS 1.1 types, and also allows Z and
73
73
  # M coordinates. It does not depend on external libraries, and is
74
74
  # thus always available, but it does not implement many of the more
75
75
  # advanced geometric operations. These limitations are:
76
- #
76
+ #
77
77
  # * Relational operators such as Feature::Geometry#intersects? are
78
78
  # not implemented for most types.
79
79
  # * Relational constructors such as Feature::Geometry#union are
@@ -85,12 +85,12 @@ module RGeo
85
85
  # * Equality and simplicity evaluation are implemented for some but
86
86
  # not all types.
87
87
  # * Assertions for polygons and multipolygons are not implemented.
88
- #
88
+ #
89
89
  # Unimplemented operations may raise Error::UnsupportedOperation
90
90
  # if invoked.
91
- #
91
+ #
92
92
  # Options include:
93
- #
93
+ #
94
94
  # [<tt>:srid</tt>]
95
95
  # Set the SRID returned by geometries created by this factory.
96
96
  # Default is 0.
@@ -130,41 +130,41 @@ module RGeo
130
130
  # configuration parameters for WKRep::WKTGenerator.new.
131
131
  # Default is the empty hash, indicating the default configuration
132
132
  # for WKRep::WKBGenerator.
133
-
133
+
134
134
  def simple_factory(opts_={})
135
135
  Cartesian::Factory.new(opts_)
136
136
  end
137
-
138
-
137
+
138
+
139
139
  # Returns a Feature::FactoryGenerator that creates preferred
140
140
  # factories. The given options are used as the default options.
141
- #
141
+ #
142
142
  # A common case for this is to provide the <tt>:srs_database</tt>
143
143
  # as a default. Then, the factory generator need only be passed
144
144
  # an SRID and it will automatically fetch the appropriate Proj4
145
145
  # and CoordSys objects.
146
-
146
+
147
147
  def preferred_factory_generator(defaults_={})
148
148
  ::Proc.new{ |c_| preferred_factory(defaults_.merge(c_)) }
149
149
  end
150
150
  alias_method :factory_generator, :preferred_factory_generator
151
-
152
-
151
+
152
+
153
153
  # Returns a Feature::FactoryGenerator that creates simple factories.
154
154
  # The given options are used as the default options.
155
- #
155
+ #
156
156
  # A common case for this is to provide the <tt>:srs_database</tt>
157
157
  # as a default. Then, the factory generator need only be passed
158
158
  # an SRID and it will automatically fetch the appropriate Proj4
159
159
  # and CoordSys objects.
160
-
160
+
161
161
  def simple_factory_generator(defaults_={})
162
162
  ::Proc.new{ |c_| simple_factory(defaults_.merge(c_)) }
163
163
  end
164
-
165
-
164
+
165
+
166
166
  end
167
-
167
+
168
168
  end
169
-
169
+
170
170
  end
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Coordinate systems for RGeo
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
- # Copyright 2010 Daniel Azuma
7
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,32 +35,32 @@
35
35
 
36
36
 
37
37
  module RGeo
38
-
39
-
38
+
39
+
40
40
  # This module provides data structures and tools related to coordinate
41
41
  # systems and coordinate transforms. It comprises the following parts:
42
- #
42
+ #
43
43
  # RGeo::CoordSys::Proj4 is a wrapper around the proj4 library, which
44
44
  # defines a commonly-used syntax for specifying geographic and projected
45
45
  # coordinate systems, and performs coordinate transformations.
46
- #
46
+ #
47
47
  # The RGeo::CoordSys::CS module contains an implementation of the CS
48
48
  # (coordinate systems) package of the OGC Coordinate Transform spec.
49
49
  # This includes classes for representing ellipsoids, datums, coordinate
50
50
  # systems, and other related concepts, as well as a parser for the WKT
51
51
  # format for specifying coordinate systems.
52
- #
52
+ #
53
53
  # The RGeo::CoordSys::SRSDatabase module contains tools for accessing
54
54
  # spatial reference databases, from which you can look up coordinate
55
55
  # system specifications. You can access the <tt>spatial_ref_sys</tt>
56
56
  # table provided with OGC-compliant spatial databases such as PostGIS,
57
57
  # read the databases provided with the proj4 library, or access URLs
58
58
  # such as those provided by spatialreference.org.
59
-
59
+
60
60
  module CoordSys
61
61
  end
62
-
63
-
62
+
63
+
64
64
  end
65
65
 
66
66
 
@@ -1,16 +1,15 @@
1
- # -*- coding: utf-8 -*-
2
1
  # -----------------------------------------------------------------------------
3
- #
2
+ #
4
3
  # OGC CS objects for RGeo
5
- #
4
+ #
6
5
  # -----------------------------------------------------------------------------
7
- # Copyright 2010 Daniel Azuma
8
- #
6
+ # Copyright 2010-2012 Daniel Azuma
7
+ #
9
8
  # All rights reserved.
10
- #
9
+ #
11
10
  # Redistribution and use in source and binary forms, with or without
12
11
  # modification, are permitted provided that the following conditions are met:
13
- #
12
+ #
14
13
  # * Redistributions of source code must retain the above copyright notice,
15
14
  # this list of conditions and the following disclaimer.
16
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -19,7 +18,7 @@
19
18
  # * Neither the name of the copyright holder, nor the names of any other
20
19
  # contributors to this software, may be used to endorse or promote products
21
20
  # derived from this software without specific prior written permission.
22
- #
21
+ #
23
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -36,57 +35,57 @@
36
35
 
37
36
 
38
37
  module RGeo
39
-
38
+
40
39
  module CoordSys
41
-
42
-
40
+
41
+
43
42
  module CS
44
-
45
-
43
+
44
+
46
45
  # An axis orientation constant for AxisInfo.
47
46
  # Unknown or unspecified axis orientation. This can be used for
48
47
  # local or fitted coordinate systems.
49
48
  AO_OTHER = 0
50
-
49
+
51
50
  # An axis orientation constant for AxisInfo.
52
51
  # Increasing ordinates values go North. This is usually used for
53
52
  # Grid Y coordinates and Latitude.
54
53
  AO_NORTH = 1
55
-
54
+
56
55
  # An axis orientation constant for AxisInfo.
57
56
  # Increasing ordinates values go South. This is rarely used.
58
57
  AO_SOUTH = 2
59
-
58
+
60
59
  # An axis orientation constant for AxisInfo.
61
60
  # Increasing ordinates values go East. This is rarely used.
62
61
  AO_EAST = 3
63
-
62
+
64
63
  # An axis orientation constant for AxisInfo.
65
64
  # Increasing ordinates values go West. This is usually used for
66
65
  # Grid X coordinates and Longitude.
67
66
  AO_WEST = 4
68
-
67
+
69
68
  # An axis orientation constant for AxisInfo.
70
69
  # Increasing ordinates values go up. This is used for vertical
71
70
  # coordinate systems.
72
71
  AO_UP = 5
73
-
72
+
74
73
  # An axis orientation constant for AxisInfo.
75
74
  # Increasing ordinates values go down. This is used for vertical
76
75
  # coordinate systems.
77
76
  AO_DOWN = 6
78
-
79
-
77
+
78
+
80
79
  # A datum type constant for HorizontalDatum.
81
80
  # Lowest possible value for horizontal datum types.
82
81
  HD_MIN = 1000
83
-
82
+
84
83
  # A datum type constant for HorizontalDatum.
85
84
  # Unspecified horizontal datum type. Horizontal datums with this
86
85
  # type should never supply a conversion to WGS84 using Bursa Wolf
87
86
  # parameters.
88
87
  HD_OTHER = 1000
89
-
88
+
90
89
  # A datum type constant for HorizontalDatum.
91
90
  # These datums, such as ED50, NAD27 and NAD83, have been designed
92
91
  # to support horizontal positions on the ellipsoid as opposed to
@@ -94,7 +93,7 @@ module RGeo
94
93
  # support a horizontal component of a position in a domain of
95
94
  # limited extent, such as a country, a region or a continent.
96
95
  HD_CLASSIC = 1001
97
-
96
+
98
97
  # A datum type constant for HorizontalDatum.
99
98
  # A geocentric datum is a "satellite age" modern geodetic datum
100
99
  # mainly of global extent, such as WGS84 (used in GPS), PZ90 (used
@@ -103,30 +102,30 @@ module RGeo
103
102
  # position (through ellipsoidal heights). The regional realizations
104
103
  # of ITRF, such as ETRF, are also included in this category.
105
104
  HD_GEOCENTRIC = 1002
106
-
105
+
107
106
  # A datum type constant for HorizontalDatum.
108
107
  # Highest possible value for horizontal datum types.
109
108
  HD_MAX = 1999
110
-
109
+
111
110
  # A datum type constant for VerticalDatum.
112
111
  # Lowest possible value for vertical datum types.
113
112
  VD_MIN = 2000
114
-
113
+
115
114
  # A datum type constant for VerticalDatum.
116
115
  # Unspecified vertical datum type.
117
116
  VD_OTHER = 2000
118
-
117
+
119
118
  # A datum type constant for VerticalDatum.
120
119
  # A vertical datum for orthometric heights that are measured along
121
120
  # the plumb line.
122
121
  VD_ORTHOMETRIC = 2001
123
-
122
+
124
123
  # A datum type constant for VerticalDatum.
125
124
  # A vertical datum for ellipsoidal heights that are measured along
126
125
  # the normal to the ellipsoid used in the definition of horizontal
127
126
  # datum.
128
127
  VD_ELLIPSOIDAL = 2002
129
-
128
+
130
129
  # A datum type constant for VerticalDatum.
131
130
  # The vertical datum of altitudes or heights in the atmosphere.
132
131
  # These are approximations of orthometric heights obtained with the
@@ -135,11 +134,11 @@ module RGeo
135
134
  # millibars (used to measure pressure levels), or theta value (units
136
135
  # used to measure geopotential height).
137
136
  VD_ALTITUDE_BAROMETRIC = 2003
138
-
137
+
139
138
  # A datum type constant for VerticalDatum.
140
139
  # A normal height system.
141
140
  VD_NORMAL = 2004
142
-
141
+
143
142
  # A datum type constant for VerticalDatum.
144
143
  # A vertical datum of geoid model derived heights, also called
145
144
  # GPS-derived heights. These heights are approximations of
@@ -147,7 +146,7 @@ module RGeo
147
146
  # (h) by the use of the given geoid undulation model (N) through
148
147
  # the equation: H=h-N.
149
148
  VD_GEOID_MODE_DERIVED = 2005
150
-
149
+
151
150
  # A datum type constant for VerticalDatum.
152
151
  # This attribute is used to support the set of datums generated for
153
152
  # hydrographic engineering projects where depth measurements below
@@ -156,61 +155,61 @@ module RGeo
156
155
  # (approximately) to the actual equipotential surfaces of the
157
156
  # earth's gravity field, using such procedures as echo-sounding.
158
157
  VD_DEPTH = 2006
159
-
158
+
160
159
  # A datum type constant for VerticalDatum.
161
160
  # Highest possible value for vertical datum types.
162
161
  VD_MAX = 2999
163
-
162
+
164
163
  # A datum type constant for LocalDatum.
165
164
  # Lowest possible value for local datum types.
166
165
  LD_MIN = 10000
167
-
166
+
168
167
  # A datum type constant for LocalDatum.
169
168
  # Highest possible value for local datum types.
170
169
  LD_MAX = 32767
171
-
172
-
170
+
171
+
173
172
  # This is a base class for all OGC coordinate system objects.
174
173
  # This includes both interfaces and data types from the OGC
175
174
  # Coordinate Transformation spec.
176
- #
175
+ #
177
176
  # This is a non-instantiable abstract class.
178
-
177
+
179
178
  class Base
180
-
181
-
179
+
180
+
182
181
  def inspect # :nodoc:
183
182
  "#<#{self.class}:0x#{object_id.to_s(16)} #{to_wkt}>"
184
183
  end
185
-
186
-
184
+
185
+
187
186
  # Tests for equality. Two objects are defined as equal if they
188
187
  # have the same type (class) and the same WKT representation.
189
-
188
+
190
189
  def eql?(rhs_)
191
190
  rhs_.class == self.class && rhs_.to_wkt == self.to_wkt
192
191
  end
193
192
  alias_method :==, :eql?
194
-
195
-
193
+
194
+
196
195
  # Returns the default WKT representation.
197
-
196
+
198
197
  def to_s
199
198
  to_wkt
200
199
  end
201
-
202
-
200
+
201
+
203
202
  # Computes the WKT representation. Options include:
204
- #
203
+ #
205
204
  # [<tt>:standard_brackets</tt>]
206
205
  # If set to true, outputs parentheses rather than square
207
206
  # brackets. Default is false.
208
-
207
+
209
208
  def to_wkt(opts_={})
210
209
  opts_[:standard_brackets] ? _to_wkt('(', ')') : _to_wkt('[', ']')
211
210
  end
212
-
213
-
211
+
212
+
214
213
  def _to_wkt(open_, close_) # :nodoc:
215
214
  content_ = _wkt_content(open_, close_).map{ |obj_| ",#{obj_}" }.join
216
215
  if defined?(@authority) && @authority
@@ -220,14 +219,14 @@ module RGeo
220
219
  end
221
220
  "#{_wkt_typename}#{open_}#{@name.inspect}#{content_}#{authority_}#{close_}"
222
221
  end
223
-
224
-
222
+
223
+
225
224
  # Marshal support
226
-
225
+
227
226
  def marshal_dump # :nodoc:
228
227
  to_wkt
229
228
  end
230
-
229
+
231
230
  def marshal_load(data_) # :nodoc:
232
231
  data_ = data_['wkt'] if data_.is_a?(::Hash)
233
232
  temp_ = CS.create_from_wkt(data_)
@@ -239,10 +238,10 @@ module RGeo
239
238
  raise ::TypeError, 'Bad Marshal data'
240
239
  end
241
240
  end
242
-
243
-
241
+
242
+
244
243
  # Psych support
245
-
244
+
246
245
  def init_with(coder_) # :nodoc:
247
246
  temp_ = CS.create_from_wkt(coder_.type == :scalar ? coder_.scalar : coder_['wkt'] )
248
247
  if temp_.class == self.class
@@ -253,33 +252,33 @@ module RGeo
253
252
  raise ::TypeError, 'Bad YAML data'
254
253
  end
255
254
  end
256
-
255
+
257
256
  def encode_with(coder_) # :nodoc:
258
257
  coder_['wkt'] = to_wkt
259
258
  end
260
-
261
-
259
+
260
+
262
261
  class << self
263
-
262
+
264
263
  private :new
265
-
264
+
266
265
  end
267
-
268
-
266
+
267
+
269
268
  end
270
-
271
-
269
+
270
+
272
271
  # == OGC spec description
273
- #
272
+ #
274
273
  # Details of axis. This is used to label axes, and indicate the
275
274
  # orientation.
276
-
275
+
277
276
  class AxisInfo < Base
278
-
277
+
279
278
  # :stopdoc:
280
279
  NAMES_BY_VALUE = ['OTHER', 'NORTH', 'SOUTH', 'EAST', 'WEST', 'UP', 'DOWN']
281
280
  # :startdoc:
282
-
281
+
283
282
  def initialize(name_, orientation_) # :nodoc:
284
283
  @name = name_
285
284
  case orientation_
@@ -289,28 +288,28 @@ module RGeo
289
288
  @orientation = orientation_.to_i
290
289
  end
291
290
  end
292
-
293
-
291
+
292
+
294
293
  # Human readable name for axis. Possible values are "X", "Y",
295
294
  # "Long", "Lat" or any other short string.
296
295
  attr_reader :name
297
-
296
+
298
297
  # Gets enumerated value for orientation.
299
298
  attr_reader :orientation
300
-
301
-
299
+
300
+
302
301
  def _wkt_typename # :nodoc:
303
302
  "AXIS"
304
303
  end
305
-
304
+
306
305
  def _wkt_content(open_, close_) # :nodoc:
307
306
  [NAMES_BY_VALUE[@orientation]]
308
307
  end
309
-
310
-
308
+
309
+
311
310
  class << self
312
-
313
-
311
+
312
+
314
313
  # Creates an AxisInfo. you must pass the human readable name for
315
314
  # the axis (e.g. "X", "Y", "Long", "Lat", or other short string)
316
315
  # and either an integer orientation code or a string. Possible
@@ -318,73 +317,73 @@ module RGeo
318
317
  # "<tt>SOUTH</tt>", "<tt>EAST</tt>", "<tt>WEST</tt>",
319
318
  # "<tt>UP</tt>", and "<tt>DOWN</tt>", or the corresponding
320
319
  # integer values 0-5.
321
-
320
+
322
321
  def create(name_, orientation_)
323
322
  new(name_, orientation_)
324
323
  end
325
-
326
-
324
+
325
+
327
326
  end
328
-
327
+
329
328
  end
330
-
331
-
329
+
330
+
332
331
  # == OGC spec description
333
- #
332
+ #
334
333
  # A named projection parameter value. The linear units of
335
334
  # parameters' values match the linear units of the containing
336
335
  # projected coordinate system. The angular units of parameter
337
336
  # values match the angular units of the geographic coordinate
338
337
  # system that the projected coordinate system is based on.
339
-
338
+
340
339
  class ProjectionParameter < Base
341
-
340
+
342
341
  def initialize(name_, value_) # :nodoc:
343
342
  @name = name_
344
343
  @value = value_.to_f
345
344
  end
346
-
347
-
345
+
346
+
348
347
  # The parameter name.
349
348
  attr_reader :name
350
-
349
+
351
350
  # The parameter value.
352
351
  attr_reader :value
353
-
354
-
352
+
353
+
355
354
  def _wkt_typename # :nodoc:
356
355
  "PARAMETER"
357
356
  end
358
-
357
+
359
358
  def _wkt_content(open_, close_) # :nodoc:
360
359
  [@value]
361
360
  end
362
-
363
-
361
+
362
+
364
363
  class << self
365
-
366
-
364
+
365
+
367
366
  # Create a parameter given the name and value.
368
-
367
+
369
368
  def create(name_, value_)
370
369
  new(name_, value_)
371
370
  end
372
-
373
-
371
+
372
+
374
373
  end
375
-
374
+
376
375
  end
377
-
378
-
376
+
377
+
379
378
  # == OGC spec description
380
- #
379
+ #
381
380
  # Parameters for a geographic transformation into WGS84. The Bursa
382
381
  # Wolf parameters should be applied to geocentric coordinates, where
383
382
  # the X axis points towards the Greenwich Prime Meridian, the Y axis
384
383
  # points East, and the Z axis points North.
385
-
384
+
386
385
  class WGS84ConversionInfo < Base
387
-
386
+
388
387
  def initialize(dx_, dy_, dz_, ex_, ey_, ez_, ppm_) # :nodoc:
389
388
  @dx = dx_.to_f
390
389
  @dy = dy_.to_f
@@ -394,65 +393,65 @@ module RGeo
394
393
  @ez = ez_.to_f
395
394
  @ppm = ppm_.to_f
396
395
  end
397
-
398
-
396
+
397
+
399
398
  # Bursa Wolf shift in meters.
400
399
  attr_reader :dx
401
-
400
+
402
401
  # Bursa Wolf shift in meters.
403
402
  attr_reader :dy
404
-
403
+
405
404
  # Bursa Wolf shift in meters.
406
405
  attr_reader :dz
407
-
406
+
408
407
  # Bursa Wolf rotation in arc seconds.
409
408
  attr_reader :ex
410
-
409
+
411
410
  # Bursa Wolf rotation in arc seconds.
412
411
  attr_reader :ey
413
-
412
+
414
413
  # Bursa Wolf rotation in arc seconds.
415
414
  attr_reader :ez
416
-
415
+
417
416
  # Bursa Wolf scaling in in parts per million.
418
417
  attr_reader :ppm
419
-
420
-
418
+
419
+
421
420
  def _to_wkt(open_, close_) # :nodoc:
422
421
  "TOWGS84#{open_}#{@dx},#{@dy},#{@dz},#{@ex},#{@ey},#{@ez},#{@ppm}#{close_}"
423
422
  end
424
-
425
-
423
+
424
+
426
425
  class << self
427
-
428
-
426
+
427
+
429
428
  # Create the horizontal datum shift transformation into WGS84,
430
429
  # given the seven Bursa Wolf parameters.
431
430
  # The Bursa Wolf shift should be in meters, the rotation in arc
432
431
  # seconds, and the scaling in parts per million.
433
-
432
+
434
433
  def create(dx_, dy_, dz_, ex_, ey_, ez_, ppm_)
435
434
  new(dx_, dy_, dz_, ex_, ey_, ez_, ppm_)
436
435
  end
437
-
438
-
436
+
437
+
439
438
  end
440
-
439
+
441
440
  end
442
-
443
-
441
+
442
+
444
443
  # == OGC spec description
445
- #
444
+ #
446
445
  # A base interface for metadata applicable to coordinate system
447
446
  # objects.
448
- #
447
+ #
449
448
  # The metadata items "Abbreviation"’, "Alias", "Authority",
450
449
  # "AuthorityCode", "Name" and "Remarks" were specified in the Simple
451
450
  # Features interfaces, so they have been kept here.
452
- #
451
+ #
453
452
  # This specification does not dictate what the contents of these
454
453
  # items should be. However, the following guidelines are suggested:
455
- #
454
+ #
456
455
  # When CS_CoordinateSystemAuthorityFactory is used to create an
457
456
  # object, the "Authority" and "AuthorityCode" values should be set
458
457
  # to the authority name of the factory object, and the authority
@@ -460,27 +459,27 @@ module RGeo
460
459
  # may not be set. (If the authority is EPSG, the implementer may
461
460
  # consider using the corresponding metadata values in the EPSG
462
461
  # tables.)
463
- #
462
+ #
464
463
  # When CS_CoordinateSystemFactory creates an object, the "Name"
465
464
  # should be set to the value supplied by the client. All of the
466
465
  # other metadata items should be left empty.
467
- #
466
+ #
468
467
  # == Notes
469
- #
468
+ #
470
469
  # This is a non-instantiable abstract class.
471
- #
470
+ #
472
471
  # Most subclasses will have a set of optional parameters in their
473
472
  # "create" method to set the metadata fields. These parameters are,
474
473
  # in order:
475
- #
474
+ #
476
475
  # * <b>authority</b>: authority name
477
476
  # * <b>authority_code</b>: authority-specific identification code
478
477
  # * <b>abbreviation</b>: an abbreviation
479
478
  # * <b>alias</b>: an alias
480
479
  # * <b>remarks</b>: provider-supplied remarks.
481
-
480
+
482
481
  class Info < Base
483
-
482
+
484
483
  def initialize(name_, authority_=nil, authority_code_=nil, abbreviation_=nil, alias_=nil, remarks_=nil) # :nodoc:
485
484
  @name = name_
486
485
  @authority = authority_ ? authority_.to_s : nil
@@ -489,14 +488,14 @@ module RGeo
489
488
  @alias = alias_ ? alias_.to_s : nil
490
489
  @remarks = remarks_ ? remarks_.to_s : nil
491
490
  end
492
-
493
-
491
+
492
+
494
493
  # Gets the abbreviation.
495
494
  attr_reader :abbreviation
496
-
495
+
497
496
  # Gets the alias.
498
497
  attr_reader :alias
499
-
498
+
500
499
  # Gets the authority name.
501
500
  # An Authority is an organization that maintains definitions of
502
501
  # Authority Codes. For example the European Petroleum Survey Group
@@ -505,7 +504,7 @@ module RGeo
505
504
  # ID. For example, the EPSG code for a WGS84 Lat/Lon coordinate
506
505
  # system is "4326".
507
506
  attr_reader :authority
508
-
507
+
509
508
  # Gets the authority-specific identification code.
510
509
  # The AuthorityCode is a compact string defined by an Authority to
511
510
  # reference a particular spatial reference object. For example,
@@ -514,187 +513,187 @@ module RGeo
514
513
  # consist of a few digits. The EPSG code for WGS84 Lat/Lon is
515
514
  # "4326".
516
515
  attr_reader :authority_code
517
-
516
+
518
517
  # Gets the name.
519
518
  attr_reader :name
520
-
519
+
521
520
  # Gets the provider-supplied remarks.
522
521
  attr_reader :remarks
523
-
524
-
522
+
523
+
525
524
  end
526
-
527
-
525
+
526
+
528
527
  # == OGC spec description
529
- #
528
+ #
530
529
  # Base interface for defining units.
531
- #
530
+ #
532
531
  # == Notes
533
- #
532
+ #
534
533
  # Normally, you will instantiate one of the subclasses LinearUnit or
535
534
  # AngularUnit. However, it is possible to instantiate Unit if it is
536
535
  # not clear whether the data refers to a LinearUnit or AngularUnit.
537
-
536
+
538
537
  class Unit < Info
539
-
538
+
540
539
  def initialize(name_, conversion_factor_, *optional_) # :nodoc:
541
540
  super(name_, *optional_)
542
541
  @conversion_factor = conversion_factor_.to_f
543
542
  end
544
-
545
-
543
+
544
+
546
545
  # This field is not part of the OGC CT spec, but is part of the
547
546
  # SFS. It is an alias of the appropriate field in the subclass,
548
547
  # i.e. LinearUnit#meters_per_unit or AngularUnit#radians_per_unit.
549
548
  attr_reader :conversion_factor
550
-
551
-
549
+
550
+
552
551
  def _wkt_typename # :nodoc:
553
552
  "UNIT"
554
553
  end
555
-
554
+
556
555
  def _wkt_content(open_, close_) # :nodoc:
557
556
  [@conversion_factor]
558
557
  end
559
-
560
-
558
+
559
+
561
560
  class << self
562
-
563
-
561
+
562
+
564
563
  # Create a bare Unit that does not specify whether it is a
565
564
  # LinearUnit or an AngularUnit, given a unit name and a
566
565
  # conversion factor. You may also provide the optional
567
566
  # parameters specified by the Info interface.
568
-
567
+
569
568
  def create(name_, conversion_factor_, *optional_)
570
569
  new(name_, conversion_factor_, *optional_)
571
570
  end
572
-
573
-
571
+
572
+
574
573
  end
575
-
574
+
576
575
  end
577
-
578
-
576
+
577
+
579
578
  # == OGC spec description
580
- #
579
+ #
581
580
  # Definition of linear units.
582
-
581
+
583
582
  class LinearUnit < Unit
584
-
585
-
583
+
584
+
586
585
  # Returns the number of meters per LinearUnit.
587
586
  # Also available as Unit#conversion_factor.
588
-
587
+
589
588
  def meters_per_unit
590
589
  @conversion_factor
591
590
  end
592
-
593
-
591
+
592
+
594
593
  class << self
595
-
596
-
594
+
595
+
597
596
  # Create a LinearUnit given a unit name and a conversion factor
598
597
  # in meters per unit. You may also provide the optional
599
598
  # parameters specified by the Info interface.
600
-
599
+
601
600
  def create(name_, meters_per_unit_, *optional_)
602
601
  new(name_, meters_per_unit_, *optional_)
603
602
  end
604
-
605
-
603
+
604
+
606
605
  end
607
-
606
+
608
607
  end
609
-
610
-
608
+
609
+
611
610
  # == OGC spec description
612
- #
611
+ #
613
612
  # Definition of angular units.
614
-
613
+
615
614
  class AngularUnit < Unit
616
-
617
-
615
+
616
+
618
617
  # Returns the number of radians per AngularUnit.
619
618
  # Also available as Unit#conversion_factor.
620
-
619
+
621
620
  def radians_per_unit
622
621
  @conversion_factor
623
622
  end
624
-
625
-
623
+
624
+
626
625
  class << self
627
-
628
-
626
+
627
+
629
628
  # Create an AngularUnit given a unit name and a conversion
630
629
  # factor in radians per unit. You may also provide the optional
631
630
  # parameters specified by the Info interface.
632
-
631
+
633
632
  def create(name_, radians_per_unit_, *optional_)
634
633
  new(name_, radians_per_unit_, *optional_)
635
634
  end
636
-
637
-
635
+
636
+
638
637
  end
639
-
638
+
640
639
  end
641
-
642
-
640
+
641
+
643
642
  # == OGC spec description
644
- #
643
+ #
645
644
  # A meridian used to take longitude measurements from.
646
-
645
+
647
646
  class PrimeMeridian < Info
648
-
647
+
649
648
  def initialize(name_, angular_unit_, longitude_, *optional_) # :nodoc:
650
649
  super(name_, *optional_)
651
650
  @angular_unit = angular_unit_
652
651
  @longitude = longitude_.to_f
653
652
  end
654
-
655
-
653
+
654
+
656
655
  # Returns the AngularUnits.
657
656
  attr_reader :angular_unit
658
-
657
+
659
658
  # Returns the longitude value relative to the Greenwich Meridian.
660
659
  # The longitude is expressed in this objects angular units.
661
660
  attr_reader :longitude
662
-
663
-
661
+
662
+
664
663
  def _wkt_typename # :nodoc:
665
664
  "PRIMEM"
666
665
  end
667
-
666
+
668
667
  def _wkt_content(open_, close_) # :nodoc:
669
668
  [@longitude]
670
669
  end
671
-
672
-
670
+
671
+
673
672
  class << self
674
-
675
-
673
+
674
+
676
675
  # Create a PrimeMeridian given a name, AngularUnits, and the
677
676
  # longitude relative to the Greenwich Meridian, expressed in
678
677
  # the AngularUnits. You may also provide the optional parameters
679
678
  # specified by the Info interface.
680
-
679
+
681
680
  def create(name_, angular_unit_, longitude_, *optional_)
682
681
  new(name_, angular_unit_, longitude_, *optional_)
683
682
  end
684
-
685
-
683
+
684
+
686
685
  end
687
-
688
-
686
+
687
+
689
688
  end
690
-
691
-
689
+
690
+
692
691
  # == OGC spec description
693
- #
692
+ #
694
693
  # An approximation of the Earth's surface as a squashed sphere.
695
-
694
+
696
695
  class Ellipsoid < Info
697
-
696
+
698
697
  def initialize(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_) # :nodoc:
699
698
  super(name_, *optional_)
700
699
  @semi_major_axis = semi_major_axis_.to_f
@@ -703,64 +702,64 @@ module RGeo
703
702
  @ivf_definitive = ivf_definitive_ ? true : false
704
703
  @linear_unit = linear_unit_
705
704
  end
706
-
707
-
705
+
706
+
708
707
  # Gets the equatorial radius. The returned length is expressed in
709
708
  # this object's axis units.
710
709
  attr_reader :semi_major_axis
711
-
710
+
712
711
  # Gets the polar radius. The returned length is expressed in this
713
712
  # object's axis units.
714
713
  attr_reader :semi_minor_axis
715
-
714
+
716
715
  # Returns the value of the inverse of the flattening constant. The
717
716
  # inverse flattening is related to the equatorial/polar radius by
718
717
  # the formula ivf=re/(re-rp). For perfect spheres, this formula
719
718
  # breaks down, and a special IVF value of zero is used.
720
719
  attr_reader :inverse_flattening
721
-
720
+
722
721
  # Is the Inverse Flattening definitive for this ellipsoid? Some
723
722
  # ellipsoids use the IVF as the defining value, and calculate the
724
723
  # polar radius whenever asked. Other ellipsoids use the polar
725
724
  # radius to calculate the IVF whenever asked. This distinction can
726
725
  # be important to avoid floating-point rounding errors.
727
726
  attr_reader :ivf_definitive
728
-
727
+
729
728
  # Returns the LinearUnit. The units of the semi-major and
730
729
  # semi-minor axis values.
731
730
  attr_reader :axis_unit
732
-
733
-
731
+
732
+
734
733
  def _wkt_typename # :nodoc:
735
734
  "SPHEROID"
736
735
  end
737
-
736
+
738
737
  def _wkt_content(open_, close_) # :nodoc:
739
738
  [@semi_major_axis, @inverse_flattening]
740
739
  end
741
-
742
-
740
+
741
+
743
742
  class << self
744
-
745
-
743
+
744
+
746
745
  # Create an Ellipsoid given a name, semi-major and semi-minor
747
746
  # axes, the inverse flattening, a boolean indicating whether
748
747
  # the inverse flattening is definitive, and the LinearUnit
749
748
  # indicating the axis units. The LinearUnit is optional and
750
749
  # may be set to nil. You may also provide the optional parameters
751
750
  # specified by the Info interface.
752
-
751
+
753
752
  def create(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_)
754
753
  new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_)
755
754
  end
756
-
757
-
755
+
756
+
758
757
  # Create an Ellipsoid given a name, semi-major and semi-minor
759
758
  # axes, and the LinearUnit indicating the axis units. In the
760
759
  # resulting ellipsoid, the inverse flattening is not definitive.
761
760
  # The LinearUnit is optional and may be set to nil. You may also
762
761
  # provide the optional parameters specified by the Info interface.
763
-
762
+
764
763
  def create_ellipsoid(name_, semi_major_axis_, semi_minor_axis_, linear_unit_, *optional_)
765
764
  semi_major_axis_ = semi_major_axis_.to_f
766
765
  semi_minor_axis_ = semi_minor_axis_.to_f
@@ -768,14 +767,14 @@ module RGeo
768
767
  inverse_flattening_ = 0.0 if inverse_flattening_.infinite?
769
768
  new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, false, linear_unit_, *optional_)
770
769
  end
771
-
772
-
770
+
771
+
773
772
  # Create an Ellipsoid given a name, semi-major axis, inverse
774
773
  # flattening, and the LinearUnit indicating the axis units. In
775
774
  # the resulting ellipsoid, the inverse flattening is definitive.
776
775
  # The LinearUnit is optional and may be set to nil. You may also
777
776
  # provide the optional parameters specified by the Info interface.
778
-
777
+
779
778
  def create_flattened_sphere(name_, semi_major_axis_, inverse_flattening_, linear_unit_, *optional_)
780
779
  semi_major_axis_ = semi_major_axis_.to_f
781
780
  inverse_flattening_ = inverse_flattening_.to_f
@@ -783,15 +782,15 @@ module RGeo
783
782
  semi_minor_axis_ = semi_major_axis_ if semi_minor_axis_.infinite?
784
783
  new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, true, linear_unit_, *optional_)
785
784
  end
786
-
787
-
785
+
786
+
788
787
  end
789
-
788
+
790
789
  end
791
-
792
-
790
+
791
+
793
792
  # == OGC spec description
794
- #
793
+ #
795
794
  # A set of quantities from which other quantities are calculated.
796
795
  # For the OGC abstract model, it can be defined as a set of real
797
796
  # points on the earth that have coordinates. EG. A datum can be
@@ -803,344 +802,344 @@ module RGeo
803
802
  # as axis of spin). The definition of the datum may also include
804
803
  # the temporal behavior (such as the rate of change of the
805
804
  # orientation of the coordinate axes).
806
- #
805
+ #
807
806
  # == Notes
808
- #
807
+ #
809
808
  # This is a non-instantiable abstract class. You must instantiate
810
809
  # one of the subclasses HorizontalDatum, VerticalDatum, or
811
810
  # LocalDatum.
812
-
811
+
813
812
  class Datum < Info
814
-
813
+
815
814
  def initialize(name_, datum_type_, *optional_) # :nodoc:
816
815
  super(name_, *optional_)
817
816
  @datum_type = datum_type_.to_i
818
817
  end
819
-
820
-
818
+
819
+
821
820
  # Gets the type of the datum as an enumerated code.
822
821
  attr_reader :datum_type
823
-
824
-
822
+
823
+
825
824
  def _wkt_content(open_, close_) # :nodoc:
826
825
  []
827
826
  end
828
-
829
-
827
+
828
+
830
829
  end
831
-
832
-
830
+
831
+
833
832
  # == OGC spec description
834
- #
833
+ #
835
834
  # Procedure used to measure vertical distances.
836
-
835
+
837
836
  class VerticalDatum < Datum
838
-
837
+
839
838
  def _wkt_typename # :nodoc:
840
839
  "VERT_DATUM"
841
840
  end
842
-
841
+
843
842
  def _wkt_content(open_, close_) # :nodoc:
844
843
  [@datum_type]
845
844
  end
846
-
845
+
847
846
  class << self
848
-
849
-
847
+
848
+
850
849
  # Create a VerticalDatum given a name and a datum type code.
851
850
  # You may also provide the optional parameters specified by the
852
851
  # Info interface.
853
-
852
+
854
853
  def create(name_, datum_type_, *optional_)
855
854
  new(name_, datum_type_, *optional_)
856
855
  end
857
-
858
-
856
+
857
+
859
858
  end
860
-
859
+
861
860
  end
862
-
863
-
861
+
862
+
864
863
  # == OGC spec description
865
- #
864
+ #
866
865
  # Local datum. If two local datum objects have the same datum type
867
866
  # and name, then they can be considered equal. This means that
868
867
  # coordinates can be transformed between two different local
869
868
  # coordinate systems, as long as they are based on the same local
870
869
  # datum.
871
-
870
+
872
871
  class LocalDatum < Datum
873
-
872
+
874
873
  def _wkt_typename # :nodoc:
875
874
  "LOCAL_DATUM"
876
875
  end
877
-
876
+
878
877
  def _wkt_content(open_, close_) # :nodoc:
879
878
  [@datum_type]
880
879
  end
881
-
880
+
882
881
  class << self
883
-
884
-
882
+
883
+
885
884
  # Create a LocalDatum given a name and a datum type code. You
886
885
  # may also provide the optional parameters specified by the
887
886
  # Info interface.
888
-
887
+
889
888
  def create(name_, datum_type_, *optional_)
890
889
  new(name_, datum_type_, *optional_)
891
890
  end
892
-
893
-
891
+
892
+
894
893
  end
895
-
894
+
896
895
  end
897
-
898
-
896
+
897
+
899
898
  # == OGC spec description
900
- #
899
+ #
901
900
  # Procedure used to measure positions on the surface of the Earth.
902
-
901
+
903
902
  class HorizontalDatum < Datum
904
-
903
+
905
904
  def initialize(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_) # :nodoc:
906
905
  super(name_, datum_type_, *optional_)
907
906
  @ellipsoid = ellipsoid_
908
907
  @wgs84_parameters = wgs84_parameters_
909
908
  end
910
-
911
-
909
+
910
+
912
911
  # Returns the Ellipsoid.
913
912
  attr_reader :ellipsoid
914
-
913
+
915
914
  # Gets preferred parameters for a Bursa Wolf transformation into
916
915
  # WGS84. The 7 returned values correspond to (dx,dy,dz) in meters,
917
916
  # (ex,ey,ez) in arc-seconds, and scaling in parts-per-million.
918
917
  attr_reader :wgs84_parameters
919
-
920
-
918
+
919
+
921
920
  def _wkt_typename # :nodoc:
922
921
  "DATUM"
923
922
  end
924
-
923
+
925
924
  def _wkt_content(open_, close_) # :nodoc:
926
925
  array_ = [@ellipsoid._to_wkt(open_, close_)]
927
926
  array_ << @wgs84_parameters._to_wkt(open_, close_) if @wgs84_parameters
928
927
  array_
929
928
  end
930
-
931
-
929
+
930
+
932
931
  class << self
933
-
934
-
932
+
933
+
935
934
  # Create a HorizontalDatum given a name, datum type code,
936
935
  # Ellipsoid, and WGS84ConversionInfo. The WGS84ConversionInfo
937
936
  # is optional and may be set to nil. You may also provide the
938
937
  # optional parameters specified by the Info interface.
939
-
938
+
940
939
  def create(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_)
941
940
  new(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_)
942
941
  end
943
-
944
-
942
+
943
+
945
944
  end
946
-
945
+
947
946
  end
948
-
949
-
947
+
948
+
950
949
  # == OGC spec description
951
- #
950
+ #
952
951
  # A projection from geographic coordinates to projected coordinates.
953
-
952
+
954
953
  class Projection < Info
955
-
954
+
956
955
  def initialize(name_, class_name_, parameters_, *optional_) # :nodoc:
957
956
  super(name_, *optional_)
958
957
  @class_name = class_name_.to_s
959
958
  @parameters = parameters_ ? parameters_.dup : []
960
959
  end
961
-
962
-
960
+
961
+
963
962
  # Gets the projection classification name
964
963
  # (e.g. "Transverse_Mercator").
965
964
  attr_reader :class_name
966
-
967
-
965
+
966
+
968
967
  # Gets number of parameters of the projection.
969
-
968
+
970
969
  def num_parameters
971
970
  @parameters.size
972
971
  end
973
-
974
-
972
+
973
+
975
974
  # Gets an inexed parameter of the projection.
976
-
975
+
977
976
  def get_parameter(index_)
978
977
  @parameters[index_]
979
978
  end
980
-
981
-
979
+
980
+
982
981
  # Iterates over the parameters of the projection.
983
-
982
+
984
983
  def each_parameter(&block_)
985
984
  @parameters.each(&block_)
986
985
  end
987
-
988
-
986
+
987
+
989
988
  def _wkt_typename # :nodoc:
990
989
  "PROJECTION"
991
990
  end
992
-
991
+
993
992
  def _wkt_content(open_, close_) # :nodoc:
994
993
  []
995
994
  end
996
-
997
-
995
+
996
+
998
997
  class << self
999
-
1000
-
998
+
999
+
1001
1000
  # Create a Projection given a name, a projection class, and an
1002
1001
  # array of ProjectionParameter. You may also provide the
1003
1002
  # optional parameters specified by the Info interface.
1004
-
1003
+
1005
1004
  def create(name_, class_name_, parameters_, *optional_)
1006
1005
  new(name_, class_name_, parameters_, *optional_)
1007
1006
  end
1008
-
1009
-
1007
+
1008
+
1010
1009
  end
1011
-
1010
+
1012
1011
  end
1013
-
1014
-
1012
+
1013
+
1015
1014
  # == OGC spec description
1016
- #
1015
+ #
1017
1016
  # Base interface for all coordinate systems.
1018
- #
1017
+ #
1019
1018
  # A coordinate system is a mathematical space, where the elements
1020
1019
  # of the space are called positions. Each position is described by
1021
1020
  # a list of numbers. The length of the list corresponds to the
1022
1021
  # dimension of the coordinate system. So in a 2D coordinate system
1023
1022
  # each position is described by a list containing 2 numbers.
1024
- #
1023
+ #
1025
1024
  # However, in a coordinate system, not all lists of numbers
1026
1025
  # correspond to a position -- some lists may be outside the domain
1027
1026
  # of the coordinate system. For example, in a 2D Lat/Lon coordinate
1028
1027
  # system, the list (91,91) does not correspond to a position.
1029
- #
1028
+ #
1030
1029
  # Some coordinate systems also have a mapping from the mathematical
1031
1030
  # space into locations in the real world. So in a Lat/Lon coordinate
1032
1031
  # system, the mathematical position (lat, long) corresponds to a
1033
1032
  # location on the surface of the Earth. This mapping from the
1034
1033
  # mathematical space into real-world locations is called a Datum.
1035
- #
1034
+ #
1036
1035
  # == Notes
1037
- #
1036
+ #
1038
1037
  # This is a non-instantiable abstract class. You must instantiate
1039
1038
  # one of the subclasses GeocentricCoordinateSystem,
1040
1039
  # GeographicCoordinateSystem, ProjectedCoordinateSystem,
1041
1040
  # VerticalCoordinateSystem, LocalCoordinateSystem, or
1042
1041
  # CompoundCoordinateSystem.
1043
-
1042
+
1044
1043
  class CoordinateSystem < Info
1045
-
1044
+
1046
1045
  def initialize(name_, dimension_, *optional_) # :nodoc:
1047
1046
  super(name_, *optional_)
1048
1047
  @dimension = dimension_.to_i
1049
1048
  end
1050
-
1051
-
1049
+
1050
+
1052
1051
  # Dimension of the coordinate system
1053
1052
  attr_reader :dimension
1054
-
1055
-
1053
+
1054
+
1056
1055
  # Gets axis details for dimension within coordinate system. Each
1057
1056
  # dimension in the coordinate system has a corresponding axis.
1058
-
1057
+
1059
1058
  def get_axis(dimension_)
1060
1059
  nil
1061
1060
  end
1062
-
1063
-
1061
+
1062
+
1064
1063
  # Gets units for dimension within coordinate system. Each
1065
1064
  # dimension in the coordinate system has corresponding units.
1066
-
1065
+
1067
1066
  def get_units(dimension_)
1068
1067
  nil
1069
1068
  end
1070
-
1071
-
1069
+
1070
+
1072
1071
  end
1073
-
1074
-
1072
+
1073
+
1075
1074
  # == OGC spec description
1076
- #
1075
+ #
1077
1076
  # An aggregate of two coordinate systems (CRS). One of these is
1078
1077
  # usually a CRS based on a two dimensional coordinate system such
1079
1078
  # as a geographic or a projected coordinate system with a horizontal
1080
1079
  # datum. The other is a vertical CRS which is a one-dimensional
1081
1080
  # coordinate system with a vertical datum.
1082
-
1081
+
1083
1082
  class CompoundCoordinateSystem < CoordinateSystem
1084
-
1083
+
1085
1084
  def initialize(name_, head_, tail_, *optional_) # :nodoc:
1086
1085
  super(name_, head_.dimension + tail_.dimension, *optional_)
1087
1086
  @head = head_
1088
1087
  @tail = tail_
1089
1088
  end
1090
-
1091
-
1089
+
1090
+
1092
1091
  # Gets first sub-coordinate system.
1093
1092
  attr_reader :head
1094
-
1093
+
1095
1094
  # Gets second sub-coordinate system.
1096
1095
  attr_reader :tail
1097
-
1098
-
1096
+
1097
+
1099
1098
  # Implements CoordinateSystem#get_axis
1100
-
1099
+
1101
1100
  def get_axis(index_)
1102
1101
  hd_ = @head.dimension
1103
1102
  index_ < hd_ ? @head.get_axis(index_) : @tail.get_axis(index_ - hd_)
1104
1103
  end
1105
-
1106
-
1104
+
1105
+
1107
1106
  # Implements CoordinateSystem#get_units
1108
-
1107
+
1109
1108
  def get_units(index_)
1110
1109
  hd_ = @head.dimension
1111
1110
  index_ < hd_ ? @head.get_units(index_) : @tail.get_units(index_ - hd_)
1112
1111
  end
1113
-
1114
-
1112
+
1113
+
1115
1114
  def _wkt_typename # :nodoc:
1116
1115
  "COMPD_CS"
1117
1116
  end
1118
-
1117
+
1119
1118
  def _wkt_content(open_, close_) # :nodoc:
1120
1119
  [@head._to_wkt(open_, close_), @tail._to_wkt(open_, close_)]
1121
1120
  end
1122
-
1123
-
1121
+
1122
+
1124
1123
  class << self
1125
-
1126
-
1124
+
1125
+
1127
1126
  # Create a CompoundCoordinateSystem given two sub-coordinate
1128
1127
  # systems. You may also provide the optional parameters
1129
1128
  # specified by the Info interface.
1130
-
1129
+
1131
1130
  def create(name_, head_, tail_, *optional_)
1132
1131
  new(name_, head_, tail_, *optional_)
1133
1132
  end
1134
-
1135
-
1133
+
1134
+
1136
1135
  end
1137
-
1138
-
1136
+
1137
+
1139
1138
  end
1140
-
1141
-
1139
+
1140
+
1142
1141
  # == OGC spec description
1143
- #
1142
+ #
1144
1143
  # A local coordinate system, with uncertain relationship to the
1145
1144
  # world. In general, a local coordinate system cannot be related to
1146
1145
  # other coordinate systems. However, if two objects supporting this
@@ -1152,78 +1151,78 @@ module RGeo
1152
1151
  # have a mechanism for correlating local datums. (E.g. from a
1153
1152
  # database of transformations, which is created and maintained from
1154
1153
  # real-world measurements.)
1155
- #
1154
+ #
1156
1155
  # == Notes
1157
- #
1156
+ #
1158
1157
  # RGeo's implementation does not provide the Coordinate
1159
1158
  # Transformation (CT) package.
1160
-
1159
+
1161
1160
  class LocalCoordinateSystem < CoordinateSystem
1162
-
1161
+
1163
1162
  def initialize(name_, local_datum_, unit_, axes_, *optional_) # :nodoc:
1164
1163
  super(name_, axes_.size, *optional_)
1165
1164
  @local_datum = local_datum_
1166
1165
  @unit = unit_
1167
1166
  @axes = axes_.dup
1168
1167
  end
1169
-
1170
-
1168
+
1169
+
1171
1170
  # Gets the local datum.
1172
1171
  attr_reader :local_datum
1173
-
1174
-
1172
+
1173
+
1175
1174
  # Implements CoordinateSystem#get_axis
1176
-
1175
+
1177
1176
  def get_axis(index_)
1178
1177
  @axes[index_]
1179
1178
  end
1180
-
1181
-
1179
+
1180
+
1182
1181
  # Implements CoordinateSystem#get_units
1183
-
1182
+
1184
1183
  def get_units(index_)
1185
1184
  @unit
1186
1185
  end
1187
-
1188
-
1186
+
1187
+
1189
1188
  def _wkt_typename # :nodoc:
1190
1189
  "LOCAL_CS"
1191
1190
  end
1192
-
1191
+
1193
1192
  def _wkt_content(open_, close_) # :nodoc:
1194
1193
  [@local_datum._to_wkt(open_, close_), @unit._to_wkt(open_, close_)] + @axes.map{ |ax_| ax_._to_wkt(open_, close_) }
1195
1194
  end
1196
-
1197
-
1195
+
1196
+
1198
1197
  class << self
1199
-
1200
-
1198
+
1199
+
1201
1200
  # Create a LocalCoordinateSystem given a name, a LocalDatum, a
1202
1201
  # Unit, and an array of at least one AxisInfo. You may also
1203
1202
  # provide the optional parameters specified by the Info
1204
1203
  # interface.
1205
-
1204
+
1206
1205
  def create(name_, local_datum_, unit_, axes_, *optional_)
1207
1206
  new(name_, local_datum_, unit_, axes_, *optional_)
1208
1207
  end
1209
-
1210
-
1208
+
1209
+
1211
1210
  end
1212
-
1211
+
1213
1212
  end
1214
-
1215
-
1213
+
1214
+
1216
1215
  # == OGC spec description
1217
- #
1216
+ #
1218
1217
  # A 3D coordinate system, with its origin at the centre of the
1219
1218
  # Earth. The X axis points towards the prime meridian. The Y axis
1220
1219
  # points East or West. The Z axis points North or South. By default
1221
1220
  # the Z axis will point North, and the Y axis will point East (e.g.
1222
1221
  # a right handed system), but you should check the axes for
1223
1222
  # non-default values.
1224
-
1223
+
1225
1224
  class GeocentricCoordinateSystem < CoordinateSystem
1226
-
1225
+
1227
1226
  def initialize(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_) # :nodoc:
1228
1227
  super(name_, 3, *optional_)
1229
1228
  @horizontal_datum = horizontal_datum_
@@ -1233,39 +1232,39 @@ module RGeo
1233
1232
  @axis1 = axis1_
1234
1233
  @axis2 = axis2_
1235
1234
  end
1236
-
1237
-
1235
+
1236
+
1238
1237
  # Returns the HorizontalDatum. The horizontal datum is used to
1239
1238
  # determine where the centre of the Earth is considered to be.
1240
1239
  # All coordinate points will be measured from the centre of the
1241
1240
  # Earth, and not the surface.
1242
1241
  attr_reader :horizontal_datum
1243
-
1242
+
1244
1243
  # Returns the PrimeMeridian.
1245
1244
  attr_reader :prime_meridian
1246
-
1245
+
1247
1246
  # Gets the units used along all the axes.
1248
1247
  attr_reader :linear_unit
1249
-
1250
-
1248
+
1249
+
1251
1250
  # Implements CoordinateSystem#get_units
1252
-
1251
+
1253
1252
  def get_units(index_)
1254
1253
  @linear_unit
1255
1254
  end
1256
-
1257
-
1255
+
1256
+
1258
1257
  # Implements CoordinateSystem#get_axis
1259
-
1258
+
1260
1259
  def get_axis(index_)
1261
1260
  [@axis0, @axis1, @axis2][index_]
1262
1261
  end
1263
-
1264
-
1262
+
1263
+
1265
1264
  def _wkt_typename # :nodoc:
1266
1265
  "GEOCCS"
1267
1266
  end
1268
-
1267
+
1269
1268
  def _wkt_content(open_, close_) # :nodoc:
1270
1269
  arr_ = [@horizontal_datum._to_wkt(open_, close_), @prime_meridian._to_wkt(open_, close_), @linear_unit._to_wkt(open_, close_)]
1271
1270
  arr_ << @axis0._to_wkt(open_, close_) if @axis0
@@ -1273,130 +1272,130 @@ module RGeo
1273
1272
  arr_ << @axis2._to_wkt(open_, close_) if @axis2
1274
1273
  arr_
1275
1274
  end
1276
-
1277
-
1275
+
1276
+
1278
1277
  class << self
1279
-
1280
-
1278
+
1279
+
1281
1280
  # Create a GeocentricCoordinateSystem given a name, a
1282
1281
  # HorizontalDatum, a PrimeMeridian, a LinearUnit, and three
1283
1282
  # AxisInfo objects. The AxisInfo are optional and may be nil.
1284
1283
  # You may also provide the optional parameters specified by the
1285
1284
  # Info interface.
1286
-
1285
+
1287
1286
  def create(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_)
1288
1287
  new(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_)
1289
1288
  end
1290
-
1291
-
1289
+
1290
+
1292
1291
  end
1293
-
1294
-
1292
+
1293
+
1295
1294
  end
1296
-
1297
-
1295
+
1296
+
1298
1297
  # == OGC spec description
1299
- #
1298
+ #
1300
1299
  # A one-dimensional coordinate system suitable for vertical
1301
1300
  # measurements.
1302
-
1301
+
1303
1302
  class VerticalCoordinateSystem < CoordinateSystem
1304
-
1303
+
1305
1304
  def initialize(name_, vertical_datum_, vertical_unit_, axis_, *optional_) # :nodoc:
1306
1305
  super(name_, 1, *optional_)
1307
1306
  @vertical_datum = vertical_datum_
1308
1307
  @vertical_unit = vertical_unit_
1309
1308
  @axis = axis_
1310
1309
  end
1311
-
1312
-
1310
+
1311
+
1313
1312
  # Gets the vertical datum, which indicates the measurement method.
1314
1313
  attr_reader :vertical_datum
1315
-
1314
+
1316
1315
  # Gets the units used along the vertical axis. The vertical units
1317
1316
  # must be the same as the CS_CoordinateSystem units.
1318
1317
  attr_reader :vertical_unit
1319
-
1320
-
1318
+
1319
+
1321
1320
  # Implements CoordinateSystem#get_units
1322
-
1321
+
1323
1322
  def get_units(index_)
1324
1323
  @vertical_unit
1325
1324
  end
1326
-
1327
-
1325
+
1326
+
1328
1327
  # Implements CoordinateSystem#get_axis
1329
-
1328
+
1330
1329
  def get_axis(index_)
1331
1330
  @axis
1332
1331
  end
1333
-
1334
-
1332
+
1333
+
1335
1334
  def _wkt_typename # :nodoc:
1336
1335
  "VERT_CS"
1337
1336
  end
1338
-
1337
+
1339
1338
  def _wkt_content(open_, close_) # :nodoc:
1340
1339
  arr_ = [@vertical_datum._to_wkt(open_, close_), @vertical_unit._to_wkt(open_, close_)]
1341
1340
  arr_ << @axis._to_wkt(open_, close_) if @axis
1342
1341
  arr_
1343
1342
  end
1344
-
1345
-
1343
+
1344
+
1346
1345
  class << self
1347
-
1348
-
1346
+
1347
+
1349
1348
  # Create a VerticalCoordinateSystem given a name, a
1350
1349
  # VerticalDatum, a LinearUnit, and an AxisInfo. The AxisInfo is
1351
1350
  # optional and may be nil. You may also provide the optional
1352
1351
  # parameters specified by the Info interface.
1353
-
1352
+
1354
1353
  def create(name_, vertical_datum_, vertical_unit_, axis_, *optional_)
1355
1354
  new(name_, vertical_datum_, vertical_unit_, axis_, *optional_)
1356
1355
  end
1357
-
1358
-
1356
+
1357
+
1359
1358
  end
1360
-
1361
-
1359
+
1360
+
1362
1361
  end
1363
-
1364
-
1362
+
1363
+
1365
1364
  # == OGC spec description
1366
- #
1365
+ #
1367
1366
  # A 2D coordinate system suitable for positions on the Earth's surface.
1368
- #
1367
+ #
1369
1368
  # == Notes
1370
- #
1369
+ #
1371
1370
  # This is a non-instantiable abstract class. You must instantiate
1372
1371
  # one of the subclasses GeographicCoordinateSystem or
1373
1372
  # ProjectedCoordinateSystem.
1374
-
1373
+
1375
1374
  class HorizontalCoordinateSystem < CoordinateSystem
1376
-
1375
+
1377
1376
  def initialize(name_, horizontal_datum_, *optional_) # :nodoc:
1378
1377
  super(name_, 2, *optional_)
1379
1378
  @horizontal_datum = horizontal_datum_
1380
1379
  end
1381
-
1382
-
1380
+
1381
+
1383
1382
  # Returns the HorizontalDatum.
1384
1383
  attr_reader :horizontal_datum
1385
-
1386
-
1384
+
1385
+
1387
1386
  end
1388
-
1389
-
1387
+
1388
+
1390
1389
  # == OGC spec description
1391
- #
1390
+ #
1392
1391
  # A coordinate system based on latitude and longitude. Some
1393
1392
  # geographic coordinate systems are Lat/Lon, and some are Lon/Lat.
1394
1393
  # You can find out which this is by examining the axes. You should
1395
1394
  # also check the angular units, since not all geographic coordinate
1396
1395
  # systems use degrees.
1397
-
1396
+
1398
1397
  class GeographicCoordinateSystem < HorizontalCoordinateSystem
1399
-
1398
+
1400
1399
  def initialize(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_) # :nodoc:
1401
1400
  super(name_, horizontal_datum_, *optional_)
1402
1401
  @prime_meridian = prime_meridian_
@@ -1404,86 +1403,86 @@ module RGeo
1404
1403
  @axis0 = axis0_
1405
1404
  @axis1 = axis1_
1406
1405
  end
1407
-
1408
-
1406
+
1407
+
1409
1408
  # Returns the PrimeMeridian.
1410
1409
  attr_reader :prime_meridian
1411
-
1410
+
1412
1411
  # Returns the AngularUnit. The angular unit must be the same as
1413
1412
  # the CS_CoordinateSystem units.
1414
1413
  attr_reader :angular_unit
1415
-
1416
-
1414
+
1415
+
1417
1416
  # Implements CoordinateSystem#get_units
1418
-
1417
+
1419
1418
  def get_units(index_)
1420
1419
  @angular_unit
1421
1420
  end
1422
-
1421
+
1423
1422
 
1424
1423
  # Implements CoordinateSystem#get_axis
1425
-
1424
+
1426
1425
  def get_axis(index_)
1427
1426
  index_ == 1 ? @axis1 : @axis0
1428
1427
  end
1429
-
1430
-
1428
+
1429
+
1431
1430
  # Gets the number of available conversions to WGS84 coordinates.
1432
-
1431
+
1433
1432
  def num_conversion_to_wgs84
1434
1433
  @horizontal_datum.wgs84_parameters ? 1 : 0
1435
1434
  end
1436
-
1437
-
1435
+
1436
+
1438
1437
  # Gets details on a conversion to WGS84. Some geographic
1439
1438
  # coordinate systems provide several transformations into WGS84,
1440
1439
  # which are designed to provide good accuracy in different areas
1441
1440
  # of interest. The first conversion (with index=0) should provide
1442
1441
  # acceptable accuracy over the largest possible area of interest.
1443
-
1442
+
1444
1443
  def get_wgs84_conversion_info(index_)
1445
1444
  @horizontal_datum.wgs84_parameters
1446
1445
  end
1447
-
1448
-
1446
+
1447
+
1449
1448
  def _wkt_typename # :nodoc:
1450
1449
  "GEOGCS"
1451
1450
  end
1452
-
1451
+
1453
1452
  def _wkt_content(open_, close_) # :nodoc:
1454
1453
  arr_ = [@horizontal_datum._to_wkt(open_, close_), @prime_meridian._to_wkt(open_, close_), @angular_unit._to_wkt(open_, close_)]
1455
1454
  arr_ << @axis0._to_wkt(open_, close_) if @axis0
1456
1455
  arr_ << @axis1._to_wkt(open_, close_) if @axis1
1457
1456
  arr_
1458
1457
  end
1459
-
1460
-
1458
+
1459
+
1461
1460
  class << self
1462
-
1463
-
1461
+
1462
+
1464
1463
  # Create a GeographicCoordinateSystem, given a name, an
1465
1464
  # AngularUnit, a HorizontalDatum, a PrimeMeridian, and two
1466
1465
  # AxisInfo objects. The AxisInfo objects are optional and may
1467
1466
  # be set to nil. You may also provide the optional parameters
1468
1467
  # specified by the Info interface.
1469
-
1468
+
1470
1469
  def create(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_)
1471
1470
  new(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_)
1472
1471
  end
1473
-
1474
-
1472
+
1473
+
1475
1474
  end
1476
-
1477
-
1475
+
1476
+
1478
1477
  end
1479
-
1480
-
1478
+
1479
+
1481
1480
  # == OGC spec description
1482
- #
1481
+ #
1483
1482
  # A 2D cartographic coordinate system.
1484
-
1483
+
1485
1484
  class ProjectedCoordinateSystem < HorizontalCoordinateSystem
1486
-
1485
+
1487
1486
  def initialize(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_) # :nodoc:
1488
1487
  super(name_, geographic_coordinate_system_.horizontal_datum, *optional_)
1489
1488
  @geographic_coordinate_system = geographic_coordinate_system_
@@ -1492,37 +1491,37 @@ module RGeo
1492
1491
  @axis0 = axis0_
1493
1492
  @axis1 = axis1_
1494
1493
  end
1495
-
1496
-
1494
+
1495
+
1497
1496
  # Returns the GeographicCoordinateSystem.
1498
1497
  attr_reader :geographic_coordinate_system
1499
-
1498
+
1500
1499
  # Gets the projection.
1501
1500
  attr_reader :projection
1502
-
1501
+
1503
1502
  # Returns the LinearUnits. The linear unit must be the same as
1504
1503
  # the CS_CoordinateSystem units.
1505
1504
  attr_reader :linear_unit
1506
-
1507
-
1505
+
1506
+
1508
1507
  # Implements CoordinateSystem#get_units
1509
-
1508
+
1510
1509
  def get_units(index_)
1511
1510
  @linear_unit
1512
1511
  end
1513
-
1514
-
1512
+
1513
+
1515
1514
  # Implements CoordinateSystem#get_axis
1516
-
1515
+
1517
1516
  def get_axis(index_)
1518
1517
  index_ == 1 ? @axis1 : @axis0
1519
1518
  end
1520
-
1521
-
1519
+
1520
+
1522
1521
  def _wkt_typename # :nodoc:
1523
1522
  "PROJCS"
1524
1523
  end
1525
-
1524
+
1526
1525
  def _wkt_content(open_, close_) # :nodoc:
1527
1526
  arr_ = [@geographic_coordinate_system._to_wkt(open_, close_), @projection._to_wkt(open_, close_)]
1528
1527
  @projection.each_parameter{ |param_| arr_ << param_._to_wkt(open_, close_) }
@@ -1531,31 +1530,31 @@ module RGeo
1531
1530
  arr_ << @axis1._to_wkt(open_, close_) if @axis1
1532
1531
  arr_
1533
1532
  end
1534
-
1535
-
1533
+
1534
+
1536
1535
  class << self
1537
-
1538
-
1536
+
1537
+
1539
1538
  # Create a ProjectedCoordinateSystem given a name, a
1540
1539
  # GeographicCoordinateSystem, and Projection, a LinearUnit, and
1541
1540
  # two AxisInfo objects. The AxisInfo objects are optional and
1542
1541
  # may be set to nil. You may also provide the optional
1543
1542
  # parameters specified by the Info interface.
1544
-
1543
+
1545
1544
  def create(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_)
1546
1545
  new(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_)
1547
1546
  end
1548
-
1549
-
1547
+
1548
+
1550
1549
  end
1551
-
1552
-
1550
+
1551
+
1553
1552
  end
1554
-
1555
-
1553
+
1554
+
1556
1555
  end
1557
-
1558
-
1556
+
1557
+
1559
1558
  end
1560
-
1559
+
1561
1560
  end