Make ws4kp being exposed optional
This commit is contained in:
@@ -31,8 +31,11 @@ function getCachedGeocode(cityQuery) {
|
||||
if (fs.existsSync(cacheFile)) {
|
||||
const data = fs.readFileSync(cacheFile, 'utf8');
|
||||
const cached = JSON.parse(data);
|
||||
console.log(`Using cached geocode for: ${cityQuery}`);
|
||||
return cached;
|
||||
// Verify the query matches
|
||||
if (cached.query && cached.query.toLowerCase().trim() === cityQuery.toLowerCase().trim()) {
|
||||
console.log(`Using cached geocode for: ${cityQuery}`);
|
||||
return cached;
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Cache read error for ${cityQuery}:`, error.message);
|
||||
@@ -88,6 +91,7 @@ async function geocodeCity(cityQuery) {
|
||||
const results = JSON.parse(data);
|
||||
if (results && results.length > 0) {
|
||||
const geocodeResult = {
|
||||
query: cityQuery,
|
||||
lat: parseFloat(results[0].lat),
|
||||
lon: parseFloat(results[0].lon),
|
||||
displayName: results[0].display_name
|
||||
|
||||
Reference in New Issue
Block a user