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

- File List

# LineString.h

    00001 /**********************************************************************
    00002  * $Id: LineString.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) 2001-2002 Vivid Solutions Inc.
    00009  * Copyright (C) 2005 2006 Refractions Research 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/LineString.java r320 (JTS-1.12)
    00019  *
    00020  **********************************************************************/
    00021
    00022 #ifndef GEOS_GEOS_LINESTRING_H
    00023 #define GEOS_GEOS_LINESTRING_H
    00024
    00025 #include <geos/export.h>
    00026 #include <geos/platform.h> // do we need this ?
    00027 #include <geos/geom/Geometry.h> // for inheritance
    00028 #include <geos/geom/Lineal.h> // for inheritance
    00029 #include <geos/geom/CoordinateSequence.h> // for proper use of auto_ptr<>
    00030 #include <geos/geom/Envelope.h> // for proper use of auto_ptr<>
    00031 #include <geos/geom/Dimension.h> // for Dimension::DimensionType
    00032
    00033 #include <string>
    00034 #include <vector>
    00035 #include <memory> // for auto_ptr
    00036
    00037 #include <geos/inline.h>
    00038
    00039 #ifdef _MSC_VER
    00040 #pragma warning(push)
    00041 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
    00042 #endif
    00043
    00044 namespace geos {
    00045         namespace geom {
    00046                 class Coordinate;
    00047                 class CoordinateArraySequence;
    00048                 class CoordinateSequenceFilter;
    00049         }
    00050 }
    00051
    00052 namespace geos {
    00053 namespace geom { // geos::geom
    00054
    00071 class GEOS_DLL LineString: public virtual Geometry, public Lineal {
    00072
    00073 public:
    00074
    00075         friend class GeometryFactory;
    00076
    00078         typedef std::vector<const LineString *> ConstVect;
    00079
    00080         virtual ~LineString();
    00081
    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
    00231
    00232 /**********************************************************************
    00233  * $Log$
    00234  * Revision 1.10  2006/06/12 10:49:43  strk
    00235  * unsigned int => size_t
    00236  *
    00237  * Revision 1.9  2006/05/04 15:49:39  strk
    00238  * updated all Geometry::getDimension() methods to return Dimension::DimensionType (closes bug#93)
    00239  *
    00240  * Revision 1.8  2006/04/28 10:55:39  strk
    00241  * Geometry constructors made protected, to ensure all constructions use GeometryFactory,
    00242  * which has been made friend of all Geometry derivates. getNumPoints() changed to return
    00243  * size_t.
    00244  *
    00245  * Revision 1.7  2006/04/11 11:16:25  strk
    00246  * Added LineString and LinearRing constructors by auto_ptr
    00247  *
    00248  * Revision 1.6  2006/04/10 18:15:09  strk
    00249  * Changed Geometry::envelope member to be of type auto_ptr<Envelope>.
    00250  * Changed computeEnvelopeInternal() signater to return auto_ptr<Envelope>
    00251  *
    00252  * Revision 1.5  2006/04/10 17:35:44  strk
    00253  * Changed LineString::points and Point::coordinates to be wrapped
    00254  * in an auto_ptr<>. This should close bugs #86 and #89
    00255  *
    00256  * Revision 1.4  2006/04/05 10:25:21  strk
    00257  * Fixed LineString constructor to ensure deletion of CoordinateSequence
    00258  * argument on exception throw
    00259  *
    00260  * Revision 1.3  2006/03/31 16:55:17  strk
    00261  * Added many assertions checking in LineString implementation.
    00262  * Changed ::getCoordinate() to return NULL on empty geom.
    00263  * Changed ::get{Start,End}Point() to return NULL on empty geom.
    00264  *
    00265  * Revision 1.2  2006/03/24 09:52:41  strk
    00266  * USE_INLINE => GEOS_INLINE
    00267  *
    00268  * Revision 1.1  2006/03/09 16:46:49  strk
    00269  * geos::geom namespace definition, first pass at headers split
    00270  *
    00271  **********************************************************************/