-
Notifications
You must be signed in to change notification settings - Fork 0
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
WIP: Feat/maplibre migration #849
base: develop
Are you sure you want to change the base?
Conversation
projects/arlas-components/src/lib/components/mapgl/mapgl.component.ts
Outdated
Show resolved
Hide resolved
projects/arlas-components/src/lib/components/mapgl/mapgl.component.ts
Outdated
Show resolved
Hide resolved
projects/arlas-components/src/lib/components/mapgl/mapgl.component.ts
Outdated
Show resolved
Hide resolved
projects/arlas-components/src/lib/components/mapgl/mapgl.component.ts
Outdated
Show resolved
Hide resolved
projects/arlas-components/src/lib/components/mapgl/mapgl.component.ts
Outdated
Show resolved
Hide resolved
projects/arlas-components/src/lib/components/mapgl/model/AbstractArlasMapGL.ts
Outdated
Show resolved
Hide resolved
projects/arlas-components/src/lib/components/mapgl/model/AbstractArlasMapGL.ts
Outdated
Show resolved
Hide resolved
public abstract getLayers(): void; | ||
public abstract enableDragPan(): void; | ||
public abstract getCenter(): void; | ||
public abstract flyTo(center, zoom: number): void; |
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.
missing type for center
* - wrap of provider methode could be implemented in another class in middle of | ||
* abstract class. | ||
*/ | ||
export class ArlasMapGl extends AbstractArlasMapGL { |
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.
The capitalisation of GL should be the same for both (Gl vs GL). Since this map is typed according to mapbox, I think it should be specified in its name to avoid any confusion
// Disable map pitch and rotation with keyboard | ||
this._mapProvider.keyboard.disableRotation(); | ||
|
||
// disable box zoom; |
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.
disable -> Disable
I don't know if it is a work in progress or if it is the solution you settled on, but I feel like ArlasMapGl is currently typed for mapbox, and can't be used generically. Other than that, it seems very promising !! |
5d228ea
to
272bf91
Compare
import centroid from '@turf/centroid'; | ||
import limitVertexDirectSelectMode from './model/LimitVertexDirectSelectMode'; | ||
import validGeomDrawPolygonMode from './model/ValidGeomDrawPolygonMode'; | ||
import * as mapboxgl from 'mapbox-gl'; | ||
import { AnyLayer, TransformRequestFunction } from 'mapbox-gl'; |
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.
You still have some mapboxgl typing here
@@ -584,75 +505,22 @@ export class MapglComponent implements OnInit, AfterViewInit, OnChanges, OnDestr | |||
|
|||
/** puts the visualisation set list in the new order after dropping */ | |||
public drop(event: CdkDragDrop<string[]>) { | |||
moveItemInArray(this.visualisationSetsConfig, event.previousIndex, event.currentIndex); |
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.
Since we keep the visualisationSetsConfig, the moveItemInArray can be kept and then you use this.map.reorderLayers to avoid defining another method (drop)
@@ -584,75 +505,22 @@ export class MapglComponent implements OnInit, AfterViewInit, OnChanges, OnDestr | |||
|
|||
/** puts the visualisation set list in the new order after dropping */ | |||
public drop(event: CdkDragDrop<string[]>) { | |||
moveItemInArray(this.visualisationSetsConfig, event.previousIndex, event.currentIndex); | |||
this.reorderLayers(); | |||
this.map.drop(event); | |||
} | |||
|
|||
/** puts the layers list in the new order after dropping */ | |||
public dropLayer(event: CdkDragDrop<string[]>, visuName: string) { |
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.
same as above
moveItemInArray(layers, event.previousIndex, event.currentIndex); | ||
this.visualisationSetsConfig.find(v => v.name === visuName).layers = layers; | ||
this.reorderLayers(); | ||
this.map.dropLayer(event, visuName); | ||
} | ||
|
||
/** Sets the layers order according to the order of `visualisationSetsConfig` list*/ | ||
public reorderLayers() { |
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.
I think the method should be kept as it was, and only the map level interactions should be moved to the ArlasMapGl, like getLayer, moveLayer. otherwise we would end up coding the same ArlasMap logic in multiple files, instead of just coding the elementary bricks that allow for more complex actions, like reordering the layers
@@ -734,270 +602,230 @@ export class MapglComponent implements OnInit, AfterViewInit, OnChanges, OnDestr | |||
} | |||
} | |||
|
|||
public defaultOnZoom(e) { | |||
if (e.features[0].properties.cluster_id !== undefined) { | |||
// TODO: should check the this.index is set with good value |
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.
Agreed, when i looked into refactoring the component, it was not clear where index was set and what it does
} | ||
} | ||
|
||
public addLayerInWritePlaceIfNotExist(layerId: string): void { |
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.
Write -> Right
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.
Should be addLayerAboveBaseLayers or something like that
|
||
public getMapExtend(): MapExtend { | ||
const bounds = this.getMapProvider().getBounds(); | ||
return { bounds: bounds.toArray(), center: bounds.getCenter().toArray(), zoom: this.getMapProvider().getZoom() }; |
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.
extra space
event: string; fn: (e?) => void; | ||
}){ | ||
this.getMapProvider().addControl(control, position); | ||
if(control instanceof ControlButton && eventOverride){ |
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.
extra space
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.
Since in ArlasMapGL you have access to the _mapProvider, it would be best to use that instead of using the access method
* the change is transparent. | ||
*/ | ||
|
||
export interface MapOverride { |
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.
typing could be more informative in this interface
@@ -91,8 +92,8 @@ export class MapglBasemapComponent implements OnInit { | |||
*/ | |||
public setStyle(s: mapboxgl.Style, newBasemap: BasemapStyle) { | |||
const selectedBasemapLayersSet = new Set<string>(); | |||
const layers: Array<mapboxgl.Layer> = (<mapboxgl.Map>this.map).getStyle().layers; | |||
const sources = (<mapboxgl.Map>this.map).getStyle().sources; | |||
const layers: Array<mapboxgl.Layer> = this.map.getStyle().layers; |
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.
mapboxgl is not removed for layers ?
@@ -42,7 +43,7 @@ export class MapboxBasemapService { | |||
this.basemaps = basemaps; | |||
} | |||
|
|||
public addProtomapBasemap(map: mapboxgl.Map) { | |||
public addProtomapBasemap(map: ArlasMapGL) { | |||
const selectedBasemap = this.basemaps.getSelected(); | |||
if (selectedBasemap.type === 'protomap') { | |||
const styleFile = selectedBasemap.styleFile as mapboxgl.Style; |
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.
mapboxgl is not removed for layers ?
@@ -68,7 +69,7 @@ export class MapboxBasemapService { | |||
this.protomapBasemapAddedSource.next(true); | |||
} | |||
|
|||
public removeProtomapBasemap(map: mapboxgl.Map) { | |||
public removeProtomapBasemap(map: ArlasMapGL) { | |||
const selectedBasemap = this.basemaps.getSelected(); | |||
if (selectedBasemap.type === 'protomap') { | |||
(selectedBasemap.styleFile as mapboxgl.Style).layers.forEach(l => { |
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.
mapboxgl is not removed for Style ?
@@ -42,7 +43,7 @@ export class MapboxBasemapService { | |||
this.basemaps = basemaps; | |||
} | |||
|
|||
public addProtomapBasemap(map: mapboxgl.Map) { | |||
public addProtomapBasemap(map: ArlasMapGL) { | |||
const selectedBasemap = this.basemaps.getSelected(); | |||
if (selectedBasemap.type === 'protomap') { | |||
const styleFile = selectedBasemap.styleFile as mapboxgl.Style; |
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.
mapboxgl is not removed for styles ?
@@ -68,7 +69,7 @@ export class MapboxBasemapService { | |||
this.protomapBasemapAddedSource.next(true); | |||
} | |||
|
|||
public removeProtomapBasemap(map: mapboxgl.Map) { | |||
public removeProtomapBasemap(map: ArlasMapGL) { | |||
const selectedBasemap = this.basemaps.getSelected(); | |||
if (selectedBasemap.type === 'protomap') { | |||
(selectedBasemap.styleFile as mapboxgl.Style).layers.forEach(l => { |
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.
mapboxgl is not removed for styles ?
private north: number; | ||
private east: number; | ||
private west: number; | ||
private south: number; | ||
private isDrawingBbox = false; | ||
private canvas: HTMLElement; | ||
private box: HTMLElement; | ||
// points which xy coordinates are in screen referential | ||
private start: mapboxgl.Point; |
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.
You still have some mapboxgl typing here
@@ -461,8 +426,9 @@ export class MapglComponent implements OnInit, AfterViewInit, OnChanges, OnDestr | |||
private drawBboxSubscription: Subscription; | |||
|
|||
public constructor(private http: HttpClient, private drawService: MapboxAoiDrawService, | |||
private basemapService: MapboxBasemapService, | |||
private _snackBar: MatSnackBar, private translate: TranslateService) { | |||
private basemapService: MapboxBasemapService, |
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.
The basemap service injected here is mapboxgl typed
'DRAW_LINE_STRING' | 'DRAW_POLYGON' | 'DRAW_POINT' | 'DRAW_RADIUS_CIRCLE' | | ||
'DRAW_STRIP' | 'DIRECT_STRIP'; | ||
|
||
export class ArlasDraw extends AbstractDraw { |
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.
should be named ArlasMapboxGLDraw ?
|
0b4c783
to
0ab5adc
Compare
Quality Gate passedIssues Measures |
Hello,
before switching to maplibre I tried a refacto which includes:
The aim is to:
I don't know whether what I've started is correct in your eyes. That's why this PR is in wip and open to changes/improvements.
If you think it's going in the wrong direction, it's okay to review the whole thing. This refacto should be seen as a working basis.
Some parts still need to be tested to ensure that everything works as planned.