Class: GeoRuby::SimpleFeatures::EWKTParser
- Inherits:
-
Object
- Object
- GeoRuby::SimpleFeatures::EWKTParser
- Defined in:
- lib/geo_ruby/simple_features/ewkt_parser.rb
Overview
Parses EWKT 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 ewkt_parser = EWKTParser::new(factory) ewkt_parser.parse(<EWKT String>) geometry = @factory.geometry
You can also use directly the static method Geometry.from_ewkt
Instance Method Summary collapse
-
#initialize(factory) ⇒ EWKTParser
constructor
A new instance of EWKTParser.
-
#parse(ewkt) ⇒ Object
Parses the ewkt string passed as argument and notifies the factory of events.
Constructor Details
#initialize(factory) ⇒ EWKTParser
Returns a new instance of EWKTParser.
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/geo_ruby/simple_features/ewkt_parser.rb', line 30 def initialize(factory) @factory = factory @parse_options ={ "POINT" => method(:parse_point), "LINESTRING" => method(:parse_line_string), "POLYGON" => method(:parse_polygon), "MULTIPOINT" => method(:parse_multi_point), "MULTILINESTRING" => method(:parse_multi_line_string), "MULTIPOLYGON" => method(:parse_multi_polygon), "GEOMETRYCOLLECTION" => method(:parse_geometry_collection) } end |
Instance Method Details
#parse(ewkt) ⇒ Object
Parses the ewkt string passed as argument and notifies the factory of events
44 45 46 47 48 49 50 51 52 |
# File 'lib/geo_ruby/simple_features/ewkt_parser.rb', line 44 def parse(ewkt) @factory.reset @tokenizer_structure = TokenizerStructure.new(ewkt) @with_z=false @with_m=false @is_3dm = false parse_geometry(true) @srid=nil end |