GEOS  3.8.0dev
WKTReader.h
1 /**********************************************************************
2  *
3  * GEOS - Geometry Engine Open Source
4  * http://geos.osgeo.org
5  *
6  * Copyright (C) 2005-2006 Refractions Research Inc.
7  * Copyright (C) 2001-2002 Vivid Solutions Inc.
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU Lesser General Public Licence as published
11  * by the Free Software Foundation.
12  * See the COPYING file for more information.
13  *
14  **********************************************************************
15  *
16  * Last port: io/WKTReader.java rev. 1.1 (JTS-1.7)
17  *
18  **********************************************************************/
19 
20 #ifndef GEOS_IO_WKTREADER_H
21 #define GEOS_IO_WKTREADER_H
22 
23 #include <geos/export.h>
24 
25 #include <geos/geom/GeometryFactory.h>
26 #include <geos/geom/CoordinateSequence.h>
27 #include <string>
28 
29 // Forward declarations
30 namespace geos {
31 namespace io {
32 class StringTokenizer;
33 }
34 namespace geom {
35 
36 class Coordinate;
37 class Geometry;
38 class GeometryCollection;
39 class Point;
40 class LineString;
41 class LinearRing;
42 class Polygon;
43 class MultiPoint;
44 class MultiLineString;
45 class MultiPolygon;
46 class PrecisionModel;
47 }
48 }
49 
50 
51 namespace geos {
52 namespace io {
53 
58 class GEOS_DLL WKTReader {
59 public:
60  //WKTReader();
61 
71 
74 
79  WKTReader();
80 
81  ~WKTReader();
82 
84  geom::Geometry* read(const std::string& wellKnownText);
85 
86 // Geometry* read(Reader& reader); //Not implemented yet
87 
88 protected:
89  geom::CoordinateSequence* getCoordinates(io::StringTokenizer* tokenizer);
90  double getNextNumber(io::StringTokenizer* tokenizer);
91  std::string getNextEmptyOrOpener(io::StringTokenizer* tokenizer);
92  std::string getNextCloserOrComma(io::StringTokenizer* tokenizer);
93  std::string getNextCloser(io::StringTokenizer* tokenizer);
94  std::string getNextWord(io::StringTokenizer* tokenizer);
95  geom::Geometry* readGeometryTaggedText(io::StringTokenizer* tokenizer);
96  geom::Point* readPointText(io::StringTokenizer* tokenizer);
97  geom::LineString* readLineStringText(io::StringTokenizer* tokenizer);
98  geom::LinearRing* readLinearRingText(io::StringTokenizer* tokenizer);
99  geom::MultiPoint* readMultiPointText(io::StringTokenizer* tokenizer);
100  geom::Polygon* readPolygonText(io::StringTokenizer* tokenizer);
101  geom::MultiLineString* readMultiLineStringText(io::StringTokenizer* tokenizer);
102  geom::MultiPolygon* readMultiPolygonText(io::StringTokenizer* tokenizer);
103  geom::GeometryCollection* readGeometryCollectionText(io::StringTokenizer* tokenizer);
104 private:
105  const geom::GeometryFactory* geometryFactory;
106  const geom::PrecisionModel* precisionModel;
107 
108  void getPreciseCoordinate(io::StringTokenizer* tokenizer, geom::Coordinate&, std::size_t& dim);
109 
110  bool isNumberNext(io::StringTokenizer* tokenizer);
111 };
112 
113 } // namespace io
114 } // namespace geos
115 
116 #ifdef GEOS_INLINE
117 # include <geos/io/WKTReader.inl>
118 #endif
119 
120 #endif // #ifndef GEOS_IO_WKTREADER_H
Coordinate is the lightweight class used to store coordinates.
Definition: Coordinate.h:60
Models a collection of Polygons.
Definition: MultiPolygon.h:59
WKT parser class; see also WKTWriter.
Definition: WKTReader.h:58
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition: Geometry.h:187
Definition: LineString.h:69
Represents a linear polygon, which may include holes.
Definition: Polygon.h:65
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:67
Represents a collection of heterogeneous Geometry objects.
Definition: GeometryCollection.h:55
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25
Definition: MultiPoint.h:54
Models an OGC SFS LinearRing.
Definition: LinearRing.h:56
The internal representation of a list of coordinates inside a Geometry.
Definition: CoordinateSequence.h:58
Definition: Point.h:66
Models a collection of (}s.
Definition: MultiLineString.h:51