GEOS  3.3.3
WKTReader.h
1 /**********************************************************************
2  * $Id: WKTReader.h 2990 2010-05-18 19:18:54Z warmerdam $
3  *
4  * GEOS - Geometry Engine Open Source
5  * http://geos.refractions.net
6  *
7  * Copyright (C) 2005-2006 Refractions Research Inc.
8  * Copyright (C) 2001-2002 Vivid Solutions Inc.
9  *
10  * This is free software; you can redistribute and/or modify it under
11  * the terms of the GNU Lesser General Public Licence as published
12  * by the Free Software Foundation.
13  * See the COPYING file for more information.
14  *
15  **********************************************************************
16  *
17  * Last port: io/WKTReader.java rev. 1.1 (JTS-1.7)
18  *
19  **********************************************************************/
20 
21 #ifndef GEOS_IO_WKTREADER_H
22 #define GEOS_IO_WKTREADER_H
23 
24 #include <geos/export.h>
25 
26 #include <geos/geom/GeometryFactory.h>
27 #include <geos/geom/CoordinateSequence.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 Geometry;
39  class GeometryCollection;
40  class Point;
41  class LineString;
42  class LinearRing;
43  class Polygon;
44  class MultiPoint;
45  class MultiLineString;
46  class MultiPolygon;
47  class PrecisionModel;
48  }
49 }
50 
51 
52 namespace geos {
53 namespace io {
54 
59 class GEOS_DLL WKTReader {
60 public:
61  //WKTReader();
62 
72 
77  WKTReader();
78 
79  ~WKTReader();
80 
82  geom::Geometry* read(const std::string &wellKnownText);
83 
84 // Geometry* read(Reader& reader); //Not implemented yet
85 
86 protected:
87  geom::CoordinateSequence* getCoordinates(io::StringTokenizer *tokenizer);
88  double getNextNumber(io::StringTokenizer *tokenizer);
89  std::string getNextEmptyOrOpener(io::StringTokenizer *tokenizer);
90  std::string getNextCloserOrComma(io::StringTokenizer *tokenizer);
91  std::string getNextCloser(io::StringTokenizer *tokenizer);
92  std::string getNextWord(io::StringTokenizer *tokenizer);
93  geom::Geometry* readGeometryTaggedText(io::StringTokenizer *tokenizer);
94  geom::Point* readPointText(io::StringTokenizer *tokenizer);
95  geom::LineString* readLineStringText(io::StringTokenizer *tokenizer);
96  geom::LinearRing* readLinearRingText(io::StringTokenizer *tokenizer);
97  geom::MultiPoint* readMultiPointText(io::StringTokenizer *tokenizer);
98  geom::Polygon* readPolygonText(io::StringTokenizer *tokenizer);
99  geom::MultiLineString* readMultiLineStringText(io::StringTokenizer *tokenizer);
100  geom::MultiPolygon* readMultiPolygonText(io::StringTokenizer *tokenizer);
101  geom::GeometryCollection* readGeometryCollectionText(io::StringTokenizer *tokenizer);
102 private:
103  const geom::GeometryFactory *geometryFactory;
104  const geom::PrecisionModel *precisionModel;
105 
106  void getPreciseCoordinate(io::StringTokenizer *tokenizer, geom::Coordinate&, std::size_t &dim );
107 
108  bool isNumberNext(io::StringTokenizer *tokenizer);
109 };
110 
111 } // namespace io
112 } // namespace geos
113 
114 #ifdef GEOS_INLINE
115 # include <geos/io/WKTReader.inl>
116 #endif
117 
118 #endif // #ifndef GEOS_IO_WKTREADER_H
119 
120 /**********************************************************************
121  * $Log$
122  * Revision 1.6 2006/04/10 13:40:14 strk
123  * Added default ctor for WKTReader (using GeometryFactory's default instance)
124  *
125  * Revision 1.5 2006/04/10 12:05:35 strk
126  * Added inline-replicator implementation files to make sure
127  * functions in .inl files are still available out-of-line.
128  * A side effect is this should fix MingW build.
129  *
130  * Revision 1.4 2006/03/30 09:26:36 strk
131  * minor cleanup
132  *
133  * Revision 1.3 2006/03/24 09:52:41 strk
134  * USE_INLINE => GEOS_INLINE
135  *
136  * Revision 1.2 2006/03/22 16:58:35 strk
137  * Removed (almost) all inclusions of geom.h.
138  * Removed obsoleted .cpp files.
139  * Fixed a bug in WKTReader not using the provided CoordinateSequence
140  * implementation, optimized out some memory allocations.
141  *
142  * Revision 1.1 2006/03/20 18:18:15 strk
143  * io.h header split
144  *
145  **********************************************************************/