rgeo 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,3 +1,12 @@
1
+ === 0.2.2 / 2010-12-15
2
+
3
+ The main theme for this release was support for spatial reference system databases. The basic functionality is done and ready for experimentation. However, documentation is still in progress, and we're still working on some ideas to make coordinate system management more seamless by integrating the SRS databases with FactoryGenerator.
4
+
5
+ * Implemented OGC coordinate system objects, including most of the CS package of the OGC Coordinate Transform spec, and a parser for the WKT.
6
+ * Defined interfaces for spatial reference system database access. Implemented a database based on ActiveRecord and backed by spatial_ref_sys tables; one based on the data files shared by the proj4 library; one based on retrieving data from spatialreference.org, and one based on retrieving data from arbitrary URLs.
7
+ * Renamed RGeo::Feature::Type::Instance marker module to RGeo::Feature::Instance. The old name is aliased for backward compatibility but is deprecated.
8
+ * Added a few more directories to the default lookup path for geos and proj4.
9
+
1
10
  === 0.2.1 / 2010-12-09
2
11
 
3
12
  * Now compatible with Rubinius (version 1.1 or later).
data/README.rdoc CHANGED
@@ -46,7 +46,8 @@ RGeo is known to work with the following Ruby implementations:
46
46
  * Standard "MRI" Ruby 1.8.7 or later. (1.9.2 or later preferred.)
47
47
  * Rubinius 1.1 or later.
48
48
  * Partial support for JRuby 1.5 or later, but a bunch of features are
49
- missing because GEOS and Proj are not available from Java.
49
+ missing because GEOS and Proj are not available from Java. We plan on
50
+ integrating with JTS in the future.
50
51
 
51
52
  Some features also require the following:
52
53
 
@@ -74,6 +75,8 @@ following locations:
74
75
  * /usr/local
75
76
  * /usr/local/geos
76
77
  * /opt/local
78
+ * /opt/geos
79
+ * /opt
77
80
  * /usr
78
81
 
79
82
  If GEOS has been installed in a different location, you must provide its
@@ -90,6 +93,9 @@ following locations by default:
90
93
  * /usr/local/proj
91
94
  * /usr/local/proj4
92
95
  * /opt/local
96
+ * /opt/proj
97
+ * /opt/proj4
98
+ * /opt
93
99
  * /usr
94
100
 
95
101
  If Proj4 is installed in a different location, you must provide its
@@ -100,9 +106,7 @@ installation prefix directory using the "--with-proj-dir" option.
100
106
  The RGeo suite of tools is evolving rapidly. The current to-do list for
101
107
  the core library includes:
102
108
 
103
- * Implementation of the OGC coordinate system spec.
104
- * Integration with spatial reference system databases.
105
- * Ellipsoidal geography implementation, probably utilizing geographiclib.
109
+ * Ellipsoidal geography implementation, possibly utilizing geographiclib.
106
110
  * JRuby support via the JTS library.
107
111
  * Windows build support.
108
112
 
data/Version CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -47,6 +47,8 @@ else
47
47
  '/usr/local/include',
48
48
  '/usr/local/geos/include',
49
49
  '/opt/local/include',
50
+ '/opt/geos/include',
51
+ '/opt/include',
50
52
  ::Config::CONFIG['includedir'],
51
53
  '/usr/include',
52
54
  ]
@@ -55,6 +57,8 @@ else
55
57
  '/usr/local/lib',
56
58
  '/usr/local/geos/lib',
57
59
  '/opt/local/lib',
60
+ '/opt/geos/lib',
61
+ '/opt/lib',
58
62
  ::Config::CONFIG['libdir'],
59
63
  '/usr/lib',
60
64
  ]
@@ -48,6 +48,9 @@ else
48
48
  '/usr/local/proj/include',
49
49
  '/usr/local/proj4/include',
50
50
  '/opt/local/include',
51
+ '/opt/proj/include',
52
+ '/opt/proj4/include',
53
+ '/opt/include',
51
54
  ::Config::CONFIG['includedir'],
52
55
  '/usr/include',
53
56
  ]
@@ -57,6 +60,9 @@ else
57
60
  '/usr/local/proj/lib',
58
61
  '/usr/local/proj4/lib',
59
62
  '/opt/local/lib',
63
+ '/opt/proj/lib',
64
+ '/opt/proj4/lib',
65
+ '/opt/lib',
60
66
  ::Config::CONFIG['libdir'],
61
67
  '/usr/lib',
62
68
  ]
@@ -63,6 +63,10 @@ module RGeo
63
63
  else
64
64
  @proj4 = nil
65
65
  end
66
+ @coord_sys = opts_[:coord_sys]
67
+ if @coord_sys.kind_of?(::String)
68
+ @coord_sys = CoordSys::CS.create_from_wkt(@coord_sys) rescue nil
69
+ end
66
70
  end
67
71
 
68
72
 
@@ -184,7 +188,7 @@ module RGeo
184
188
  # See ::RGeo::Feature::Factory#coord_sys
185
189
 
186
190
  def coord_sys
187
- nil
191
+ @coord_sys
188
192
  end
189
193
 
190
194
 
@@ -38,13 +38,24 @@ module RGeo
38
38
 
39
39
 
40
40
  # This module provides data structures and tools related to coordinate
41
- # systems and coordinate transforms.
41
+ # systems and coordinate transforms. It comprises the following parts:
42
42
  #
43
- # Currently, the Proj4 class provides a wrapper around the proj4
44
- # library, which specifies geographic and projected coordinate systems
45
- # and performs transformations. In the future, this module will also
46
- # contain an implementation of the OGC coordinate transformation
47
- # specification.
43
+ # RGeo::CoordSys::Proj4 is a wrapper around the proj4 library, which
44
+ # defines a commonly-used syntax for specifying geographic and projected
45
+ # coordinate systems, and performs coordinate transformations.
46
+ #
47
+ # The RGeo::CoordSys::CS module contains an implementation of the CS
48
+ # (coordinate systems) package of the OGC Coordinate Transform spec.
49
+ # This includes classes for representing ellipsoids, datums, coordinate
50
+ # systems, and other related concepts, as well as a parser for the WKT
51
+ # format for specifying coordinate systems.
52
+ #
53
+ # The RGeo::CoordSys::SRSDatabase module contains tools for accessing
54
+ # spatial reference databases, from which you can look up coordinate
55
+ # system specifications. You can access the <tt>spatial_ref_sys</tt>
56
+ # table provided with OGC-compliant spatial databases such as PostGIS,
57
+ # read the databases provided with the proj4 library, or access URLs
58
+ # such as those provided by spatialreference.org.
48
59
 
49
60
  module CoordSys
50
61
  end
@@ -58,3 +69,11 @@ begin
58
69
  require 'rgeo/coord_sys/proj4_c_impl'
59
70
  rescue ::LoadError; end
60
71
  require 'rgeo/coord_sys/proj4'
72
+ require 'rgeo/coord_sys/cs/factories'
73
+ require 'rgeo/coord_sys/cs/entities'
74
+ require 'rgeo/coord_sys/cs/wkt_parser'
75
+ require 'rgeo/coord_sys/srs_database/interface.rb'
76
+ require 'rgeo/coord_sys/srs_database/active_record_table.rb'
77
+ require 'rgeo/coord_sys/srs_database/proj4_data.rb'
78
+ require 'rgeo/coord_sys/srs_database/url_reader.rb'
79
+ require 'rgeo/coord_sys/srs_database/sr_org.rb'
@@ -0,0 +1,805 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # OGC CS objects for RGeo
4
+ #
5
+ # -----------------------------------------------------------------------------
6
+ # Copyright 2010 Daniel Azuma
7
+ #
8
+ # All rights reserved.
9
+ #
10
+ # Redistribution and use in source and binary forms, with or without
11
+ # modification, are permitted provided that the following conditions are met:
12
+ #
13
+ # * Redistributions of source code must retain the above copyright notice,
14
+ # this list of conditions and the following disclaimer.
15
+ # * Redistributions in binary form must reproduce the above copyright notice,
16
+ # this list of conditions and the following disclaimer in the documentation
17
+ # and/or other materials provided with the distribution.
18
+ # * Neither the name of the copyright holder, nor the names of any other
19
+ # contributors to this software, may be used to endorse or promote products
20
+ # derived from this software without specific prior written permission.
21
+ #
22
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
+ # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
+ # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25
+ # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29
+ # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30
+ # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31
+ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
+ # POSSIBILITY OF SUCH DAMAGE.
33
+ # -----------------------------------------------------------------------------
34
+ ;
35
+
36
+
37
+ module RGeo
38
+
39
+ module CoordSys
40
+
41
+
42
+ module CS
43
+
44
+
45
+ AO_OTHER = 0
46
+ AO_NORTH = 1
47
+ AO_SOUTH = 2
48
+ AO_EAST = 3
49
+ AO_WEST = 4
50
+ AO_UP = 5
51
+ AO_DOWN = 6
52
+
53
+ HD_MIN = 1000
54
+ HD_OTHER = 1000
55
+ HD_CLASSIC = 1001
56
+ HD_GEOCENTRIC = 1002
57
+ HD_MAX = 1999
58
+ VD_MIN = 2000
59
+ VD_OTHER = 2000
60
+ VD_ORTHOMETRIC = 2001
61
+ VD_ELLIPSOIDAL = 2002
62
+ VD_ALTITUDE_BAROMETRIC = 2003
63
+ VD_NORMAL = 2004
64
+ VD_GEOID_MODE_DERIVED = 2005
65
+ VD_DEPTH = 2006
66
+ VD_MAX = 2999
67
+ LD_MIN = 10000
68
+ LD_MAX = 32767
69
+
70
+
71
+ class Base
72
+
73
+ def initialize(name_) # :nodoc:
74
+ @name = name_.to_s
75
+ end
76
+
77
+ attr_reader :name
78
+
79
+ def inspect
80
+ "#<#{self.class}:0x#{object_id.to_s(16)} #{to_wkt}>"
81
+ end
82
+
83
+ def eql?(rhs_)
84
+ rhs_.class == self.class && rhs_.to_wkt == self.to_wkt
85
+ end
86
+ alias_method :==, :eql?
87
+
88
+ def to_s
89
+ to_wkt
90
+ end
91
+
92
+ def to_wkt(opts_={})
93
+ opts_[:standard_brackets] ? _to_wkt('(', ')') : _to_wkt('[', ']')
94
+ end
95
+
96
+ def _to_wkt(open_, close_) # :nodoc:
97
+ content_ = _wkt_content(open_, close_).map{ |obj_| ",#{obj_}" }.join
98
+ if defined?(@authority) && @authority
99
+ authority_ = ",AUTHORITY#{open_}#{@authority.inspect},#{@authority_code.inspect}#{close_}"
100
+ else
101
+ authority_ = ''
102
+ end
103
+ "#{_wkt_typename}#{open_}#{@name.inspect}#{content_}#{authority_}#{close_}"
104
+ end
105
+
106
+ class << self
107
+
108
+ private :new
109
+
110
+ end
111
+
112
+ end
113
+
114
+
115
+ class AxisInfo < Base
116
+
117
+ NAMES_BY_VALUE = ['OTHER', 'NORTH', 'SOUTH', 'EAST', 'WEST', 'UP', 'DOWN']
118
+
119
+ def initialize(name_, orientation_) # :nodoc:
120
+ super(name_)
121
+ if orientation_.kind_of?(::String)
122
+ @orientation = NAMES_BY_VALUE.index(orientation_).to_i
123
+ else
124
+ @orientation = orientation_.to_i
125
+ end
126
+ end
127
+
128
+ attr_reader :orientation
129
+
130
+ def _wkt_typename # :nodoc:
131
+ "AXIS"
132
+ end
133
+
134
+ def _wkt_content(open_, close_) # :nodoc:
135
+ [NAMES_BY_VALUE[@orientation]]
136
+ end
137
+
138
+ class << self
139
+
140
+ def create(name_, orientation_)
141
+ new(name_, orientation_)
142
+ end
143
+
144
+ end
145
+
146
+ end
147
+
148
+
149
+ class ProjectionParameter < Base
150
+
151
+ def initialize(name_, value_) # :nodoc:
152
+ super(name_)
153
+ @value = value_.to_f
154
+ end
155
+
156
+ attr_reader :value
157
+
158
+ def _wkt_typename # :nodoc:
159
+ "PARAMETER"
160
+ end
161
+
162
+ def _wkt_content(open_, close_) # :nodoc:
163
+ [@value]
164
+ end
165
+
166
+ class << self
167
+
168
+ def create(name_, value_)
169
+ new(name_, value_)
170
+ end
171
+
172
+ end
173
+
174
+ end
175
+
176
+
177
+ class WGS84ConversionInfo < Base
178
+
179
+ def initialize(dx_, dy_, dz_, ex_, ey_, ez_, ppm_) # :nodoc:
180
+ super('TOWGS84')
181
+ @dx = dx_.to_f
182
+ @dy = dy_.to_f
183
+ @dz = dz_.to_f
184
+ @ex = ex_.to_f
185
+ @ey = ey_.to_f
186
+ @ez = ez_.to_f
187
+ @ppm = ppm_.to_f
188
+ end
189
+
190
+ attr_reader :dx
191
+ attr_reader :dy
192
+ attr_reader :dz
193
+ attr_reader :ex
194
+ attr_reader :ey
195
+ attr_reader :ez
196
+ attr_reader :ppm
197
+
198
+ def _to_wkt(open_, close_) # :nodoc:
199
+ "TOWGS84#{open_}#{@dx},#{@dy},#{@dz},#{@ex},#{@ey},#{@ez},#{@ppm}#{close_}"
200
+ end
201
+
202
+ class << self
203
+
204
+ def create(dx_, dy_, dz_, ex_, ey_, ez_, ppm_)
205
+ new(dx_, dy_, dz_, ex_, ey_, ez_, ppm_)
206
+ end
207
+
208
+ end
209
+
210
+ end
211
+
212
+
213
+ class Info < Base
214
+
215
+ def initialize(name_, authority_=nil, authority_code_=nil, abbreviation_=nil, alias_=nil, remarks_=nil) # :nodoc:
216
+ super(name_)
217
+ @authority = authority_ ? authority_.to_s : nil
218
+ @authority_code = authority_code_ ? authority_code_.to_s : nil
219
+ @abbreviation = abbreviation_ ? abbreviation_.to_s : nil
220
+ @alias = alias_ ? alias_.to_s : nil
221
+ @remarks = remarks_ ? remarks_.to_s : nil
222
+ end
223
+
224
+ attr_reader :authority
225
+ attr_reader :authority_code
226
+ attr_reader :abbreviation
227
+ attr_reader :alias
228
+ attr_reader :remarks
229
+
230
+ end
231
+
232
+
233
+ class Unit < Info
234
+
235
+ def initialize(name_, conversion_factor_, *optional_) # :nodoc:
236
+ super(name_, *optional_)
237
+ @conversion_factor = conversion_factor_.to_f
238
+ end
239
+
240
+ attr_reader :conversion_factor
241
+
242
+ def _wkt_typename # :nodoc:
243
+ "UNIT"
244
+ end
245
+
246
+ def _wkt_content(open_, close_) # :nodoc:
247
+ [@conversion_factor]
248
+ end
249
+
250
+ class << self
251
+
252
+ def create(name_, conversion_factor_, *optional_)
253
+ new(name_, conversion_factor_, *optional_)
254
+ end
255
+
256
+ end
257
+
258
+ end
259
+
260
+
261
+ class LinearUnit < Unit
262
+
263
+ alias_method :meters_per_unit, :conversion_factor
264
+
265
+ class << self
266
+
267
+ def create(name_, meters_per_unit_, *optional_)
268
+ new(name_, meters_per_unit_, *optional_)
269
+ end
270
+
271
+ end
272
+
273
+ end
274
+
275
+
276
+ class AngularUnit < Unit
277
+
278
+ alias_method :radians_per_unit, :conversion_factor
279
+
280
+ class << self
281
+
282
+ def create(name_, radians_per_unit_, *optional_)
283
+ new(name_, radians_per_unit_, *optional_)
284
+ end
285
+
286
+ end
287
+
288
+ end
289
+
290
+
291
+ class PrimeMeridian < Info
292
+
293
+ def initialize(name_, angular_unit_, longitude_, *optional_) # :nodoc:
294
+ super(name_, *optional_)
295
+ @angular_unit = angular_unit_
296
+ @longitude = longitude_.to_f
297
+ end
298
+
299
+ attr_reader :angular_unit
300
+ attr_reader :longitude
301
+
302
+ def _wkt_typename # :nodoc:
303
+ "PRIMEM"
304
+ end
305
+
306
+ def _wkt_content(open_, close_) # :nodoc:
307
+ [@longitude]
308
+ end
309
+
310
+ class << self
311
+
312
+ def create(name_, angular_unit_, longitude_, *optional_)
313
+ new(name_, angular_unit_, longitude_, *optional_)
314
+ end
315
+
316
+ end
317
+
318
+ end
319
+
320
+
321
+ class Ellipsoid < Info
322
+
323
+ def initialize(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_) # :nodoc:
324
+ super(name_, *optional_)
325
+ @semi_major_axis = semi_major_axis_.to_f
326
+ @semi_minor_axis = semi_minor_axis_.to_f
327
+ @inverse_flattening = inverse_flattening_.to_f
328
+ @ivf_definitive = ivf_definitive_ ? true : false
329
+ @linear_unit = linear_unit_
330
+ end
331
+
332
+ attr_reader :semi_major_axis
333
+ attr_reader :semi_minor_axis
334
+ attr_reader :inverse_flattening
335
+ attr_reader :ivf_definitive
336
+ attr_reader :linear_unit
337
+
338
+ def _wkt_typename # :nodoc:
339
+ "SPHEROID"
340
+ end
341
+
342
+ def _wkt_content(open_, close_) # :nodoc:
343
+ [@semi_major_axis, @inverse_flattening]
344
+ end
345
+
346
+ def self.create_ellipsoid(name_, semi_major_axis_, semi_minor_axis_, linear_unit_, *optional_)
347
+ semi_major_axis_ = semi_major_axis_.to_f
348
+ semi_minor_axis_ = semi_minor_axis_.to_f
349
+ inverse_flattening_ = semi_major_axis_ / (semi_major_axis_ - semi_minor_axis_)
350
+ inverse_flattening_ = 0.0 if inverse_flattening_.infinite?
351
+ new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, false, linear_unit_, *optional_)
352
+ end
353
+
354
+ def self.create_flattened_sphere(name_, semi_major_axis_, inverse_flattening_, linear_unit_, *optional_)
355
+ semi_major_axis_ = semi_major_axis_.to_f
356
+ inverse_flattening_ = inverse_flattening_.to_f
357
+ semi_minor_axis_ = semi_major_axis_ - semi_major_axis_ / inverse_flattening_
358
+ semi_minor_axis_ = semi_major_axis_ if semi_minor_axis_.infinite?
359
+ new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, true, linear_unit_, *optional_)
360
+ end
361
+
362
+ class << self
363
+
364
+ def create(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_)
365
+ new(name_, semi_major_axis_, semi_minor_axis_, inverse_flattening_, ivf_definitive_, linear_unit_, *optional_)
366
+ end
367
+
368
+ end
369
+
370
+ end
371
+
372
+
373
+ class Datum < Info
374
+
375
+ def initialize(name_, datum_type_, *optional_) # :nodoc:
376
+ super(name_, *optional_)
377
+ @datum_type = datum_type_.to_i
378
+ end
379
+
380
+ attr_reader :datum_type
381
+
382
+ def _wkt_content(open_, close_) # :nodoc:
383
+ []
384
+ end
385
+
386
+ class << self
387
+
388
+ def create(name_, datum_type_, *optional_)
389
+ new(name_, datum_type_, *optional_)
390
+ end
391
+
392
+ end
393
+
394
+ end
395
+
396
+
397
+ class VerticalDatum < Datum
398
+
399
+ def _wkt_typename # :nodoc:
400
+ "VERT_DATUM"
401
+ end
402
+
403
+ def _wkt_content(open_, close_) # :nodoc:
404
+ [@datum_type]
405
+ end
406
+
407
+ class << self
408
+
409
+ def create(name_, datum_type_, *optional_)
410
+ new(name_, datum_type_, *optional_)
411
+ end
412
+
413
+ end
414
+
415
+ end
416
+
417
+
418
+ class LocalDatum < Datum
419
+
420
+ def _wkt_typename # :nodoc:
421
+ "LOCAL_DATUM"
422
+ end
423
+
424
+ def _wkt_content(open_, close_) # :nodoc:
425
+ [@datum_type]
426
+ end
427
+
428
+ class << self
429
+
430
+ def create(name_, datum_type_, *optional_)
431
+ new(name_, datum_type_, *optional_)
432
+ end
433
+
434
+ end
435
+
436
+ end
437
+
438
+
439
+ class HorizontalDatum < Datum
440
+
441
+ def initialize(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_) # :nodoc:
442
+ super(name_, datum_type_, *optional_)
443
+ @ellipsoid = ellipsoid_
444
+ @wgs84_parameters = wgs84_parameters_
445
+ end
446
+
447
+ attr_reader :ellipsoid
448
+ attr_reader :wgs84_parameters
449
+
450
+ def _wkt_typename # :nodoc:
451
+ "DATUM"
452
+ end
453
+
454
+ def _wkt_content(open_, close_) # :nodoc:
455
+ array_ = [@ellipsoid._to_wkt(open_, close_)]
456
+ array_ << @wgs84_parameters._to_wkt(open_, close_) if @wgs84_parameters
457
+ array_
458
+ end
459
+
460
+ class << self
461
+
462
+ def create(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_)
463
+ new(name_, datum_type_, ellipsoid_, wgs84_parameters_, *optional_)
464
+ end
465
+
466
+ end
467
+
468
+ end
469
+
470
+
471
+ class Projection < Info
472
+
473
+ def initialize(name_, class_name_, parameters_, *optional_) # :nodoc:
474
+ super(name_, *optional_)
475
+ @class_name = class_name_.to_s
476
+ @parameters = parameters_ ? parameters_.dup : []
477
+ end
478
+
479
+ attr_reader :class_name
480
+
481
+ def num_parameters
482
+ @parameters.size
483
+ end
484
+
485
+ def get_parameter(index_)
486
+ @parameters[index_]
487
+ end
488
+
489
+ def each_parameter(&block_)
490
+ @parameters.each(&block_)
491
+ end
492
+
493
+ def _wkt_typename # :nodoc:
494
+ "PROJECTION"
495
+ end
496
+
497
+ def _wkt_content(open_, close_) # :nodoc:
498
+ []
499
+ end
500
+
501
+ class << self
502
+
503
+ def create(name_, class_name_, parameters_, *optional_)
504
+ new(name_, class_name_, parameters_, *optional_)
505
+ end
506
+
507
+ end
508
+
509
+ end
510
+
511
+
512
+ class CoordinateSystem < Info
513
+
514
+ def initialize(name_, dimension_, *optional_) # :nodoc:
515
+ super(name_, *optional_)
516
+ @dimension = dimension_.to_i
517
+ end
518
+
519
+ attr_reader :dimension
520
+
521
+ end
522
+
523
+
524
+ class CompoundCoordinateSystem < CoordinateSystem
525
+
526
+ def initialize(name_, head_, tail_, *optional_) # :nodoc:
527
+ super(name_, head_.dimension + tail_.dimension, *optional_)
528
+ @head = head_
529
+ @tail = tail_
530
+ end
531
+
532
+ attr_reader :head
533
+ attr_reader :tail
534
+
535
+ def get_axis(index_)
536
+ hd_ = @head.dimension
537
+ index_ < hd_ ? @head.get_axis(index_) : @tail.get_axis(index_ - hd_)
538
+ end
539
+
540
+ def get_units(index_)
541
+ hd_ = @head.dimension
542
+ index_ < hd_ ? @head.get_units(index_) : @tail.get_units(index_ - hd_)
543
+ end
544
+
545
+ def _wkt_typename # :nodoc:
546
+ "COMPD_CS"
547
+ end
548
+
549
+ def _wkt_content(open_, close_) # :nodoc:
550
+ [@head._to_wkt(open_, close_), @tail._to_wkt(open_, close_)]
551
+ end
552
+
553
+ class << self
554
+
555
+ def create(name_, head_, tail_, *optional_)
556
+ new(name_, head_, tail_, *optional_)
557
+ end
558
+
559
+ end
560
+
561
+ end
562
+
563
+
564
+ class LocalCoordinateSystem < CoordinateSystem
565
+
566
+ def initialize(name_, local_datum_, unit_, axes_, *optional_) # :nodoc:
567
+ super(name_, axes_.size, *optional_)
568
+ @local_datum = local_datum_
569
+ @unit = unit_
570
+ @axes = axes_.dup
571
+ end
572
+
573
+ attr_reader :local_datum
574
+
575
+ def get_axis(index_)
576
+ @axes[index_]
577
+ end
578
+
579
+ def get_units(index_)
580
+ @unit
581
+ end
582
+
583
+ def _wkt_typename # :nodoc:
584
+ "LOCAL_CS"
585
+ end
586
+
587
+ def _wkt_content(open_, close_) # :nodoc:
588
+ [@local_datum._to_wkt(open_, close_), @unit._to_wkt(open_, close_)] + @axes.map{ |ax_| ax_._to_wkt(open_, close_) }
589
+ end
590
+
591
+ class << self
592
+
593
+ def create(name_, local_datum_, unit_, axes_, *optional_)
594
+ new(name_, local_datum_, unit_, axes_, *optional_)
595
+ end
596
+
597
+ end
598
+
599
+ end
600
+
601
+
602
+ class GeocentricCoordinateSystem < CoordinateSystem
603
+
604
+ def initialize(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_) # :nodoc:
605
+ super(name_, 3, *optional_)
606
+ @horizontal_datum = horizontal_datum_
607
+ @prime_meridian = prime_meridian_
608
+ @linear_unit = linear_unit_
609
+ @axis0 = axis0_
610
+ @axis1 = axis1_
611
+ @axis2 = axis2_
612
+ end
613
+
614
+ attr_reader :horizontal_datum
615
+ attr_reader :prime_meridian
616
+ attr_reader :linear_unit
617
+
618
+ def get_units(index_)
619
+ @linear_unit
620
+ end
621
+
622
+ def get_axis(index_)
623
+ [@axis0, @axis1, @axis2][index_]
624
+ end
625
+
626
+ def _wkt_typename # :nodoc:
627
+ "GEOCCS"
628
+ end
629
+
630
+ def _wkt_content(open_, close_) # :nodoc:
631
+ arr_ = [@horizontal_datum._to_wkt(open_, close_), @prime_meridian._to_wkt(open_, close_), @linear_unit._to_wkt(open_, close_)]
632
+ arr_ << @axis0._to_wkt(open_, close_) if @axis0
633
+ arr_ << @axis1._to_wkt(open_, close_) if @axis1
634
+ arr_ << @axis2._to_wkt(open_, close_) if @axis2
635
+ arr_
636
+ end
637
+
638
+ class << self
639
+
640
+ def create(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_)
641
+ new(name_, horizontal_datum_, prime_meridian_, linear_unit_, axis0_, axis1_, axis2_, *optional_)
642
+ end
643
+
644
+ end
645
+
646
+ end
647
+
648
+
649
+ class VerticalCoordinateSystem < CoordinateSystem
650
+
651
+ def initialize(name_, vertical_datum_, vertical_unit_, axis_, *optional_) # :nodoc:
652
+ super(name_, 1, *optional_)
653
+ @vertical_datum = vertical_datum_
654
+ @vertical_unit = vertical_unit_
655
+ @axis = axis_
656
+ end
657
+
658
+ attr_reader :vertical_datum
659
+ attr_reader :vertical_unit
660
+
661
+ def get_units(index_)
662
+ @vertical_unit
663
+ end
664
+
665
+ def get_axis(index_)
666
+ @axis
667
+ end
668
+
669
+ def _wkt_typename # :nodoc:
670
+ "VERT_CS"
671
+ end
672
+
673
+ def _wkt_content(open_, close_) # :nodoc:
674
+ arr_ = [@vertical_datum._to_wkt(open_, close_), @vertical_unit._to_wkt(open_, close_)]
675
+ arr_ << @axis._to_wkt(open_, close_) if @axis
676
+ arr_
677
+ end
678
+
679
+ class << self
680
+
681
+ def create(name_, vertical_datum_, vertical_unit_, axis_, *optional_)
682
+ new(name_, vertical_datum_, vertical_unit_, axis_, *optional_)
683
+ end
684
+
685
+ end
686
+
687
+ end
688
+
689
+
690
+ class HorizontalCoordinateSystem < CoordinateSystem
691
+
692
+ def initialize(name_, horizontal_datum_, *optional_) # :nodoc:
693
+ super(name_, 2, *optional_)
694
+ @horizontal_datum = horizontal_datum_
695
+ end
696
+
697
+ attr_reader :horizontal_datum
698
+
699
+ end
700
+
701
+
702
+ class GeographicCoordinateSystem < HorizontalCoordinateSystem
703
+
704
+ def initialize(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_) # :nodoc:
705
+ super(name_, horizontal_datum_, *optional_)
706
+ @prime_meridian = prime_meridian_
707
+ @angular_unit = angular_unit_
708
+ @axis0 = axis0_
709
+ @axis1 = axis1_
710
+ end
711
+
712
+ attr_reader :prime_meridian
713
+ attr_reader :angular_unit
714
+
715
+ def get_units(index_)
716
+ @angular_unit
717
+ end
718
+
719
+ def get_axis(index_)
720
+ index_ == 1 ? @axis1 : @axis0
721
+ end
722
+
723
+ def num_conversion_to_wgs84
724
+ @horizontal_datum.wgs84_parameters ? 1 : 0
725
+ end
726
+
727
+ def get_wgs84_conversion_info(index_)
728
+ @horizontal_datum.wgs84_parameters
729
+ end
730
+
731
+ def _wkt_typename # :nodoc:
732
+ "GEOGCS"
733
+ end
734
+
735
+ def _wkt_content(open_, close_) # :nodoc:
736
+ arr_ = [@horizontal_datum._to_wkt(open_, close_), @prime_meridian._to_wkt(open_, close_), @angular_unit._to_wkt(open_, close_)]
737
+ arr_ << @axis0._to_wkt(open_, close_) if @axis0
738
+ arr_ << @axis1._to_wkt(open_, close_) if @axis1
739
+ arr_
740
+ end
741
+
742
+ class << self
743
+
744
+ def create(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_)
745
+ new(name_, angular_unit_, horizontal_datum_, prime_meridian_, axis0_, axis1_, *optional_)
746
+ end
747
+
748
+ end
749
+
750
+ end
751
+
752
+
753
+ class ProjectedCoordinateSystem < HorizontalCoordinateSystem
754
+
755
+ def initialize(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_) # :nodoc:
756
+ super(name_, geographic_coordinate_system_.horizontal_datum, *optional_)
757
+ @geographic_coordinate_system = geographic_coordinate_system_
758
+ @projection = projection_
759
+ @linear_unit = linear_unit_
760
+ @axis0 = axis0_
761
+ @axis1 = axis1_
762
+ end
763
+
764
+ attr_reader :geographic_coordinate_system
765
+ attr_reader :projection
766
+ attr_reader :linear_unit
767
+
768
+ def get_units(index_)
769
+ @linear_unit
770
+ end
771
+
772
+ def get_axis(index_)
773
+ index_ == 1 ? @axis1 : @axis0
774
+ end
775
+
776
+ def _wkt_typename # :nodoc:
777
+ "PROJCS"
778
+ end
779
+
780
+ def _wkt_content(open_, close_) # :nodoc:
781
+ arr_ = [@geographic_coordinate_system._to_wkt(open_, close_), @projection._to_wkt(open_, close_)]
782
+ @projection.each_parameter{ |param_| arr_ << param_._to_wkt(open_, close_) }
783
+ arr_ << @linear_unit._to_wkt(open_, close_)
784
+ arr_ << @axis0._to_wkt(open_, close_) if @axis0
785
+ arr_ << @axis1._to_wkt(open_, close_) if @axis1
786
+ arr_
787
+ end
788
+
789
+ class << self
790
+
791
+ def create(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_)
792
+ new(name_, geographic_coordinate_system_, projection_, linear_unit_, axis0_, axis1_, *optional_)
793
+ end
794
+
795
+ end
796
+
797
+ end
798
+
799
+
800
+ end
801
+
802
+
803
+ end
804
+
805
+ end