🌍 Geo Helper

Utility functies voor geografische coördinaten, validatie en afstandsberekeningen.

← Terug naar Core Library

📖 Introductie

De Geo Helper bevat utility functies voor het werken met geografische data zoals coördinaten, afstandsbepaling en locatievalidatie.

👉 Deze helper wordt gebruikt voor locatie-gebaseerde logica binnen formulieren en integraties.

📦 Functionaliteit

🌍 Country Lookup

setCountryLookup(formContext, fieldName, countryCode)
Zet een land lookup veld op basis van een ISO2 country code (bijv. NL, BE, DE)

Werking

  • Normaliseert country code naar uppercase
  • Zoekt metadata via interne mapping
  • Zet lookup waarde op veld
⚠️ Werkt alleen volledig als Dataverse country records aanwezig zijn (met echte GUID).

Voorbeeld

core.Geo.setCountryLookup(formContext, "address1_country", "NL");

✅ Validatie

  • isValidCoordinate(lat, lon) → controleert geldige ranges

📏 Berekeningen

  • calculateDistance(lat1, lon1, lat2, lon2) → afstand (km)
  • isWithinRadius(lat1, lon1, lat2, lon2, radiusKm) → binnen straal

🧾 Formatting

  • formatCoordinate(lat, lon) → leesbare string output

⚙️ Werking

De Geo helper is een pure client-side utility zonder externe dependencies.

👉 De helper:
  • valideert numerieke input
  • gebruikt Haversine-formule voor afstand
  • werkt volledig client-side

Validatie

  • Latitude: -90 tot 90
  • Longitude: -180 tot 180

Berekening

  • Aardstraal: 6371 km
  • Resultaat in kilometers

⚠️ Belangrijke aandachtspunten

  • Alle functies zijn synchronous
  • Input mag string zijn (wordt parsed)
  • Geen API of Dataverse calls
  • Altijd via core.Geo.*

💡 Voorbeelden

Validatie

const valid = core.Geo.isValidCoordinate(52.3702, 4.8952);
// true

Afstand

const distance = core.Geo.calculateDistance(
  52.3702, 4.8952,
  51.9244, 4.4777
);

Binnen straal

const inside = core.Geo.isWithinRadius(
  52.3702, 4.8952,
  52.1, 5.1,
  25
);

Formatting

const formatted = core.Geo.formatCoordinate(52.3702, 4.8952);
// "52.370200, 4.895200"

📊 Samenvatting

✅ Validatie van coördinaten
✅ Afstandsbepaling
✅ Location-based logica
✅ Volledig client-side