dlr-eoc/ukis-frontend-libraries

Projection as part of mapState

Opened this issue · 4 comments

voinSR commented

Description

I propose to include current map projection into mapState object, next to the coordiantes, zoom and time.

  • What is it useful for?
    it can be useful for maps with multiple projection. Let's say we want to restore a view that user stored (specific coordinates, layers, time and projection) and/or generate stateful links. Another bonus is that we can listen for projection changes and do some actions. Eg. when projection is changed all features are reprojected automatically, but when we have Webmercator and the new projection is Polar Stereographic all features located in higher that 85 deg lat would have distorted coordinates. Having projection in the mapState we could catch such situations and implement some workarounds.

  • Does this change impact existing behaviors? If so how? --> no

Relevant Package

This feature request is for @dlr-eoc/....

Examples

Are there any examples in other projects that demonstrate this feature or enhancement? --> not yet

Describe alternatives you've considered

Have you considered any alternative solutions or workarounds? --> no alternatives

if you guys give me a green light I would implement this feature and create PR

voinSR commented

in mapService i found projectionChange: Subject which can do the trick. But think it could make sense to bring this into mapState, isn't it?

Yes, that's a good idea.

So would it be enough to extend the MapState with epsg: string e.g.

export class MapState implements IMapState {
  zoom: number;
  center: {
    lat: number;
    lon: number;
  };
  options: IMapStateOptions;
  extent: TGeoExtent;
  time: string;
  epsg: string;
...

or do you need more parameters of a projection?

voinSR commented

i think we need to store somewhere a container with projection definitions for the map and to move the logic for projection switch to mapState (as we do with coordinates) and then projectionSwitch would not call mapSvc to change projection, but the mapState... ahh it is a bit bigger change than i thought

i have to think a bit