Class: RGeo::CoordSys::CS::CoordinateTransform

Inherits:
Info
  • Object
show all
Defined in:
lib/rgeo/coord_sys/cs/entities.rb

Overview

CoordinateTransform object. Note it is a combo of CoordinateTransform and MathTransform as specified in the OGC standard. This is just to simplify the model and keep all functionality in this class.

See Also:

Instance Attribute Summary collapse

Attributes inherited from Info

#abbreviation, #alias, #authority, #authority_code, #name, #remarks

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Info

#extension

Methods inherited from Base

#encode_with, #eql?, #hash, #init_with, #marshal_dump, #marshal_load, #to_s, #to_wkt

Constructor Details

#initialize(source_cs, target_cs, *optional) ⇒ CoordinateTransform

Initialize a new CoordinateTransform

Note this class should not be used directly since it does not implement any transformation logic. It merely defines what methods actual implementations must use.

Parameters:



1424
1425
1426
1427
1428
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1424

def initialize(source_cs, target_cs, *optional)
  super(optional)
  @source_cs = source_cs
  @target_cs = target_cs
end

Instance Attribute Details

#source_csObject

Returns the value of attribute source_cs.



1429
1430
1431
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1429

def source_cs
  @source_cs
end

#target_csObject

Returns the value of attribute target_cs.



1429
1430
1431
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1429

def target_cs
  @target_cs
end

Class Method Details

.create(source_cs, target_cs, *optional) ⇒ CoordinateTransform

Initialize a new CoordinateTransform

Note this class should not be used directly since it does not implement any transformation logic. It merely defines what methods actual implementations must use.

Parameters:

Returns:



1541
1542
1543
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1541

def create(source_cs, target_cs, *optional)
  new(source_cs, target_cs, optional)
end

Instance Method Details

#area_of_useString

Human readable description of domain in source coordinate system.

Returns:

  • (String)

Raises:

  • (NotImplementedError)


1446
1447
1448
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1446

def area_of_use
  raise NotImplementedError, "#{__method__} is not implemented in the abstract CoordinateTransform class."
end

#codomain_convex_hull(points) ⇒ Array<<Array<Integer>>]

Gets transformed convex hull. The supplied ordinates are interpreted as a sequence of points, which generates a convex hull in the source space. The returned sequence of ordinates represents a convex hull in the output space. The number of output points will often be different from the number of input points. Each of the input points should be inside the valid domain (this can be checked by testing the points’ domain flags individually). However, the convex hull of the input points may go outside the valid domain. The returned convex hull should contain the transformed image of the intersection of the source convex hull and the source domain.

Parameters:

  • Array<<Array<Integer>>] (Array<<Array<Integer>>] points in tuples of (x,y,z) with z being optional)

    points in tuples of (x,y,z) with z being optional

Returns:

  • (Array<<Array<Integer>>])

    Array<<Array<Integer>>]

Raises:

  • (NotImplementedError)


1500
1501
1502
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1500

def codomain_convex_hull(points)
  raise NotImplementedError, "#{__method__} is not implemented in the abstract CoordinateTransform class."
end

#dim_sourceInteger

Dimension of the source_cs

Returns:

  • (Integer)


1460
1461
1462
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1460

def dim_source
  source_cs.dimension
end

#dim_targetInteger

Dimension of the target_cs

Returns:

  • (Integer)


1467
1468
1469
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1467

def dim_target
  target_cs.dimension
end

#domain_flags(points) ⇒ Array<Integer>

Gets flags classifying domain points within a convex hull. The supplied ordinates are interpreted as a sequence of points, which generates a convex hull in the source space. Conceptually, each of the (usually infinite) points inside the convex hull is then tested against the source domain. The flags of all these tests are then combined. In practice, implementations of different transforms will use different short-cuts to avoid doing an infinite number of tests.

Parameters:

  • Array<<Array<Integer>>] (Array<<Array<Integer>>] points in tuples of (x,y,z) with z being optional)

    points in tuples of (x,y,z) with z being optional

Returns:

  • (Array<Integer>)

    the domain_flags of the input points

Raises:

  • (NotImplementedError)


1486
1487
1488
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1486

def domain_flags(points)
  raise NotImplementedError, "#{__method__} is not implemented in the abstract CoordinateTransform class."
end

#identity?Boolean

Tests whether this transform does not move any points

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


1474
1475
1476
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1474

def identity?
  raise NotImplementedError, "#{__method__} is not implemented in the abstract CoordinateTransform class."
end

#inspectObject



1439
1440
1441
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1439

def inspect
  "#<#{self.class}:0x#{object_id.to_s(16)} @source_cs=#{source_cs.to_wkt} @target_cs=#{target_cs.to_wkt}>"
end

#inverseCoordinateTransform

Creates the inverse transform of this object. This method may fail if the transform is not one to one. However, all cartographic projections should succeed.

Returns:



1526
1527
1528
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1526

def inverse
  self.class.create(target_cs, source_cs)
end

#transform_coords(x, y, z = nil) ⇒ Array<Integer>

Transforms a coordinate point. The passed parameter point should not be modified.

Parameters:

  • x (Integer)
  • y (Integer)
  • z (Integer) (defaults to: nil)

    optional

Returns:

  • (Array<Integer>)

    transformed point coordinates in (x,y,z) order

Raises:

  • (NotImplementedError)


1510
1511
1512
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1510

def transform_coords(x, y, z = nil)
  raise NotImplementedError, "#{__method__} is not implemented in the abstract CoordinateTransform class."
end

#transform_list(points) ⇒ Array<Array<Integer>>

Transforms a coordinate point. The passed parameter point should not be modified.

Parameters:

  • points (Array<Array<Integer>>)

    in (x,y,z) tuples where z is optional

Returns:

  • (Array<Array<Integer>>)

    list of transformed point coordinates in (x,y,z) order



1518
1519
1520
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1518

def transform_list(points)
  points.map { |x, y, z| transform_coords(x, y, z) }
end

#transform_typeString

Semantic type of transform. For example, a datum transformation or a coordinate conversion.

Returns:

  • (String)

Raises:

  • (NotImplementedError)


1453
1454
1455
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1453

def transform_type
  raise NotImplementedError, "#{__method__} is not implemented in the abstract CoordinateTransform class."
end

#wkt_typenameObject

TODO: This changes depending on what type of conversion is done and we can’t know unless we implement the conversion ourselves. We should delegate all of the wkt generation to the library if possible.



1435
1436
1437
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1435

def wkt_typename
  "CONVERSION"
end