UNPKG

mapbox-gl-draw

Version:

A drawing component for Mapbox GL JS

174 lines (173 loc) 5.41 kB
<!doctype html> <html lang="en"> <head> <title>Code coverage report for mapbox-gl-draw/src/lib/features_at.js</title> <meta charset="utf-8" /> <link rel="stylesheet" href="../../../prettify.css" /> <link rel="stylesheet" href="../../../base.css" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <style type='text/css'> .coverage-summary .sorter { background-image: url(../../../sort-arrow-sprite.png); } </style> </head> <body> <div class='wrapper'> <div class='pad1'> <h1> <a href="../../../index.html">all files</a> / <a href="index.html">mapbox-gl-draw/src/lib/</a> features_at.js </h1> <div class='clearfix'> <div class='fl pad1y space-right2'> <span class="strong">96.15% </span> <span class="quiet">Statements</span> <span class='fraction'>25/26</span> </div> <div class='fl pad1y space-right2'> <span class="strong">87.5% </span> <span class="quiet">Branches</span> <span class='fraction'>7/8</span> </div> <div class='fl pad1y space-right2'> <span class="strong">100% </span> <span class="quiet">Functions</span> <span class='fraction'>4/4</span> </div> <div class='fl pad1y space-right2'> <span class="strong">100% </span> <span class="quiet">Lines</span> <span class='fraction'>20/20</span> </div> </div> </div> <div class='status-line high'></div> <pre><table class="coverage"> <tr><td class="line-count quiet">1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37</td><td class="line-coverage quiet"><span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes"></span> <span class="cline-any cline-yes">456×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">456×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">456×</span> <span class="cline-any cline-yes">15470×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">456×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">143×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">456×</span> <span class="cline-any cline-yes">456×</span> <span class="cline-any cline-yes">456×</span> <span class="cline-any cline-yes">142×</span> <span class="cline-any cline-yes">142×</span> <span class="cline-any cline-yes">141×</span> <span class="cline-any cline-yes">141×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-yes">456×</span> <span class="cline-any cline-neutral">&nbsp;</span> <span class="cline-any cline-neutral">&nbsp;</span></td><td class="text"><pre class="prettyprint lang-js">const sortFeatures = require('./sort_features'); const mapEventToBoundingBox = require('./map_event_to_bounding_box'); const Constants = require('../constants'); const StringSet = require('./string_set'); &nbsp; const META_TYPES = [ Constants.meta.FEATURE, Constants.meta.MIDPOINT, Constants.meta.VERTEX ]; &nbsp; // Requires either event or bbox module.exports = function(event, bbox, ctx) { <span class="missing-if-branch" title="if path not taken" >I</span>if (ctx.map === null) <span class="cstat-no" title="statement not covered" >return [];</span> &nbsp; const box = (event) ? mapEventToBoundingBox(event, ctx.options.clickBuffer) : bbox; &nbsp; const queryParams = {}; if (ctx.options.styles) queryParams.layers = ctx.options.styles.map(s =&gt; s.id); &nbsp; const features = ctx.map.queryRenderedFeatures(box, queryParams) .filter((feature) =&gt; { return META_TYPES.indexOf(feature.properties.meta) !== -1; }); &nbsp; const featureIds = new StringSet(); const uniqueFeatures = []; features.forEach((feature) =&gt; { const featureId = feature.properties.id; if (featureIds.has(featureId)) return; featureIds.add(featureId); uniqueFeatures.push(feature); }); &nbsp; return sortFeatures(uniqueFeatures); }; &nbsp;</pre></td></tr> </table></pre> <div class='push'></div><!-- for sticky footer --> </div><!-- /wrapper --> <div class='footer quiet pad2 space-top1 center small'> Code coverage generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Thu Nov 17 2016 15:31:58 GMT-0500 (EST) </div> </div> <script src="../../../prettify.js"></script> <script> window.onload = function () { if (typeof prettyPrint === 'function') { prettyPrint(); } }; </script> <script src="../../../sorter.js"></script> </body> </html>