Class: Armg::WkbSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/armg/wkb_serializer.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  type_format: :ewkb,
  little_endian: true
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ WkbSerializer

Returns a new instance of WkbSerializer.



10
11
12
13
# File 'lib/armg/wkb_serializer.rb', line 10

def initialize(**options)
  options = DEFAULT_OPTIONS.merge(options)
  @wkb_generator = RGeo::WKRep::WKBGenerator.new(options)
end

Instance Method Details

#serialize(obj) ⇒ Object



15
16
17
18
# File 'lib/armg/wkb_serializer.rb', line 15

def serialize(obj)
  srid = Armg::Utils.pack_srid(obj.srid)
  srid + @wkb_generator.generate(obj)
end