point-vs-bbox

Benchmark created by ryanttb on


Description

Is a test against a point bbox too much overhead vs. just testing the point

Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="//host.appgeo.com/libs/geo/test/jquery-geo-test.min.js"></script>
 
<script>
  var shape = {type:"Point", coordinates:[-34, 84]};
  var bbox = null;
  var point = {type:"Point", coordinates:[-34.5, 84.5]};
  var mapTol = 1;
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
bbox
if (!bbox) {
  bbox = $.geo._bbox(shape);
}
var bboxPolygon = {
      type: "Polygon",
      coordinates: [[
        [bbox[0], bbox[1]],
        [bbox[0], bbox[3]],
        [bbox[2], bbox[3]],
        [bbox[2], bbox[1]],
        [bbox[0], bbox[1]]
      ]]
    };

if ($.geo._distance(bboxPolygon, point) <= mapTol) {
  // all i need to test
}
 
ready
point
if (shape.type == "Point" && $.geo._distance(shape, point) <= mapTol) {
  // all i need to test
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.