Module: OGR::SpatialReferenceMixins::ParameterGetterSetters

Included in:
OGR::SpatialReference
Defined in:
lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb

Instance Method Summary collapse

Instance Method Details

#angular_unitsHash{unit_name: String, value: Float}

Returns unit_name is the name of the unit type (“degree” or “radian”). value is the number to multiply angular distances to transform them to radians.

Returns:

  • (Hash{unit_name: String, value: Float})

    unit_name is the name of the unit type (“degree” or “radian”). value is the number to multiply angular distances to transform them to radians.



27
28
29
30
31
32
# File 'lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb', line 27

def angular_units
  name_ptr = GDAL._pointer_pointer(:string)
  value = FFI::OGR::SRSAPI.OSRGetAngularUnits(@c_pointer, name_ptr)

  { unit_name: GDAL._read_pointer_pointer_safely(name_ptr, :string), value: value }
end

#attribute_value(name, child = 0) ⇒ String?

Parameters:

  • name (String)

    The case-insensitive tree node to look for.

  • child (Integer) (defaults to: 0)

    The child of the node to fetch.

Returns:



9
10
11
# File 'lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb', line 9

def attribute_value(name, child = 0)
  FFI::OGR::SRSAPI.OSRGetAttrValue(@c_pointer, name, child)
end

#linear_unitsHash{unit_name: String, value: Float}

Returns unit_name is the name of the unit type (e.g. “Meters”). value is the number to multiply linear distances to transform them to meters.

Returns:

  • (Hash{unit_name: String, value: Float})

    unit_name is the name of the unit type (e.g. “Meters”). value is the number to multiply linear distances to transform them to meters.



49
50
51
52
53
54
# File 'lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb', line 49

def linear_units
  name_ptr = GDAL._pointer_pointer(:string)
  value = FFI::OGR::SRSAPI.OSRGetLinearUnits(@c_pointer, name_ptr)

  { unit_name: GDAL._read_pointer_pointer_safely(name_ptr, :string), value: value }
end

#prime_meridianHash

Returns:

  • (Hash)


111
112
113
114
115
116
# File 'lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb', line 111

def prime_meridian
  pm_ptr = GDAL._pointer_pointer(:string)
  value = FFI::OGR::SRSAPI.OSRGetPrimeMeridian(@c_pointer, pm_ptr)

  { name: GDAL._read_pointer_pointer_safely(pm_ptr, :string), value: value }
end

#set_angular_units(unit_label, transform_to_radians) ⇒ Object

Parameters:

  • unit_label (String)
  • transform_to_radians (Float)

    The value to multiply an angle to transform the value to radians.

Raises:



38
39
40
41
42
43
44
# File 'lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb', line 38

def set_angular_units(unit_label, transform_to_radians)
  msg = "Unable to set angular units to #{unit_label} (transform to radians? #{transform_to_radians})"

  OGR::ErrorHandling.handle_ogr_err(msg) do
    FFI::OGR::SRSAPI.OSRSetAngularUnits(@c_pointer, unit_label, transform_to_radians.to_f)
  end
end

#set_attribute_value(path, value) ⇒ Object

Parameters:

  • path (String)

    Path to the node to update/set. If nested, use the pipe symbol to denote nesting. i.e. ‘GEOCCS|UNIT’.

  • value (String)

    The new value for the node/path. Should be a String, but if not, will be converted for you.

Raises:



18
19
20
21
22
# File 'lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb', line 18

def set_attribute_value(path, value)
  OGR::ErrorHandling.handle_ogr_err("Unable to set attribute (#{path}) to value #{value}") do
    FFI::OGR::SRSAPI.OSRSetAttrValue(@c_pointer, path, value.to_s)
  end
end

#set_linear_units(unit_label, transform_to_meters) ⇒ Object

Parameters:

  • unit_label (String)
  • transform_to_meters (Float)

    The value to multiply a length to transform the value to meters.

Raises:



60
61
62
63
64
65
66
# File 'lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb', line 60

def set_linear_units(unit_label, transform_to_meters)
  msg = "Unable to set linear units to #{unit_label} (transform to meters? #{transform_to_meters})"

  OGR::ErrorHandling.handle_ogr_err(msg) do
    FFI::OGR::SRSAPI.OSRSetLinearUnits(@c_pointer, unit_label, transform_to_meters.to_f)
  end
end

#set_linear_units_and_update_parameters(unit_label, transform_to_meters) ⇒ Object

Does the same as #set_linear_units, but also converts parameters to use the new units.

Parameters:

  • unit_label (String)
  • transform_to_meters (Float)

    The value to multiply a length to transform the value to meters.

Raises:



75
76
77
78
79
80
81
82
# File 'lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb', line 75

def set_linear_units_and_update_parameters(unit_label, transform_to_meters)
  msg = "Unable to set linear units to #{unit_label} (transform to meters? #{transform_to_meters}) and update" \
        "parameters"

  OGR::ErrorHandling.handle_ogr_err(msg) do
    FFI::OGR::SRSAPI.OSRSetLinearUnitsAndUpdateParameters(@c_pointer, unit_label, transform_to_meters.to_f)
  end
end

#set_target_linear_units(target_key, unit_label, transform_to_meters) ⇒ Object

Parameters:

  • target_key (String)

    The keyword to set linear units for (“PROJCS”, “VERT_CS”, etc.).

  • unit_label (String)

    Name of the units to be used.

  • transform_to_meters (Float)

    The value to multiple a length to transform the value to meters.

Raises:



101
102
103
104
105
106
107
108
# File 'lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb', line 101

def set_target_linear_units(target_key, unit_label, transform_to_meters)
  msg = "Unable to set target (#{target_key}) linear units to #{unit_label} " \
        "(transform to meters? #{transform_to_meters})"

  OGR::ErrorHandling.handle_ogr_err(msg) do
    FFI::OGR::SRSAPI.OSRSetTargetLinearUnits(@c_pointer, target_key, unit_label, transform_to_meters)
  end
end

#target_linear_units(target_key) ⇒ Hash

The linear units for the projection.

Parameters:

  • target_key (String)

    I.e. “PROJCS” or “VERT_CS”.

Returns:

  • (Hash)


88
89
90
91
92
93
# File 'lib/ogr/spatial_reference_mixins/parameter_getter_setters.rb', line 88

def target_linear_units(target_key)
  name_ptr = GDAL._pointer_pointer(:string)
  value = FFI::OGR::SRSAPI.OSRGetTargetLinearUnits(@c_pointer, target_key, name_ptr)

  { unit_name: GDAL._read_pointer_pointer_safely(name_ptr, :string), value: value }
end