refactor: optimize AramaFunnelKarti styles and enhance city data structure
All checks were successful
Deploy / deploy (push) Successful in 7m30s
All checks were successful
Deploy / deploy (push) Successful in 7m30s
Removed unnecessary elements and optimized styles in the AramaFunnelKarti component for improved layout. Updated the city data structure in harita-ulkeler.ts to include coordinates, enhancing geographical data handling. Additionally, refactored risk color definitions in risk.ts for better clarity and maintainability.
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
||||
type UlkeKodu,
|
||||
type UlkeHarita,
|
||||
} from "./harita-ulkeler-verisi";
|
||||
import type { LatLng } from "./uni-koordinatlar";
|
||||
|
||||
export {
|
||||
ULKE_HARITALARI,
|
||||
@@ -25,23 +26,41 @@ export const ULKE_ISO: Record<UlkeKodu, string> = {
|
||||
arnavutluk: "AL",
|
||||
};
|
||||
|
||||
type Sehir = { ulke: UlkeKodu; ad: string };
|
||||
type Sehir = { ulke: UlkeKodu; ad: string; koord: LatLng };
|
||||
|
||||
/** DB'deki il değerlerinden ve düzeltme tablosundan şehir anahtarları. */
|
||||
const SEHIRLER: Record<string, Sehir> = {
|
||||
GİRNE: { ulke: "kktc", ad: "Girne" },
|
||||
LEFKOŞA: { ulke: "kktc", ad: "Lefkoşa" },
|
||||
GAZİMAĞUSA: { ulke: "kktc", ad: "Gazimağusa" },
|
||||
GÜZELYURT: { ulke: "kktc", ad: "Güzelyurt" },
|
||||
LEFKE: { ulke: "kktc", ad: "Lefke" },
|
||||
"BAKÜ-AZERBAYCAN": { ulke: "azerbaycan", ad: "Bakü" },
|
||||
"BİŞKEK-KIRGIZİSTAN": { ulke: "kirgizistan", ad: "Bişkek" },
|
||||
"TÜRKİSTAN-KAZAKİSTAN": { ulke: "kazakistan", ad: "Türkistan" },
|
||||
"SARAYBOSNA - BOSNA - HERSEK": { ulke: "bosna-hersek", ad: "Saraybosna" },
|
||||
ÜSKÜP: { ulke: "makedonya", ad: "Üsküp" },
|
||||
TİRAN: { ulke: "arnavutluk", ad: "Tiran" },
|
||||
GİRNE: { ulke: "kktc", ad: "Girne", koord: [35.341, 33.319] },
|
||||
LEFKOŞA: { ulke: "kktc", ad: "Lefkoşa", koord: [35.19, 33.365] },
|
||||
GAZİMAĞUSA: { ulke: "kktc", ad: "Gazimağusa", koord: [35.125, 33.941] },
|
||||
GÜZELYURT: { ulke: "kktc", ad: "Güzelyurt", koord: [35.198, 32.994] },
|
||||
LEFKE: { ulke: "kktc", ad: "Lefke", koord: [35.111, 32.849] },
|
||||
"BAKÜ-AZERBAYCAN": {
|
||||
ulke: "azerbaycan",
|
||||
ad: "Bakü",
|
||||
koord: [40.409, 49.867],
|
||||
},
|
||||
"BİŞKEK-KIRGIZİSTAN": {
|
||||
ulke: "kirgizistan",
|
||||
ad: "Bişkek",
|
||||
koord: [42.875, 74.603],
|
||||
},
|
||||
"TÜRKİSTAN-KAZAKİSTAN": {
|
||||
ulke: "kazakistan",
|
||||
ad: "Türkistan",
|
||||
koord: [43.297, 68.252],
|
||||
},
|
||||
"SARAYBOSNA - BOSNA - HERSEK": {
|
||||
ulke: "bosna-hersek",
|
||||
ad: "Saraybosna",
|
||||
koord: [43.856, 18.413],
|
||||
},
|
||||
ÜSKÜP: { ulke: "makedonya", ad: "Üsküp", koord: [41.997, 21.428] },
|
||||
TİRAN: { ulke: "arnavutluk", ad: "Tiran", koord: [41.328, 19.818] },
|
||||
};
|
||||
|
||||
type SehirAnahtari = keyof typeof SEHIRLER;
|
||||
|
||||
/**
|
||||
* Kaynak verideki gürültü için üniversite adına göre düzeltme:
|
||||
* - Uluslararası Balkan Üniversitesi Üsküp'tedir; YÖK Atlas satırlarının
|
||||
@@ -51,7 +70,7 @@ const SEHIRLER: Record<string, Sehir> = {
|
||||
* null → Türkiye haritasında kalır.
|
||||
* Anahtar: uniAdiNormalize edilmiş adın tr-TR büyük harf hali.
|
||||
*/
|
||||
const UNI_DUZELTME: Record<string, keyof typeof SEHIRLER | null> = {
|
||||
const UNI_DUZELTME: Record<string, SehirAnahtari | null> = {
|
||||
"ULUSLARARASI BALKAN ÜNİVERSİTESİ": "ÜSKÜP",
|
||||
"TİRAN NEW YORK ÜNİVERSİTESİ": "TİRAN",
|
||||
"KIBRIS AYDIN ÜNİVERSİTESİ": "GİRNE", // il alanı yalnızca "KIBRIS"
|
||||
@@ -62,6 +81,24 @@ const UNI_DUZELTME: Record<string, keyof typeof SEHIRLER | null> = {
|
||||
/** il değeri Türkiye dışını mı gösteriyor? ("KIBRIS" genel değeri dahil) */
|
||||
const YURTDISI_IL = new Set([...Object.keys(SEHIRLER), "KIBRIS"]);
|
||||
|
||||
/** Üniversite adı + il'den şehir anahtarı; şehri bilinmeyen KKTC'de ülke. */
|
||||
type Cozum = { anahtar: SehirAnahtari } | { ulke: UlkeKodu } | null;
|
||||
|
||||
function coz(universite: string, il: string | null): Cozum {
|
||||
const ad = universite
|
||||
.replace(/\s*\([^)]*\)\s*$/, "")
|
||||
.trim()
|
||||
.toLocaleUpperCase("tr-TR");
|
||||
|
||||
if (ad in UNI_DUZELTME) {
|
||||
const anahtar = UNI_DUZELTME[ad];
|
||||
return anahtar === null ? null : { anahtar };
|
||||
}
|
||||
if (!il || !YURTDISI_IL.has(il)) return null;
|
||||
if (il in SEHIRLER) return { anahtar: il as SehirAnahtari };
|
||||
return { ulke: "kktc" }; // il "KIBRIS": ülke bilinir, şehir bilinmez
|
||||
}
|
||||
|
||||
export type UlkeKonum = {
|
||||
ulke: UlkeKodu;
|
||||
ulkeAd: string;
|
||||
@@ -71,45 +108,59 @@ export type UlkeKonum = {
|
||||
sehir: string | null;
|
||||
};
|
||||
|
||||
function sehirdenKonum(anahtar: keyof typeof SEHIRLER): UlkeKonum {
|
||||
const sehir = SEHIRLER[anahtar];
|
||||
const harita = ULKE_HARITALARI[sehir.ulke];
|
||||
return {
|
||||
ulke: sehir.ulke,
|
||||
ulkeAd: harita.ad,
|
||||
iso: ULKE_ISO[sehir.ulke],
|
||||
harita,
|
||||
sehir: sehir.ad,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Üniversite Türkiye dışındaysa ülke haritası + şehir konumu döner;
|
||||
* Üniversite Türkiye dışındaysa ülke haritası + şehir adı döner;
|
||||
* Türkiye'deyse (veya çözülemiyorsa) null — Türkiye haritası kullanılır.
|
||||
*/
|
||||
export function uniUlkeKonum(
|
||||
universite: string,
|
||||
il: string | null,
|
||||
): UlkeKonum | null {
|
||||
const ad = universite
|
||||
.replace(/\s*\([^)]*\)\s*$/, "")
|
||||
.trim()
|
||||
.toLocaleUpperCase("tr-TR");
|
||||
|
||||
if (ad in UNI_DUZELTME) {
|
||||
const anahtar = UNI_DUZELTME[ad];
|
||||
return anahtar === null ? null : sehirdenKonum(anahtar);
|
||||
}
|
||||
if (!il || !YURTDISI_IL.has(il)) return null;
|
||||
if (il in SEHIRLER) return sehirdenKonum(il as keyof typeof SEHIRLER);
|
||||
|
||||
// il "KIBRIS": ülke bilinir, şehir bilinmez — haritayı işaretsiz göster
|
||||
const harita = ULKE_HARITALARI.kktc;
|
||||
const cozum = coz(universite, il);
|
||||
if (!cozum) return null;
|
||||
const ulke = "anahtar" in cozum ? SEHIRLER[cozum.anahtar].ulke : cozum.ulke;
|
||||
const harita = ULKE_HARITALARI[ulke];
|
||||
return {
|
||||
ulke: "kktc",
|
||||
ulke,
|
||||
ulkeAd: harita.ad,
|
||||
iso: ULKE_ISO.kktc,
|
||||
iso: ULKE_ISO[ulke],
|
||||
harita,
|
||||
sehir: null,
|
||||
sehir: "anahtar" in cozum ? SEHIRLER[cozum.anahtar].ad : null,
|
||||
};
|
||||
}
|
||||
|
||||
/** Yurtdışı şehir merkezinin kendi ülke haritasındaki viewBox konumu. */
|
||||
export type YurtdisiKonum = {
|
||||
ulke: UlkeKodu;
|
||||
ulkeAd: string;
|
||||
sehir: string;
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
|
||||
function sehirKonumu(anahtar: SehirAnahtari): YurtdisiKonum {
|
||||
const sehir = SEHIRLER[anahtar];
|
||||
const { ad, proje } = ULKE_HARITALARI[sehir.ulke];
|
||||
const [lat, lng] = sehir.koord;
|
||||
return {
|
||||
ulke: sehir.ulke,
|
||||
ulkeAd: ad,
|
||||
sehir: sehir.ad,
|
||||
x: proje.ax * lng + proje.bx,
|
||||
y: proje.ay * lat + proje.by,
|
||||
};
|
||||
}
|
||||
|
||||
/** Yurtdışı üniversitenin şehir konumu; şehir çözülemiyorsa null. */
|
||||
export function yurtdisiUniKonum(
|
||||
universite: string,
|
||||
il: string | null,
|
||||
): YurtdisiKonum | null {
|
||||
const cozum = coz(universite, il);
|
||||
return cozum && "anahtar" in cozum ? sehirKonumu(cozum.anahtar) : null;
|
||||
}
|
||||
|
||||
/** Yalnızca il değerinden (kilitli satırlar) yurtdışı şehir konumu. */
|
||||
export function yurtdisiIlKonum(il: string | null): YurtdisiKonum | null {
|
||||
return il && il in SEHIRLER ? sehirKonumu(il as SehirAnahtari) : null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user