mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-13 12:32:09 +00:00
228 lines
17 KiB
HTML
228 lines
17 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
<title>Boost.Geometry (aka GGL, Generic Geometry Library)</title>
|
||
<link href="doxygen.css" rel="stylesheet" type="text/css">
|
||
<link href="tabs.css" rel="stylesheet" type="text/css">
|
||
</head>
|
||
|
||
<table cellpadding="2" width="100%">
|
||
<tbody>
|
||
<tr>
|
||
<td valign="top">
|
||
<img alt="Boost.Geometry" src="images/ggl-logo-big.png" height="80" width="200">
|
||
|
||
</td>
|
||
<td valign="top" align="right">
|
||
<a href="http://www.boost.org">
|
||
<img alt="Boost C++ Libraries" src="images/accepted_by_boost.png" height="80" width="230" border="0">
|
||
</a>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<!-- Generated by Doxygen 1.5.9 -->
|
||
<div class="navigation" id="top">
|
||
<div class="tabs">
|
||
<ul>
|
||
<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="modules.html"><span>Modules</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>
|
||
<li><a href="examples.html"><span>Examples</span></a></li>
|
||
</ul>
|
||
</div>
|
||
<div class="tabs">
|
||
<ul>
|
||
<li><a href="files.html"><span>File List</span></a></li>
|
||
<li><a href="globals.html"><span>File Members</span></a></li>
|
||
</ul>
|
||
</div>
|
||
<h1>boost/geometry/algorithms/length.hpp</h1><a href="algorithms_2length_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Boost.Geometry (aka GGL, Generic Geometry Library)</span>
|
||
<a name="l00002"></a>00002 <span class="comment">//</span>
|
||
<a name="l00003"></a>00003 <span class="comment">// Copyright Barend Gehrels 2007-2009, Geodan, Amsterdam, the Netherlands.</span>
|
||
<a name="l00004"></a>00004 <span class="comment">// Copyright Bruno Lalande 2008, 2009</span>
|
||
<a name="l00005"></a>00005 <span class="comment">// Use, modification and distribution is subject to the Boost Software License,</span>
|
||
<a name="l00006"></a>00006 <span class="comment">// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span>
|
||
<a name="l00007"></a>00007 <span class="comment">// http://www.boost.org/LICENSE_1_0.txt)</span>
|
||
<a name="l00008"></a>00008
|
||
<a name="l00009"></a>00009 <span class="preprocessor">#ifndef BOOST_GEOMETRY_ALGORITHMS_LENGTH_HPP</span>
|
||
<a name="l00010"></a>00010 <span class="preprocessor"></span><span class="preprocessor">#define BOOST_GEOMETRY_ALGORITHMS_LENGTH_HPP</span>
|
||
<a name="l00011"></a>00011 <span class="preprocessor"></span>
|
||
<a name="l00012"></a>00012 <span class="preprocessor">#include <iterator></span>
|
||
<a name="l00013"></a>00013
|
||
<a name="l00014"></a>00014 <span class="preprocessor">#include <boost/range/functions.hpp></span>
|
||
<a name="l00015"></a>00015 <span class="preprocessor">#include <boost/range/metafunctions.hpp></span>
|
||
<a name="l00016"></a>00016
|
||
<a name="l00017"></a>00017 <span class="preprocessor">#include <boost/mpl/if.hpp></span>
|
||
<a name="l00018"></a>00018 <span class="preprocessor">#include <boost/type_traits.hpp></span>
|
||
<a name="l00019"></a>00019
|
||
<a name="l00020"></a>00020
|
||
<a name="l00021"></a>00021 <span class="preprocessor">#include <<a class="code" href="cs_8hpp.html">boost/geometry/core/cs.hpp</a>></span>
|
||
<a name="l00022"></a>00022
|
||
<a name="l00023"></a>00023 <span class="preprocessor">#include <<a class="code" href="geometries_2concepts_2check_8hpp.html">boost/geometry/geometries/concepts/check.hpp</a>></span>
|
||
<a name="l00024"></a>00024
|
||
<a name="l00025"></a>00025 <span class="preprocessor">#include <<a class="code" href="assign_8hpp.html">boost/geometry/algorithms/assign.hpp</a>></span>
|
||
<a name="l00026"></a>00026 <span class="preprocessor">#include <<a class="code" href="calculate__null_8hpp.html">boost/geometry/algorithms/detail/calculate_null.hpp</a>></span>
|
||
<a name="l00027"></a>00027
|
||
<a name="l00028"></a>00028 <span class="preprocessor">#include <<a class="code" href="strategies_2distance_8hpp.html">boost/geometry/strategies/distance.hpp</a>></span>
|
||
<a name="l00029"></a>00029 <span class="preprocessor">#include <<a class="code" href="length__result_8hpp.html">boost/geometry/strategies/length_result.hpp</a>></span>
|
||
<a name="l00030"></a>00030
|
||
<a name="l00045"></a>00045 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>geometry
|
||
<a name="l00046"></a>00046 {
|
||
<a name="l00047"></a>00047
|
||
<a name="l00048"></a>00048
|
||
<a name="l00049"></a>00049
|
||
<a name="l00050"></a>00050 <span class="preprocessor">#ifndef DOXYGEN_NO_DETAIL</span>
|
||
<a name="l00051"></a>00051 <span class="preprocessor"></span><span class="keyword">namespace </span>detail { <span class="keyword">namespace </span><a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1" title="Calculate length of a geometry.">length</a> {
|
||
<a name="l00052"></a>00052
|
||
<a name="l00053"></a>00053
|
||
<a name="l00054"></a>00054 <span class="keyword">template</span><<span class="keyword">typename</span> Segment, <span class="keyword">typename</span> Strategy>
|
||
<a name="l00055"></a>00055 <span class="keyword">struct </span>segment_length
|
||
<a name="l00056"></a>00056 {
|
||
<a name="l00057"></a>00057 <span class="keyword">static</span> <span class="keyword">inline</span> <span class="keyword">typename</span> length_result<Segment>::type apply(
|
||
<a name="l00058"></a>00058 Segment <span class="keyword">const</span>& segment, Strategy <span class="keyword">const</span>& strategy)
|
||
<a name="l00059"></a>00059 {
|
||
<a name="l00060"></a>00060 <span class="keyword">typedef</span> <span class="keyword">typename</span> point_type<Segment>::type point_type;
|
||
<a name="l00061"></a>00061 point_type p1, p2;
|
||
<a name="l00062"></a>00062 assign_point_from_index<0>(segment, p1);
|
||
<a name="l00063"></a>00063 assign_point_from_index<1>(segment, p2);
|
||
<a name="l00064"></a>00064 <span class="keywordflow">return</span> strategy.apply(p1, p2);
|
||
<a name="l00065"></a>00065 }
|
||
<a name="l00066"></a>00066 };
|
||
<a name="l00067"></a>00067
|
||
<a name="l00074"></a>00074 <span class="keyword">template</span><<span class="keyword">typename</span> Range, <span class="keyword">typename</span> Strategy>
|
||
<a name="l00075"></a>00075 <span class="keyword">struct </span>range_length
|
||
<a name="l00076"></a>00076 {
|
||
<a name="l00077"></a>00077 <span class="keyword">typedef</span> <span class="keyword">typename</span> length_result<Range>::type return_type;
|
||
<a name="l00078"></a>00078
|
||
<a name="l00079"></a>00079 <span class="keyword">static</span> <span class="keyword">inline</span> return_type apply(
|
||
<a name="l00080"></a>00080 Range <span class="keyword">const</span>& range, Strategy <span class="keyword">const</span>& strategy)
|
||
<a name="l00081"></a>00081 {
|
||
<a name="l00082"></a>00082 return_type sum = return_type();
|
||
<a name="l00083"></a>00083
|
||
<a name="l00084"></a>00084 <span class="keyword">typedef</span> <span class="keyword">typename</span> boost::range_const_iterator<Range>::type iterator_type;
|
||
<a name="l00085"></a>00085 iterator_type it = boost::begin(range);
|
||
<a name="l00086"></a>00086 <span class="keywordflow">if</span> (it != boost::end(range))
|
||
<a name="l00087"></a>00087 {
|
||
<a name="l00088"></a>00088 iterator_type previous = it++;
|
||
<a name="l00089"></a>00089 <span class="keywordflow">while</span>(it != boost::end(range))
|
||
<a name="l00090"></a>00090 {
|
||
<a name="l00091"></a>00091 <span class="comment">// Add point-point distance using the return type belonging</span>
|
||
<a name="l00092"></a>00092 <span class="comment">// to strategy</span>
|
||
<a name="l00093"></a>00093 sum += strategy.apply(*previous, *it);
|
||
<a name="l00094"></a>00094 previous = it++;
|
||
<a name="l00095"></a>00095 }
|
||
<a name="l00096"></a>00096 }
|
||
<a name="l00097"></a>00097
|
||
<a name="l00098"></a>00098 <span class="keywordflow">return</span> sum;
|
||
<a name="l00099"></a>00099 }
|
||
<a name="l00100"></a>00100 };
|
||
<a name="l00101"></a>00101
|
||
<a name="l00102"></a>00102 }} <span class="comment">// namespace detail::length</span>
|
||
<a name="l00103"></a>00103 <span class="preprocessor">#endif // DOXYGEN_NO_DETAIL</span>
|
||
<a name="l00104"></a>00104 <span class="preprocessor"></span>
|
||
<a name="l00105"></a>00105 <span class="preprocessor">#ifndef DOXYGEN_NO_DISPATCH</span>
|
||
<a name="l00106"></a>00106 <span class="preprocessor"></span><span class="keyword">namespace </span>dispatch
|
||
<a name="l00107"></a>00107 {
|
||
<a name="l00108"></a>00108
|
||
<a name="l00109"></a>00109
|
||
<a name="l00110"></a>00110 <span class="keyword">template</span> <<span class="keyword">typename</span> Tag, <span class="keyword">typename</span> Geometry, <span class="keyword">typename</span> Strategy>
|
||
<a name="l00111"></a>00111 <span class="keyword">struct </span><a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1" title="Calculate length of a geometry.">length</a> : detail::calculate_null
|
||
<a name="l00112"></a>00112 <
|
||
<a name="l00113"></a>00113 typename length_result<Geometry>::type,
|
||
<a name="l00114"></a>00114 Geometry,
|
||
<a name="l00115"></a>00115 Strategy
|
||
<a name="l00116"></a>00116 >
|
||
<a name="l00117"></a>00117 {};
|
||
<a name="l00118"></a>00118
|
||
<a name="l00119"></a>00119
|
||
<a name="l00120"></a>00120 <span class="keyword">template</span> <<span class="keyword">typename</span> Geometry, <span class="keyword">typename</span> Strategy>
|
||
<a name="l00121"></a>00121 <span class="keyword">struct </span><a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1" title="Calculate length of a geometry.">length</a><linestring_tag, Geometry, Strategy>
|
||
<a name="l00122"></a>00122 : detail::<a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1" title="Calculate length of a geometry.">length</a>::range_length<Geometry, Strategy>
|
||
<a name="l00123"></a>00123 {};
|
||
<a name="l00124"></a>00124
|
||
<a name="l00125"></a>00125
|
||
<a name="l00126"></a>00126 <span class="comment">// RING: length is currently 0; it might be argued that it is the "perimeter"</span>
|
||
<a name="l00127"></a>00127
|
||
<a name="l00128"></a>00128
|
||
<a name="l00129"></a>00129 <span class="keyword">template</span> <<span class="keyword">typename</span> Geometry, <span class="keyword">typename</span> Strategy>
|
||
<a name="l00130"></a>00130 <span class="keyword">struct </span><a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1" title="Calculate length of a geometry.">length</a><segment_tag, Geometry, Strategy>
|
||
<a name="l00131"></a>00131 : detail::<a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1" title="Calculate length of a geometry.">length</a>::segment_length<Geometry, Strategy>
|
||
<a name="l00132"></a>00132 {};
|
||
<a name="l00133"></a>00133
|
||
<a name="l00134"></a>00134
|
||
<a name="l00135"></a>00135 } <span class="comment">// namespace dispatch</span>
|
||
<a name="l00136"></a>00136 <span class="preprocessor">#endif // DOXYGEN_NO_DISPATCH</span>
|
||
<a name="l00137"></a>00137 <span class="preprocessor"></span>
|
||
<a name="l00138"></a>00138
|
||
<a name="l00153"></a>00153 <span class="keyword">template</span><<span class="keyword">typename</span> Geometry>
|
||
<a name="l00154"></a><a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1">00154</a> <span class="keyword">inline</span> <span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1length__result.html" title="Meta-function defining return type of length function.">length_result<Geometry>::type</a> <a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1" title="Calculate length of a geometry.">length</a>(
|
||
<a name="l00155"></a>00155 Geometry <span class="keyword">const</span>& geometry)
|
||
<a name="l00156"></a>00156 {
|
||
<a name="l00157"></a>00157 concept::check<const Geometry>();
|
||
<a name="l00158"></a>00158
|
||
<a name="l00159"></a>00159 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1point__type.html" title="Meta-function which defines point type of any geometry.">point_type<Geometry>::type</a> <a class="code" href="structboost_1_1geometry_1_1point__type.html" title="Meta-function which defines point type of any geometry.">point_type</a>;
|
||
<a name="l00160"></a>00160 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1cs__tag.html" title="Meta-function returning coordinate system tag (cs family) of any geometry.">cs_tag<point_type>::type</a> <a class="code" href="structboost_1_1geometry_1_1cs__tag.html" title="Meta-function returning coordinate system tag (cs family) of any geometry.">cs_tag</a>;
|
||
<a name="l00161"></a>00161 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1strategy__distance.html" title="Traits class binding a distance strategy to a (possibly two) coordinate system(s)...">strategy_distance</a>
|
||
<a name="l00162"></a>00162 <
|
||
<a name="l00163"></a>00163 cs_tag,
|
||
<a name="l00164"></a>00164 cs_tag,
|
||
<a name="l00165"></a>00165 point_type,
|
||
<a name="l00166"></a>00166 point_type
|
||
<a name="l00167"></a>00167 >::type strategy_type;
|
||
<a name="l00168"></a>00168
|
||
<a name="l00169"></a>00169 <span class="keywordflow">return</span> <a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1" title="Calculate length of a geometry.">dispatch::length</a>
|
||
<a name="l00170"></a>00170 <
|
||
<a name="l00171"></a>00171 <span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1geometry__not__recognized__tag.html" title="&quot;default&quot; tag">tag<Geometry>::type</a>,
|
||
<a name="l00172"></a>00172 Geometry,
|
||
<a name="l00173"></a>00173 strategy_type
|
||
<a name="l00174"></a>00174 >::apply(geometry, strategy_type());
|
||
<a name="l00175"></a>00175 }
|
||
<a name="l00176"></a>00176
|
||
<a name="l00177"></a>00177
|
||
<a name="l00195"></a>00195 <span class="keyword">template</span><<span class="keyword">typename</span> Geometry, <span class="keyword">typename</span> Strategy>
|
||
<a name="l00196"></a><a class="code" href="group__length.html#g9cccd3df58ebe23f8a5ba35ddca81b31">00196</a> <span class="keyword">inline</span> <span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1length__result.html" title="Meta-function defining return type of length function.">length_result<Geometry>::type</a> <a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1" title="Calculate length of a geometry.">length</a>(
|
||
<a name="l00197"></a>00197 Geometry <span class="keyword">const</span>& geometry, Strategy <span class="keyword">const</span>& strategy)
|
||
<a name="l00198"></a>00198 {
|
||
<a name="l00199"></a>00199 concept::check<const Geometry>();
|
||
<a name="l00200"></a>00200
|
||
<a name="l00201"></a>00201 <span class="keywordflow">return</span> <a class="code" href="group__length.html#g1537537131cd91037cf3ad9fd80d50f1" title="Calculate length of a geometry.">dispatch::length</a>
|
||
<a name="l00202"></a>00202 <
|
||
<a name="l00203"></a>00203 <span class="keyword">typename</span> <a class="code" href="structboost_1_1geometry_1_1geometry__not__recognized__tag.html" title="&quot;default&quot; tag">tag<Geometry>::type</a>,
|
||
<a name="l00204"></a>00204 Geometry,
|
||
<a name="l00205"></a>00205 Strategy
|
||
<a name="l00206"></a>00206 >::apply(geometry, strategy);
|
||
<a name="l00207"></a>00207 }
|
||
<a name="l00208"></a>00208
|
||
<a name="l00209"></a>00209
|
||
<a name="l00210"></a>00210 }} <span class="comment">// namespace boost::geometry</span>
|
||
<a name="l00211"></a>00211
|
||
<a name="l00212"></a>00212 <span class="preprocessor">#endif // BOOST_GEOMETRY_ALGORITHMS_LENGTH_HPP</span>
|
||
</pre></div></div>
|
||
<hr size="1">
|
||
<table width="100%">
|
||
<tbody>
|
||
<tr>
|
||
<td align="left"><small>
|
||
<p>December 1, 2009</p>
|
||
</small></td>
|
||
<td align="right">
|
||
<small>Copyright <20> 1995-2009 Barend Gehrels, Geodan, Amsterdam<br>
|
||
Copyright <20> 2008-2009 Bruno Lalande, Paris<br>
|
||
Copyright <20> 2009 Mateusz Loskot, Cadcorp, London<br>
|
||
</small>
|
||
</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
|
||
<address style="text-align: right;"><small>
|
||
Documentation is generated by <a href="http://www.doxygen.org/index.html">Doxygen</a>
|
||
</small></address>
|
||
</body>
|
||
</html>
|