
Multiplatform library efficiently determines a geo position's region, adapted from a Java library. Offers functionality to check region presence and intersection within specified bounds.
Kotlin multiplatform library to find in which region a given geo position is located fast.
It is a port of the de.westnordost.countryboundaries Java library to Kotlin Multiplatform.
© 2025 Tobias Zwick. This library is released under the terms of the GNU Lesser General Public License (LGPL).
Add de.westnordost:region-index:1.0.0 as a dependency.
// load data. You should do this once and use RegionIndex as a singleton.
val source = FileSystem.source("boundaries.ser").buffered()
val index = source.use { RegionIndex.load(it) }
// when using the default data also used in the Java library:
// get ids of regions at position
index.getIds(
longitude = -96.7954,
latitude = 32.7816
) // returns "US-TX","US"
// check if a position is in region with specified id
index.isIn(
longitude = 8.6910,
latitude = 47.6973,
id = "DE"
) // returns true
// get ids of the regions that are present in the given bounds
index.getIntersectingIds(
minLongitude = 50.6,
minLatitude = 5.9,
maxLongitude = 50.8,
maxLatitude = 6.1
) // returns "NL", "LU", "DE", "BE", "BE-VLG", "BE-WAL"
// get ids of the regions that completely cover the given bounds
index.getContainingIds(
minLongitude = 50.6,
minLatitude = 5.9,
maxLongitude = 50.8,
maxLatitude = 6.1
) // returns empty listKotlin multiplatform library to find in which region a given geo position is located fast.
It is a port of the de.westnordost.countryboundaries Java library to Kotlin Multiplatform.
© 2025 Tobias Zwick. This library is released under the terms of the GNU Lesser General Public License (LGPL).
Add de.westnordost:region-index:1.0.0 as a dependency.
// load data. You should do this once and use RegionIndex as a singleton.
val source = FileSystem.source("boundaries.ser").buffered()
val index = source.use { RegionIndex.load(it) }
// when using the default data also used in the Java library:
// get ids of regions at position
index.getIds(
longitude = -96.7954,
latitude = 32.7816
) // returns "US-TX","US"
// check if a position is in region with specified id
index.isIn(
longitude = 8.6910,
latitude = 47.6973,
id = "DE"
) // returns true
// get ids of the regions that are present in the given bounds
index.getIntersectingIds(
minLongitude = 50.6,
minLatitude = 5.9,
maxLongitude = 50.8,
maxLatitude = 6.1
) // returns "NL", "LU", "DE", "BE", "BE-VLG", "BE-WAL"
// get ids of the regions that completely cover the given bounds
index.getContainingIds(
minLongitude = 50.6,
minLatitude = 5.9,
maxLongitude = 50.8,
maxLatitude = 6.1
) // returns empty list