fix: Fix name on map
and fix city name in sight list
This commit is contained in:
@ -146,7 +146,7 @@ class MapStore {
|
||||
|
||||
if (featureType === "station") {
|
||||
data = {
|
||||
name: properties.name || "Новая остановка",
|
||||
name: properties.name || "Остановка 1",
|
||||
latitude: geometry.coordinates[1],
|
||||
longitude: geometry.coordinates[0],
|
||||
};
|
||||
@ -159,7 +159,7 @@ class MapStore {
|
||||
};
|
||||
} else if (featureType === "sight") {
|
||||
data = {
|
||||
name: properties.name || "Новая достопримечательность",
|
||||
name: properties.name || "Достопримечательность 1",
|
||||
description: properties.description || "",
|
||||
latitude: geometry.coordinates[1],
|
||||
longitude: geometry.coordinates[0],
|
||||
@ -1263,14 +1263,42 @@ class MapService {
|
||||
|
||||
feature.set("featureType", fType);
|
||||
|
||||
// --- ИЗМЕНЕНИЕ: Именование с порядковым номером для маршрутов ---
|
||||
// --- ИЗМЕНЕНИЕ: Именование с порядковым номером для всех типов объектов ---
|
||||
let resourceName: string;
|
||||
switch (fType) {
|
||||
case "station":
|
||||
resourceName = "Новая остановка";
|
||||
// Находим следующий доступный номер остановки
|
||||
const existingStations = this.vectorSource
|
||||
.getFeatures()
|
||||
.filter((f) => f.get("featureType") === "station");
|
||||
const stationNumbers = existingStations
|
||||
.map((f) => {
|
||||
const name = f.get("name") as string;
|
||||
const match = name.match(/^Остановка (\d+)$/);
|
||||
return match ? parseInt(match[1], 10) : 0;
|
||||
})
|
||||
.filter((num) => num > 0);
|
||||
|
||||
const nextStationNumber =
|
||||
stationNumbers.length > 0 ? Math.max(...stationNumbers) + 1 : 1;
|
||||
resourceName = `Остановка ${nextStationNumber}`;
|
||||
break;
|
||||
case "sight":
|
||||
resourceName = "Новая достопримечательность";
|
||||
// Находим следующий доступный номер достопримечательности
|
||||
const existingSights = this.vectorSource
|
||||
.getFeatures()
|
||||
.filter((f) => f.get("featureType") === "sight");
|
||||
const sightNumbers = existingSights
|
||||
.map((f) => {
|
||||
const name = f.get("name") as string;
|
||||
const match = name.match(/^Достопримечательность (\d+)$/);
|
||||
return match ? parseInt(match[1], 10) : 0;
|
||||
})
|
||||
.filter((num) => num > 0);
|
||||
|
||||
const nextSightNumber =
|
||||
sightNumbers.length > 0 ? Math.max(...sightNumbers) + 1 : 1;
|
||||
resourceName = `Достопримечательность ${nextSightNumber}`;
|
||||
break;
|
||||
case "route":
|
||||
// Находим следующий доступный номер маршрута
|
||||
@ -1285,9 +1313,9 @@ class MapService {
|
||||
})
|
||||
.filter((num) => num > 0);
|
||||
|
||||
const nextNumber =
|
||||
const nextRouteNumber =
|
||||
routeNumbers.length > 0 ? Math.max(...routeNumbers) + 1 : 1;
|
||||
resourceName = `Маршрут ${nextNumber}`;
|
||||
resourceName = `Маршрут ${nextRouteNumber}`;
|
||||
break;
|
||||
default:
|
||||
resourceName = "Объект";
|
||||
@ -1920,7 +1948,7 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
|
||||
if (aIsChecked && !bIsChecked) return -1;
|
||||
if (!aIsChecked && bIsChecked) return 1;
|
||||
|
||||
// 3. Сортировка по ID (новые объекты с большими ID в начале)
|
||||
// 3. Сортировка по ID (объекты остаются в порядке создания)
|
||||
const aNumericId = aId ? parseInt(String(aId).split("-")[1], 10) : 0;
|
||||
const bNumericId = bId ? parseInt(String(bId).split("-")[1], 10) : 0;
|
||||
if (
|
||||
@ -1928,7 +1956,7 @@ const MapSightbar: React.FC<MapSightbarProps> = ({
|
||||
!isNaN(bNumericId) &&
|
||||
aNumericId !== bNumericId
|
||||
) {
|
||||
return bNumericId - aNumericId; // По убыванию - новые сверху
|
||||
return aNumericId - bNumericId; // По возрастанию - старые сверху, новые снизу
|
||||
}
|
||||
|
||||
// 4. Запасная сортировка по имени
|
||||
|
Reference in New Issue
Block a user