mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
* [Maps] handle extents that wrap globe * simplify logic
This commit is contained in:
parent
49d76ab813
commit
2b1b61765f
2 changed files with 17 additions and 1 deletions
|
@ -224,7 +224,8 @@ function formatEnvelopeAsPolygon({ maxLat, maxLon, minLat, minLon }) {
|
|||
* Convert map bounds to polygon
|
||||
*/
|
||||
export function convertMapExtentToPolygon({ maxLat, maxLon, minLat, minLon }) {
|
||||
if (maxLon > 180 && minLon < -180) {
|
||||
const lonDelta = maxLon - minLon;
|
||||
if (lonDelta >= 360) {
|
||||
return formatEnvelopeAsPolygon({
|
||||
maxLat,
|
||||
maxLon: 180,
|
||||
|
|
|
@ -299,6 +299,21 @@ describe('convertMapExtentToPolygon', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('should clamp longitudes to -180 to 180 when bounds span entire globe (360)', () => {
|
||||
const bounds = {
|
||||
maxLat: 10,
|
||||
maxLon: 170,
|
||||
minLat: -10,
|
||||
minLon: -400,
|
||||
};
|
||||
expect(convertMapExtentToPolygon(bounds)).toEqual({
|
||||
"type": "polygon",
|
||||
"coordinates": [
|
||||
[[-180, 10], [-180, -10], [180, -10], [180, 10], [-180, 10]]
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle bounds that cross dateline(east to west)', () => {
|
||||
const bounds = {
|
||||
maxLat: 10,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue