class Armg::WktSerializer

Constants

DEFAULT_WKB_GENERATOR_OPTIONS
DEFAULT_WKT_PARSER_OPTIONS

Public Class Methods

new(factory: nil, wkb_generator_options: {}, wkt_parser_options: {}) click to toggle source
# File lib/armg/wkt_serializer.rb, line 14
def initialize(factory: nil, wkb_generator_options: {}, wkt_parser_options: {})
  @wkb_generator = RGeo::WKRep::WKBGenerator.new(
    DEFAULT_WKB_GENERATOR_OPTIONS.merge(wkb_generator_options)
  )
  @wkt_parser = RGeo::WKRep::WKTParser.new(
    factory,
    DEFAULT_WKT_PARSER_OPTIONS.merge(wkt_parser_options)
  )
end

Public Instance Methods

serialize(wkt) click to toggle source
# File lib/armg/wkt_serializer.rb, line 24
def serialize(wkt)
  obj = @wkt_parser.parse(wkt)
  srid = Armg::Utils.pack_srid(obj.srid)
  srid + @wkb_generator.generate(obj)
end