LineString.h

00001 /**********************************************************************
00002  * $Id: LineString.h 1820 2006-09-06 16:54:23Z mloskot $
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 #ifndef GEOS_GEOS_LINESTRING_H
00018 #define GEOS_GEOS_LINESTRING_H
00019 
00020 #include <geos/platform.h> // do we need this ?
00021 #include <geos/geom/Geometry.h> // for inheritance
00022 #include <geos/geom/CoordinateSequence.h> // for proper use of auto_ptr<>
00023 #include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
00024 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
00025 
00026 #include <string>
00027 #include <vector>
00028 #include <memory> // for auto_ptr
00029 
00030 #include <geos/inline.h>
00031 
00032 namespace geos {
00033         namespace geom {
00034                 class Coordinate;
00035                 class CoordinateArraySequence;
00036         }
00037 }
00038 
00039 namespace geos {
00040 namespace geom { // geos::geom
00041 
00046 class LineString: public Geometry {
00047 
00048 public:
00049 
00050         friend class GeometryFactory;
00051 
00053         typedef std::vector<const LineString *> ConstVect;
00054 
00055         virtual ~LineString();
00056 
00057         virtual Geometry *clone() const;
00058 
00059         virtual CoordinateSequence* getCoordinates() const;
00060 
00062         const CoordinateSequence* getCoordinatesRO() const;
00063 
00064         virtual const Coordinate& getCoordinateN(int n) const;
00065 
00067         virtual Dimension::DimensionType getDimension() const;
00068 
00074         virtual int getBoundaryDimension() const;
00075 
00081         virtual Geometry* getBoundary() const;
00082 
00083         virtual bool isEmpty() const;
00084 
00085         virtual size_t getNumPoints() const;
00086 
00087         virtual Point* getPointN(size_t n) const;
00088 
00093         virtual Point* getStartPoint() const;
00094 
00099         virtual Point* getEndPoint() const;
00100 
00101         virtual bool isClosed() const;
00102 
00103         virtual bool isRing() const;
00104 
00105         virtual std::string getGeometryType() const;
00106 
00107         virtual GeometryTypeId getGeometryTypeId() const;
00108 
00109         virtual bool isSimple() const;
00110 
00111         virtual bool isCoordinate(Coordinate& pt) const;
00112 
00113         virtual bool equalsExact(const Geometry *other, double tolerance=0)
00114                 const;
00115 
00116         virtual void apply_rw(const CoordinateFilter *filter);
00117 
00118         virtual void apply_ro(CoordinateFilter *filter) const;
00119 
00120         virtual void apply_rw(GeometryFilter *filter);
00121 
00122         virtual void apply_ro(GeometryFilter *filter) const;
00123 
00124         virtual void apply_rw(GeometryComponentFilter *filter);
00125 
00126         virtual void apply_ro(GeometryComponentFilter *filter) const;
00127 
00135         virtual void normalize();
00136 
00137         //was protected
00138         virtual int compareToSameClass(const Geometry *ls) const;
00139 
00140         virtual const Coordinate* getCoordinate() const;
00141 
00142         virtual double getLength() const;
00143 
00150         LineString* reverse() const;
00151 
00152 protected:
00153 
00154         LineString(const LineString &ls);
00155 
00159         LineString(CoordinateSequence *pts, const GeometryFactory *newFactory);
00160 
00162         LineString(CoordinateSequence::AutoPtr pts,
00163                         const GeometryFactory *newFactory);
00164 
00165         Envelope::AutoPtr computeEnvelopeInternal() const;
00166 
00167         CoordinateSequence::AutoPtr points;
00168 
00169 private:
00170 
00171         void validateConstruction();
00172 
00173 };
00174 
00175 struct LineStringLT {
00176         bool operator()(const LineString *ls1, const LineString *ls2) const {
00177                 return ls1->compareTo(ls2)<0;
00178         }
00179 };
00180 
00181 
00182 inline Geometry*
00183 LineString::clone() const {
00184         return new LineString(*this);
00185 }
00186 
00187 } // namespace geos::geom
00188 } // namespace geos
00189 
00190 //#ifdef GEOS_INLINE
00191 //# include "geos/geom/LineString.inl"
00192 //#endif
00193 
00194 #endif // ndef GEOS_GEOS_LINESTRING_H
00195 
00196 /**********************************************************************
00197  * $Log$
00198  * Revision 1.10  2006/06/12 10:49:43  strk
00199  * unsigned int => size_t
00200  *
00201  * Revision 1.9  2006/05/04 15:49:39  strk
00202  * updated all Geometry::getDimension() methods to return Dimension::DimensionType (closes bug#93)
00203  *
00204  * Revision 1.8  2006/04/28 10:55:39  strk
00205  * Geometry constructors made protected, to ensure all constructions use GeometryFactory,
00206  * which has been made friend of all Geometry derivates. getNumPoints() changed to return
00207  * size_t.
00208  *
00209  * Revision 1.7  2006/04/11 11:16:25  strk
00210  * Added LineString and LinearRing constructors by auto_ptr
00211  *
00212  * Revision 1.6  2006/04/10 18:15:09  strk
00213  * Changed Geometry::envelope member to be of type auto_ptr<Envelope>.
00214  * Changed computeEnvelopeInternal() signater to return auto_ptr<Envelope>
00215  *
00216  * Revision 1.5  2006/04/10 17:35:44  strk
00217  * Changed LineString::points and Point::coordinates to be wrapped
00218  * in an auto_ptr<>. This should close bugs #86 and #89
00219  *
00220  * Revision 1.4  2006/04/05 10:25:21  strk
00221  * Fixed LineString constructor to ensure deletion of CoordinateSequence
00222  * argument on exception throw
00223  *
00224  * Revision 1.3  2006/03/31 16:55:17  strk
00225  * Added many assertions checking in LineString implementation.
00226  * Changed ::getCoordinate() to return NULL on empty geom.
00227  * Changed ::get{Start,End}Point() to return NULL on empty geom.
00228  *
00229  * Revision 1.2  2006/03/24 09:52:41  strk
00230  * USE_INLINE => GEOS_INLINE
00231  *
00232  * Revision 1.1  2006/03/09 16:46:49  strk
00233  * geos::geom namespace definition, first pass at headers split
00234  *
00235  **********************************************************************/

Generated on Fri Mar 27 04:52:50 2009 for GEOS by  doxygen 1.5.4