lustre_kakaomap/coords
Coordinate types for KakaoMap.
Provides WGS84 coordinates (LatLng), rectangular bounds (LatLngBounds), pixel coordinates (Point), and size values (Size). All types are opaque with constructor functions and accessors. Includes preset coordinates for major Korean cities.
// Create coordinates and compute distance
let pos = coords.lat_lng(lat: 37.5665, lng: 126.978)
let d = coords.distance(from: coords.seoul(), to: coords.busan())
// Bounds utilities
let bounds = coords.bounds_from_list([coords.seoul(), coords.busan(), coords.jeju()])
let center = coords.bounds_center(bounds)
// Navigation helpers
let bearing = coords.bearing(from: coords.seoul(), to: coords.busan())
let dest = coords.destination(from: coords.seoul(), bearing_deg: 90.0, distance_m: 1000.0)
Types
A rectangular bounds defined by southwest and northeast corners.
pub opaque type LatLngBounds
Values
pub fn bearing(from from: LatLng, to to: LatLng) -> Float
Returns the initial bearing (degrees, 0-360) from one position to another.
let deg = coords.bearing(from: coords.seoul(), to: coords.busan())
// approximately 165 degrees (south-southeast)
pub fn bounds_center(bounds: LatLngBounds) -> LatLng
Returns the center point of bounds.
let bounds = coords.lat_lng_bounds(sw: coords.seoul(), ne: coords.busan())
let center = coords.bounds_center(bounds)
pub fn bounds_equals(a: LatLngBounds, b: LatLngBounds) -> Bool
Tests structural equality of two LatLngBounds values.
pub fn bounds_from_list(positions: List(LatLng)) -> LatLngBounds
Creates bounds that contain all positions in a list. Returns bounds with (0,0)-(0,0) for an empty list.
let bounds = coords.bounds_from_list([coords.seoul(), coords.busan(), coords.jeju()])
pub fn bounds_overlap(a: LatLngBounds, b: LatLngBounds) -> Bool
Returns True if two bounds overlap (share any area).
let a = coords.lat_lng_bounds(sw: coords.seoul(), ne: coords.busan())
let b = coords.lat_lng_bounds(sw: coords.daejeon(), ne: coords.daegu())
coords.bounds_overlap(a, b) // True
pub fn bounds_to_string(bounds: LatLngBounds) -> String
Returns a string representation: “((sw_lat, sw_lng), (ne_lat, ne_lng))”.
pub fn contains(bounds: LatLngBounds, position: LatLng) -> Bool
Returns True if the position is within the bounds. The southwest corner is inclusive, the northeast corner is exclusive.
pub fn destination(
from from: LatLng,
bearing_deg bearing_deg: Float,
distance_m distance_m: Float,
) -> LatLng
Calculates a destination point given bearing (degrees) and distance (meters).
let dest = coords.destination(from: coords.seoul(), bearing_deg: 0.0, distance_m: 1000.0)
// ~1km north of Seoul
pub fn distance(from from: LatLng, to to: LatLng) -> Float
Returns the distance in meters between two coordinates (Haversine formula).
let d = coords.distance(from: coords.seoul(), to: coords.busan())
// approximately 325,000 meters
pub fn extend(
bounds: LatLngBounds,
position: LatLng,
) -> LatLngBounds
Extends the bounds to include the given position.
pub fn lat_lng(lat lat: Float, lng lng: Float) -> LatLng
Creates a LatLng from latitude and longitude values.
pub fn lat_lng_bounds(
sw sw: LatLng,
ne ne: LatLng,
) -> LatLngBounds
Creates bounds from southwest and northeast coordinates.
pub fn lat_lng_to_string(position: LatLng) -> String
Returns a string representation: “(lat, lng)”.
pub fn midpoint(a: LatLng, b: LatLng) -> LatLng
Returns the midpoint between two coordinates.
let mid = coords.midpoint(coords.seoul(), coords.busan())
pub fn offset(
position: LatLng,
lat_offset lat_offset: Float,
lng_offset lng_offset: Float,
) -> LatLng
Shifts a position by latitude/longitude offset (in degrees).
let shifted = coords.offset(coords.seoul(), lat_offset: 0.01, lng_offset: -0.01)
pub fn point(x x: Float, y y: Float) -> Point
Creates a Point from x and y pixel coordinates.
pub fn size(width width: Float, height height: Float) -> Size
Creates a Size from width and height values.