<!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: LineSegment.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>LineSegment.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: LineSegment.h 2556 2009-06-06 22:22:28Z 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) 2009 Sandro Santilli <strk@keybit.net></span> <a name="l00008"></a>00008 <span class="comment"> * Copyright (C) 2006 Refractions Research Inc.</span> <a name="l00009"></a>00009 <span class="comment"> *</span> <a name="l00010"></a>00010 <span class="comment"> * This is free software; you can redistribute and/or modify it under</span> <a name="l00011"></a>00011 <span class="comment"> * the terms of the GNU Lesser General Public Licence as published</span> <a name="l00012"></a>00012 <span class="comment"> * by the Free Software Foundation. </span> <a name="l00013"></a>00013 <span class="comment"> * See the COPYING file for more information.</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"> *</span> <a name="l00017"></a>00017 <span class="comment"> * Last port: geom/LineSegment.java rev. 1.30 (JTS-1.9)</span> <a name="l00018"></a>00018 <span class="comment"> *</span> <a name="l00019"></a>00019 <span class="comment"> **********************************************************************/</span> <a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="preprocessor">#ifndef GEOS_GEOM_LINESEGMENT_H</span> <a name="l00022"></a>00022 <span class="preprocessor"></span><span class="preprocessor">#define GEOS_GEOM_LINESEGMENT_H</span> <a name="l00023"></a>00023 <span class="preprocessor"></span> <a name="l00024"></a>00024 <span class="preprocessor">#include <geos/export.h></span> <a name="l00025"></a>00025 <span class="preprocessor">#include <geos/geom/Coordinate.h></span> <span class="comment">// for composition</span> <a name="l00026"></a>00026 <a name="l00027"></a>00027 <span class="preprocessor">#include <geos/inline.h></span> <a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="preprocessor">#include <iostream></span> <span class="comment">// for ostream</span> <a name="l00030"></a>00030 <span class="preprocessor">#include <memory></span> <span class="comment">// for auto_ptr</span> <a name="l00031"></a>00031 <a name="l00032"></a>00032 <span class="comment">// Forward declarations</span> <a name="l00033"></a>00033 <span class="keyword">namespace </span>geos { <a name="l00034"></a>00034 <span class="keyword">namespace </span>geom { <a name="l00035"></a>00035 <span class="keyword">class </span>CoordinateSequence; <a name="l00036"></a>00036 <span class="keyword">class </span>GeometryFactory; <a name="l00037"></a>00037 <span class="keyword">class </span>LineString; <a name="l00038"></a>00038 } <a name="l00039"></a>00039 } <a name="l00040"></a>00040 <a name="l00041"></a>00041 <span class="keyword">namespace </span>geos { <a name="l00042"></a>00042 <span class="keyword">namespace </span>geom { <span class="comment">// geos::geom</span> <a name="l00043"></a>00043 <a name="l00057"></a><a class="code" href="classgeos_1_1geom_1_1LineSegment.html">00057</a> <span class="keyword">class </span>GEOS_DLL <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a> { <a name="l00058"></a>00058 <span class="keyword">public</span>: <a name="l00059"></a>00059 <a name="l00060"></a>00060 <span class="keyword">friend</span> std::ostream& <a class="code" href="namespacegeos_1_1geom.html#ab8723f7afa29f8c4dcb9b77fa42132e4" title="Output function.">operator<< </a>(std::ostream& o, <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& l); <a name="l00061"></a>00061 <a name="l00062"></a>00062 <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a> p0; <a name="l00063"></a>00063 <a name="l00064"></a><a class="code" href="classgeos_1_1geom_1_1LineSegment.html#a9382e49d86a10de5d5be69560824d900">00064</a> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a> p1; <a name="l00065"></a>00065 <a name="l00066"></a>00066 <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>(); <a name="l00067"></a>00067 <a name="l00068"></a>00068 <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a> &ls); <a name="l00069"></a>00069 <a name="l00071"></a>00071 <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& c0, <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& c1); <a name="l00072"></a>00072 <a name="l00073"></a>00073 <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>(<span class="keywordtype">double</span> x0, <span class="keywordtype">double</span> y0, <span class="keywordtype">double</span> x1, <span class="keywordtype">double</span> y1); <a name="l00074"></a>00074 <a name="l00075"></a>00075 <span class="keyword">virtual</span> ~<a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>(); <a name="l00076"></a>00076 <a name="l00077"></a>00077 <span class="keywordtype">void</span> setCoordinates(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& c0, <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& c1); <a name="l00078"></a>00078 <a name="l00079"></a>00079 <span class="comment">// obsoleted, use operator[] instead</span> <a name="l00080"></a>00080 <span class="comment">//const Coordinate& getCoordinate(size_t i) const;</span> <a name="l00081"></a>00081 <a name="l00082"></a>00082 <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& operator[](<span class="keywordtype">size_t</span> i) <span class="keyword">const</span>; <a name="l00083"></a>00083 <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& operator[](<span class="keywordtype">size_t</span> i); <a name="l00084"></a>00084 <a name="l00085"></a>00085 <span class="keywordtype">void</span> setCoordinates(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& ls); <a name="l00086"></a>00086 <a name="l00088"></a>00088 <span class="keywordtype">double</span> getLength() <span class="keyword">const</span>; <a name="l00089"></a>00089 <a name="l00091"></a>00091 <span class="comment">//</span> <a name="l00094"></a>00094 <span class="comment"></span> <span class="keywordtype">bool</span> isHorizontal() <span class="keyword">const</span>; <a name="l00095"></a>00095 <a name="l00097"></a>00097 <span class="comment">//</span> <a name="l00100"></a>00100 <span class="comment"></span> <span class="keywordtype">bool</span> isVertical() <span class="keyword">const</span>; <a name="l00101"></a>00101 <a name="l00123"></a>00123 <span class="keywordtype">int</span> orientationIndex(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& seg) <span class="keyword">const</span>; <a name="l00124"></a>00124 <a name="l00125"></a>00125 <span class="comment">// TODO: deprecate this</span> <a name="l00126"></a>00126 <span class="keywordtype">int</span> orientationIndex(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>* seg) <span class="keyword">const</span>; <a name="l00127"></a>00127 <a name="l00144"></a>00144 <span class="keywordtype">int</span> orientationIndex(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& p) <span class="keyword">const</span>; <a name="l00145"></a>00145 <a name="l00147"></a>00147 <span class="keywordtype">void</span> reverse(); <a name="l00148"></a>00148 <a name="l00150"></a>00150 <span class="comment">//</span> <a name="l00154"></a>00154 <span class="comment"></span> <span class="keywordtype">void</span> normalize(); <a name="l00155"></a>00155 <a name="l00157"></a>00157 <span class="keywordtype">double</span> angle() <span class="keyword">const</span>; <a name="l00158"></a>00158 <a name="l00160"></a>00160 <span class="comment">//</span> <a name="l00163"></a>00163 <span class="comment"></span> <span class="keywordtype">void</span> midPoint(<a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& ret) <span class="keyword">const</span>; <a name="l00164"></a>00164 <a name="l00166"></a>00166 <span class="keywordtype">double</span> distance(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& ls) <span class="keyword">const</span>; <a name="l00167"></a>00167 <a name="l00169"></a>00169 <span class="keywordtype">double</span> distance(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& p) <span class="keyword">const</span>; <a name="l00170"></a>00170 <a name="l00175"></a>00175 <span class="keywordtype">double</span> distancePerpendicular(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& p) <span class="keyword">const</span>; <a name="l00176"></a>00176 <a name="l00191"></a>00191 <span class="keywordtype">void</span> pointAlong(<span class="keywordtype">double</span> segmentLengthFraction, <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& ret) <span class="keyword">const</span>; <a name="l00192"></a>00192 <a name="l00215"></a>00215 <span class="keywordtype">void</span> pointAlongOffset(<span class="keywordtype">double</span> segmentLengthFraction, <a name="l00216"></a>00216 <span class="keywordtype">double</span> offsetDistance, <a name="l00217"></a>00217 <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& ret) <span class="keyword">const</span>; <a name="l00218"></a>00218 <a name="l00236"></a>00236 <span class="keywordtype">double</span> projectionFactor(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& p) <span class="keyword">const</span>; <a name="l00237"></a>00237 <a name="l00253"></a>00253 <span class="keywordtype">double</span> segmentFraction(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& inputPt) <span class="keyword">const</span>; <a name="l00254"></a>00254 <a name="l00263"></a>00263 <span class="keywordtype">void</span> project(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& p, <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& ret) <span class="keyword">const</span>; <a name="l00264"></a>00264 <a name="l00280"></a>00280 <span class="keywordtype">bool</span> project(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& seg, <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& ret) <span class="keyword">const</span>; <a name="l00281"></a>00281 <a name="l00283"></a>00283 <span class="comment">//</span> <a name="l00288"></a>00288 <span class="comment"></span> <span class="keywordtype">void</span> closestPoint(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& p, <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& ret) <span class="keyword">const</span>; <a name="l00289"></a>00289 <a name="l00301"></a>00301 <span class="keywordtype">int</span> compareTo(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& other) <span class="keyword">const</span>; <a name="l00302"></a>00302 <a name="l00312"></a>00312 <span class="keywordtype">bool</span> equalsTopo(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& other) <span class="keyword">const</span>; <a name="l00313"></a>00313 <a name="l00321"></a>00321 <a class="code" href="classgeos_1_1geom_1_1CoordinateSequence.html" title="The internal representation of a list of coordinates inside a Geometry.">CoordinateSequence</a>* closestPoints(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& line); <a name="l00322"></a>00322 <a name="l00323"></a>00323 <a class="code" href="classgeos_1_1geom_1_1CoordinateSequence.html" title="The internal representation of a list of coordinates inside a Geometry.">CoordinateSequence</a>* closestPoints(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>* line); <a name="l00324"></a>00324 <a name="l00338"></a>00338 <span class="keywordtype">bool</span> intersection(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& line, <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& coord) <span class="keyword">const</span>; <a name="l00339"></a>00339 <a name="l00357"></a>00357 <span class="keywordtype">bool</span> lineIntersection(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& line, <a class="code" href="classgeos_1_1geom_1_1Coordinate.html" title="Coordinate is the lightweight class used to store coordinates.">Coordinate</a>& coord) <span class="keyword">const</span>; <a name="l00358"></a>00358 <a name="l00365"></a>00365 std::auto_ptr<LineString> toGeometry(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1GeometryFactory.html" title="Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...">GeometryFactory</a>& gf) <span class="keyword">const</span>; <a name="l00366"></a>00366 <a name="l00367"></a>00367 }; <a name="l00368"></a>00368 <a name="l00369"></a>00369 std::ostream& <a class="code" href="namespacegeos_1_1geom.html#ab8723f7afa29f8c4dcb9b77fa42132e4" title="Output function.">operator<< </a>(std::ostream& o, <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& l); <a name="l00370"></a>00370 <a name="l00372"></a>00372 <span class="keywordtype">bool</span> <a class="code" href="namespacegeos_1_1geom.html#a47d9ceb105719b7108cf095799b4888d" title="Equality operator for Coordinate. 2D only.">operator==</a>(<span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& a, <span class="keyword">const</span> <a class="code" href="classgeos_1_1geom_1_1LineSegment.html">LineSegment</a>& b); <a name="l00373"></a>00373 <a name="l00374"></a>00374 <a name="l00375"></a>00375 } <span class="comment">// namespace geos::geom</span> <a name="l00376"></a>00376 } <span class="comment">// namespace geos</span> <a name="l00377"></a>00377 <a name="l00378"></a>00378 <span class="preprocessor">#ifdef GEOS_INLINE</span> <a name="l00379"></a>00379 <span class="preprocessor"></span><span class="preprocessor"># include "geos/geom/LineSegment.inl"</span> <a name="l00380"></a>00380 <span class="preprocessor">#endif</span> <a name="l00381"></a>00381 <span class="preprocessor"></span> <a name="l00382"></a>00382 <span class="preprocessor">#endif // ndef GEOS_GEOM_LINESEGMENT_H</span> <a name="l00383"></a>00383 <span class="preprocessor"></span> <a name="l00384"></a>00384 <span class="comment">/**********************************************************************</span> <a name="l00385"></a>00385 <span class="comment"> * $Log$</span> <a name="l00386"></a>00386 <span class="comment"> * Revision 1.8 2006/07/21 14:49:58 strk</span> <a name="l00387"></a>00387 <span class="comment"> * Fixed typo in comment</span> <a name="l00388"></a>00388 <span class="comment"> *</span> <a name="l00389"></a>00389 <span class="comment"> * Revision 1.7 2006/06/12 10:10:39 strk</span> <a name="l00390"></a>00390 <span class="comment"> * Fixed getGeometryN() to take size_t rather then int, changed unsigned int parameters to size_t.</span> <a name="l00391"></a>00391 <span class="comment"> *</span> <a name="l00392"></a>00392 <span class="comment"> * Revision 1.6 2006/04/12 17:19:56 strk</span> <a name="l00393"></a>00393 <span class="comment"> * Ported TaggedLineStringSimplifier class, made LineSegment class</span> <a name="l00394"></a>00394 <span class="comment"> * polymorphic to fix derivation of TaggedLineSegment</span> <a name="l00395"></a>00395 <span class="comment"> *</span> <a name="l00396"></a>00396 <span class="comment"> * Revision 1.5 2006/03/28 09:14:12 strk</span> <a name="l00397"></a>00397 <span class="comment"> * Headers inclusion fix.</span> <a name="l00398"></a>00398 <span class="comment"> *</span> <a name="l00399"></a>00399 <span class="comment"> * Revision 1.4 2006/03/24 09:52:41 strk</span> <a name="l00400"></a>00400 <span class="comment"> * USE_INLINE => GEOS_INLINE</span> <a name="l00401"></a>00401 <span class="comment"> *</span> <a name="l00402"></a>00402 <span class="comment"> * Revision 1.3 2006/03/16 13:28:22 strk</span> <a name="l00403"></a>00403 <span class="comment"> * obsoleted getCoordinate(), replaced by operator[]</span> <a name="l00404"></a>00404 <span class="comment"> *</span> <a name="l00405"></a>00405 <span class="comment"> * Revision 1.2 2006/03/13 22:33:09 strk</span> <a name="l00406"></a>00406 <span class="comment"> * Added missing forward declarations</span> <a name="l00407"></a>00407 <span class="comment"> *</span> <a name="l00408"></a>00408 <span class="comment"> * Revision 1.1 2006/03/09 16:46:49 strk</span> <a name="l00409"></a>00409 <span class="comment"> * geos::geom namespace definition, first pass at headers split</span> <a name="l00410"></a>00410 <span class="comment"> *</span> <a name="l00411"></a>00411 <span class="comment"> **********************************************************************/</span> </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>