Skip to content

Commit

Permalink
only index features strictly within tile boundaries
Browse files Browse the repository at this point in the history
Instead of indexing all features for querying, index only those that are
actually within the tile boundaries. This prevents duplicate results
from being returned for point features. This is only a partial fix for
the duplicate results problem (lines and polygons can still return
duplicate results).
  • Loading branch information
ansis committed Apr 3, 2018
1 parent 11feb3b commit 866ab7b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 86 deletions.
7 changes: 6 additions & 1 deletion src/data/feature_index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ class FeatureIndex {
bbox[3] = Math.max(bbox[3], p.y);
}

this.grid.insert(key, bbox[0], bbox[1], bbox[2], bbox[3]);
if (bbox[0] < EXTENT &&
bbox[1] < EXTENT &&
bbox[2] >= 0 &&
bbox[3] >= 0) {
this.grid.insert(key, bbox[0], bbox[1], bbox[2], bbox[3]);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,54 +1,28 @@
[
{
"properties": {
"id": "B"
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
90,
0
]
}
{
"geometry": {
"type": "Point",
"coordinates": [
90,
0
]
},
{
"properties": {
"id": "C"
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
270,
0
]
}
},
{
"properties": {
"id": "B"
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-270,
0
]
}
"type": "Feature",
"properties": {
"id": "B"
}
},
{
"geometry": {
"type": "Point",
"coordinates": [
-90,
0
]
},
{
"properties": {
"id": "C"
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-90,
0
]
}
"type": "Feature",
"properties": {
"id": "C"
}
]
}
]
37 changes: 2 additions & 35 deletions test/integration/query-tests/edge-cases/null-island/expected.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,13 @@
[
{
"properties": {},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
},
{
"properties": {},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
},
{
"properties": {},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
},
{
"properties": {},
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
"properties": {}
}
]

0 comments on commit 866ab7b

Please sign in to comment.