Skip to content
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

chartos: front: add lpv layer #2176

Merged
merged 7 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions chartos/chartos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@
on_field: geographic
cache_duration: 3600
data_expr: signal.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_signalmodel signal on signal.obj_id = layer.obj_id and signal.infra_id = layer.infra_id
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: signal.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_signalmodel signal on signal.obj_id = layer.obj_id and signal.infra_id = layer.infra_id

Expand All @@ -44,16 +42,39 @@
on_field: geographic
cache_duration: 3600
data_expr: speed_section.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_speedsectionmodel speed_section on speed_section.obj_id = layer.obj_id and speed_section.infra_id = layer.infra_id
where:
- not (speed_section.data @? '$.extensions.lpv_sncf.z')
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: speed_section.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_speedsectionmodel speed_section on speed_section.obj_id = layer.obj_id and speed_section.infra_id = layer.infra_id
where:
- not (speed_section.data @? '$.extensions.lpv_sncf.z')

- name: lpv
table_name: osrd_infra_speedsectionlayer
id_field: id
views:
- name: geo
on_field: geographic
cache_duration: 3600
data_expr: speed_section.data
joins:
- inner join osrd_infra_speedsectionmodel speed_section on speed_section.obj_id = layer.obj_id and speed_section.infra_id = layer.infra_id
where:
- speed_section.data @? '$.extensions.lpv_sncf.z'
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: speed_section.data
joins:
- inner join osrd_infra_speedsectionmodel speed_section on speed_section.obj_id = layer.obj_id and speed_section.infra_id = layer.infra_id
where:
- speed_section.data @? '$.extensions.lpv_sncf.z'

- name: track_section_links
table_name: osrd_infra_tracksectionlinklayer
Expand All @@ -63,14 +84,12 @@
on_field: geographic
cache_duration: 3600
data_expr: track_section_link.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_tracksectionlinkmodel track_section_link on track_section_link.obj_id = layer.obj_id and track_section_link.infra_id = layer.infra_id
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: track_section_link.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_tracksectionlinkmodel track_section_link on track_section_link.obj_id = layer.obj_id and track_section_link.infra_id = layer.infra_id

Expand All @@ -82,14 +101,12 @@
on_field: geographic
cache_duration: 3600
data_expr: switch.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_switchmodel switch on switch.obj_id = layer.obj_id and switch.infra_id = layer.infra_id
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: switch.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_switchmodel switch on switch.obj_id = layer.obj_id and switch.infra_id = layer.infra_id

Expand All @@ -101,14 +118,12 @@
on_field: geographic
cache_duration: 3600
data_expr: detector.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_detectormodel detector on detector.obj_id = layer.obj_id and detector.infra_id = layer.infra_id
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: detector.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_detectormodel detector on detector.obj_id = layer.obj_id and detector.infra_id = layer.infra_id

Expand All @@ -120,14 +135,12 @@
on_field: geographic
cache_duration: 3600
data_expr: buffer_stop.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_bufferstopmodel buffer_stop on buffer_stop.obj_id = layer.obj_id and buffer_stop.infra_id = layer.infra_id
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: buffer_stop.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_bufferstopmodel buffer_stop on buffer_stop.obj_id = layer.obj_id and buffer_stop.infra_id = layer.infra_id

Expand All @@ -139,14 +152,12 @@
on_field: geographic
cache_duration: 3600
data_expr: route.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_routemodel route on route.obj_id = layer.obj_id and route.infra_id = layer.infra_id
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: route.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_routemodel route on route.obj_id = layer.obj_id and route.infra_id = layer.infra_id

Expand All @@ -158,14 +169,12 @@
on_field: geographic
cache_duration: 3600
data_expr: operational_point.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_operationalpointmodel operational_point on operational_point.obj_id = layer.obj_id and operational_point.infra_id = layer.infra_id
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: operational_point.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_operationalpointmodel operational_point on operational_point.obj_id = layer.obj_id and operational_point.infra_id = layer.infra_id

Expand All @@ -177,14 +186,12 @@
on_field: geographic
cache_duration: 3600
data_expr: catenary.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_catenarymodel catenary on catenary.obj_id = layer.obj_id and catenary.infra_id = layer.infra_id
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: catenary.data
exclude_fields: [geo, sch]
joins:
- inner join osrd_infra_catenarymodel catenary on catenary.obj_id = layer.obj_id and catenary.infra_id = layer.infra_id

Expand All @@ -196,9 +203,7 @@
on_field: geographic
cache_duration: 3600
data_expr: layer.information
exclude_fields: [geo, sch]
- name: sch
on_field: schematic
cache_duration: 3600
data_expr: layer.information
exclude_fields: [geo, sch]
2 changes: 2 additions & 0 deletions chartos/chartos/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class View:
exclude_fields: List[str] = field(compare=False)
joins: List[JoinExpr] = field(compare=False)
cache_duration: int = field(compare=False)
where: List[str] = field(compare=False)

@staticmethod
def parse(data):
Expand All @@ -37,6 +38,7 @@ def parse(data):
data.get("exclude_fields", []),
data.get("joins", []),
data["cache_duration"],
data.get("where", []),
)

def todict(self):
Expand Down
5 changes: 5 additions & 0 deletions chartos/chartos/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
from collections import defaultdict
from functools import reduce
from typing import Any, Dict, List, Mapping, NewType, Tuple

from asyncpg import Connection
Expand Down Expand Up @@ -141,6 +142,8 @@ async def mvt_query(psql, layer, infra, view: View, z: int, x: int, y: int) -> b
f"{' '.join(view.joins)} "
# filter by infra
f"WHERE layer.infra_id = $4 "
# Where view conditions
f"{reduce(lambda base, cond: f'{base} AND ({cond}) ', view.where, '')}"
# we only want objects which are inside the tile BBox
f"AND {view.on_field} && bbox.geom "
# exclude geometry collections
Expand Down Expand Up @@ -287,6 +290,8 @@ async def get_objects_in_bbox(
f"{' '.join(view.joins)} "
# Filter by infra
"WHERE layer.infra_id = $1 "
# Where view conditions
f"{reduce(lambda base, cond: f'{base} AND ({cond}) ', view.where, '')}"
# Filter by objects inside the bounding box
f"AND layer.{view.on_field} && ST_Transform(ST_MakeEnvelope($2, $3, $4, $5, 4326), 3857)"
)
Expand Down
4 changes: 3 additions & 1 deletion front/public/locales/fr/map-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"signalisation": "Signalisation",
"showOSM": "Afficher le fond de carte",
"showOSMtracksections": "Afficher les voies OSM",
"sncf_lpv": "Limites permanentes de vitesse",
"speedlimits": "Vitesses limites",
"stops": "Pancartes d'arrêt",
"switches": "Appareils de voie",
Expand All @@ -28,5 +29,6 @@
"geographic": "Géographique",
"schematic": "Schématique"
},
"tvds": "Circuits de voie"
"tvds": "Circuits de voie",
"zone": "Zone"
}
12 changes: 7 additions & 5 deletions front/src/applications/carto/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import SearchMarker from 'common/Map/Layers/SearchMarker';
import SignalingType from 'common/Map/Layers/SignalingType';
import Signals from 'common/Map/Layers/Signals';
import SpeedLimits from 'common/Map/Layers/SpeedLimits';
import SNCF_LPV from 'common/Map/Layers/extensions/SNCF/SNCF_LPV';
import Switches from 'common/Map/Layers/Switches';
import TVDs from 'common/Map/Layers/TVDs';
import TracksGeographic from 'common/Map/Layers/TracksGeographic';
import TracksOSM from 'common/Map/Layers/TracksOSM';
import TracksSchematic from 'common/Map/Layers/TracksSchematic';
Expand Down Expand Up @@ -128,27 +128,29 @@ function Map() {
{/* Have to duplicate objects with sourceLayer to avoid cache problems in mapbox */}
{mapTrackSources === 'geographic' ? (
<>
<Catenaries geomType="geo" colors={colors[mapStyle]} />
<TVDs geomType="geo" colors={colors[mapStyle]} idHover={idHover} />
<Platform colors={colors[mapStyle]} />
<TracksGeographic colors={colors[mapStyle]} />
<Catenaries geomType="geo" colors={colors[mapStyle]} />
<TracksOSM colors={colors[mapStyle]} />
<OperationalPoints geomType="geo" colors={colors[mapStyle]} />
<SignalingType geomType="geo" />
<Routes geomType="geo" colors={colors[mapStyle]} />
<SpeedLimits geomType="geo" colors={colors[mapStyle]} />
<Signals sourceTable="signals" colors={colors[mapStyle]} sourceLayer="geo" />
<SNCF_LPV geomType="geo" colors={colors[mapStyle]} />
<Signals sourceLayer="geo" sourceTable="signals" colors={colors[mapStyle]} />
<BufferStops geomType="geo" colors={colors[mapStyle]} />
<Detectors geomType="geo" colors={colors[mapStyle]} />
<Switches geomType="geo" colors={colors[mapStyle]} />
</>
) : (
<>
<TracksSchematic colors={colors[mapStyle]} idHover={idHover} />
<Catenaries geomType="sch" colors={colors[mapStyle]} />
<OperationalPoints geomType="sch" colors={colors[mapStyle]} />
<Routes geomType="sch" colors={colors[mapStyle]} />
<SpeedLimits geomType="sch" colors={colors[mapStyle]} />
<Signals sourceTable="signals" colors={colors[mapStyle]} sourceLayer="sch" />
<SNCF_LPV geomType="sch" colors={colors[mapStyle]} />
<Signals sourceLayer="sch" sourceTable="signals" colors={colors[mapStyle]} />
<BufferStops geomType="sch" colors={colors[mapStyle]} />
<Detectors geomType="sch" colors={colors[mapStyle]} />
<Switches geomType="sch" colors={colors[mapStyle]} />
Expand Down
14 changes: 3 additions & 11 deletions front/src/assets/mapstyles/OSMStyle.json
Original file line number Diff line number Diff line change
Expand Up @@ -1054,19 +1054,11 @@
"source": "openmaptiles",
"source-layer": "building",
"type": "fill-extrusion",
"minzoom": 15,
"minzoom": 0,
"paint": {
"fill-extrusion-color": "#aaa",
"fill-extrusion-height": [
"interpolate", ["linear"], ["zoom"],
15, 0,
15.05, ["get", "render_height"]
],
"fill-extrusion-base": [
"interpolate", ["linear"], ["zoom"],
15, 0,
15.05, ["get", "render_min_height"]
],
"fill-extrusion-height": ["get", "render_height"],
"fill-extrusion-base": ["get", "render_min_height"],
"fill-extrusion-opacity": 0.6
}
},
Expand Down
2 changes: 1 addition & 1 deletion front/src/common/BootstrapSNCF/SwitchSNCF/SwitchSNCF.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default class SwitchSNCF extends Component {
id={optionId}
name={name}
className="custom-control-input"
checked={option.value === checkedName}
checked={checked}
onChange={onChange}
value={option.value}
/>
Expand Down
26 changes: 25 additions & 1 deletion front/src/common/Map/Consts/colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ const colors: Record<string, Theme> = {
text: '#555555',
halo: '#eee',
},
lpv: {
pointtext: '#5b5b5b',
pointhalo: '#ffffff',
detailtext: '#555555',
detailhalo: '#ffffff',
text: '#4d4f53',
halo: '#ffffff',
},
mapmarker: {
text: '#0088ce',
circle: '#0088ce',
Expand Down Expand Up @@ -98,7 +106,7 @@ const colors: Record<string, Theme> = {
pointhalo: '#5b5b5b',
detailtext: '#555555',
detailhalo: '#ffffff',
text: '#555555',
text: '#4d4f53',
halo: '#ffffff',
},
station: {
Expand Down Expand Up @@ -164,6 +172,14 @@ const colors: Record<string, Theme> = {
text: '#4895ef',
halo: '#0b011d',
},
lpv: {
pointtext: '#eeeeee',
pointhalo: '#3a86ff',
detailtext: '#3a86ff',
detailhalo: '#0b011d',
text: '#3a86ff',
halo: '#000000',
},
mapmarker: {
text: '#ffaa39',
circle: '#ffaa39',
Expand Down Expand Up @@ -292,6 +308,14 @@ const colors: Record<string, Theme> = {
text: bpLight,
halo: bpBg,
},
lpv: {
pointtext: bpLight,
pointhalo: bpBg,
detailtext: bpLight,
detailhalo: bpBg,
text: bpLight,
halo: bpBg,
},
mapmarker: {
text: bpMedium,
circle: bpLight,
Expand Down
6 changes: 3 additions & 3 deletions front/src/common/Map/Layers/OperationalPoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function OperationalPoints(props) {
const layerName = {
type: 'symbol',
'source-layer': 'operational_points',
minzoom: 9,
minzoom: 9.5,
layout: {
'text-field': [
'concat',
Expand Down Expand Up @@ -57,12 +57,12 @@ export default function OperationalPoints(props) {
const layerNameShort = {
type: 'symbol',
'source-layer': 'operational_points',
maxzoom: 9,
maxzoom: 9.5,
minzoom: 7,
layout: {
'text-field': [
'concat',
['get', 'trigram'],
['get', 'extensions_sncf_trigram'],
' ',
[
'case',
Expand Down
Loading