One-way hiking route members (forward/backward roles) kept in their direction by maplibre-gl-lanes; raise Valhalla trace limits for the per-country route summary
This commit is contained in:
1 parent
43119cfdae
commit
db586c0166
4 files changed
+47
-7
No files matched your search
@@ -229,7 +229,7 @@ export class HikingTrailsControl {
|
||||
const features = [...this._selectedCountries].flatMap((code) => this._trailData.get(code)?.features || []);
|
||||
let graph = null;
|
||||
if (features.length > 0) {
|
||||
graph = buildLineGraph(features, { routeProperty: "id" });
|
||||
graph = buildLineGraph(features.flatMap(splitOneway), { routeProperty: "id", onewayProperty: "oneway" });
|
||||
await orderLanesAsync(graph);
|
||||
}
|
||||
if (this._lanesBuild !== build) return;
|
||||
@@ -448,3 +448,17 @@ function routeHtml(info) {
|
||||
);
|
||||
return parts.join("");
|
||||
}
|
||||
|
||||
// A route's one-way lines (oneway_lines, already pointing the way they're
|
||||
// walked: lib/maptool/hiking_trails.rb) as a feature of their own marked
|
||||
// oneway, so maplibre-gl-lanes keeps the route on them in that direction.
|
||||
function splitOneway(feature) {
|
||||
const oneway = new Set(feature.properties.oneway_lines);
|
||||
if (oneway.size === 0) return [feature];
|
||||
const lines = feature.geometry.coordinates;
|
||||
const part = (coordinates, properties) => ({ ...feature, properties, geometry: { type: "MultiLineString", coordinates } });
|
||||
return [
|
||||
part(lines.filter((_, i) => !oneway.has(i)), feature.properties),
|
||||
part(lines.filter((_, i) => oneway.has(i)), { ...feature.properties, oneway: "yes" }),
|
||||
].filter((f) => f.geometry.coordinates.length > 0);
|
||||
}
|
||||
Reference in new issue
Block a user