Class: OGR::Geometry::EWKBRecord

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

Overview

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

Constant Summary collapse

WKB_Z =
0x8000_0000
WKB_M =
0x4000_0000
WKB_SRID =
0x2000_0000

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_wkb_record(wkb_record, srid = 0) ⇒ OGR::Geometry::EWKBRecord

Parameters:

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/ogr/extensions/geometry/ewkb_record.rb', line 45

def self.from_wkb_record(wkb_record, srid = 0)
  ewkb_type_flag = if srid.zero?
                     wkb_record.wkb_type
                   else
                     (wkb_record.wkb_type | WKB_SRID)
                   end

  ewkb_type_flag |= WKB_Z if wkb_record.has_z?

  new(endianness: wkb_record.endianness,
      wkb_type: ewkb_type_flag,
      srid: srid,
      geometry: wkb_record.geometry)
end

Instance Method Details

#geometry_typeFixnum

Returns Enum number that matches the FFI::OGR::Core::WKBGeometryType.

Returns:

  • (Fixnum)

    Enum number that matches the FFI::OGR::Core::WKBGeometryType.



76
77
78
79
80
# File 'lib/ogr/extensions/geometry/ewkb_record.rb', line 76

def geometry_type
  type = wkb_type & 0x0fff_ffff

  has_z? ? (type | WKB_Z) : type
end

#has_m?Boolean

Returns Is the M flag set?.

Returns:

  • (Boolean)

    Is the M flag set?



66
67
68
# File 'lib/ogr/extensions/geometry/ewkb_record.rb', line 66

def has_m?
  wkb_type & WKB_M != 0
end

#has_srid?Boolean

Returns Is the SRID flag set?.

Returns:

  • (Boolean)

    Is the SRID flag set?



71
72
73
# File 'lib/ogr/extensions/geometry/ewkb_record.rb', line 71

def has_srid?
  wkb_type & WKB_SRID != 0
end

#has_z?Boolean

Returns Is the Z flag set?.

Returns:

  • (Boolean)

    Is the Z flag set?



61
62
63
# File 'lib/ogr/extensions/geometry/ewkb_record.rb', line 61

def has_z?
  wkb_type & WKB_Z != 0
end

#to_wkbString

Returns WKB binary string.

Returns:

  • (String)

    WKB binary string.



88
89
90
# File 'lib/ogr/extensions/geometry/ewkb_record.rb', line 88

def to_wkb
  to_wkb_record.to_binary_s
end

#to_wkb_recordOGR::Geometry::WKBRecord



83
84
85
# File 'lib/ogr/extensions/geometry/ewkb_record.rb', line 83

def to_wkb_record
  WKBRecord.from_ewkb_record(self)
end