GEOS: LineString.h Source File

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

- File List

# LineString.h

    00001 /**********************************************************************
    00002  * $Id: LineString.h 2556 2009-06-06 22:22:28Z strk $
    00003  *
    00004  * GEOS - Geometry Engine Open Source
    00005  * http://geos.refractions.net
    00006  *
    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 rev. 1.46
    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/CoordinateSequence.h> // for proper use of auto_ptr<>
    00028 #include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
    00029 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
    00030
    00031 #include <string>
    00032 #include <vector>
    00033 #include <memory> // for auto_ptr
    00034
    00035 #include <geos/inline.h>
    00036
    00037 namespace geos {
    00038         namespace geom {
    00039                 class Coordinate;
    00040                 class CoordinateArraySequence;
    00041                 class CoordinateSequenceFilter;
    00042         }
    00043 }
    00044
    00045 namespace geos {
    00046 namespace geom { // geos::geom
    00047
    00052 class GEOS_DLL LineString: public Geometry {
    00053
    00054 public:
    00055
    00056         friend class GeometryFactory;
    00057
    00059         typedef std::vector<const LineString *> ConstVect;
    00060
    00061         virtual ~LineString();
    00062
    00069         virtual Geometry *clone() const;
    00070
    00071         virtual CoordinateSequence* getCoordinates() const;
    00072
    00074         const CoordinateSequence* getCoordinatesRO() const;
    00075
    00076         virtual const Coordinate& getCoordinateN(int n) const;
    00077
    00079         virtual Dimension::DimensionType getDimension() const;
    00080
    00086         virtual int getBoundaryDimension() const;
    00087
    00093         virtual Geometry* getBoundary() const;
    00094
    00095         virtual bool isEmpty() const;
    00096
    00097         virtual size_t getNumPoints() const;
    00098
    00099         virtual Point* getPointN(size_t n) const;
    00100
    00105         virtual Point* getStartPoint() const;
    00106
    00111         virtual Point* getEndPoint() const;
    00112
    00113         virtual bool isClosed() const;
    00114
    00115         virtual bool isRing() const;
    00116
    00117         virtual std::string getGeometryType() const;
    00118
    00119         virtual GeometryTypeId getGeometryTypeId() const;
    00120
    00121         virtual bool isCoordinate(Coordinate& pt) const;
    00122
    00123         virtual bool equalsExact(const Geometry *other, double tolerance=0)
    00124                 const;
    00125
    00126         virtual void apply_rw(const CoordinateFilter *filter);
    00127
    00128         virtual void apply_ro(CoordinateFilter *filter) const;
    00129
    00130         virtual void apply_rw(GeometryFilter *filter);
    00131
    00132         virtual void apply_ro(GeometryFilter *filter) const;
    00133
    00134         virtual void apply_rw(GeometryComponentFilter *filter);
    00135
    00136         virtual void apply_ro(GeometryComponentFilter *filter) const;
    00137
    00138         void apply_rw(CoordinateSequenceFilter& filter);
    00139
    00140         void apply_ro(CoordinateSequenceFilter& filter) const;
    00141
    00149         virtual void normalize();
    00150
    00151         //was protected
    00152         virtual int compareToSameClass(const Geometry *ls) const;
    00153
    00154         virtual const Coordinate* getCoordinate() const;
    00155
    00156         virtual double getLength() const;
    00157
    00164         Geometry* reverse() const;
    00165
    00166 protected:
    00167
    00168         LineString(const LineString &ls);
    00169
    00173         LineString(CoordinateSequence *pts, const GeometryFactory *newFactory);
    00174
    00176         LineString(CoordinateSequence::AutoPtr pts,
    00177                         const GeometryFactory *newFactory);
    00178
    00179         Envelope::AutoPtr computeEnvelopeInternal() const;
    00180
    00181         CoordinateSequence::AutoPtr points;
    00182
    00183 private:
    00184
    00185         void validateConstruction();
    00186
    00187 };
    00188
    00189 struct GEOS_DLL  LineStringLT {
    00190         bool operator()(const LineString *ls1, const LineString *ls2) const {
    00191                 return ls1->compareTo(ls2)<0;
    00192         }
    00193 };
    00194
    00195
    00196 inline Geometry*
    00197 LineString::clone() const {
    00198         return new LineString(*this);
    00199 }
    00200
    00201 } // namespace geos::geom
    00202 } // namespace geos
    00203
    00204 //#ifdef GEOS_INLINE
    00205 //# include "geos/geom/LineString.inl"
    00206 //#endif
    00207
    00208 #endif // ndef GEOS_GEOS_LINESTRING_H
    00209
    00210 /**********************************************************************
    00211  * $Log$
    00212  * Revision 1.10  2006/06/12 10:49:43  strk
    00213  * unsigned int => size_t
    00214  *
    00215  * Revision 1.9  2006/05/04 15:49:39  strk
    00216  * updated all Geometry::getDimension() methods to return Dimension::DimensionType (closes bug#93)
    00217  *
    00218  * Revision 1.8  2006/04/28 10:55:39  strk
    00219  * Geometry constructors made protected, to ensure all constructions use GeometryFactory,
    00220  * which has been made friend of all Geometry derivates. getNumPoints() changed to return
    00221  * size_t.
    00222  *
    00223  * Revision 1.7  2006/04/11 11:16:25  strk
    00224  * Added LineString and LinearRing constructors by auto_ptr
    00225  *
    00226  * Revision 1.6  2006/04/10 18:15:09  strk
    00227  * Changed Geometry::envelope member to be of type auto_ptr<Envelope>.
    00228  * Changed computeEnvelopeInternal() signater to return auto_ptr<Envelope>
    00229  *
    00230  * Revision 1.5  2006/04/10 17:35:44  strk
    00231  * Changed LineString::points and Point::coordinates to be wrapped
    00232  * in an auto_ptr<>. This should close bugs #86 and #89
    00233  *
    00234  * Revision 1.4  2006/04/05 10:25:21  strk
    00235  * Fixed LineString constructor to ensure deletion of CoordinateSequence
    00236  * argument on exception throw
    00237  *
    00238  * Revision 1.3  2006/03/31 16:55:17  strk
    00239  * Added many assertions checking in LineString implementation.
    00240  * Changed ::getCoordinate() to return NULL on empty geom.
    00241  * Changed ::get{Start,End}Point() to return NULL on empty geom.
    00242  *
    00243  * Revision 1.2  2006/03/24 09:52:41  strk
    00244  * USE_INLINE => GEOS_INLINE
    00245  *
    00246  * Revision 1.1  2006/03/09 16:46:49  strk
    00247  * geos::geom namespace definition, first pass at headers split
    00248  *
    00249  **********************************************************************/