From 79d0e38e0ca5d91deedf1a96ae5ceef580a1c560 Mon Sep 17 00:00:00 2001 From: Jilles van Gurp Date: Fri, 17 Nov 2023 15:49:23 +0100 Subject: [PATCH] mark function as private --- src/commonMain/kotlin/com/jillesvangurp/geo/mgrs.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/commonMain/kotlin/com/jillesvangurp/geo/mgrs.kt b/src/commonMain/kotlin/com/jillesvangurp/geo/mgrs.kt index b9e12bc..9b6c3eb 100644 --- a/src/commonMain/kotlin/com/jillesvangurp/geo/mgrs.kt +++ b/src/commonMain/kotlin/com/jillesvangurp/geo/mgrs.kt @@ -97,8 +97,9 @@ private fun Int.colLetters() = when (this) { private fun Int.rowLetters() = if (this % 2 == 0) "FGHJKLMNPQRSTUVABCDE" else "ABCDEFGHJKLMNPQRSTUV" -fun UtmCoordinate.lookupGridLetters(): Pair { +private fun UtmCoordinate.lookupGridLetters(): Pair { var row = 1 + // always floor in mgrs, or you might end up in the wrong grid cell var n = floor(northing).toInt() while (n >= GRID_SIZE_M) { n -= GRID_SIZE_M @@ -107,6 +108,7 @@ fun UtmCoordinate.lookupGridLetters(): Pair { row %= 20 var col = 0 + // always floor in mgrs, or you might end up in the wrong grid cell var e = floor(easting).toInt() while (e >= GRID_SIZE_M) { e -= GRID_SIZE_M @@ -132,11 +134,11 @@ fun UtmCoordinate.lookupGridLetters(): Pair { * various precision. * * Note, this does not support coordinates in the UPS coordinate system currently. - * */ fun UtmCoordinate.toMgrs(): MgrsCoordinate { val (l1, l2) = lookupGridLetters() + // always floor in mgrs, or you might end up in the wrong grid cell val mgrsEasting = floor(easting % GRID_SIZE_M).toInt() val mgrsNorthing = floor(northing % GRID_SIZE_M).toInt() // println("cols ${northing.toInt() / BLOCK_SIZE} $northing ${(northing / 1000).toInt()}")