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

- File List

# WKTWriter.h

    00001 /**********************************************************************
    00002  * $Id: WKTWriter.h 2579 2009-06-15 14:03:52Z strk $
    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  * Last port: io/WKTWriter.java rev. 1.34 (JTS-1.7)
    00018  *
    00019  **********************************************************************/
    00020
    00021 #ifndef GEOS_IO_WKTWRITER_H
    00022 #define GEOS_IO_WKTWRITER_H
    00023
    00024 #include <geos/export.h>
    00025
    00026 #include <string>
    00027
    00028 // Forward declarations
    00029 namespace geos {
    00030         namespace geom {
    00031                 class Coordinate;
    00032                 class CoordinateSequence;
    00033                 class Geometry;
    00034                 class GeometryCollection;
    00035                 class Point;
    00036                 class LineString;
    00037                 class LinearRing;
    00038                 class Polygon;
    00039                 class MultiPoint;
    00040                 class MultiLineString;
    00041                 class MultiPolygon;
    00042                 class PrecisionModel;
    00043         }
    00044         namespace io {
    00045                 class Writer;
    00046         }
    00047 }
    00048
    00049
    00050 namespace geos {
    00051 namespace io {
    00052
    00074 class GEOS_DLL WKTWriter {
    00075 public:
    00076         WKTWriter();
    00077         ~WKTWriter();
    00078
    00079         //string(count, ch) can be used for this
    00080         //static string stringOfChar(char ch, int count);
    00081
    00083         std::string write(const geom::Geometry *geometry);
    00084
    00085         // Send Geometry's WKT to the given Writer
    00086         void write(const geom::Geometry *geometry, Writer *writer);
    00087
    00088         std::string writeFormatted(const geom::Geometry *geometry);
    00089
    00090         void writeFormatted(const geom::Geometry *geometry, Writer *writer);
    00091
    00099         static std::string toLineString(const geom::CoordinateSequence& seq);
    00100
    00109         static std::string toLineString(const geom::Coordinate& p0, const geom::Coordinate& p1);
    00110
    00118         static std::string toPoint(const geom::Coordinate& p0);
    00119
    00120
    00121 protected:
    00122
    00123         std::string formatter;
    00124
    00125         void appendGeometryTaggedText(const geom::Geometry *geometry, int level, Writer *writer);
    00126
    00127         void appendPointTaggedText(
    00128                         const geom::Coordinate* coordinate,
    00129                         int level, Writer *writer);
    00130
    00131         void appendLineStringTaggedText(
    00132                         const geom::LineString *lineString,
    00133                         int level, Writer *writer);
    00134
    00135         void appendLinearRingTaggedText(
    00136                         const geom::LinearRing *lineString,
    00137                         int level, Writer *writer);
    00138
    00139         void appendPolygonTaggedText(
    00140                         const geom::Polygon *polygon,
    00141                         int level, Writer *writer);
    00142
    00143         void appendMultiPointTaggedText(
    00144                         const geom::MultiPoint *multipoint,
    00145                         int level, Writer *writer);
    00146
    00147         void appendMultiLineStringTaggedText(
    00148                         const geom::MultiLineString *multiLineString,
    00149                         int level,Writer *writer);
    00150
    00151         void appendMultiPolygonTaggedText(
    00152                         const geom::MultiPolygon *multiPolygon,
    00153                         int level, Writer *writer);
    00154
    00155         void appendGeometryCollectionTaggedText(
    00156                         const geom::GeometryCollection *geometryCollection,
    00157                         int level,Writer *writer);
    00158
    00159         void appendPointText(const geom::Coordinate* coordinate, int level,
    00160                         Writer *writer);
    00161
    00162         void appendCoordinate(const geom::Coordinate* coordinate,
    00163                         Writer *writer);
    00164
    00165         std::string writeNumber(double d);
    00166
    00167         void appendLineStringText(
    00168                         const geom::LineString *lineString,
    00169                         int level, bool doIndent, Writer *writer);
    00170
    00171         void appendPolygonText(
    00172                         const geom::Polygon *polygon,
    00173                         int level, bool indentFirst, Writer *writer);
    00174
    00175         void appendMultiPointText(
    00176                         const geom::MultiPoint *multiPoint,
    00177                         int level, Writer *writer);
    00178
    00179         void appendMultiLineStringText(
    00180                         const geom::MultiLineString *multiLineString,
    00181                         int level, bool indentFirst,Writer *writer);
    00182
    00183         void appendMultiPolygonText(
    00184                         const geom::MultiPolygon *multiPolygon,
    00185                         int level, Writer *writer);
    00186
    00187         void appendGeometryCollectionText(
    00188                         const geom::GeometryCollection *geometryCollection,
    00189                         int level,Writer *writer);
    00190
    00191 private:
    00192
    00193         enum {
    00194                 INDENT = 2
    00195         };
    00196
    00197 //      static const int INDENT = 2;
    00198
    00199         static std::string createFormatter(
    00200                         const geom::PrecisionModel* precisionModel);
    00201
    00202         bool isFormatted;
    00203
    00204         int level;
    00205
    00206         void writeFormatted(
    00207                         const geom::Geometry *geometry,
    00208                         bool isFormatted, Writer *writer);
    00209
    00210         void indent(int level, Writer *writer);
    00211 };
    00212
    00213 } // namespace geos::io
    00214 } // namespace geos
    00215
    00216 #endif // #ifndef GEOS_IO_WKTWRITER_H
    00217
    00218 /**********************************************************************
    00219  * $Log$
    00220  * Revision 1.3  2006/06/12 16:55:53  strk
    00221  * fixed compiler warnings, fixed some methods to omit unused parameters.
    00222  *
    00223  * Revision 1.2  2006/03/22 16:58:35  strk
    00224  * Removed (almost) all inclusions of geom.h.
    00225  * Removed obsoleted .cpp files.
    00226  * Fixed a bug in WKTReader not using the provided CoordinateSequence
    00227  * implementation, optimized out some memory allocations.
    00228  *
    00229  * Revision 1.1  2006/03/20 18:18:15  strk
    00230  * io.h header split
    00231  *
    00232  **********************************************************************/