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:



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

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.



1433
1434
1435
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1433

def source_cs
  @source_cs
end

#target_csObject

Returns the value of attribute target_cs.



1433
1434
1435
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1433

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:



1545
1546
1547
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1545

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)


1450
1451
1452
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1450

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)


1504
1505
1506
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1504

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)


1464
1465
1466
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1464

def dim_source
  source_cs.dimension
end

#dim_targetInteger

Dimension of the target_cs

Returns:

  • (Integer)


1471
1472
1473
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1471

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)


1490
1491
1492
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1490

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)


1478
1479
1480
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1478

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

#inspectObject



1443
1444
1445
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1443

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:



1530
1531
1532
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1530

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)


1514
1515
1516
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1514

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



1522
1523
1524
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1522

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)


1457
1458
1459
# File 'lib/rgeo/coord_sys/cs/entities.rb', line 1457

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.



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

def wkt_typename
  "CONVERSION"
end