Class: Armg::WktDeserializer

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

Constant Summary collapse

DEFAULT_WKB_PARSER_OPTIONS =
{
  support_ewkb: true
}.freeze
DEFAULT_WKT_GENERATOR_OPTIONS =
{
  tag_format: :ewkt
  # emit_ewkt_srid: true,
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(factory: nil, wkb_parser_options: {}, wkt_generator_options: {}) ⇒ WktDeserializer

Returns a new instance of WktDeserializer.



14
15
16
17
18
19
20
21
22
# File 'lib/armg/wkt_deserializer.rb', line 14

def initialize(factory: nil, wkb_parser_options: {}, wkt_generator_options: {})
  @wkb_parser = RGeo::WKRep::WKBParser.new(
    factory,
    DEFAULT_WKB_PARSER_OPTIONS.merge(wkb_parser_options)
  )
  @wkt_generator = RGeo::WKRep::WKTGenerator.new(
    DEFAULT_WKT_GENERATOR_OPTIONS.merge(wkt_generator_options)
  )
end

Instance Method Details

#deserialize(mysql_geometry) ⇒ Object



24
25
26
27
28
# File 'lib/armg/wkt_deserializer.rb', line 24

def deserialize(mysql_geometry)
  wkb = Armg::Utils.mysql_geometry_to_wkb(mysql_geometry)
  obj = @wkb_parser.parse(wkb)
  @wkt_generator.generate(obj)
end