style: run prettier
This commit is contained in:
@ -11,8 +11,8 @@ function getFeatureDistance(f: GeoJSON.Feature, point: [number, number]) {
|
||||
// Compute the min distance across all parts
|
||||
return Math.min(
|
||||
...f.geometry.coordinates.map((coords) =>
|
||||
pointToLineDistance(point, lineString(coords))
|
||||
)
|
||||
pointToLineDistance(point, lineString(coords)),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return Infinity;
|
||||
@ -30,8 +30,11 @@ export async function getMeta(coord: WorldLocation, layer: string) {
|
||||
const feature = layerData.feature(i);
|
||||
features.push(feature.toGeoJSON(zxy.x, zxy.y, zxy.z));
|
||||
}
|
||||
const filtered = features.filter((f) => f.geometry.type === "LineString" || f.geometry.type == "MultiLineString");
|
||||
if(filtered.length === 0) return null;
|
||||
const filtered = features.filter(
|
||||
(f) =>
|
||||
f.geometry.type === "LineString" || f.geometry.type == "MultiLineString",
|
||||
);
|
||||
if (filtered.length === 0) return null;
|
||||
const nearest = filtered.reduce((a, b) => {
|
||||
const distA = getFeatureDistance(a, [coord.lon, coord.lat]);
|
||||
const distB = getFeatureDistance(b, [coord.lon, coord.lat]);
|
||||
@ -44,16 +47,16 @@ const IMPLICIT_SPEEDS: Record<string, number> = {
|
||||
"DE:urban": 50,
|
||||
"DE:rural": 100, // TODO: 80 (hgv weight > 3.5t, or trailer), 60 (weight > 7.5t)
|
||||
"DE:living_street": 7,
|
||||
"DE:bicycle_road": 30
|
||||
}
|
||||
"DE:bicycle_road": 30,
|
||||
};
|
||||
|
||||
export function getSpeed(maxspeed: string): number | null {
|
||||
if(!isNaN(parseInt(maxspeed))) return parseInt(maxspeed);
|
||||
if(maxspeed.endsWith(" mph")) {
|
||||
if (!isNaN(parseInt(maxspeed))) return parseInt(maxspeed);
|
||||
if (maxspeed.endsWith(" mph")) {
|
||||
const val = parseInt(maxspeed.replace(" mph", ""));
|
||||
if(!isNaN(val)) return Math.round(val * 1.60934); // Convert to km/h
|
||||
if (!isNaN(val)) return Math.round(val * 1.60934); // Convert to km/h
|
||||
}
|
||||
if(maxspeed === "walk") return 7; // https://wiki.openstreetmap.org/wiki/Proposed_features/maxspeed_walk
|
||||
if (maxspeed === "walk") return 7; // https://wiki.openstreetmap.org/wiki/Proposed_features/maxspeed_walk
|
||||
return IMPLICIT_SPEEDS[maxspeed as keyof typeof IMPLICIT_SPEEDS] || null;
|
||||
}
|
||||
|
||||
@ -64,11 +67,11 @@ function coordToTile(coord: WorldLocation, zoom: number) {
|
||||
((1 -
|
||||
Math.log(
|
||||
Math.tan((coord.lat * Math.PI) / 180) +
|
||||
1 / Math.cos((coord.lat * Math.PI) / 180)
|
||||
1 / Math.cos((coord.lat * Math.PI) / 180),
|
||||
) /
|
||||
Math.PI) /
|
||||
2) *
|
||||
Math.pow(2, z)
|
||||
Math.pow(2, z),
|
||||
);
|
||||
return { z, x, y };
|
||||
}
|
||||
@ -117,7 +120,7 @@ export async function fetchTile(z: number, x: number, y: number) {
|
||||
const pmtiles = (await hasPMTiles("tiles"))
|
||||
? new PMTiles(new FSSource("tiles"))
|
||||
: new PMTiles("https://trafficcue-tiles.picoscratch.de/germany.pmtiles");
|
||||
const tile = (await pmtiles.getZxy(z, x, y));
|
||||
const tile = await pmtiles.getZxy(z, x, y);
|
||||
if (!tile) {
|
||||
console.log(tile);
|
||||
throw new Error(`Tile not found: z${z} x${x} y${y}`);
|
||||
|
||||
Reference in New Issue
Block a user