Class: GeoRuby::SimpleFeatures::EWKBParser
- Inherits:
-
Object
- Object
- GeoRuby::SimpleFeatures::EWKBParser
- Defined in:
- lib/geo_ruby/simple_features/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(
You can also use directly the static method Geometry.from_ewkb
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(factory) ⇒ EWKBParser
constructor
A new instance of EWKBParser.
-
#parse(ewkb) ⇒ Object
Parses the ewkb string passed as argument and notifies the factory of events.
Constructor Details
#initialize(factory) ⇒ EWKBParser
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 28 def initialize(factory) @factory = factory ={ 1 => method(:parse_point), 2 => method(:parse_line_string), 3 => method(:parse_polygon), 4 => method(:parse_multi_point), 5 => method(:parse_multi_line_string), 6 => method(:parse_multi_polygon), 7 => method(:parse_geometry_collection) } end |
Instance Method Details
#parse(ewkb) ⇒ Object
Parses the ewkb string passed as argument and notifies the factory of events
42 43 44 45 46 47 48 49 50 |
# File 'lib/geo_ruby/simple_features/ewkb_parser.rb', line 42 def parse(ewkb) @factory.reset @unpack_structure=UnpackStructure::new(ewkb) @with_z = false @with_m = false parse_geometry @unpack_structure.done @srid=nil end |