| Class | GeoRuby::SimpleFeatures::EWKTParser |
| In: |
lib/geo_ruby/simple_features/ewkt_parser.rb
|
| Parent: | Object |
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.
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
# File lib/geo_ruby/simple_features/ewkt_parser.rb, line 30
30: def initialize(factory)
31: @factory = factory
32: @parse_options ={
33: "POINT" => method(:parse_point),
34: "LINESTRING" => method(:parse_line_string),
35: "POLYGON" => method(:parse_polygon),
36: "MULTIPOINT" => method(:parse_multi_point),
37: "MULTILINESTRING" => method(:parse_multi_line_string),
38: "MULTIPOLYGON" => method(:parse_multi_polygon),
39: "GEOMETRYCOLLECTION" => method(:parse_geometry_collection)
40: }
41: end
Parses the ewkt string passed as argument and notifies the factory of events
# File lib/geo_ruby/simple_features/ewkt_parser.rb, line 44
44: def parse(ewkt)
45: @factory.reset
46: @tokenizer_structure = TokenizerStructure.new(ewkt)
47: @with_z=false
48: @with_m=false
49: @is_3dm = false
50: parse_geometry(true)
51: @srid=nil
52: end