Class: OGR::Geometry::WKBRecord

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/ogr/extensions/geometry/wkb_record.rb

Overview

Parses raw WKB and turns into a data structure. Only really exists for converting to and from EWKB.

See Also:

Constant Summary collapse

WKB_Z =
0x8000_0000

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_ewkb(ewkb_data) ⇒ OGR::Geometry::WKBRecord

Parameters:

  • ewkb_data (String)

    Binary string with the EWKB data.

Returns:



41
42
43
# File 'lib/ogr/extensions/geometry/wkb_record.rb', line 41

def self.from_ewkb(ewkb_data)
  from_ewkb_record(EWKBRecord.read(ewkb_data))
end

.from_ewkb_record(ewkb_record) ⇒ OGR::Geometry::WKBRecord

Parameters:

Returns:



33
34
35
36
37
# File 'lib/ogr/extensions/geometry/wkb_record.rb', line 33

def self.from_ewkb_record(ewkb_record)
  new(endianness: ewkb_record.endianness,
      wkb_type: ewkb_record.geometry_type,
      geometry: ewkb_record.geometry)
end

Instance Method Details

#geometry_typeFixnum

Returns Enum number that matches the FFI::OGR::Core::WKBGeometryType. Defined to keep the API consistent with EWKBRecord.

Returns:

  • (Fixnum)

    Enum number that matches the FFI::OGR::Core::WKBGeometryType. Defined to keep the API consistent with EWKBRecord.



52
53
54
55
56
57
58
59
60
# File 'lib/ogr/extensions/geometry/wkb_record.rb', line 52

def geometry_type
  # ISO SQL/MM style Z types are between 1001 and 1007
  if wkb_type.value >= 1001 && wkb_type.value <= 1007
    raw_type_int = wkb_type.value - 1000
    raw_type_int | WKB_Z
  else
    wkb_type.value
  end
end

#has_z?Boolean

Returns Is the Z flag set?.

Returns:

  • (Boolean)

    Is the Z flag set?



46
47
48
# File 'lib/ogr/extensions/geometry/wkb_record.rb', line 46

def has_z? # rubocop:disable Naming/PredicateName
  geometry_type & WKB_Z != 0
end