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 <geos/geom/Geometry.h>
28 #include <string>
29 
30 // Forward declarations
31 namespace geos {
32 namespace io {
33 class StringTokenizer;
34 }
35 namespace geom {
36 
37 class Coordinate;
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  std::unique_ptr<geom::Geometry> read(const std::string& wellKnownText);
85 
86 // Geometry* read(Reader& reader); //Not implemented yet
87 
88 protected:
89  std::unique_ptr<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  std::unique_ptr<geom::Geometry> readGeometryTaggedText(io::StringTokenizer* tokenizer);
96  std::unique_ptr<geom::Point> readPointText(io::StringTokenizer* tokenizer);
97  std::unique_ptr<geom::LineString> readLineStringText(io::StringTokenizer* tokenizer);
98  std::unique_ptr<geom::LinearRing> readLinearRingText(io::StringTokenizer* tokenizer);
99  std::unique_ptr<geom::MultiPoint> readMultiPointText(io::StringTokenizer* tokenizer);
100  std::unique_ptr<geom::Polygon> readPolygonText(io::StringTokenizer* tokenizer);
101  std::unique_ptr<geom::MultiLineString> readMultiLineStringText(io::StringTokenizer* tokenizer);
102  std::unique_ptr<geom::MultiPolygon> readMultiPolygonText(io::StringTokenizer* tokenizer);
103  std::unique_ptr<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
WKT parser class; see also WKTWriter.
Definition: WKTReader.h:58
Specifies the precision model of the Coordinate in a Geometry.
Definition: PrecisionModel.h:87
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition: GeometryFactory.h:66
Basic namespace for all GEOS functionalities.
Definition: IndexedNestedRingTester.h:25