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

- File List

# Polygon.h

    00001 /**********************************************************************
    00002  * $Id: Polygon.h 3185 2011-02-07 15:39:27Z strk $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    00007  * Copyright (C) 2011 Sandro Santilli <strk@keybit.net>
    00008  * Copyright (C) 2005 2006 Refractions Research Inc.
    00009  * Copyright (C) 2001-2002 Vivid Solutions Inc.
    00010  *
    00011  * This is free software; you can redistribute and/or modify it under
    00012  * the terms of the GNU Lesser General Public Licence as published
    00013  * by the Free Software Foundation.
    00014  * See the COPYING file for more information.
    00015  *
    00016  **********************************************************************
    00017  *
    00018  * Last port: geom/Polygon.java r320 (JTS-1.12)
    00019  *
    00020  **********************************************************************/
    00021
    00022 #ifndef GEOS_GEOM_POLYGON_H
    00023 #define GEOS_GEOM_POLYGON_H
    00024
    00025 #include <geos/export.h>
    00026 #include <string>
    00027 #include <vector>
    00028 #include <geos/platform.h>
    00029 #include <geos/geom/Geometry.h> // for inheritance
    00030 #include <geos/geom/Polygonal.h> // for inheritance
    00031 #include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
    00032 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
    00033
    00034 #include <geos/inline.h>
    00035
    00036 #include <memory> // for auto_ptr
    00037
    00038 // Forward declarations
    00039 namespace geos {
    00040         namespace geom { // geos::geom
    00041                 class Coordinate;
    00042                 class CoordinateArraySequence;
    00043                 class CoordinateSequenceFilter;
    00044                 class LinearRing;
    00045                 class LineString;
    00046         }
    00047 }
    00048
    00049 namespace geos {
    00050 namespace geom { // geos::geom
    00051
    00067 class GEOS_DLL Polygon: public virtual Geometry, public Polygonal
    00068 {
    00069
    00070 public:
    00071
    00072         friend class GeometryFactory;
    00073
    00075         typedef std::vector<const Polygon *> ConstVect;
    00076
    00077         virtual ~Polygon();
    00078
    00085         virtual Geometry *clone() const { return new Polygon(*this); }
    00086
    00087         CoordinateSequence* getCoordinates() const;
    00088
    00089         size_t getNumPoints() const;
    00090
    00092         Dimension::DimensionType getDimension() const;
    00093
    00095         virtual int getCoordinateDimension() const;
    00096
    00098         int getBoundaryDimension() const;
    00099
    00106         Geometry* getBoundary() const;
    00107
    00108         bool isEmpty() const;
    00109
    00116         bool isSimple() const;
    00117
    00119         const LineString* getExteriorRing() const;
    00120
    00122         size_t getNumInteriorRing() const;
    00123
    00125         const LineString* getInteriorRingN(std::size_t n) const;
    00126
    00127         std::string getGeometryType() const;
    00128         virtual GeometryTypeId getGeometryTypeId() const;
    00129         bool equalsExact(const Geometry *other, double tolerance=0) const;
    00130         void apply_rw(const CoordinateFilter *filter);
    00131         void apply_ro(CoordinateFilter *filter) const;
    00132         void apply_rw(GeometryFilter *filter);
    00133         void apply_ro(GeometryFilter *filter) const;
    00134         void apply_rw(CoordinateSequenceFilter& filter);
    00135         void apply_ro(CoordinateSequenceFilter& filter) const;
    00136
    00137         Geometry* convexHull() const;
    00138
    00139         void normalize();
    00140
    00141         int compareToSameClass(const Geometry *p) const; //was protected
    00142
    00143         const Coordinate* getCoordinate() const;
    00144
    00145         double getArea() const;
    00146
    00148         double getLength() const;
    00149
    00150         void apply_rw(GeometryComponentFilter *filter);
    00151
    00152         void apply_ro(GeometryComponentFilter *filter) const;
    00153
    00154         bool isRectangle() const;
    00155
    00156 protected:
    00157
    00158
    00159         Polygon(const Polygon &p);
    00160
    00179         Polygon(LinearRing *newShell, std::vector<Geometry *> *newHoles,
    00180                 const GeometryFactory *newFactory);
    00181
    00182         LinearRing *shell;
    00183
    00184         std::vector<Geometry *> *holes; //Actually vector<LinearRing *>
    00185
    00186         Envelope::AutoPtr computeEnvelopeInternal() const;
    00187
    00188 private:
    00189
    00190         void normalize(LinearRing *ring, bool clockwise);
    00191 };
    00192
    00193 } // namespace geos::geom
    00194 } // namespace geos
    00195
    00196 #endif // ndef GEOS_GEOM_POLYGON_H
    00197
    00198 /**********************************************************************
    00199  * $Log$
    00200  * Revision 1.7  2006/06/08 17:58:57  strk
    00201  * Polygon::getNumInteriorRing() return size_t, Polygon::interiorRingN() takes size_t.
    00202  *
    00203  * Revision 1.6  2006/05/04 15:49:39  strk
    00204  * updated all Geometry::getDimension() methods to return Dimension::DimensionType (closes bug#93)
    00205  *
    00206  * Revision 1.5  2006/04/28 10:55:39  strk
    00207  * Geometry constructors made protected, to ensure all constructions use GeometryFactory,
    00208  * which has been made friend of all Geometry derivates. getNumPoints() changed to return
    00209  * size_t.
    00210  *
    00211  * Revision 1.4  2006/04/10 18:15:09  strk
    00212  * Changed Geometry::envelope member to be of type auto_ptr<Envelope>.
    00213  * Changed computeEnvelopeInternal() signater to return auto_ptr<Envelope>
    00214  *
    00215  * Revision 1.3  2006/03/24 09:52:41  strk
    00216  * USE_INLINE => GEOS_INLINE
    00217  *
    00218  * Revision 1.2  2006/03/15 09:12:45  strk
    00219  * isSimple doc
    00220  *
    00221  * Revision 1.1  2006/03/09 16:46:49  strk
    00222  * geos::geom namespace definition, first pass at headers split
    00223  *
    00224  **********************************************************************/