Skip to content

Commit

Permalink
Initial support Coordinate System Metadata for Proj 9.4 (not released…
Browse files Browse the repository at this point in the history
… yet)
  • Loading branch information
cfis committed Jan 31, 2024
1 parent bb653e2 commit 3de2128
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/api/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def self.load_api
'6.0.0', '6.1.0', '6.2.0', '6.3.0',
'7.0.0', '7.1.0', '7.2.0',
'8.0.0', '8.1.0', '8.2.0',
'9.1.0', '9.2.0']
'9.1.0', '9.2.0', '9.4.0']

versions.each do |version|
api_version = Gem::Version.new(version)
Expand Down
6 changes: 6 additions & 0 deletions lib/api/api_9_4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Proj
module Api
attach_function :proj_coordinate_metadata_create, [:PJ_CONTEXT, :PJ, :double], :PJ
attach_function :proj_crs_has_point_motion_operation, [:PJ_CONTEXT, :PJ], :int
end
end
38 changes: 38 additions & 0 deletions lib/proj/coordinate_metadata.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# encoding: UTF-8

module Proj
# Coordinate metadata is the information required to make coordinates unambiguous. For a
# coordinate set referenced to a static CRS it is the CRS definition. For a
# coordinate set referenced to a dynamic CRS it is the CRS definition together
# with the coordinate epoch of the coordinates in the coordinate set.
#
# In a dynamic CRS, coordinates of a point on the surface of the Earth may change with time.
# To be unambiguous the coordinates must always be qualified with the epoch at which they
# are valid. The coordinate epoch is not necessarily the epoch at which the observation
# was collected.
class CoordinateMetadata < PjObject
# Create a CoordinateMetadata object
#
# @param crs [Crs] The associated Crs
# @param context [Context]. An optional Context
# @param epoch [Double]. Epoch at wich the CRS is valid
#
# @return [CoordinateMetadata]
def initialize(crs, context=nil, epoch=nil)
ptr = Api.proj_coordinate_metadata_create(context || Context.current, crs, epoch)

if ptr.null?
Error.check_object(self)
end

super(ptr, context)
end

# Returns the coordinate epoch
#
# @return [Double]
def epoch
Api.proj_coordinate_metadata_get_epoch(self.context, self)
end
end
end
8 changes: 8 additions & 0 deletions lib/proj/crs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,14 @@ def coordinate_operation
self.class.create_object(ptr, self.context)
end

# Returns whether a CRS has an associated PointMotionOperation
#
# @return [Boolean]
def point_motion_operation?
result = Api.proj_crs_get_coordoperation(self.context, self)
result == 1 ? true : false
end

# Returns the prime meridian
#
# @see https://proj.org/development/reference/functions.html#c.proj_get_prime_meridian
Expand Down
2 changes: 2 additions & 0 deletions lib/proj/pj_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def self.create_object(pointer, context)
Ellipsoid
when :PJ_TYPE_PRIME_MERIDIAN
PrimeMeridian
when :PJ_TYPE_COORDINATE_METADATA
CoordinateMetadata
else
# Return whatever the current class is
self
Expand Down

0 comments on commit 3de2128

Please sign in to comment.