Module: OGR::Tools

Defined in:
lib/ffi-ogr/tools.rb

Class Method Summary collapse

Class Method Details

.cast_coordinate_transformation(ct_ptr, auto_free = true) ⇒ Object

Raises:

  • (RuntimeError)


9
10
11
12
# File 'lib/ffi-ogr/tools.rb', line 9

def cast_coordinate_transformation(ct_ptr, auto_free=true)
  raise RuntimeError.new("Coordinate Transformation pointer is NULL") if ct_ptr.null?
  CoordinateTransformation.new ct_ptr
end

.cast_data_source(ds_ptr, auto_free = true) ⇒ Object

Raises:

  • (RuntimeError)


14
15
16
17
# File 'lib/ffi-ogr/tools.rb', line 14

def cast_data_source(ds_ptr, auto_free=true)
  raise RuntimeError.new("Data Source pointer is NULL") if ds_ptr.null?
  DataSource.new ds_ptr
end

.cast_feature(f_ptr, auto_free = true) ⇒ Object

Raises:

  • (RuntimeError)


24
25
26
27
# File 'lib/ffi-ogr/tools.rb', line 24

def cast_feature(f_ptr, auto_free=true)
  raise RuntimeError.new("Feature pointer is NULL") if f_ptr.null?
  Feature.new f_ptr
end

.cast_geometry(geom_ptr, auto_free = true) ⇒ Object

Raises:

  • (RuntimeError)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ffi-ogr/tools.rb', line 29

def cast_geometry(geom_ptr, auto_free=true)
  #options = {auto_free: true}.merge(options)
  raise RuntimeError.new("Geometry pointer is NULL") if geom_ptr.null?

  geom_type = FFIOGR.OGR_G_GetGeometryType(geom_ptr)

  klass = case geom_type
  when :point
    OGR::Point
  when :line_string
    OGR::LineString
  when :polygon
    OGR::Polygon
  when :multi_point
    OGR::MultiPoint
  when :multi_line_string
    OGR::MultiLineString
  when :multi_polygon
    OGR::MultiPolygon
  when :geometry_collection
    OGR::GeometryCollection
  when :linear_ring
    OGR::LinearRing
  when :point_25d
    OGR::Point25D
  when :line_string_25d
    OGR::LineString25D
  when :polygon_25d
    OGR::Polygon25D
  when :multi_point_25d
    OGR::MultiPoint25D
  when :multi_line_string_25d
    OGR::MultiLineString25D
  when :multi_polygon_25d
    OGR::MultiPolygon25D
  when :geometry_collection_25d
    OGR::GeometryCollection25D
  end

  klass.new(geom_ptr)
end

.cast_layer(l_ptr, auto_free = true) ⇒ Object

Raises:

  • (RuntimeError)


19
20
21
22
# File 'lib/ffi-ogr/tools.rb', line 19

def cast_layer(l_ptr, auto_free=true)
  raise RuntimeError.new("Layer pointer is NULL") if l_ptr.null?
  Layer.new l_ptr
end

.cast_spatial_reference(sr_ptr, auto_free = true) ⇒ Object

Raises:

  • (RuntimeError)


4
5
6
7
# File 'lib/ffi-ogr/tools.rb', line 4

def cast_spatial_reference(sr_ptr, auto_free=true)
  raise RuntimeError.new("Spatial Reference pointer is NULL") if sr_ptr.null?
  SpatialReference.new sr_ptr
end