<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>GEOS: DistanceOp.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.1 --> <div class="navigation" id="top"> <div class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <h1>DistanceOp.h</h1> </div> </div> <div class="contents"> <div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/**********************************************************************</span> <a name="l00002"></a>00002 <span class="comment"> * $Id: DistanceOp.h 2560 2009-06-08 10:29:54Z strk $</span> <a name="l00003"></a>00003 <span class="comment"> *</span> <a name="l00004"></a>00004 <span class="comment"> * GEOS - Geometry Engine Open Source</span> <a name="l00005"></a>00005 <span class="comment"> * http://geos.refractions.net</span> <a name="l00006"></a>00006 <span class="comment"> *</span> <a name="l00007"></a>00007 <span class="comment"> * Copyright (C) 2006 Refractions Research Inc.</span> <a name="l00008"></a>00008 <span class="comment"> *</span> <a name="l00009"></a>00009 <span class="comment"> * This is free software; you can redistribute and/or modify it under</span> <a name="l00010"></a>00010 <span class="comment"> * the terms of the GNU Lesser General Public Licence as published</span> <a name="l00011"></a>00011 <span class="comment"> * by the Free Software Foundation. </span> <a name="l00012"></a>00012 <span class="comment"> * See the COPYING file for more information.</span> <a name="l00013"></a>00013 <span class="comment"> *</span> <a name="l00014"></a>00014 <span class="comment"> **********************************************************************</span> <a name="l00015"></a>00015 <span class="comment"> *</span> <a name="l00016"></a>00016 <span class="comment"> * Last port: operation/distance/DistanceOp.java rev 1.21 (JTS-1.10)</span> <a name="l00017"></a>00017 <span class="comment"> *</span> <a name="l00018"></a>00018 <span class="comment"> **********************************************************************/</span> <a name="l00019"></a>00019 <a name="l00020"></a>00020 <span class="preprocessor">#ifndef GEOS_OP_DISTANCE_DISTANCEOP_H</span> <a name="l00021"></a>00021 <span class="preprocessor"></span><span class="preprocessor">#define GEOS_OP_DISTANCE_DISTANCEOP_H</span> <a name="l00022"></a>00022 <span class="preprocessor"></span> <a name="l00023"></a>00023 <span class="preprocessor">#include <geos/export.h></span> <a name="l00024"></a>00024 <a name="l00025"></a>00025 <span class="preprocessor">#include <geos/algorithm/PointLocator.h></span> <span class="comment">// for composition</span> <a name="l00026"></a>00026 <a name="l00027"></a>00027 <span class="preprocessor">#include <vector></span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="comment">// Forward declarations</span> <a name="l00030"></a>00030 <span class="keyword">namespace </span>geos { <a name="l00031"></a>00031 <span class="keyword">namespace </span>geom { <a name="l00032"></a>00032 <span class="keyword">class </span>Coordinate; <a name="l00033"></a>00033 <span class="keyword">class </span>Polygon; <a name="l00034"></a>00034 <span class="keyword">class </span>LineString; <a name="l00035"></a>00035 <span class="keyword">class </span>Point; <a name="l00036"></a>00036 <span class="keyword">class </span>Geometry; <a name="l00037"></a>00037 <span class="keyword">class </span>CoordinateSequence; <a name="l00038"></a>00038 } <a name="l00039"></a>00039 <span class="keyword">namespace </span>operation { <a name="l00040"></a>00040 <span class="keyword">namespace </span>distance { <a name="l00041"></a>00041 <span class="keyword">class </span>GeometryLocation; <a name="l00042"></a>00042 } <a name="l00043"></a>00043 } <a name="l00044"></a>00044 } <a name="l00045"></a>00045 <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="keyword">namespace </span>geos { <a name="l00048"></a>00048 <span class="keyword">namespace </span>operation { <span class="comment">// geos::operation</span> <a name="l00049"></a>00049 <span class="keyword">namespace </span>distance { <span class="comment">// geos::operation::distance</span> <a name="l00050"></a>00050 <a name="l00069"></a><a class="code" href="classgeos_1_1operation_1_1distance_1_1DistanceOp.html">00069</a> <span class="keyword">class </span>GEOS_DLL <a class="code" href="classgeos_1_1operation_1_1distance_1_1DistanceOp.html" title="Find two points on two Geometrys which lie within a given distance, or else are the nearest points on...">DistanceOp</a> { <a name="l00070"></a>00070 <span class="keyword">public</span>: <a name="l00079"></a>00079 <span class="keyword">static</span> <span class="keywordtype">double</span> distance(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>& g0, <a name="l00080"></a>00080 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>& g1); <a name="l00081"></a>00081 <a name="l00083"></a>00083 <span class="keyword">static</span> <span class="keywordtype">double</span> distance(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a> *g0, <a name="l00084"></a>00084 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a> *g1); <a name="l00085"></a>00085 <a name="l00096"></a>00096 <span class="keyword">static</span> <span class="keywordtype">bool</span> isWithinDistance(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>& g0, <a name="l00097"></a>00097 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>& g1, <a name="l00098"></a>00098 <span class="keywordtype">double</span> distance); <a name="l00099"></a>00099 <a name="l00112"></a>00112 <span class="keyword">static</span> <a class="code" href="classgeos_1_1geom_1_1CoordinateSequence.html" title="The internal representation of a list of coordinates inside a Geometry.">geom::CoordinateSequence</a>* nearestPoints( <a name="l00113"></a>00113 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a> *g0, <a name="l00114"></a>00114 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a> *g1); <a name="l00115"></a>00115 <a name="l00129"></a>00129 <span class="keyword">static</span> <a class="code" href="classgeos_1_1geom_1_1CoordinateSequence.html" title="The internal representation of a list of coordinates inside a Geometry.">geom::CoordinateSequence</a>* closestPoints( <a name="l00130"></a>00130 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a> *g0, <a name="l00131"></a>00131 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a> *g1); <a name="l00132"></a>00132 <a name="l00134"></a>00134 <a class="code" href="classgeos_1_1operation_1_1distance_1_1DistanceOp.html" title="Find two points on two Geometrys which lie within a given distance, or else are the nearest points on...">DistanceOp</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a> *g0, <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a> *g1); <a name="l00135"></a>00135 <a name="l00144"></a>00144 <a class="code" href="classgeos_1_1operation_1_1distance_1_1DistanceOp.html" title="Find two points on two Geometrys which lie within a given distance, or else are the nearest points on...">DistanceOp</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>& g0, <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>& g1); <a name="l00145"></a>00145 <a name="l00156"></a>00156 <a class="code" href="classgeos_1_1operation_1_1distance_1_1DistanceOp.html" title="Find two points on two Geometrys which lie within a given distance, or else are the nearest points on...">DistanceOp</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>& g0, <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Geometry.html" title="Basic implementation of Geometry, constructed and destructed by GeometryFactory.">geom::Geometry</a>& g1, <a name="l00157"></a>00157 <span class="keywordtype">double</span> terminateDistance); <a name="l00158"></a>00158 <a name="l00159"></a>00159 ~<a class="code" href="classgeos_1_1operation_1_1distance_1_1DistanceOp.html" title="Find two points on two Geometrys which lie within a given distance, or else are the nearest points on...">DistanceOp</a>(); <a name="l00160"></a>00160 <a name="l00166"></a>00166 <span class="keywordtype">double</span> distance(); <a name="l00167"></a>00167 <a name="l00177"></a>00177 <a class="code" href="classgeos_1_1geom_1_1CoordinateSequence.html" title="The internal representation of a list of coordinates inside a Geometry.">geom::CoordinateSequence</a>* closestPoints(); <a name="l00178"></a>00178 <a name="l00187"></a>00187 <a class="code" href="classgeos_1_1geom_1_1CoordinateSequence.html" title="The internal representation of a list of coordinates inside a Geometry.">geom::CoordinateSequence</a>* nearestPoints(); <a name="l00188"></a>00188 <a name="l00189"></a>00189 <span class="keyword">private</span>: <a name="l00190"></a>00190 <a name="l00203"></a>00203 std::vector<GeometryLocation*>* nearestLocations(); <a name="l00204"></a>00204 <a name="l00205"></a>00205 <span class="comment">// input (TODO: use two references instead..)</span> <a name="l00206"></a>00206 std::vector<geom::Geometry const*> geom; <a name="l00207"></a>00207 <span class="keywordtype">double</span> terminateDistance; <a name="l00208"></a>00208 <a name="l00209"></a>00209 <span class="comment">// working </span> <a name="l00210"></a>00210 <a class="code" href="classgeos_1_1algorithm_1_1PointLocator.html" title="Computes the topological relationship (Location) of a single point to a Geometry.">algorithm::PointLocator</a> ptLocator; <a name="l00211"></a>00211 <span class="comment">// TODO: use auto_ptr</span> <a name="l00212"></a>00212 std::vector<GeometryLocation*> *minDistanceLocation; <a name="l00213"></a>00213 <span class="keywordtype">double</span> minDistance; <a name="l00214"></a>00214 <a name="l00215"></a>00215 <span class="comment">// memory management</span> <a name="l00216"></a>00216 std::vector<geom::Coordinate *> newCoords; <a name="l00217"></a>00217 <a name="l00218"></a>00218 <a name="l00219"></a>00219 <span class="keywordtype">void</span> updateMinDistance(std::vector<GeometryLocation*>& locGeom, <a name="l00220"></a>00220 <span class="keywordtype">bool</span> flip); <a name="l00221"></a>00221 <a name="l00222"></a>00222 <span class="keywordtype">void</span> computeMinDistance(); <a name="l00223"></a>00223 <a name="l00224"></a>00224 <span class="keywordtype">void</span> computeContainmentDistance(); <a name="l00225"></a>00225 <a name="l00226"></a>00226 <span class="keywordtype">void</span> computeInside(std::vector<GeometryLocation*> *locs, <a name="l00227"></a>00227 <span class="keyword">const</span> std::vector<const geom::Polygon*>& polys, <a name="l00228"></a>00228 std::vector<GeometryLocation*> *locPtPoly); <a name="l00229"></a>00229 <a name="l00230"></a>00230 <span class="keywordtype">void</span> computeInside(<a class="code" href="classgeos_1_1operation_1_1distance_1_1GeometryLocation.html" title="Represents the location of a point on a Geometry.">GeometryLocation</a> *ptLoc, <a name="l00231"></a>00231 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Polygon.html" title="Represents a linear polygon, which may include holes.">geom::Polygon</a> *poly, <a name="l00232"></a>00232 std::vector<GeometryLocation*> *locPtPoly); <a name="l00233"></a>00233 <a name="l00238"></a>00238 <span class="keywordtype">void</span> computeFacetDistance(); <a name="l00239"></a>00239 <a name="l00240"></a>00240 <span class="keywordtype">void</span> computeMinDistanceLines( <a name="l00241"></a>00241 <span class="keyword">const</span> std::vector<const geom::LineString*>& lines0, <a name="l00242"></a>00242 <span class="keyword">const</span> std::vector<const geom::LineString*>& lines1, <a name="l00243"></a>00243 std::vector<GeometryLocation*>& locGeom); <a name="l00244"></a>00244 <a name="l00245"></a>00245 <span class="keywordtype">void</span> computeMinDistancePoints( <a name="l00246"></a>00246 <span class="keyword">const</span> std::vector<const geom::Point*>& points0, <a name="l00247"></a>00247 <span class="keyword">const</span> std::vector<const geom::Point*>& points1, <a name="l00248"></a>00248 std::vector<GeometryLocation*>& locGeom); <a name="l00249"></a>00249 <a name="l00250"></a>00250 <span class="keywordtype">void</span> computeMinDistanceLinesPoints( <a name="l00251"></a>00251 <span class="keyword">const</span> std::vector<const geom::LineString*>& lines0, <a name="l00252"></a>00252 <span class="keyword">const</span> std::vector<const geom::Point*>& points1, <a name="l00253"></a>00253 std::vector<GeometryLocation*>& locGeom); <a name="l00254"></a>00254 <a name="l00255"></a>00255 <span class="keywordtype">void</span> computeMinDistance(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineString.html" title="Basic implementation of LineString.">geom::LineString</a> *line0, <a name="l00256"></a>00256 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineString.html" title="Basic implementation of LineString.">geom::LineString</a> *line1, <a name="l00257"></a>00257 std::vector<GeometryLocation*>& locGeom); <a name="l00258"></a>00258 <a name="l00259"></a>00259 <span class="keywordtype">void</span> computeMinDistance(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineString.html" title="Basic implementation of LineString.">geom::LineString</a> *line, <a name="l00260"></a>00260 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Point.html" title="Basic implementation of Point.">geom::Point</a> *pt, <a name="l00261"></a>00261 std::vector<GeometryLocation*>& locGeom); <a name="l00262"></a>00262 }; <a name="l00263"></a>00263 <a name="l00264"></a>00264 <a name="l00265"></a>00265 } <span class="comment">// namespace geos::operation::distance</span> <a name="l00266"></a>00266 } <span class="comment">// namespace geos::operation</span> <a name="l00267"></a>00267 } <span class="comment">// namespace geos</span> <a name="l00268"></a>00268 <a name="l00269"></a>00269 <span class="preprocessor">#endif // GEOS_OP_DISTANCE_DISTANCEOP_H</span> <a name="l00270"></a>00270 <span class="preprocessor"></span> <a name="l00271"></a>00271 <span class="comment">/**********************************************************************</span> <a name="l00272"></a>00272 <span class="comment"> * $Log$</span> <a name="l00273"></a>00273 <span class="comment"> * Revision 1.1 2006/03/21 17:55:01 strk</span> <a name="l00274"></a>00274 <span class="comment"> * opDistance.h header split</span> <a name="l00275"></a>00275 <span class="comment"> *</span> <a name="l00276"></a>00276 <span class="comment"> **********************************************************************/</span> <a name="l00277"></a>00277 </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Thu Jul 22 2010 for GEOS by <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address> </body> </html>