GEOS
3.6.2
|
00001 /********************************************************************** 00002 * 00003 * GEOS - Geometry Engine Open Source 00004 * http://geos.osgeo.org 00005 * 00006 * Copyright (C) 2011 Sandro Santilli <strk@keybit.net> 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: geom/Polygon.java r320 (JTS-1.12) 00018 * 00019 **********************************************************************/ 00020 00021 #ifndef GEOS_GEOM_POLYGON_H 00022 #define GEOS_GEOM_POLYGON_H 00023 00024 #include <geos/export.h> 00025 #include <string> 00026 #include <vector> 00027 #include <geos/platform.h> 00028 #include <geos/geom/Geometry.h> // for inheritance 00029 #include <geos/geom/Polygonal.h> // for inheritance 00030 #include <geos/geom/Envelope.h> // for proper use of auto_ptr<> 00031 #include <geos/geom/Dimension.h> // for Dimension::DimensionType 00032 00033 #include <geos/inline.h> 00034 00035 #include <memory> // for auto_ptr 00036 00037 // Forward declarations 00038 namespace geos { 00039 namespace geom { // geos::geom 00040 class Coordinate; 00041 class CoordinateArraySequence; 00042 class CoordinateSequenceFilter; 00043 class LinearRing; 00044 class LineString; 00045 } 00046 } 00047 00048 namespace geos { 00049 namespace geom { // geos::geom 00050 00066 class GEOS_DLL Polygon: public virtual Geometry, public Polygonal 00067 { 00068 00069 public: 00070 00071 friend class GeometryFactory; 00072 00074 typedef std::vector<const Polygon *> ConstVect; 00075 00076 virtual ~Polygon(); 00077 00084 virtual Geometry *clone() const { return new Polygon(*this); } 00085 00086 CoordinateSequence* getCoordinates() const; 00087 00088 size_t getNumPoints() const; 00089 00091 Dimension::DimensionType getDimension() const; 00092 00094 virtual int getCoordinateDimension() const; 00095 00097 int getBoundaryDimension() const; 00098 00105 Geometry* getBoundary() const; 00106 00107 bool isEmpty() const; 00108 00115 bool isSimple() const; 00116 00118 const LineString* getExteriorRing() const; 00119 00121 size_t getNumInteriorRing() const; 00122 00124 const LineString* getInteriorRingN(std::size_t n) const; 00125 00126 std::string getGeometryType() const; 00127 virtual GeometryTypeId getGeometryTypeId() const; 00128 bool equalsExact(const Geometry *other, double tolerance=0) const; 00129 void apply_rw(const CoordinateFilter *filter); 00130 void apply_ro(CoordinateFilter *filter) const; 00131 void apply_rw(GeometryFilter *filter); 00132 void apply_ro(GeometryFilter *filter) const; 00133 void apply_rw(CoordinateSequenceFilter& filter); 00134 void apply_ro(CoordinateSequenceFilter& filter) const; 00135 00136 Geometry* convexHull() const; 00137 00138 void normalize(); 00139 00140 int compareToSameClass(const Geometry *p) const; //was protected 00141 00142 const Coordinate* getCoordinate() const; 00143 00144 double getArea() const; 00145 00147 double getLength() const; 00148 00149 void apply_rw(GeometryComponentFilter *filter); 00150 00151 void apply_ro(GeometryComponentFilter *filter) const; 00152 00153 bool isRectangle() const; 00154 00155 protected: 00156 00157 00158 Polygon(const Polygon &p); 00159 00178 Polygon(LinearRing *newShell, std::vector<Geometry *> *newHoles, 00179 const GeometryFactory *newFactory); 00180 00181 LinearRing *shell; 00182 00183 std::vector<Geometry *> *holes; //Actually vector<LinearRing *> 00184 00185 Envelope::AutoPtr computeEnvelopeInternal() const; 00186 00187 private: 00188 00189 void normalize(LinearRing *ring, bool clockwise); 00190 }; 00191 00192 } // namespace geos::geom 00193 } // namespace geos 00194 00195 #endif // ndef GEOS_GEOM_POLYGON_H