GEOS: DistanceOp.h Source File

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

- File List

# DistanceOp.h

    00001 /**********************************************************************
    00002  * $Id: DistanceOp.h 3259 2011-03-02 13:45:13Z 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) 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: operation/distance/DistanceOp.java r335 (JTS-1.12-)
    00018  *
    00019  **********************************************************************/
    00020
    00021 #ifndef GEOS_OP_DISTANCE_DISTANCEOP_H
    00022 #define GEOS_OP_DISTANCE_DISTANCEOP_H
    00023
    00024 #include <geos/export.h>
    00025
    00026 #include <geos/algorithm/PointLocator.h> // for composition
    00027
    00028 #include <vector>
    00029
    00030 #ifdef _MSC_VER
    00031 #pragma warning(push)
    00032 #pragma warning(disable: 4251) // warning C4251: needs to have dll-interface to be used by clients of class
    00033 #endif
    00034
    00035 // Forward declarations
    00036 namespace geos {
    00037         namespace geom {
    00038                 class Coordinate;
    00039                 class Polygon;
    00040                 class LineString;
    00041                 class Point;
    00042                 class Geometry;
    00043                 class CoordinateSequence;
    00044         }
    00045         namespace operation {
    00046                 namespace distance {
    00047                         class GeometryLocation;
    00048                 }
    00049         }
    00050 }
    00051
    00052
    00053 namespace geos {
    00054 namespace operation { // geos::operation
    00055 namespace distance { // geos::operation::distance
    00056
    00075 class GEOS_DLL DistanceOp {
    00076 public:
    00087         static double distance(const geom::Geometry& g0,
    00088                                const geom::Geometry& g1);
    00089
    00091         static double distance(const geom::Geometry *g0,
    00092                                 const geom::Geometry *g1);
    00093
    00104         static bool isWithinDistance(const geom::Geometry& g0,
    00105                                      const geom::Geometry& g1,
    00106                                                     double distance);
    00107
    00120         static geom::CoordinateSequence* nearestPoints(
    00121                                                 const geom::Geometry *g0,
    00122                                                 const geom::Geometry *g1);
    00123
    00137         static geom::CoordinateSequence* closestPoints(
    00138                                                 const geom::Geometry *g0,
    00139                                                 const geom::Geometry *g1);
    00140
    00142         DistanceOp(const geom::Geometry *g0, const geom::Geometry *g1);
    00143
    00152         DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1);
    00153
    00164         DistanceOp(const geom::Geometry& g0, const geom::Geometry& g1,
    00165                                               double terminateDistance);
    00166
    00167         ~DistanceOp();
    00168
    00174         double distance();
    00175
    00185         geom::CoordinateSequence* closestPoints();
    00186
    00195         geom::CoordinateSequence* nearestPoints();
    00196
    00197 private:
    00198
    00211         std::vector<GeometryLocation*>* nearestLocations();
    00212
    00213         // input (TODO: use two references instead..)
    00214         std::vector<geom::Geometry const*> geom;
    00215         double terminateDistance;
    00216
    00217         // working
    00218         algorithm::PointLocator ptLocator;
    00219         // TODO: use auto_ptr
    00220         std::vector<GeometryLocation*> *minDistanceLocation;
    00221         double minDistance;
    00222
    00223         // memory management
    00224         std::vector<geom::Coordinate *> newCoords;
    00225
    00226
    00227         void updateMinDistance(std::vector<GeometryLocation*>& locGeom,
    00228                                bool flip);
    00229
    00230         void computeMinDistance();
    00231
    00232         void computeContainmentDistance();
    00233
    00234         void computeInside(std::vector<GeometryLocation*> *locs,
    00235                         const std::vector<const geom::Polygon*>& polys,
    00236                         std::vector<GeometryLocation*> *locPtPoly);
    00237
    00238         void computeInside(GeometryLocation *ptLoc,
    00239                         const geom::Polygon *poly,
    00240                         std::vector<GeometryLocation*> *locPtPoly);
    00241
    00246         void computeFacetDistance();
    00247
    00248         void computeMinDistanceLines(
    00249                         const std::vector<const geom::LineString*>& lines0,
    00250                         const std::vector<const geom::LineString*>& lines1,
    00251                         std::vector<GeometryLocation*>& locGeom);
    00252
    00253         void computeMinDistancePoints(
    00254                         const std::vector<const geom::Point*>& points0,
    00255                         const std::vector<const geom::Point*>& points1,
    00256                         std::vector<GeometryLocation*>& locGeom);
    00257
    00258         void computeMinDistanceLinesPoints(
    00259                         const std::vector<const geom::LineString*>& lines0,
    00260                         const std::vector<const geom::Point*>& points1,
    00261                         std::vector<GeometryLocation*>& locGeom);
    00262
    00263         void computeMinDistance(const geom::LineString *line0,
    00264                         const geom::LineString *line1,
    00265                         std::vector<GeometryLocation*>& locGeom);
    00266
    00267         void computeMinDistance(const geom::LineString *line,
    00268                         const geom::Point *pt,
    00269                         std::vector<GeometryLocation*>& locGeom);
    00270 };
    00271
    00272
    00273 } // namespace geos::operation::distance
    00274 } // namespace geos::operation
    00275 } // namespace geos
    00276
    00277 #ifdef _MSC_VER
    00278 #pragma warning(pop)
    00279 #endif
    00280
    00281 #endif // GEOS_OP_DISTANCE_DISTANCEOP_H
    00282
    00283 /**********************************************************************
    00284  * $Log$
    00285  * Revision 1.1  2006/03/21 17:55:01  strk
    00286  * opDistance.h header split
    00287  *
    00288  **********************************************************************/
    00289