From 1f1f6ad798933f78e98b9a11a3d69f7827646e2b Mon Sep 17 00:00:00 2001 From: jaroslawjanas Date: Mon, 15 Jun 2020 02:59:16 +0100 Subject: [PATCH 1/4] Polyline support --- .../DndLayerControl.js | 8 ++++--- public/vislib/vector_layer_types/EsLayer.js | 22 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/public/lib/dragAndDroplayercontrol/DndLayerControl.js b/public/lib/dragAndDroplayercontrol/DndLayerControl.js index ee1e361..0c6b146 100644 --- a/public/lib/dragAndDroplayercontrol/DndLayerControl.js +++ b/public/lib/dragAndDroplayercontrol/DndLayerControl.js @@ -430,14 +430,16 @@ function getExtendedMapControl() { resp.responses.forEach(spatialPathDoc => { if (spatialPathDoc.hits.hits.length === 1) { - const spaitalPathSource = spatialPathDoc.hits.hits[0]._source; + const spatialPathSource = spatialPathDoc.hits.hits[0]._source; let geometryType = 'point'; - if (spaitalPathSource.geometry.type.includes('Polygon')) { + if (spatialPathSource.geometry.type.includes('Polygon')) { geometryType = 'polygon'; + } else if (spatialPathSource.geometry.type.includes('Line')) { + geometryType = 'line'; } - layerTypes[spaitalPathSource.spatial_path] = geometryType; + layerTypes[spatialPathSource.spatial_path] = geometryType; } }); return layerTypes; diff --git a/public/vislib/vector_layer_types/EsLayer.js b/public/vislib/vector_layer_types/EsLayer.js index f6c2069..281bc35 100644 --- a/public/vislib/vector_layer_types/EsLayer.js +++ b/public/vislib/vector_layer_types/EsLayer.js @@ -49,7 +49,11 @@ export default class EsLayer { layer.unbindPopup(); }; self.bindPopup(layer, options); - } else if ('geo_shape' === geo.type || 'polygon' === geo.type || 'multipolygon' === geo.type) { + } else if ('geo_shape' === geo.type || + 'polygon' === geo.type || + 'multipolygon' === geo.type || + 'linestring' === geo.type || + 'multilinestring' === geo.type) { const shapesWithGeometry = _.remove(hits, hit => { return _.get(hit, `_source[${geo.field}]`); }); @@ -59,7 +63,11 @@ export default class EsLayer { geometry.type = self.capitalizeFirstLetter(geometry.type); if (geometry.type === 'Multipolygon') { - geometry.type === 'MultiPolygon'; + geometry.type = 'MultiPolygon'; + } else if (geometry.type === 'Linestring') { + geometry.type = 'LineString'; + } else if (geometry.type === 'Multilinestring') { + geometry.type = 'MultiLineString'; } if (type === 'es_ref') { @@ -130,7 +138,11 @@ export default class EsLayer { } ); self.bindPopup(layer, options); - layer.icon = ``; + if (geo.type.includes('line')) { + layer.icon = ``; + } else { + layer.icon = ``; + } layer.type = type + '_shape'; layer.destroy = () => layer.options.destroy(); } else { @@ -165,8 +177,10 @@ export default class EsLayer { if (geo.type === 'point') { layer.icon = ``; + } else if (geo.type.includes('line')) { + layer.icon = ``; } else { - layer.icon = ``; + layer.icon = ``; } layer.options = { pane: 'overlayPane' }; From bb609f82106776978495aaacf4fb00bca082f2a1 Mon Sep 17 00:00:00 2001 From: Jaroslaw Janas Date: Mon, 15 Jun 2020 12:09:08 +0100 Subject: [PATCH 2/4] Update public/vislib/vector_layer_types/EsLayer.js Co-authored-by: Edwin <36197976+corrigancd@users.noreply.github.com> --- public/vislib/vector_layer_types/EsLayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/vislib/vector_layer_types/EsLayer.js b/public/vislib/vector_layer_types/EsLayer.js index 281bc35..6ef3a87 100644 --- a/public/vislib/vector_layer_types/EsLayer.js +++ b/public/vislib/vector_layer_types/EsLayer.js @@ -138,7 +138,7 @@ export default class EsLayer { } ); self.bindPopup(layer, options); - if (geo.type.includes('line')) { + if (geo.type === 'linestring' || geo.type === 'multilinestring) { layer.icon = ``; } else { layer.icon = ``; From 01d1790d626ad16da72d4070dc81ac1aa3b286d6 Mon Sep 17 00:00:00 2001 From: jaroslawjanas Date: Mon, 15 Jun 2020 18:44:10 +0100 Subject: [PATCH 3/4] syntax fix --- public/vislib/vector_layer_types/EsLayer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/vislib/vector_layer_types/EsLayer.js b/public/vislib/vector_layer_types/EsLayer.js index 6ef3a87..bbea842 100644 --- a/public/vislib/vector_layer_types/EsLayer.js +++ b/public/vislib/vector_layer_types/EsLayer.js @@ -138,7 +138,7 @@ export default class EsLayer { } ); self.bindPopup(layer, options); - if (geo.type === 'linestring' || geo.type === 'multilinestring) { + if (geo.type === 'linestring' || geo.type === 'multilinestring') { layer.icon = ``; } else { layer.icon = ``; From b50f457ddfaaf93d20cb03c81261b546ade08c45 Mon Sep 17 00:00:00 2001 From: jaroslawjanas Date: Tue, 16 Jun 2020 14:32:21 +0100 Subject: [PATCH 4/4] Bug fix for line --- public/lib/dragAndDroplayercontrol/DndLayerControl.js | 2 +- public/vislib/vector_layer_types/EsLayer.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/public/lib/dragAndDroplayercontrol/DndLayerControl.js b/public/lib/dragAndDroplayercontrol/DndLayerControl.js index 0c6b146..41ca9c0 100644 --- a/public/lib/dragAndDroplayercontrol/DndLayerControl.js +++ b/public/lib/dragAndDroplayercontrol/DndLayerControl.js @@ -490,7 +490,7 @@ function getExtendedMapControl() { // a check if there are any stored layers if (resp) { const aggs = resp.aggregations[2].buckets; - geometryTypeOfSpatialPaths = _getGeometryTypeOfSpatialPaths(aggs); + geometryTypeOfSpatialPaths = await _getGeometryTypeOfSpatialPaths(aggs); const savedStoredLayers = []; aggs.forEach(agg => { diff --git a/public/vislib/vector_layer_types/EsLayer.js b/public/vislib/vector_layer_types/EsLayer.js index bbea842..517740d 100644 --- a/public/vislib/vector_layer_types/EsLayer.js +++ b/public/vislib/vector_layer_types/EsLayer.js @@ -177,7 +177,7 @@ export default class EsLayer { if (geo.type === 'point') { layer.icon = ``; - } else if (geo.type.includes('line')) { + } else if (geo.type === 'line') { layer.icon = ``; } else { layer.icon = ``;