Click here to Skip to main content
15,896,606 members
Articles / Web Development / HTML

Polyline Simplification

Rate me:
Please Sign up or sign in to vote.
4.93/5 (97 votes)
25 Jun 2011MPL28 min read 261.7K   12.4K   185  
A generic C++ implementation for n-dimensional Douglas-Peucker approximation
<!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>psimpl: psimpl::PolylineSimplification&lt; DIM, InputIterator, OutputIterator &gt;::DPHelper Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">psimpl&#160;<span id="projectnumber">7</span></div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('classpsimpl_1_1_polyline_simplification_1_1_d_p_helper.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="#pri-static-methods">Static Private Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">psimpl::PolylineSimplification&lt; DIM, InputIterator, OutputIterator &gt;::DPHelper Class Reference</div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="psimpl::PolylineSimplification::DPHelper" -->
<p>Douglas-Peucker approximation helper class.  
 <a href="classpsimpl_1_1_polyline_simplification_1_1_d_p_helper.html#details">More...</a></p>

<p><a href="classpsimpl_1_1_polyline_simplification_1_1_d_p_helper-members.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structpsimpl_1_1_polyline_simplification_1_1_d_p_helper_1_1_key_info.html">KeyInfo</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines the key of a polyline.  <a href="structpsimpl_1_1_polyline_simplification_1_1_d_p_helper_1_1_key_info.html#details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structpsimpl_1_1_polyline_simplification_1_1_d_p_helper_1_1_sub_poly.html">SubPoly</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines a sub polyline.  <a href="structpsimpl_1_1_polyline_simplification_1_1_d_p_helper_1_1_sub_poly.html#details">More...</a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structpsimpl_1_1_polyline_simplification_1_1_d_p_helper_1_1_sub_poly_alt.html">SubPolyAlt</a></td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines a sub polyline including its key.  <a href="structpsimpl_1_1_polyline_simplification_1_1_d_p_helper_1_1_sub_poly_alt.html#details">More...</a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpsimpl_1_1_polyline_simplification_1_1_d_p_helper.html#a19ef5bd5a4ff343e4defbe3765215c28">Approximate</a> (const <a class="el" href="classpsimpl_1_1_polyline_simplification.html#aacad79ca2e6dc004483838f460ab8df1">value_type</a> *coords, <a class="el" href="classpsimpl_1_1_polyline_simplification.html#a08f998ecc4af984c070603b489b3ce28">ptr_diff_type</a> coordCount, <a class="el" href="classpsimpl_1_1_polyline_simplification.html#aacad79ca2e6dc004483838f460ab8df1">value_type</a> tol, unsigned char *keys)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs Douglas-Peucker approximation.  <a href="#a19ef5bd5a4ff343e4defbe3765215c28"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpsimpl_1_1_polyline_simplification_1_1_d_p_helper.html#afd49bef5d20db1ef171f9dcfc297e953">ApproximateN</a> (const <a class="el" href="classpsimpl_1_1_polyline_simplification.html#aacad79ca2e6dc004483838f460ab8df1">value_type</a> *coords, <a class="el" href="classpsimpl_1_1_polyline_simplification.html#a08f998ecc4af984c070603b489b3ce28">ptr_diff_type</a> coordCount, unsigned countTol, unsigned char *keys)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs Douglas-Peucker approximation.  <a href="#afd49bef5d20db1ef171f9dcfc297e953"></a><br/></td></tr>
<tr><td colspan="2"><h2><a name="pri-static-methods"></a>
Static Private Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static <a class="el" href="structpsimpl_1_1_polyline_simplification_1_1_d_p_helper_1_1_key_info.html">KeyInfo</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classpsimpl_1_1_polyline_simplification_1_1_d_p_helper.html#ab1e1bf2f9c562d9ea784466129ce0b19">FindKey</a> (const <a class="el" href="classpsimpl_1_1_polyline_simplification.html#aacad79ca2e6dc004483838f460ab8df1">value_type</a> *coords, <a class="el" href="classpsimpl_1_1_polyline_simplification.html#a08f998ecc4af984c070603b489b3ce28">ptr_diff_type</a> first, <a class="el" href="classpsimpl_1_1_polyline_simplification.html#a08f998ecc4af984c070603b489b3ce28">ptr_diff_type</a> last)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Finds the key for the given sub polyline.  <a href="#ab1e1bf2f9c562d9ea784466129ce0b19"></a><br/></td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><h3>template&lt;unsigned DIM, class InputIterator, class OutputIterator&gt;<br/>
class psimpl::PolylineSimplification&lt; DIM, InputIterator, OutputIterator &gt;::DPHelper</h3>

<p>Douglas-Peucker approximation helper class. </p>
<p>Contains helper implentations for Douglas-Peucker approximation that operate solely on value_type arrays and value_type pointers. Note that the <a class="el" href="classpsimpl_1_1_polyline_simplification.html" title="Provides various simplification algorithms for n-dimensional simple polylines.">PolylineSimplification</a> class only operates on iterators. </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a19ef5bd5a4ff343e4defbe3765215c28"></a><!-- doxytag: member="psimpl::PolylineSimplification::DPHelper::Approximate" ref="a19ef5bd5a4ff343e4defbe3765215c28" args="(const value_type *coords, ptr_diff_type coordCount, value_type tol, unsigned char *keys)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;unsigned DIM, class InputIterator, class OutputIterator&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">static void <a class="el" href="classpsimpl_1_1_polyline_simplification.html">psimpl::PolylineSimplification</a>&lt; DIM, InputIterator, OutputIterator &gt;::DPHelper::Approximate </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classpsimpl_1_1_polyline_simplification.html#aacad79ca2e6dc004483838f460ab8df1">value_type</a> *&#160;</td>
          <td class="paramname"><em>coords</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classpsimpl_1_1_polyline_simplification.html#a08f998ecc4af984c070603b489b3ce28">ptr_diff_type</a>&#160;</td>
          <td class="paramname"><em>coordCount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classpsimpl_1_1_polyline_simplification.html#aacad79ca2e6dc004483838f460ab8df1">value_type</a>&#160;</td>
          <td class="paramname"><em>tol</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char *&#160;</td>
          <td class="paramname"><em>keys</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Performs Douglas-Peucker approximation. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">coords</td><td>array of polyline coordinates </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">coordCount</td><td>number of coordinates in coords [] </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">tol</td><td>approximation tolerance </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">keys</td><td>indicates for each polyline point if it is a key </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="afd49bef5d20db1ef171f9dcfc297e953"></a><!-- doxytag: member="psimpl::PolylineSimplification::DPHelper::ApproximateN" ref="afd49bef5d20db1ef171f9dcfc297e953" args="(const value_type *coords, ptr_diff_type coordCount, unsigned countTol, unsigned char *keys)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;unsigned DIM, class InputIterator, class OutputIterator&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">static void <a class="el" href="classpsimpl_1_1_polyline_simplification.html">psimpl::PolylineSimplification</a>&lt; DIM, InputIterator, OutputIterator &gt;::DPHelper::ApproximateN </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classpsimpl_1_1_polyline_simplification.html#aacad79ca2e6dc004483838f460ab8df1">value_type</a> *&#160;</td>
          <td class="paramname"><em>coords</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classpsimpl_1_1_polyline_simplification.html#a08f998ecc4af984c070603b489b3ce28">ptr_diff_type</a>&#160;</td>
          <td class="paramname"><em>coordCount</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned&#160;</td>
          <td class="paramname"><em>countTol</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">unsigned char *&#160;</td>
          <td class="paramname"><em>keys</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Performs Douglas-Peucker approximation. </p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">coords</td><td>array of polyline coordinates </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">coordCount</td><td>number of coordinates in coords [] </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">countTol</td><td>point count tolerance </td></tr>
    <tr><td class="paramdir">[out]</td><td class="paramname">keys</td><td>indicates for each polyline point if it is a key </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="ab1e1bf2f9c562d9ea784466129ce0b19"></a><!-- doxytag: member="psimpl::PolylineSimplification::DPHelper::FindKey" ref="ab1e1bf2f9c562d9ea784466129ce0b19" args="(const value_type *coords, ptr_diff_type first, ptr_diff_type last)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;unsigned DIM, class InputIterator, class OutputIterator&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">static <a class="el" href="structpsimpl_1_1_polyline_simplification_1_1_d_p_helper_1_1_key_info.html">KeyInfo</a> <a class="el" href="classpsimpl_1_1_polyline_simplification.html">psimpl::PolylineSimplification</a>&lt; DIM, InputIterator, OutputIterator &gt;::DPHelper::FindKey </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="classpsimpl_1_1_polyline_simplification.html#aacad79ca2e6dc004483838f460ab8df1">value_type</a> *&#160;</td>
          <td class="paramname"><em>coords</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classpsimpl_1_1_polyline_simplification.html#a08f998ecc4af984c070603b489b3ce28">ptr_diff_type</a>&#160;</td>
          <td class="paramname"><em>first</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="classpsimpl_1_1_polyline_simplification.html#a08f998ecc4af984c070603b489b3ce28">ptr_diff_type</a>&#160;</td>
          <td class="paramname"><em>last</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td><code> [inline, static, private]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Finds the key for the given sub polyline. </p>
<p>Finds the point in the range [first, last] that is furthest away from the segment (first, last). This point is called the key.</p>
<dl><dt><b>Parameters:</b></dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">coords</td><td>array of polyline coordinates </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">first</td><td>the first coordinate of the first polyline point </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">last</td><td>the first coordinate of the last polyline point </td></tr>
  </table>
  </dd>
</dl>
<dl class="return"><dt><b>Returns:</b></dt><dd>the index of the key and its distance, or last when a key could not be found </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>D:/Code/Projects/psimpl/trunk/lib/<a class="el" href="psimpl_8h_source.html">psimpl.h</a></li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="namespacepsimpl.html">psimpl</a>      </li>
      <li class="navelem"><a class="el" href="classpsimpl_1_1_polyline_simplification.html">PolylineSimplification</a>      </li>
      <li class="navelem"><a class="el" href="classpsimpl_1_1_polyline_simplification_1_1_d_p_helper.html">DPHelper</a>      </li>
      <li class="footer">Generated on Fri Jun 24 2011 14:56:29 for psimpl by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </li>
    </ul>
  </div>

</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Mozilla Public License 1.1 (MPL 1.1)


Written By
Software Developer Optiver
Netherlands Netherlands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions