Class: Proj::CoordinateSystem
- Defined in:
- lib/proj/coordinate_system.rb
Overview
Represents a coordinate system for a CRS
Class Method Summary collapse
-
.create(cs_type, axes, context) ⇒ CoordinateSystem
Create a CoordinateSystem.
-
.create_cartesian_2d(context, cs_type, unit_name: nil, unit_conv_factor: 0) ⇒ CoordinateSystem
Create a CartesiansCS 2D coordinate system.
-
.create_ellipsoidal_2d(cs_type, context, unit_name: nil, unit_conv_factor: 0) ⇒ CoordinateSystem
Create an Ellipsoidal 2D CoordinateSystem.
-
.create_ellipsoidal_3d(cs_type, context, horizontal_angular_unit_name: nil, horizontal_angular_unit_conv_factor: 0, vertical_linear_unit_name: nil, vertical_linear_unit_conv_factor: 0) ⇒ CoordinateSystem
Create an Ellipsoidal 3D CoordinateSystem.
Instance Method Summary collapse
-
#axes ⇒ Array<AxisInfo>
Returns information about all axes.
-
#axis_count ⇒ Integer
Returns the number of axes in the coordinate system.
-
#axis_info(index) ⇒ AxisInfo
Returns information about a single axis.
-
#cs_type ⇒ PjCoordinateSystemType
Returns the type of the coordinate system.
Methods inherited from PjObject
#accuracy, #area_of_use, #auth, #auth_name, #context, #context=, create_from_database, create_from_name, create_from_wkt, #definition, #deprecated?, #description, #destroy, #domains, #equivalent_to?, #errorno, #factors, #geod_direct, #geod_distance, #has_inverse?, #id, #id_code, #info, #initialize, #initialize_copy, #lp_distance, #lpz_distance, #name, #non_deprecated, #proj_type, #remarks, #scope, #source_crs, #target_crs, #to_json, #to_proj_string, #to_ptr, #to_s, #to_wkt
Constructor Details
This class inherits a constructor from Proj::PjObject
Class Method Details
.create(cs_type, axes, context) ⇒ CoordinateSystem
Create a CoordinateSystem
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/proj/coordinate_system.rb', line 13 def self.create(cs_type, axes, context) Error.validate_context!(context) axes_ptr = FFI::MemoryPointer.new(Api::PjAxisDescription, axes.size) # Keep source descriptions alive so their retained string pointers # are not GC'd before proj_create_cs reads them. descriptions = axes.map { |axis| axis.to_description } descriptions.each_with_index do |axis_description_source, i| axis_description_target = Api::PjAxisDescription.new(axes_ptr[i]) axis_description_target.to_ptr.__copy_from__(axis_description_source.to_ptr, Api::PjAxisDescription.size) end pointer = Api.proj_create_cs(context, cs_type, axes.count, axes_ptr) Error.check_context(context) self.create_object(pointer, context) end |
.create_cartesian_2d(context, cs_type, unit_name: nil, unit_conv_factor: 0) ⇒ CoordinateSystem
Create a CartesiansCS 2D coordinate system
69 70 71 72 73 74 |
# File 'lib/proj/coordinate_system.rb', line 69 def self.create_cartesian_2d(context, cs_type, unit_name: nil, unit_conv_factor: 0) Error.validate_context!(context) pointer = Api.proj_create_cartesian_2d_cs(context, cs_type, unit_name, unit_conv_factor) Error.check_context(context) self.create_object(pointer, context) end |
.create_ellipsoidal_2d(cs_type, context, unit_name: nil, unit_conv_factor: 0) ⇒ CoordinateSystem
Create an Ellipsoidal 2D CoordinateSystem
37 38 39 40 41 42 |
# File 'lib/proj/coordinate_system.rb', line 37 def self.create_ellipsoidal_2d(cs_type, context, unit_name: nil, unit_conv_factor: 0) Error.validate_context!(context) pointer = Api.proj_create_ellipsoidal_2d_cs(context, cs_type, unit_name, unit_conv_factor) Error.check_context(context) self.create_object(pointer, context) end |
.create_ellipsoidal_3d(cs_type, context, horizontal_angular_unit_name: nil, horizontal_angular_unit_conv_factor: 0, vertical_linear_unit_name: nil, vertical_linear_unit_conv_factor: 0) ⇒ CoordinateSystem
Create an Ellipsoidal 3D CoordinateSystem
54 55 56 57 58 59 |
# File 'lib/proj/coordinate_system.rb', line 54 def self.create_ellipsoidal_3d(cs_type, context, horizontal_angular_unit_name: nil, horizontal_angular_unit_conv_factor: 0, vertical_linear_unit_name: nil, vertical_linear_unit_conv_factor: 0) Error.validate_context!(context) pointer = Api.proj_create_ellipsoidal_3d_cs(context, cs_type, horizontal_angular_unit_name, horizontal_angular_unit_conv_factor, vertical_linear_unit_name, vertical_linear_unit_conv_factor) Error.check_context(context) self.create_object(pointer, context) end |
Instance Method Details
#axes ⇒ Array<AxisInfo>
Returns information about all axes
137 138 139 140 141 |
# File 'lib/proj/coordinate_system.rb', line 137 def axes self.axis_count.times.map do |index| self.axis_info(index) end end |
#axis_count ⇒ Integer
Returns the number of axes in the coordinate system
94 95 96 97 98 99 100 |
# File 'lib/proj/coordinate_system.rb', line 94 def axis_count result = Api.proj_cs_get_axis_count(self.context, self) if result == -1 Error.check_object(self) end result end |
#axis_info(index) ⇒ AxisInfo
Returns information about a single axis
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/proj/coordinate_system.rb', line 109 def axis_info(index) p_name = FFI::MemoryPointer.new(:pointer) p_abbreviation = FFI::MemoryPointer.new(:pointer) p_direction = FFI::MemoryPointer.new(:pointer) p_unit_conv_factor = FFI::MemoryPointer.new(:double) p_unit_name = FFI::MemoryPointer.new(:pointer) p_unit_auth_name = FFI::MemoryPointer.new(:pointer) p_unit_code = FFI::MemoryPointer.new(:pointer) result = Api.proj_cs_get_axis_info(self.context, self, index, p_name, p_abbreviation, p_direction, p_unit_conv_factor, p_unit_name, p_unit_auth_name, p_unit_code) unless result Error.check_object(self) end AxisInfo.new(name: p_name.read_pointer.read_string, abbreviation: p_abbreviation.read_pointer.read_string_to_null, direction: p_direction.read_pointer.read_string_to_null, unit_conv_factor: p_unit_conv_factor.read_double, unit_name: p_unit_name.read_pointer.read_string_to_null, unit_auth_name: p_unit_auth_name.read_pointer.read_string_to_null, unit_code: p_unit_code.read_pointer.read_string_to_null) end |
#cs_type ⇒ PjCoordinateSystemType
Returns the type of the coordinate system
81 82 83 84 85 86 87 |
# File 'lib/proj/coordinate_system.rb', line 81 def cs_type result = Api.proj_cs_get_type(self.context, self) if result == :PJ_CS_TYPE_UNKNOWN Error.check_object(self) end result end |