UNPKG

terraformer

Version:

A Geo-toolkit built in Javascript.

250 lines (226 loc) 11.4 kB
<!doctype html> <html> <head> <meta charset="utf-8"> <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible"> <title>Terraformer</title> <link href="/assets/css/terraformer-02847305.css" media="screen" rel="stylesheet" type="text/css" /> </head> <body class="geostore geostore_spatial-indexes geostore_spatial-indexes_index" id="wrap"> <nav> <ul> <li> <a href="/" class="">Terraformer</a> </li> <li> <a href="https://github.com/search?q=%40Esri+terraformer" class="">GitHub</a> </li> <li> <a href="/install" class="">Install</a> </li> <li> <a href="/" data-direction="active-top" class="toggle" id="close-drawer">Docs</a> </li> </ul> </nav> <div class="drawer" id="drawer"> <div class="doctoc drawer-nav drawer-top"> <div class="container"> <ul> <h3>Terraformer Documentation</h3> <li><a href="/getting-started/">Getting Started</a></li> <li><a href="/core/">Terraformer Core</a></li> <li class="indent"><a href="/core/#terraformerprimitive">Primitives</a></li> <li class="indent"><a href="/core/#terraformertools">Tools</a></li> <li><a href="/geostore/">GeoStores</a></li> <li class="indent"><a href="/geostore/data-stores/">DataStores</a></li> <li class="indent"><a href="/geostore/spatial-indexes/">Spatial Indexes</a></li> <li><a href="/arcgis-parser/">ArcGIS Parser</a></li> <li><a href="/wkt-parser/">WKT Parser</a></li> <li><a href="/glossary/">Glossary</a></li> </ul> </div> </div> </div> <main class="docs main-content" id="main-content"> <h1>GeoStore Spatial Indexes</h1> <div class='semantic-toc'><ol><li><a href='#existing-spatial-indexes'>Existing Spatial Indexes</a></li><li><a href='#writing-a-spatial-index'>Writing a Spatial Index</a><ol><li><a href='#methods'>Methods</a><ol><li><a href='#new-spatialindex'>new SpatialIndex()</a></li><li><a href='#spatialindexinsert'>SpatialIndex.insert(geojson | envelope, id, callback)</a></li><li><a href='#spatialindexremove'>SpatialIndex.remove(geojson | envelope, id, callback)</a></li><li><a href='#spatialindexsearch'>SpatialIndex.search(geojson | envelope, callback)</a></li><li><a href='#spatialindexwithin'>SpatialIndex.within(geojson | envelope, callback)</a></div> <p>Spatial Indexes are an extremely important part of the GeoStore. Spatial Indexes allow for very quick elimination of <code>Features</code> and are part of the core of the GeoStore.</p> <p>Spatial Indexes are asyncronous and use Node.js style callbacks.</p> <h2> <a id='existing-spatial-indexes' class='section-link'></a> <a href='#existing-spatial-indexes' class='header-link'>Link</a> Existing Spatial Indexes <a href='#' class='back-to-top-link'>Back to Top</a> </h2> <p>Terraformer currently ships with a single spatial index, with more coming soon.</p> <ul> <li><a href="https://github.com/esri/terraformer-geostore-rtree">RTree</a> - RTree Index, works in Node.js and the browser</li> </ul> <h2> <a id='writing-a-spatial-index' class='section-link'></a> <a href='#writing-a-spatial-index' class='header-link'>Link</a> Writing a Spatial Index <a href='#' class='back-to-top-link'>Back to Top</a> </h2> <p>Spatial Indexes are designed for searching spatial data, whether in 2D or 3D. The Terraformer GeoStore platform has defined a set of indexes that allow for multiple spatial index types to be used. As long as the methods are asyncronous and conform to the Terraformer GeoStore interface, any type of spatial index can be used.</p> <h3> <a id='methods' class='section-link'></a> <a href='#methods' class='header-link'>Link</a> Methods <a href='#' class='back-to-top-link'>Back to Top</a> </h3><h4> <a id='new-spatialindex' class='section-link'></a> <a href='#new-spatialindex' class='header-link'>Link</a> new SpatialIndex() <a href='#' class='back-to-top-link'>Back to Top</a> </h4> <p>Instantiating a <code>SpatialIndex</code> should return a new object containing method signatures conforming to the <code>SpatialIndex</code> interface.</p> <p>You can pass any needed arguments while instantiating.</p> <p><em>Example:</em></p> <pre class="highlight javascript"><code><span class="kd">var</span> <span class="nx">si</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">SpatialIndex</span><span class="p">({</span> <span class="s2">"width"</span><span class="p">:</span> <span class="mi">45</span><span class="p">,</span> <span class="s2">"dateline"</span><span class="p">:</span> <span class="kc">false</span> <span class="p">});</span> </code></pre> <h4> <a id='spatialindexinsert' class='section-link'></a> <a href='#spatialindexinsert' class='header-link'>Link</a> SpatialIndex.insert(geojson | envelope, id, callback) <a href='#' class='back-to-top-link'>Back to Top</a> </h4> <p>Add a <code>geojson</code> object or <code>envelope</code> to a <code>SpatialIndex</code>. It is important to include an <code>id</code>, as this is the key that is returned from searches.</p> <table><thead> <tr> <th>Option</th> <th>Value</th> <th>Description</th> </tr> </thead><tbody> <tr> <td><a href="/glossary/#geojson"><code>GeoJSON</code></a> <em>or</em> <a href="/glossary/#envelope"><code>Envelope</code></a></td> <td><code>object</code></td> <td>Must be either <code>GeoJSON</code> or <code>Envelope</code></td> </tr> <tr> <td>id</td> <td><code>String</code> <em>or</em> <code>Number</code></td> <td>The <code>id</code> of the spatial area</td> </tr> <tr> <td>callback</td> <td><code>function</code></td> <td>Callback to be fired when the <code>insert</code> has been completed</td> </tr> </tbody></table> <p><em>Example:</em></p> <pre class="highlight javascript"><code><span class="nx">si</span><span class="p">.</span><span class="nx">insert</span><span class="p">(</span><span class="nx">geojson</span><span class="p">,</span> <span class="nx">id</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// Node.js style callback</span> <span class="p">});</span> </code></pre> <h4> <a id='spatialindexremove' class='section-link'></a> <a href='#spatialindexremove' class='header-link'>Link</a> SpatialIndex.remove(geojson | envelope, id, callback) <a href='#' class='back-to-top-link'>Back to Top</a> </h4> <p>Remove a <code>geojson</code> or <code>envelope</code> object already in a SpatialIndex.</p> <table><thead> <tr> <th>Option</th> <th>Value</th> <th>Description</th> </tr> </thead><tbody> <tr> <td><a href="/glossary/#geojson"><code>GeoJSON</code></a> <em>or</em> <a href="/glossary/#envelope"><code>Envelope</code></a></td> <td><code>object</code></td> <td>Must be either <code>GeoJSON</code> or <code>Envelope</code></td> </tr> <tr> <td>id</td> <td><code>String</code> <em>or</em> <code>Number</code></td> <td>The <code>id</code> of the spatial area</td> </tr> <tr> <td>callback</td> <td><code>function</code></td> <td>Callback to be fired when the <code>remove</code> has been completed</td> </tr> </tbody></table> <p><em>Example:</em></p> <pre class="highlight javascript"><code><span class="nx">si</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nx">geojson</span><span class="p">,</span> <span class="nx">id</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// Node.js style callback</span> <span class="p">});</span> </code></pre> <h4> <a id='spatialindexsearch' class='section-link'></a> <a href='#spatialindexsearch' class='header-link'>Link</a> SpatialIndex.search(geojson | envelope, callback) <a href='#' class='back-to-top-link'>Back to Top</a> </h4> <p>Searches for any <code>id</code>&rsquo;s that can contain the <code>geojson</code> or <code>envelope</code> passed in. These are returned as an <code>Array</code>.</p> <table><thead> <tr> <th>Option</th> <th>Value</th> <th>Description</th> </tr> </thead><tbody> <tr> <td><a href="/glossary/#geojson"><code>GeoJSON</code></a> <em>or</em> <a href="/glossary/#envelope"><code>Envelope</code></a></td> <td><code>object</code></td> <td>Must be either <code>GeoJSON</code> or <code>Envelope</code></td> </tr> <tr> <td>callback</td> <td><code>function</code></td> <td>Callback to be fired when the <code>search</code> has been completed</td> </tr> </tbody></table> <p><em>Example:</em></p> <pre class="highlight javascript"><code><span class="nx">si</span><span class="p">.</span><span class="nx">search</span><span class="p">(</span><span class="nx">geojson</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// Node.js style callback</span> <span class="p">});</span> </code></pre> <h4> <a id='spatialindexwithin' class='section-link'></a> <a href='#spatialindexwithin' class='header-link'>Link</a> SpatialIndex.within(geojson | envelope, callback) <a href='#' class='back-to-top-link'>Back to Top</a> </h4> <p>Searches for any <code>id</code>&rsquo;s that are within the <code>geojson</code> or <code>envelope</code> passed in. These are returned as an <code>Array</code>.</p> <table><thead> <tr> <th>Option</th> <th>Value</th> <th>Description</th> </tr> </thead><tbody> <tr> <td><a href="/glossary/#geojson"><code>GeoJSON</code></a> <em>or</em> <a href="/glossary/#envelope"><code>Envelope</code></a></td> <td><code>object</code></td> <td>Must be either <code>GeoJSON</code> or <code>Envelope</code></td> </tr> <tr> <td>callback</td> <td><code>function</code></td> <td>Callback to be fired when the <code>search</code> has been completed</td> </tr> </tbody></table> <p><em>Example:</em></p> <pre class="highlight javascript"><code><span class="nx">si</span><span class="p">.</span><span class="nx">within</span><span class="p">(</span><span class="nx">geojson</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">err</span><span class="p">,</span> <span class="nx">res</span><span class="p">)</span> <span class="p">{</span> <span class="c1">// Node.js style callback</span> <span class="p">});</span> </code></pre> </main> <footer> <p> Terraformer is an open source project from the <a href="http://pdx.esri.com/">Esri Portland R&amp;D Center</a> </p> </footer> <script src="/assets/javascripts/modernizr.custom-cadc78a2.js" type="text/javascript"></script> <script src="/assets/javascripts/classie-b6db1f70.js" type="text/javascript"></script> <script src="/assets/javascripts/drawer-3a1490eb.js" type="text/javascript"></script> </body> </html>