Sha256: 781026e5dfde85a9e265b4878bd2ea7fee6cb34d00775c37d6064f4fe5ae729a

Contents?: true

Size: 812 Bytes

Versions: 1

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

module Armg
  class WktDeserializer
    DEFAULT_WKB_PARSER_OPTIONS = {
      support_ewkb: true
    }.freeze

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

    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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
armg-0.7.2 lib/armg/wkt_deserializer.rb