Skip to content

Commit

Permalink
front: fix bug lpv color when selecting a speed section tag
Browse files Browse the repository at this point in the history
  • Loading branch information
clarani committed Feb 14, 2024
1 parent f00b337 commit 3acd113
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
7 changes: 3 additions & 4 deletions front/src/common/Map/Layers/GeoJSONs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,12 @@ import {
getPointTextErrorsLayerProps,
} from 'common/Map/Layers/Errors';
import {
getSpeedSectionsFilter,
getFilterBySpeedSectionsTag,
getSpeedSectionsLineLayerProps,
getSpeedSectionsPointLayerProps,
getSpeedSectionsTextLayerProps,
} from 'common/Map/Layers/SpeedLimits';
import {
getPSLFilter,
getPSLSpeedLineBGLayerProps,
getPSLSpeedLineLayerProps,
getPSLSpeedValueLayerProps,
Expand Down Expand Up @@ -288,7 +287,7 @@ function getPSLSignsLayers(context: LayerContext, prefix: string): LayerProps[]
}

function getPSLLayers(context: LayerContext, prefix: string): LayerProps[] {
const filter = getPSLFilter(context.layersSettings);
const filter = getFilterBySpeedSectionsTag(context.layersSettings);
const bgProps = getPSLSpeedLineBGLayerProps(context);
const layerProps = getPSLSpeedLineLayerProps(context);

Expand Down Expand Up @@ -331,7 +330,7 @@ function getSwitchesLayers(context: LayerContext, prefix: string): LayerProps[]
}

function getSpeedSectionLayers(context: LayerContext, prefix: string): LayerProps[] {
const filter = getSpeedSectionsFilter(context.layersSettings);
const filter = getFilterBySpeedSectionsTag(context.layersSettings);
return [
{
...getSpeedSectionsLineLayerProps(context),
Expand Down
4 changes: 2 additions & 2 deletions front/src/common/Map/Layers/SpeedLimits.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function getSpeedSectionsName(
return ['round', ['*', 3.6, ['case', ['!=', tag, 'null'], ['get', tag], ['get', 'speed_limit']]]];
}

export function getSpeedSectionsFilter(
export function getFilterBySpeedSectionsTag(
layersSettings: MapState['layersSettings']
): FilterSpecification {
return isNil(layersSettings.speedlimittag)
Expand Down Expand Up @@ -173,7 +173,7 @@ export function getSpeedSectionsTextLayerProps({
export default function SpeedLimits({ colors, layerOrder, infraID }: SpeedLimitsProps) {
const { layersSettings } = useSelector((state: RootState) => state.map);

const filter = getSpeedSectionsFilter(layersSettings);
const filter = getFilterBySpeedSectionsTag(layersSettings);
const lineProps = {
...getSpeedSectionsLineLayerProps({
colors,
Expand Down
9 changes: 2 additions & 7 deletions front/src/common/Map/Layers/extensions/SNCF/PSL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import type { LineLayer, SymbolLayer } from 'react-map-gl/maplibre';
import { isNil } from 'lodash';
import type { TFunction } from 'i18next';
import { useTranslation } from 'react-i18next';
import type { FilterSpecification } from 'maplibre-gl';

import type { Theme, OmitLayer } from 'types';

import { MAP_URL } from 'common/Map/const';
import OrderedLayer from 'common/Map/Layers/OrderedLayer';
import SNCF_PSL_Signs from 'common/Map/Layers/extensions/SNCF/PSLSigns';
import { getSpeedSectionsTag, getSpeedSectionsName } from 'common/Map/Layers/SpeedLimits';
import { getSpeedSectionsName, getFilterBySpeedSectionsTag } from 'common/Map/Layers/SpeedLimits';

import type { RootState } from 'reducers';
import type { MapState } from 'reducers/map';
Expand All @@ -24,10 +23,6 @@ interface SNCF_PSLProps {
infraID?: number | undefined;
}

export function getPSLFilter(layersSettings: MapState['layersSettings']): FilterSpecification {
return ['any', ['has', 'speed_limit'], ['has', getSpeedSectionsTag(layersSettings)]];
}

export function getPSLSpeedValueLayerProps({
colors,
sourceTable,
Expand Down Expand Up @@ -161,7 +156,7 @@ const SNCF_PSL = ({ colors, layerOrder, infraID }: SNCF_PSLProps) => {
const { t } = useTranslation('map-settings');
const { layersSettings } = useSelector((state: RootState) => state.map);

const speedSectionFilter = getPSLFilter(layersSettings);
const speedSectionFilter = getFilterBySpeedSectionsTag(layersSettings);

const speedValueParams = {
...getPSLSpeedValueLayerProps({
Expand Down

0 comments on commit 3acd113

Please sign in to comment.