Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbeae37e39 |
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "worldwideview",
|
||||
"version": "2.18.6",
|
||||
"version": "2.18.7",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"packageManager": "[email protected]",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { transliterate } from "@/lib/utils/transliterate";
|
||||
|
||||
// Server-side cache: keyed by place_id, 24-hour TTL (place geometry is stable)
|
||||
const cache = new Map<string, { data: unknown; expiresAt: number }>();
|
||||
@@ -50,7 +51,7 @@ export async function GET(request: Request) {
|
||||
const result = {
|
||||
lat: location.lat,
|
||||
lon: location.lng,
|
||||
name: data.result.name,
|
||||
name: transliterate(data.result.name ?? ""),
|
||||
types: data.result.types || [],
|
||||
viewport: data.result.geometry?.viewport || null,
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { transliterate } from "@/lib/utils/transliterate";
|
||||
|
||||
// Server-side cache: keyed by normalised input, 1-hour TTL
|
||||
const cache = new Map<string, { data: unknown; expiresAt: number }>();
|
||||
@@ -44,10 +45,10 @@ export async function GET(request: Request) {
|
||||
}
|
||||
|
||||
const predictions = data.predictions.map((p: any) => ({
|
||||
description: p.description,
|
||||
description: transliterate(p.description ?? ""),
|
||||
placeId: p.place_id,
|
||||
mainText: p.structured_formatting?.main_text || p.description,
|
||||
secondaryText: p.structured_formatting?.secondary_text || "",
|
||||
mainText: transliterate(p.structured_formatting?.main_text || p.description),
|
||||
secondaryText: transliterate(p.structured_formatting?.secondary_text || ""),
|
||||
types: p.types,
|
||||
}));
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// Characters that don't decompose to a base ASCII letter via NFD normalization.
|
||||
const SUPPLEMENTAL_MAP: Record<string, string> = {
|
||||
"Đ": "D", "đ": "d", // Đ đ
|
||||
"Ø": "O", "ø": "o", // Ø ø
|
||||
"Ł": "L", "ł": "l", // Ł ł
|
||||
"Ð": "D", "ð": "d", // Ð ð
|
||||
"Þ": "Th", "þ": "th", // Þ þ
|
||||
"ß": "ss", // ß
|
||||
"Æ": "AE", "æ": "ae", // Æ æ
|
||||
"Œ": "OE", "œ": "oe", // Œ œ
|
||||
};
|
||||
|
||||
/**
|
||||
* Replaces diacritical characters with their closest ASCII equivalents so that
|
||||
* place and airport names remain readable even in environments where the font
|
||||
* or encoding does not support the original glyphs (e.g. Š→S, Č→C, Ž→Z).
|
||||
*/
|
||||
export function transliterate(text: string): string {
|
||||
return (
|
||||
text
|
||||
// Decompose characters like Š into base letter + combining mark (e.g. S + caron)
|
||||
.normalize("NFD")
|
||||
// Strip all Unicode combining diacritical marks (U+0300–U+036F)
|
||||
.replace(/[̀-ͯ]/g, "")
|
||||
// Replace any remaining non-ASCII characters using the supplemental map
|
||||
.replace(/[^\x00-\x7F]/g, (ch) => SUPPLEMENTAL_MAP[ch] ?? ch)
|
||||
);
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
import type { GeoEntity } from "@/core/plugins/PluginTypes";
|
||||
import type { GeoJsonFeature, GeoJsonGeometry } from "@/types/geojson";
|
||||
import { transliterate } from "@/lib/utils/transliterate";
|
||||
|
||||
/** Extract a representative [lat, lon, alt?] from any geometry. */
|
||||
function representativePoint(
|
||||
@@ -50,7 +51,7 @@ export function featuresToEntities(
|
||||
longitude: point.lon,
|
||||
altitude: point.alt,
|
||||
timestamp: new Date(),
|
||||
label: (feature.properties.name as string) ?? undefined,
|
||||
label: feature.properties.name ? transliterate(feature.properties.name as string) : undefined,
|
||||
properties: {
|
||||
...feature.properties,
|
||||
_layerId: layerId,
|
||||
|
||||
Reference in new issue
Block a user