Class: GeoRuby::SimpleFeatures::EWKBParser

Inherits:
Object
  • Object
show all
Defined in:
lib/geo_ruby/ewk/ewkb_parser.rb

Overview

Parses EWKB strings and notifies of events (such as the beginning of the definition of geometry, the value of the SRID…) the factory passed as argument to the constructor.

Example

factory = GeometryFactory::new ewkb_parser = EWKBParser::new(factory) ewkb_parser.parse(<EWKB String>) geometry = @factory.geometry

You can also use directly the static method Geometry.from_ewkb

Direct Known Subclasses

HexEWKBParser

Instance Method Summary collapse

Constructor Details

#initialize(factory) ⇒ EWKBParser

Returns a new instance of EWKBParser.



17
18
19
# File 'lib/geo_ruby/ewk/ewkb_parser.rb', line 17

def initialize(factory)
  @factory = factory
end

Instance Method Details

#parse(ewkb) ⇒ Object

Parses the ewkb string passed as argument and notifies the factory of events



22
23
24
25
26
27
28
29
30
# File 'lib/geo_ruby/ewk/ewkb_parser.rb', line 22

def parse(ewkb)
  @factory.reset
  @with_z = false
  @with_m = false
  @unpack_structure = UnpackStructure.new(ewkb)
  parse_geometry
  @unpack_structure.done
  @srid = nil
end