module OGR::SpatialReferenceMixins::Exporters

Public Instance Methods

to_erm() click to toggle source

@return [Hash] @raise [OGR::NotEnoughData] If name, datum name, and units are not set.

# File lib/ogr/spatial_reference_mixins/exporters.rb, line 8
def to_erm
  projection_name = FFI::MemoryPointer.new(:string, 32)
  datum_name = FFI::MemoryPointer.new(:string, 32)
  units = FFI::MemoryPointer.new(:string, 32)

  OGR::ErrorHandling.handle_ogr_err("Required parameters (name, datum name, units) are not defined") do
    FFI::OGR::SRSAPI.OSRExportToERM(@c_pointer, projection_name, datum_name, units)
  end

  {
    projection_name: projection_name.read_string,
    datum_name: datum_name.read_string,
    units: units.read_string
  }
end
to_gml()
Alias for: to_xml
to_mapinfo() click to toggle source

@return [Array<String>] @raise [OGR::Failure]

# File lib/ogr/spatial_reference_mixins/exporters.rb, line 26
def to_mapinfo
  GDAL._cpl_read_and_free_string do |return_ptr_ptr|
    OGR::ErrorHandling.handle_ogr_err("Unable to export to MapInfo") do
      FFI::OGR::SRSAPI.OSRExportToMICoordSys(@c_pointer, return_ptr_ptr)
    end
  end
end
to_pci() click to toggle source

@return [Hash] @raise [OGR::Failure]

# File lib/ogr/spatial_reference_mixins/exporters.rb, line 36
def to_pci
  proj_ptr_ptr = GDAL._pointer_pointer(:string)
  proj_ptr_ptr.autorelease = false
  units_ptr_ptr = GDAL._pointer_pointer(:string)
  units_ptr_ptr.autorelease = false
  prj_params_ptr_ptr = GDAL._pointer_pointer(:double)
  prj_params_ptr_ptr.autorelease = false

  OGR::ErrorHandling.handle_ogr_err("Unable to export to PCI") do
    FFI::OGR::SRSAPI.OSRExportToPCI(@c_pointer, proj_ptr_ptr, units_ptr_ptr, prj_params_ptr_ptr)
  end

  projection = proj_ptr_ptr.read_pointer.read_string
  units = units_ptr_ptr.read_pointer.read_string
  projection_parameters = prj_params_ptr_ptr.read_array_of_double(0)

  result = {
    projection: projection,
    units: units,
    projection_parameters: projection_parameters
  }

  FFI::CPL::VSI.VSIFree(proj_ptr_ptr)
  FFI::CPL::VSI.VSIFree(units_ptr_ptr)
  FFI::CPL::VSI.VSIFree(prj_params_ptr_ptr)

  result
end
to_pretty_wkt(simplify: false) click to toggle source

@param simplify [Boolean] true strips off AXIS, AUTHORITY and

+EXTENSION+ nodes.

@raise [OGR::Failure] @return [String]

# File lib/ogr/spatial_reference_mixins/exporters.rb, line 119
def to_pretty_wkt(simplify: false)
  return +"" if @c_pointer.null?

  GDAL._cpl_read_and_free_string do |wkt_ptr_ptr|
    OGR::ErrorHandling.handle_ogr_err("Unable to export to pretty WKT") do
      FFI::OGR::SRSAPI.OSRExportToPrettyWkt(@c_pointer, wkt_ptr_ptr, simplify)
    end
  end
end
to_proj4() click to toggle source

@return [String] @raise [GDAL::UnsupportedOperation] If empty definition.

# File lib/ogr/spatial_reference_mixins/exporters.rb, line 67
def to_proj4
  GDAL._cpl_read_and_free_string do |proj4_ptr_ptr|
    OGR::ErrorHandling.handle_ogr_err("Unable to export to PROJ.4") do
      FFI::OGR::SRSAPI.OSRExportToProj4(@c_pointer, proj4_ptr_ptr)
    end
  end
end
to_usgs() click to toggle source

@return [Hash] @raise [OGR::Failure]

# File lib/ogr/spatial_reference_mixins/exporters.rb, line 77
def to_usgs
  proj_sys_ptr = FFI::MemoryPointer.new(:long)
  zone_ptr = FFI::MemoryPointer.new(:long)
  datum_ptr = FFI::MemoryPointer.new(:long)
  prj_params_ptr_ptr = GDAL._pointer_pointer(:double)
  prj_params_ptr_ptr.autorelease = false

  OGR::ErrorHandling.handle_ogr_err("Unable to export to USGS GCTP") do
    FFI::OGR::SRSAPI.OSRExportToUSGS(@c_pointer, proj_sys_ptr, zone_ptr, prj_params_ptr_ptr, datum_ptr)
  end

  projection_system_code = proj_sy_ptrs.read_long
  zone = zon_ptre.read_long
  projection_parameters = prj_params_pt_ptrr.read_array_of_double(0)
  datum = datu_ptrm.read_long

  result = {
    projection_system_code: projection_system_code,
    zone: zone,
    projection_parameters: projection_parameters,
    datum: datum
  }

  FFI::CPL::VSI.VSIFree(prj_params_ptr_ptr)

  result
end
to_wkt() click to toggle source

@return [String] @raise [OGR::Failure]

# File lib/ogr/spatial_reference_mixins/exporters.rb, line 107
def to_wkt
  GDAL._cpl_read_and_free_string do |wkt_ptr_ptr|
    OGR::ErrorHandling.handle_ogr_err("Unable to export to WKT") do
      FFI::OGR::SRSAPI.OSRExportToWkt(@c_pointer, wkt_ptr_ptr)
    end
  end
end
to_xml() click to toggle source

@return [String] @raise [OGR::Failure]

# File lib/ogr/spatial_reference_mixins/exporters.rb, line 131
def to_xml
  GDAL._cpl_read_and_free_string do |xml_ptr_ptr|
    OGR::ErrorHandling.handle_ogr_err("Unable to export to XML (GML)") do
      FFI::OGR::SRSAPI.OSRExportToXML(@c_pointer, xml_ptr_ptr, nil)
    end
  end
end
Also aliased as: to_gml