GEOS  3.6.2
LineString.h
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) 2001-2002 Vivid Solutions Inc.
00008  * Copyright (C) 2005 2006 Refractions Research 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/LineString.java r320 (JTS-1.12)
00018  *
00019  **********************************************************************/
00020 
00021 #ifndef GEOS_GEOS_LINESTRING_H
00022 #define GEOS_GEOS_LINESTRING_H
00023 
00024 #include <geos/export.h>
00025 #include <geos/platform.h> // do we need this ?
00026 #include <geos/geom/Geometry.h> // for inheritance
00027 #include <geos/geom/Lineal.h> // for inheritance
00028 #include <geos/geom/CoordinateSequence.h> // for proper use of auto_ptr<>
00029 #include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
00030 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
00031 
00032 #include <string>
00033 #include <vector>
00034 #include <memory> // for auto_ptr
00035 
00036 #include <geos/inline.h>
00037 
00038 #ifdef _MSC_VER
00039 #pragma warning(push)
00040 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
00041 #endif
00042 
00043 namespace geos {
00044         namespace geom {
00045                 class Coordinate;
00046                 class CoordinateArraySequence;
00047                 class CoordinateSequenceFilter;
00048         }
00049 }
00050 
00051 namespace geos {
00052 namespace geom { // geos::geom
00053 
00070 class GEOS_DLL LineString: public virtual Geometry, public Lineal {
00071 
00072 public:
00073 
00074         friend class GeometryFactory;
00075 
00077         typedef std::vector<const LineString *> ConstVect;
00078 
00079         virtual ~LineString();
00080 
00088         virtual Geometry *clone() const;
00089 
00090         virtual CoordinateSequence* getCoordinates() const;
00091 
00093         const CoordinateSequence* getCoordinatesRO() const;
00094 
00095         virtual const Coordinate& getCoordinateN(int n) const;
00096 
00098         virtual Dimension::DimensionType getDimension() const;
00099 
00105         virtual int getBoundaryDimension() const;
00106 
00108         virtual int getCoordinateDimension() const;
00109 
00115         virtual Geometry* getBoundary() const;
00116 
00117         virtual bool isEmpty() const;
00118 
00119         virtual std::size_t getNumPoints() const;
00120 
00121         virtual Point* getPointN(std::size_t n) const;
00122 
00127         virtual Point* getStartPoint() const;
00128 
00133         virtual Point* getEndPoint() const;
00134 
00135         virtual bool isClosed() const;
00136 
00137         virtual bool isRing() const;
00138 
00139         virtual std::string getGeometryType() const;
00140 
00141         virtual GeometryTypeId getGeometryTypeId() const;
00142 
00143         virtual bool isCoordinate(Coordinate& pt) const;
00144 
00145         virtual bool equalsExact(const Geometry *other, double tolerance=0)
00146                 const;
00147 
00148         virtual void apply_rw(const CoordinateFilter *filter);
00149 
00150         virtual void apply_ro(CoordinateFilter *filter) const;
00151 
00152         virtual void apply_rw(GeometryFilter *filter);
00153 
00154         virtual void apply_ro(GeometryFilter *filter) const;
00155 
00156         virtual void apply_rw(GeometryComponentFilter *filter);
00157 
00158         virtual void apply_ro(GeometryComponentFilter *filter) const;
00159 
00160         void apply_rw(CoordinateSequenceFilter& filter);
00161 
00162         void apply_ro(CoordinateSequenceFilter& filter) const;
00163 
00171         virtual void normalize();
00172 
00173         //was protected
00174         virtual int compareToSameClass(const Geometry *ls) const;
00175 
00176         virtual const Coordinate* getCoordinate() const;
00177 
00178         virtual double getLength() const;
00179 
00186         Geometry* reverse() const;
00187 
00188 protected:
00189 
00190         LineString(const LineString &ls);
00191 
00195         LineString(CoordinateSequence *pts, const GeometryFactory *newFactory);
00196 
00198         LineString(CoordinateSequence::AutoPtr pts,
00199                         const GeometryFactory *newFactory);
00200 
00201         Envelope::AutoPtr computeEnvelopeInternal() const;
00202 
00203         CoordinateSequence::AutoPtr points;
00204 
00205 private:
00206 
00207         void validateConstruction();
00208 
00209 };
00210 
00211 struct GEOS_DLL  LineStringLT {
00212         bool operator()(const LineString *ls1, const LineString *ls2) const {
00213                 return ls1->compareTo(ls2)<0;
00214         }
00215 };
00216 
00217 
00218 inline Geometry*
00219 LineString::clone() const {
00220         return new LineString(*this);
00221 }
00222 
00223 } // namespace geos::geom
00224 } // namespace geos
00225 
00226 #ifdef _MSC_VER
00227 #pragma warning(pop)
00228 #endif
00229 
00230 #endif // ndef GEOS_GEOS_LINESTRING_H