-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix extrusion querying for polygons with coincident points #9138
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
test/integration/query-tests/regressions/mapbox-gl-js#8999/expected.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
[ | ||
{ | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[ | ||
-19.9951171875, | ||
-40.01078714046552 | ||
], | ||
[ | ||
-19.9951171875, | ||
40.01078714046551 | ||
], | ||
[ | ||
39.990234375, | ||
40.01078714046551 | ||
], | ||
[ | ||
-19.9951171875, | ||
-40.01078714046552 | ||
] | ||
] | ||
] | ||
}, | ||
"type": "Feature", | ||
"properties": { | ||
"layer": "extrusion_three_points" | ||
}, | ||
"source": "extrusion_three_points", | ||
"state": {} | ||
} | ||
] |
65 changes: 65 additions & 0 deletions
65
test/integration/query-tests/regressions/mapbox-gl-js#8999/style.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"version": 8, | ||
"metadata": { | ||
"test": { | ||
"debug": true, | ||
"width": 200, | ||
"height": 200, | ||
"queryGeometry": [ | ||
100, | ||
40 | ||
] | ||
} | ||
}, | ||
"pitch": 0, | ||
"center": [ | ||
0, | ||
0 | ||
], | ||
"zoom": 0, | ||
"sources": { | ||
"extrusion_three_points": { | ||
"type": "geojson", | ||
"data": { | ||
"type": "Feature", | ||
"properties": { | ||
"layer": "extrusion_three_points" | ||
}, | ||
"geometry": { | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[ | ||
-20, | ||
-40 | ||
], | ||
[ | ||
-20, | ||
40 | ||
], | ||
[ | ||
40, | ||
40 | ||
], | ||
[ | ||
-20, | ||
-40 | ||
] | ||
] | ||
] | ||
} | ||
} | ||
} | ||
}, | ||
"layers": [ | ||
{ | ||
"id": "extrusion_three_points", | ||
"type": "fill-extrusion", | ||
"source": "extrusion_three_points", | ||
"paint": { | ||
"fill-extrusion-color": "#ecc", | ||
"fill-extrusion-height": 0 | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {test} from '../../../util/test'; | ||
import {getIntersectionDistance} from '../../../../src/style/style_layer/fill_extrusion_style_layer'; | ||
import Point from '@mapbox/point-geometry'; | ||
|
||
test('getIntersectionDistance', (t) => { | ||
const queryPoint = [new Point(100, 100)]; | ||
const z = 3; | ||
const a = new Point(100, -90); | ||
const b = new Point(110, 110); | ||
const c = new Point(-110, 110); | ||
a.z = z; | ||
b.z = z; | ||
c.z = z; | ||
|
||
t.test('one point', (t) => { | ||
const projectedFace = [a, a]; | ||
t.equal(getIntersectionDistance(queryPoint, projectedFace), Infinity); | ||
t.end(); | ||
}); | ||
|
||
t.test('two points', (t) => { | ||
const projectedFace = [a, b, a]; | ||
t.equal(getIntersectionDistance(queryPoint, projectedFace), Infinity); | ||
t.end(); | ||
}); | ||
|
||
t.test('two points coincident', (t) => { | ||
const projectedFace = [a, a, a, b, b, b, b, a]; | ||
t.equal(getIntersectionDistance(queryPoint, projectedFace), Infinity); | ||
t.end(); | ||
}); | ||
|
||
t.test('three points', (t) => { | ||
const projectedFace = [a, b, c, a]; | ||
t.equal(getIntersectionDistance(queryPoint, projectedFace), z); | ||
t.end(); | ||
}); | ||
|
||
t.test('three points coincident points', (t) => { | ||
const projectedFace = [a, a, b, b, b, c, c, a]; | ||
t.equal(getIntersectionDistance(queryPoint, projectedFace), z); | ||
t.end(); | ||
}); | ||
t.end(); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, just one question.
Is numerical stability a concern with with floating point rounding errors with the
equals
checks? Would doing a distance check with a small epsilon be safer?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... good question. I think the minimum distance (when not equal) should be safely large because vector tile positions are stored as (fairly small) integers. Also, any precision issues would just result in sorting errors which wouldn't be the end of the world.
I think it makes sense to leave it as is for now.