From af4560180dda2469feac5b313a8e647dca24fb6c Mon Sep 17 00:00:00 2001 From: Merge angular migration to maplibre/mapbox refactor Date: Fri, 20 Dec 2024 18:09:06 +0100 Subject: [PATCH] More refactor --- .../src/lib/draw/themes/default-theme.ts | 131 +++++++--------- src/tools/map.constants.ts | 147 +----------------- 2 files changed, 55 insertions(+), 223 deletions(-) diff --git a/projects/arlas-map/src/lib/draw/themes/default-theme.ts b/projects/arlas-map/src/lib/draw/themes/default-theme.ts index 377a0d89..a364c9a1 100644 --- a/projects/arlas-map/src/lib/draw/themes/default-theme.ts +++ b/projects/arlas-map/src/lib/draw/themes/default-theme.ts @@ -22,6 +22,43 @@ const roundLineLayout = { 'line-join': 'round' }; +const staticModeVertex = ['all', + ['==', 'meta', 'vertex'], + ['==', '$type', 'Point'], + ['!=', 'mode', 'static'] +]; + +const deactivatedStaticModeFeature = ['all', + ['==', 'active', 'false'], + ['==', '$type', 'Point'], + ['==', 'meta', 'feature'], + ['!=', 'mode', 'static'] +]; +const deactivatedStaticPolygon = ['all', + ['==', 'active', 'false'], + ['==', '$type', 'Polygon'], + ['!=', 'mode', 'static'] +]; + +const activatedMidPoint = ['all', + ['==', '$type', 'Point'], + ['==', 'active', 'true'], + ['!=', 'meta', 'midpoint'] +]; +const staticLineMidPoint = ['all', ['==', 'meta', 'midpoint'], + ['==', 'actionType', 'rotation'], + ['==', '$type', 'LineString'], + ['!=', 'mode', 'static'] +]; + +const staticPolygon = ['all', ['==', 'mode', 'static'], ['==', '$type', 'Polygon']]; +const activePolygon = ['all', ['==', 'active', 'true'], ['==', '$type', 'Polygon']]; +const staticMidpoint = ['all', + ['==', 'meta', 'midpoint'], + ['==', 'actionType', 'resize'], + ['==', '$type', 'Point'], + ['!=', 'mode', 'static'] +]; const dashedLinePaint = { 'line-color': '#fbb03b', 'line-dasharray': [0.2, 2], @@ -43,11 +80,7 @@ export default [ { 'id': 'gl-draw-polygon-fill-inactive', 'type': 'fill', - 'filter': ['all', - ['==', 'active', 'false'], - ['==', '$type', 'Polygon'], - ['!=', 'mode', 'static'] - ], + 'filter': deactivatedStaticPolygon, 'paint': { 'fill-color': '#3bb2d0', 'fill-outline-color': '#3bb2d0', @@ -57,7 +90,7 @@ export default [ { 'id': 'gl-draw-polygon-fill-active', 'type': 'fill', - 'filter': ['all', ['==', 'active', 'true'], ['==', '$type', 'Polygon']], + 'filter': activePolygon, 'paint': { 'fill-color': '#fbb03b', 'fill-outline-color': '#fbb03b', @@ -78,18 +111,14 @@ export default [ { 'id': 'gl-draw-polygon-stroke-inactive', 'type': 'line', - 'filter': ['all', - ['==', 'active', 'false'], - ['==', '$type', 'Polygon'], - ['!=', 'mode', 'static'] - ], + 'filter': deactivatedStaticPolygon, 'layout': roundLineLayout, 'paint': linePaint }, { 'id': 'gl-draw-polygon-stroke-active', 'type': 'line', - 'filter': ['all', ['==', 'active', 'true'], ['==', '$type', 'Polygon']], + 'filter': activePolygon, 'layout': roundLineLayout, 'paint': dashedLinePaint }, @@ -118,11 +147,7 @@ export default [ { 'id': 'gl-draw-polygon-and-line-vertex-stroke-inactive', 'type': 'circle', - 'filter': ['all', - ['==', 'meta', 'vertex'], - ['==', '$type', 'Point'], - ['!=', 'mode', 'static'] - ], + 'filter': staticModeVertex, 'paint': { 'circle-radius': 5, 'circle-color': '#fff' @@ -131,11 +156,7 @@ export default [ { 'id': 'gl-draw-polygon-and-line-vertex-inactive', 'type': 'circle', - 'filter': ['all', - ['==', 'meta', 'vertex'], - ['==', '$type', 'Point'], - ['!=', 'mode', 'static'] - ], + 'filter': staticModeVertex, 'paint': { 'circle-radius': 3, 'circle-color': '#fbb03b' @@ -144,12 +165,7 @@ export default [ { 'id': 'gl-draw-point-point-stroke-inactive', 'type': 'circle', - 'filter': ['all', - ['==', 'active', 'false'], - ['==', '$type', 'Point'], - ['==', 'meta', 'feature'], - ['!=', 'mode', 'static'] - ], + 'filter': deactivatedStaticModeFeature, 'paint': { 'circle-radius': 5, 'circle-opacity': 1, @@ -159,12 +175,7 @@ export default [ { 'id': 'gl-draw-point-inactive', 'type': 'circle', - 'filter': ['all', - ['==', 'active', 'false'], - ['==', '$type', 'Point'], - ['==', 'meta', 'feature'], - ['!=', 'mode', 'static'] - ], + 'filter': deactivatedStaticModeFeature, 'paint': { 'circle-radius': 3, 'circle-color': '#3bb2d0' @@ -173,11 +184,7 @@ export default [ { 'id': 'gl-draw-point-stroke-active', 'type': 'circle', - 'filter': ['all', - ['==', '$type', 'Point'], - ['==', 'active', 'true'], - ['!=', 'meta', 'midpoint'] - ], + 'filter': activatedMidPoint, 'paint': { 'circle-radius': 7, 'circle-color': '#fff' @@ -186,10 +193,7 @@ export default [ { 'id': 'gl-draw-point-active', 'type': 'circle', - 'filter': ['all', - ['==', '$type', 'Point'], - ['!=', 'meta', 'midpoint'], - ['==', 'active', 'true']], + 'filter': activatedMidPoint, 'paint': { 'circle-radius': 5, 'circle-color': '#fbb03b' @@ -198,7 +202,7 @@ export default [ { 'id': 'gl-draw-polygon-fill-static', 'type': 'fill', - 'filter': ['all', ['==', 'mode', 'static'], ['==', '$type', 'Polygon']], + 'filter': staticPolygon, 'paint': { 'fill-color': '#3bb2d0', 'fill-outline-color': '#3bb2d0', @@ -208,7 +212,7 @@ export default [ { 'id': 'gl-draw-polygon-stroke-static', 'type': 'line', - 'filter': ['all', ['==', 'mode', 'static'], ['==', '$type', 'Polygon']], + 'filter': staticPolygon, 'layout': roundLineLayout, 'paint': linePaint @@ -236,13 +240,7 @@ export default [ { 'id': 'gl-draw-line-rotate-point', 'type': 'line', - 'filter': ['all', - ['==', 'meta', 'midpoint'], - ['==', 'actionType', 'rotation'], - ['==', '$type', 'LineString'], - ['!=', 'mode', 'static'] - // ['==', 'active', 'true'] - ], + 'filter': staticLineMidPoint, 'layout': roundLineLayout, 'paint': dashedLinePaint @@ -287,13 +285,7 @@ export default [ { 'id': 'gl-draw-line-resize-point', 'type': 'line', - 'filter': ['all', - ['==', 'meta', 'midpoint'], - ['==', 'actionType', 'rotation'], - ['==', '$type', 'LineString'], - ['!=', 'mode', 'static'] - // ['==', 'active', 'true'] - ], + 'filter': staticLineMidPoint, 'layout': roundLineLayout, 'paint': dashedLinePaint @@ -301,12 +293,7 @@ export default [ { 'id': 'gl-draw-polygon-resize-point-stroke', 'type': 'circle', - 'filter': ['all', - ['==', 'meta', 'midpoint'], - ['==', 'actionType', 'resize'], - ['==', '$type', 'Point'], - ['!=', 'mode', 'static'] - ], + 'filter': staticMidpoint, 'paint': { 'circle-radius': 5, 'circle-color': '#fff' @@ -315,12 +302,7 @@ export default [ { 'id': 'gl-draw-polygon-resize-point', 'type': 'circle', - 'filter': ['all', - ['==', 'meta', 'midpoint'], - ['==', 'actionType', 'resize'], - ['==', '$type', 'Point'], - ['!=', 'mode', 'static'] - ], + 'filter': staticMidpoint, 'paint': { 'circle-radius': 6, 'circle-color': '#fbb03b' @@ -329,12 +311,7 @@ export default [ { 'id': 'gl-draw-polygon-resize-point-icon', 'type': 'symbol', - 'filter': ['all', - ['==', 'meta', 'midpoint'], - ['==', 'actionType', 'resize'], - ['==', '$type', 'Point'], - ['!=', 'mode', 'static'] - ], + 'filter': staticMidpoint, 'layout': { 'icon-image': 'resize', 'icon-allow-overlap': true, diff --git a/src/tools/map.constants.ts b/src/tools/map.constants.ts index cd450e30..5e073e42 100644 --- a/src/tools/map.constants.ts +++ b/src/tools/map.constants.ts @@ -276,152 +276,7 @@ export const mapLayers = { zoomOnClick: [], emitOnClick: [], onHover: [] - }, - styleGroups: [ - { - id: 'point-0', - name: 'Point 0', - base: [ - ], - styles: [ - { - id: 'heat-distrib', - name: 'Path', - layerIds: [ - ], - isDefault: false, - geomStrategy: 'centroid' - }, - { - id: 'fill', - name: 'Dot', - layerIds: [ - ], - isDefault: true, - geomStrategy: 'geohash' - } - ] - }, - { - id: 'point-1', - name: 'Point 1', - base: [ - ], - styles: [ - { - id: 'heat-distrib', - name: 'Path', - layerIds: [ - ], - isDefault: false, - geomStrategy: 'centroid' - }, - { - id: 'fill', - name: 'Dot', - layerIds: [ - ], - isDefault: true, - geomStrategy: 'geohash' - } - ] - }, - { - id: 'point-2', - name: 'Point 2', - base: [ - ], - styles: [ - { - id: 'heat-distrib', - name: 'Heats', - layerIds: [ - ], - isDefault: false, - geomStrategy: 'centroid' - }, - { - id: 'fill', - name: 'Rectangle', - layerIds: [ - ], - isDefault: true, - geomStrategy: 'geohash' - } - ] - }, - { - id: 'point-3', - name: 'Point 3', - base: [ - ], - styles: [ - { - id: 'heat-distrib', - name: 'Heats', - layerIds: [ - ], - isDefault: false, - geomStrategy: 'centroid' - }, - { - id: 'fill', - name: 'Rectangle', - layerIds: [ - ], - isDefault: true, - geomStrategy: 'geohash' - } - ] - }, - { - id: 'distribution', - name: 'Distribution', - base: [ - ], - styles: [ - { - id: 'heat-distrib', - name: 'Heats', - layerIds: [ - ], - isDefault: false, - geomStrategy: 'centroid' - }, - { - id: 'fill', - name: 'Rectangle', - layerIds: [ - ], - isDefault: true, - geomStrategy: 'geohash' - } - ] - }, - { - id: 'accuracy', - name: 'Accuracy', - base: [], - styles: [ - { - id: 'heat-acc', - name: 'Heats', - layerIds: [ - ], - isDefault: false, - geomStrategy: 'centroid' - }, - { - id: 'fill-precision', - name: 'Rectangle', - layerIds: [ - ], - isDefault: true, - geomStrategy: 'geohash' - } - ] - } - ] + } } as any; export const drawOptions = {