Skip to content

Conversation

@vlach1989
Copy link
Contributor

@vlach1989 vlach1989 commented Jan 7, 2026

This pull request introduces a significant refactor of how map layers are managed and rendered in the mapping client, enabling to fetch data directly from layer component. This step is needed before implementing MVT layers. Instead of parsing and constructing Deck.gl layer instances directly in the SingleMap component, the new approach delegates this responsibility to a modular LayerManager component and a set of specialized layer source components (XYZLayerSource, COGLayerSource, GeojsonLayerSource, WMSLayerSource). This change improves code modularity, maintainability, and extensibility.

Additionally, there are improvements to tooltip attribute imports and a deprecation notice for the old map rendering component.

Layer Management Refactor:

  • Introduced a new LayerManager component that dynamically renders the appropriate layer source component based on datasource labels, and handles the lifecycle and updates of Deck.gl layer instances. (src/client/map/components/layers/LayerManager.tsx)
  • Added new modular layer source components for COG, GeoJSON, and WMS layers, each responsible for creating, updating, and cleaning up their respective Deck.gl layer instances. (src/client/map/components/layers/COGLayerSource.tsx, GeojsonLayerSource.tsx, WMSLayerSource.tsx) [1] [2] [3]
  • Refactored SingleMap to use the LayerManager for layer instantiation and management, maintaining a registry of current layer instances and passing only active layers to DeckGL. (src/client/map/MapSet/SingleMap.tsx) [1] [2] [3] [4] [5]

Tooltip and Model Imports:

  • Updated imports for TooltipAttribute to consistently use the shared model definition, improving code clarity and maintainability. (src/client/map/MapSet/MapTooltip/MapTooltip.tsx, getMapTooltip.ts, handleMapHover.ts, SingleMap.tsx) [1] [2] F6740cb3L1)

Deprecation and Cleanup:

  • Marked the old RenderingMap component as deprecated in favor of the new MapSet and related components, guiding future development. (src/client/map/components/RenderingMap.tsx)

Compatibility
It shouldn't break LUISA application.
Updates for fe-core: https://github.com/Gisat/fe-core/tree/refactoring/map-layers
Updates for GG: https://github.com/Gisat/app-euHorizonGreengage/tree/refactoring/map-layers

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the map layer management system by introducing a modular architecture that separates layer creation logic into specialized source components, improving code organization and maintainability. The changes replace direct layer parsing in SingleMap with a LayerManager that delegates to type-specific layer sources.

Key Changes:

  • Introduced LayerManager and specialized layer source components (XYZ, COG, GeoJSON, WMS) for modular layer handling
  • Refactored SingleMap to use a layer registry pattern with the new LayerManager
  • Consolidated TooltipAttribute interface into a shared model file and updated all imports

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/client/shared/models/models.tooltip.ts Created new shared model file for TooltipAttribute interface
src/client/story/utils/getTooltipAttributes.ts Replaced local TooltipAttribute definition with import from shared models
src/client/map/MapSet/MapTooltip/MapTooltip.tsx Updated TooltipAttribute import to use shared model
src/client/map/MapSet/MapTooltip/getMapTooltip.ts Updated TooltipAttribute import to use shared model
src/client/map/MapSet/handleMapHover.ts Updated TooltipAttribute import to use shared model
src/client/map/MapSet/SingleMap.tsx Refactored to use LayerManager with layer registry pattern instead of direct parsing
src/client/map/components/layers/LayerManager.tsx Created new component to route layer rendering based on datasource labels
src/client/map/components/layers/XYZLayerSource.tsx Created XYZ tile layer source component
src/client/map/components/layers/COGLayerSource.tsx Created COG layer source component
src/client/map/components/layers/GeojsonLayerSource.tsx Created GeoJSON layer source component
src/client/map/components/layers/WMSLayerSource.tsx Created WMS layer source component
src/client/shared/models/models.layers.ts Made level property optional in RenderingLayer interface
src/client/map/components/RenderingMap.tsx Added deprecation notice
src/client/map/logic/validate.layers.ts Added deprecation notice
src/client/map/logic/parsing.layers.ts Added deprecation notice
src/client/map/logic/map.layers.wms.ts Added deprecation notice
src/client/map/logic/map.layers.tile.ts Added deprecation notice
src/client/map/logic/map.layers.mvt.ts Added deprecation notice
src/client/map/logic/map.layers.geojson.ts Removed route parameter and data fetching logic; added deprecation notice
src/client/map/logic/map.layers.cog.ts Added deprecation notice

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

/* TODO: Since sublayers are derived from configuration, which originally is a string
(from ptr-be-core model HasConfiguration) and later parsed to an object,
we need to stringify it here to avoid infinite render loops due to object reference changes. */
}, [url, isActive, key, opacity, JSON.stringify(sublayers)]);
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using JSON.stringify(sublayers) in the dependency array causes the useMemo to recompute on every render when sublayers is an object, defeating its purpose. Consider using a more stable approach such as storing the stringified value in a separate useMemo, or redesigning the data flow to avoid object reference changes.

Copilot uses AI. Check for mistakes.
/* TODO: Since cogBitmapOptions is derived from configuration, which originally is a string
(from ptr-be-core model HasConfiguration) and later parsed to an object,
we need to stringify it here to avoid infinite render loops due to object reference changes. */
}, [url, isActive, key, opacity, JSON.stringify(cogBitmapOptions)]);
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using JSON.stringify(cogBitmapOptions) in the dependency array causes the useMemo to recompute on every render when cogBitmapOptions is an object, defeating its purpose. Consider using a more stable approach such as storing the stringified value in a separate useMemo, or redesigning the data flow to avoid object reference changes.

Copilot uses AI. Check for mistakes.
@vlach1989 vlach1989 changed the base branch from main to dev January 7, 2026 06:31
@vlach1989 vlach1989 added the minor Increment the minor version when merged label Jan 7, 2026
Copy link
Collaborator

@barluq barluq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Than sou for edits. I have found few minors that seems to be a bit problematic for general NPM. Primary default routes or NPM methods.

error,
isLoading,
} = useAxios(
{ fetchUrl: route ?? '/api/features' }, // if no route is provided, use default
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this is NPM, there should be no default to route.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// Log an error if data fetching fails
if (error) {
// just warning for now due to backward compatibility for apps which not using route for geojson fetching
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this there sould be an issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ fetchUrl: route ?? '/api/features' }, // if no route is provided, use default
undefined,
{ documentId: documentId, validIntervalIso, url },
{ method: 'POST' }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if its not a post?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@KrystofVavra KrystofVavra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Increment the minor version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants