GEOS: WKTWriter.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# WKTWriter.h

    00001 /**********************************************************************
    00002  * $Id: WKTWriter.h 1820 2006-09-06 16:54:23Z mloskot $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2005-2006 Refractions Research Inc.
    00008  * Copyright (C) 2001-2002 Vivid Solutions Inc.
    00009  *
    00010  * This is free software; you can redistribute and/or modify it under
    00011  * the terms of the GNU Lesser General Public Licence as published
    00012  * by the Free Software Foundation.
    00013  * See the COPYING file for more information.
    00014  *
    00015  **********************************************************************/
    00016
    00017 #ifndef GEOS_IO_WKTWRITER_H
    00018 #define GEOS_IO_WKTWRITER_H
    00019
    00020 #include <string>
    00021
    00022 // Forward declarations
    00023 namespace geos {
    00024         namespace geom {
    00025                 class Coordinate;
    00026                 class CoordinateSequence;
    00027                 class Geometry;
    00028                 class GeometryCollection;
    00029                 class Point;
    00030                 class LineString;
    00031                 class LinearRing;
    00032                 class Polygon;
    00033                 class MultiPoint;
    00034                 class MultiLineString;
    00035                 class MultiPolygon;
    00036                 class PrecisionModel;
    00037         }
    00038         namespace io {
    00039                 class Writer;
    00040         }
    00041 }
    00042
    00043
    00044 namespace geos {
    00045 namespace io {
    00046
    00068 class WKTWriter {
    00069 public:
    00070         WKTWriter();
    00071         ~WKTWriter();
    00072
    00073         //string(count, ch) can be used for this
    00074         //static string stringOfChar(char ch, int count);
    00075
    00077         std::string write(const geom::Geometry *geometry);
    00078
    00079         // Send Geometry's WKT to the given Writer
    00080         void write(const geom::Geometry *geometry, Writer *writer);
    00081
    00082         std::string writeFormatted(const geom::Geometry *geometry);
    00083
    00084         void writeFormatted(const geom::Geometry *geometry, Writer *writer);
    00085
    00093         static std::string toLineString(const geom::CoordinateSequence& seq);
    00094
    00103         static std::string toLineString(const geom::Coordinate& p0, const geom::Coordinate& p1);
    00104
    00112         static std::string toPoint(const geom::Coordinate& p0);
    00113
    00114
    00115 protected:
    00116
    00117         std::string formatter;
    00118
    00119         void appendGeometryTaggedText(const geom::Geometry *geometry, int level, Writer *writer);
    00120
    00121         void appendPointTaggedText(
    00122                         const geom::Coordinate* coordinate,
    00123                         int level, Writer *writer);
    00124
    00125         void appendLineStringTaggedText(
    00126                         const geom::LineString *lineString,
    00127                         int level, Writer *writer);
    00128
    00129         void appendLinearRingTaggedText(
    00130                         const geom::LinearRing *lineString,
    00131                         int level, Writer *writer);
    00132
    00133         void appendPolygonTaggedText(
    00134                         const geom::Polygon *polygon,
    00135                         int level, Writer *writer);
    00136
    00137         void appendMultiPointTaggedText(
    00138                         const geom::MultiPoint *multipoint,
    00139                         int level, Writer *writer);
    00140
    00141         void appendMultiLineStringTaggedText(
    00142                         const geom::MultiLineString *multiLineString,
    00143                         int level,Writer *writer);
    00144
    00145         void appendMultiPolygonTaggedText(
    00146                         const geom::MultiPolygon *multiPolygon,
    00147                         int level, Writer *writer);
    00148
    00149         void appendGeometryCollectionTaggedText(
    00150                         const geom::GeometryCollection *geometryCollection,
    00151                         int level,Writer *writer);
    00152
    00153         void appendPointText(const geom::Coordinate* coordinate, int level,
    00154                         Writer *writer);
    00155
    00156         void appendCoordinate(const geom::Coordinate* coordinate,
    00157                         Writer *writer);
    00158
    00159         std::string writeNumber(double d);
    00160
    00161         void appendLineStringText(
    00162                         const geom::LineString *lineString,
    00163                         int level, bool doIndent, Writer *writer);
    00164
    00165         void appendPolygonText(
    00166                         const geom::Polygon *polygon,
    00167                         int level, bool indentFirst, Writer *writer);
    00168
    00169         void appendMultiPointText(
    00170                         const geom::MultiPoint *multiPoint,
    00171                         int level, Writer *writer);
    00172
    00173         void appendMultiLineStringText(
    00174                         const geom::MultiLineString *multiLineString,
    00175                         int level, bool indentFirst,Writer *writer);
    00176
    00177         void appendMultiPolygonText(
    00178                         const geom::MultiPolygon *multiPolygon,
    00179                         int level, Writer *writer);
    00180
    00181         void appendGeometryCollectionText(
    00182                         const geom::GeometryCollection *geometryCollection,
    00183                         int level,Writer *writer);
    00184
    00185 private:
    00186
    00187         enum {
    00188                 INDENT = 2
    00189         };
    00190
    00191 //      static const int INDENT = 2;
    00192
    00193         static std::string createFormatter(
    00194                         const geom::PrecisionModel* precisionModel);
    00195
    00196         bool isFormatted;
    00197
    00198         int level;
    00199
    00200         void writeFormatted(
    00201                         const geom::Geometry *geometry,
    00202                         bool isFormatted, Writer *writer);
    00203
    00204         void indent(int level, Writer *writer);
    00205 };
    00206
    00207 } // namespace geos::io
    00208 } // namespace geos
    00209
    00210 #endif // #ifndef GEOS_IO_WKTWRITER_H
    00211
    00212 /**********************************************************************
    00213  * $Log$
    00214  * Revision 1.3  2006/06/12 16:55:53  strk
    00215  * fixed compiler warnings, fixed some methods to omit unused parameters.
    00216  *
    00217  * Revision 1.2  2006/03/22 16:58:35  strk
    00218  * Removed (almost) all inclusions of geom.h.
    00219  * Removed obsoleted .cpp files.
    00220  * Fixed a bug in WKTReader not using the provided CoordinateSequence
    00221  * implementation, optimized out some memory allocations.
    00222  *
    00223  * Revision 1.1  2006/03/20 18:18:15  strk
    00224  * io.h header split
    00225  *
    00226  **********************************************************************/