Class: Proj::CoordinateSystem
- Defined in:
- lib/proj/coordinate_system.rb
Overview
Represents a coordinate system for a CRS
Class Method Summary collapse
-
.create(type, axes, context) ⇒ CoordinateSystem
Create a CoordinateSystem.
-
.create_cartesian_2d(context, type, unit_name: nil, unit_conv_factor: 0) ⇒ CoordinateSystem
Create a CartesiansCS 2D coordinate system.
-
.create_ellipsoidal_2d(type, context, unit_name: nil, unit_conv_factor: 0) ⇒ CoordinateSystem
Create an Ellipsoidal 2D CoordinateSystem.
-
.create_ellipsoidal_3d(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.
-
#type ⇒ PJ_COORDINATE_SYSTEM_TYPE
Returns the type of the coordinate system.
Methods inherited from PjObject
#accuracy, #angular_input?, #angular_output?, #area_of_use, #auth, #auth_name, #context, #context=, create_from_database, create_from_name, create_from_wkt, #definition, #degree_input?, #degree_output?, #deprecated?, #description, #equivalent_to?, #errno, #errorno, #factors, #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, #xy_distance, #xyz_distance
Constructor Details
This class inherits a constructor from Proj::PjObject
Class Method Details
.create(type, axes, context) ⇒ CoordinateSystem
Create a CoordinateSystem
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/proj/coordinate_system.rb', line 13 def self.create(type, axes, context) axes_ptr = FFI::MemoryPointer.new(Api::PJ_AXIS_DESCRIPTION, axes.size) axes.each_with_index do |axis, i| axis_description_target = Api::PJ_AXIS_DESCRIPTION.new(axes_ptr[i]) axis_description_source = axis.to_description axis_description_target.to_ptr.__copy_from__(axis_description_source.to_ptr, Api::PJ_AXIS_DESCRIPTION.size) end pointer = Api.proj_create_cs(context, type, axes.count, axes_ptr) Error.check_context(context) self.create_object(pointer, context) end |
.create_cartesian_2d(context, type, unit_name: nil, unit_conv_factor: 0) ⇒ CoordinateSystem
Create a CartesiansCS 2D coordinate system
64 65 66 67 68 |
# File 'lib/proj/coordinate_system.rb', line 64 def self.create_cartesian_2d(context, type, unit_name: nil, unit_conv_factor: 0) pointer = Api.proj_create_cartesian_2D_cs(context, type, unit_name, unit_conv_factor) Error.check_context(context) self.create_object(pointer, context) end |
.create_ellipsoidal_2d(type, context, unit_name: nil, unit_conv_factor: 0) ⇒ CoordinateSystem
Create an Ellipsoidal 2D CoordinateSystem
34 35 36 37 38 |
# File 'lib/proj/coordinate_system.rb', line 34 def self.create_ellipsoidal_2d(type, context, unit_name: nil, unit_conv_factor: 0) pointer = Api.proj_create_ellipsoidal_2D_cs(context, type, unit_name, unit_conv_factor) Error.check_context(context) self.create_object(pointer, context) end |
.create_ellipsoidal_3d(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
50 51 52 53 54 |
# File 'lib/proj/coordinate_system.rb', line 50 def self.create_ellipsoidal_3d(type, context, horizontal_angular_unit_name: nil, horizontal_angular_unit_conv_factor: 0, vertical_linear_unit_name: nil, vertical_linear_unit_conv_factor: 0) pointer = Api.proj_create_ellipsoidal_3D_cs(context, 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
131 132 133 134 135 |
# File 'lib/proj/coordinate_system.rb', line 131 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
88 89 90 91 92 93 94 |
# File 'lib/proj/coordinate_system.rb', line 88 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
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/proj/coordinate_system.rb', line 103 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 |
#type ⇒ PJ_COORDINATE_SYSTEM_TYPE
Returns the type of the coordinate system
75 76 77 78 79 80 81 |
# File 'lib/proj/coordinate_system.rb', line 75 def type result = Api.proj_cs_get_type(self.context, self) if result == :PJ_CS_TYPE_UNKNOWN Error.check_object(self) end result end |