mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Maps] Add support for envelope (#80614)
This commit is contained in:
parent
6b8e8a5b46
commit
b1af4ba9ae
2 changed files with 34 additions and 0 deletions
|
@ -175,6 +175,16 @@ export function convertESShapeToGeojsonGeometry(value) {
|
|||
geoJson.type = GEO_JSON_TYPE.GEOMETRY_COLLECTION;
|
||||
break;
|
||||
case 'envelope':
|
||||
// format defined here https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-shape.html#_envelope
|
||||
const polygon = formatEnvelopeAsPolygon({
|
||||
minLon: geoJson.coordinates[0][0],
|
||||
maxLon: geoJson.coordinates[1][0],
|
||||
minLat: geoJson.coordinates[1][1],
|
||||
maxLat: geoJson.coordinates[0][1],
|
||||
});
|
||||
geoJson.type = polygon.type;
|
||||
geoJson.coordinates = polygon.coordinates;
|
||||
break;
|
||||
case 'circle':
|
||||
const errorMessage = i18n.translate(
|
||||
'xpack.maps.es_geo_utils.convert.unsupportedGeometryTypeErrorMessage',
|
||||
|
|
|
@ -250,6 +250,30 @@ describe('geoShapeToGeometry', () => {
|
|||
expect(shapes[0].coordinates).toEqual(coordinates);
|
||||
});
|
||||
|
||||
it('Should convert envelope to geojson', () => {
|
||||
const coordinates = [
|
||||
[100.0, 1.0],
|
||||
[101.0, 0.0],
|
||||
];
|
||||
const value = {
|
||||
type: 'envelope',
|
||||
coordinates: coordinates,
|
||||
};
|
||||
const shapes = [];
|
||||
geoShapeToGeometry(value, shapes);
|
||||
expect(shapes.length).toBe(1);
|
||||
expect(shapes[0].type).toBe('Polygon');
|
||||
expect(shapes[0].coordinates).toEqual([
|
||||
[
|
||||
[100, 1],
|
||||
[100, 0],
|
||||
[101, 0],
|
||||
[101, 1],
|
||||
[100, 1],
|
||||
],
|
||||
]);
|
||||
});
|
||||
|
||||
it('Should convert array of values', () => {
|
||||
const linestringCoordinates = [
|
||||
[-77.03653, 38.897676],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue