wip: POC arrival times
This commit is contained in:
@@ -13,6 +13,19 @@
|
|||||||
:layout="cluster_label"
|
:layout="cluster_label"
|
||||||
/>
|
/>
|
||||||
</mgl-geo-json-source>
|
</mgl-geo-json-source>
|
||||||
|
|
||||||
|
<div ref="popup">
|
||||||
|
<div v-for="data in popupData" :key="data.pattern.id">
|
||||||
|
Direction {{ data.pattern.lastStopName }}
|
||||||
|
<div v-for="time in data.times" :key="time.tripId">
|
||||||
|
{{
|
||||||
|
time.realtimeArrival -
|
||||||
|
(Math.floor(new Date().getTime() / 1000) -
|
||||||
|
time.serviceDay)
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</ClientOnly>
|
</ClientOnly>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -28,14 +41,16 @@ const cluster_label = {
|
|||||||
"text-field": ["get", "id"],
|
"text-field": ["get", "id"],
|
||||||
};
|
};
|
||||||
const map = useMap("main");
|
const map = useMap("main");
|
||||||
|
const popup = useTemplateRef("popup");
|
||||||
|
|
||||||
const { clusters } = defineProps<{
|
const { clusters } = defineProps<{
|
||||||
clusters: FeatureCollection<Point>;
|
clusters: FeatureCollection<Point>;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
console.log(clusters);
|
const popupData = ref<StopTimesPattern[]>([]);
|
||||||
|
|
||||||
async function clusterClick(e: FeatureCollection) {
|
async function clusterClick(e: FeatureCollection) {
|
||||||
|
popupData.value = [];
|
||||||
const feature = e.features[0];
|
const feature = e.features[0];
|
||||||
if (!feature || !feature.properties) {
|
if (!feature || !feature.properties) {
|
||||||
return;
|
return;
|
||||||
@@ -53,7 +68,19 @@ async function clusterClick(e: FeatureCollection) {
|
|||||||
.setHTML(
|
.setHTML(
|
||||||
`Cluster code : ${feature.properties.code}<br/>This cluster contains ${data.features.length} stops`,
|
`Cluster code : ${feature.properties.code}<br/>This cluster contains ${data.features.length} stops`,
|
||||||
)
|
)
|
||||||
|
.setDOMContent(popup.value)
|
||||||
|
.setMaxWidth("500px")
|
||||||
.addTo(map.map!);
|
.addTo(map.map!);
|
||||||
|
|
||||||
|
popupData.value = await $fetch<StopTimesPattern[]>(
|
||||||
|
`https://data.mobilites-m.fr/api/routers/default/index/clusters/${feature.properties.code}/stoptimes?showCancelledTrips=false`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
origin: "PersonalProjectMreso",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
console.log(popupData.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function clusterEnter() {
|
function clusterEnter() {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const center = new LngLat(5.735, 45.185);
|
|||||||
const zoom = 12;
|
const zoom = 12;
|
||||||
|
|
||||||
const store = useMresoStore();
|
const store = useMresoStore();
|
||||||
store.fetchData();
|
await store.fetchData();
|
||||||
const shownClusters = ref<FeatureCollection<Point> | null>(null);
|
const shownClusters = ref<FeatureCollection<Point> | null>(null);
|
||||||
|
|
||||||
const { selectedRoutesId } = defineProps<{
|
const { selectedRoutesId } = defineProps<{
|
||||||
|
|||||||
+2
-2
@@ -27,7 +27,7 @@ export const useMresoStore = defineStore("mresoStore", {
|
|||||||
return Object.fromEntries(state.routes.map((r) => [r.id, r]));
|
return Object.fromEntries(state.routes.map((r) => [r.id, r]));
|
||||||
},
|
},
|
||||||
linesById(state): { [id: string]: Feature<MultiLineString> } {
|
linesById(state): { [id: string]: Feature<MultiLineString> } {
|
||||||
if (!state.lines) {
|
if (!("features" in state.lines)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return Object.fromEntries(
|
return Object.fromEntries(
|
||||||
@@ -35,7 +35,7 @@ export const useMresoStore = defineStore("mresoStore", {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
clustersById(state): { [id: string]: Feature<Point> } {
|
clustersById(state): { [id: string]: Feature<Point> } {
|
||||||
if (!state.clusters) {
|
if (!("features" in state.clusters)) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
return Object.fromEntries(
|
return Object.fromEntries(
|
||||||
|
|||||||
Vendored
+31
@@ -21,3 +21,34 @@ interface Cluster {
|
|||||||
name: string;
|
name: string;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface StopTimesPattern {
|
||||||
|
pattern: {
|
||||||
|
id: string;
|
||||||
|
desc: string;
|
||||||
|
dir: number;
|
||||||
|
shortDesc: string;
|
||||||
|
lastStop: string;
|
||||||
|
lastStopName: string;
|
||||||
|
};
|
||||||
|
times: StopTimes[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StopTimes {
|
||||||
|
stopId: string;
|
||||||
|
stopName: string;
|
||||||
|
scheduledArrival: number;
|
||||||
|
scheduledDeparture: number;
|
||||||
|
realtimeArrival: number;
|
||||||
|
realtimeDeparture: number;
|
||||||
|
arrivalDelay: number;
|
||||||
|
departureDelay: number;
|
||||||
|
timepoint: boolean;
|
||||||
|
realtime: boolean;
|
||||||
|
realtimeState: string;
|
||||||
|
serviceDay: number;
|
||||||
|
tripId: string;
|
||||||
|
pickupType: string;
|
||||||
|
occupancy: string;
|
||||||
|
occupancyId: number;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user