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 WGS84 coordinate with latitude and longitude.

pub opaque type LatLng

A rectangular bounds defined by southwest and northeast corners.

pub opaque type LatLngBounds

A pixel coordinate on the screen.

pub opaque type Point

A size in pixels.

pub opaque type Size

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 busan() -> LatLng

Busan Station (부산역).

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 daegu() -> LatLng

Daegu Station (대구역).

pub fn daejeon() -> LatLng

Daejeon Station (대전역).

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 gwangju() -> LatLng

Gwangju Station (광주역).

pub fn incheon() -> LatLng

Incheon City Hall (인천시청).

pub fn is_empty(bounds: LatLngBounds) -> Bool

Returns True if the bounds has no area.

pub fn jeju() -> LatLng

Jeju City Hall (제주시청).

pub fn lat(position: LatLng) -> Float

Returns the latitude.

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_equals(a: LatLng, b: LatLng) -> Bool

Tests structural equality of two LatLng values.

pub fn lat_lng_to_string(position: LatLng) -> String

Returns a string representation: “(lat, lng)”.

pub fn lng(position: LatLng) -> Float

Returns the longitude.

pub fn midpoint(a: LatLng, b: LatLng) -> LatLng

Returns the midpoint between two coordinates.

let mid = coords.midpoint(coords.seoul(), coords.busan())
pub fn north_east(bounds: LatLngBounds) -> LatLng

Returns the northeast corner.

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 pangyo() -> LatLng

Pangyo Kakao Headquarters (판교 카카오 본사).

pub fn point(x x: Float, y y: Float) -> Point

Creates a Point from x and y pixel coordinates.

pub fn point_x(p: Point) -> Float

Returns the x coordinate.

pub fn point_y(p: Point) -> Float

Returns the y coordinate.

pub fn sejong() -> LatLng

Sejong Government Complex (세종정부청사).

pub fn seoul() -> LatLng

Seoul City Hall (서울시청).

pub fn size(width width: Float, height height: Float) -> Size

Creates a Size from width and height values.

pub fn size_height(s: Size) -> Float

Returns the height.

pub fn size_width(s: Size) -> Float

Returns the width.

pub fn south_west(bounds: LatLngBounds) -> LatLng

Returns the southwest corner.

pub fn ulsan() -> LatLng

Ulsan City Hall (울산시청).

Search Document