/**
 * Given a string with geographic coordinates, convert it into a nested tuple with latitude and longitude values.
 *
 * @param coordStr The string containing geographic coordinates in the format: "latitude,longitude"
 * @return A nested tuple with latitude and longitude values.
 */
fun createCoordinatesTuple(coordStr: String): Pair<String, String> {

    // Split the string by comma and strip whitespace from each coordinate
    val (lat, lon) = coordStr.split(",")
    val latTrimmed = lat.trim()
    val lonTrimmed = lon.trim()

    // Check if the latitude is within valid range (-90 to 90)
    if (latTrimmed.toDouble() < -90 || latTrimmed.toDouble() > 90) {
        return Pair("Invalid latitude value", "")
    }

    // Check if the longitude is within valid range (-180 to 180)
    if (lonTrimmed.toDouble() < -180 || lonTrimmed.toDouble() > 180) {
        return Pair("", "Invalid longitude value")
    }

    // Determine the hemisphere for latitude
    val latHemisphere = if (latTrimmed.toDouble() >= 0) "N" else "S"

    // Determine the hemisphere for longitude
    val lonHemisphere = if (lonTrimmed.toDouble() >= 0) "E" else "W"

    return Pair(latHemisphere, lonHemisphere)
}
/**
 * Given a string with geographic coordinates, convert it into a nested tuple with latitude and longitude values.
 *
 * @param coordStr The string containing geographic coordinates in the format: "latitude,longitude"
 * @return A nested tuple with latitude and longitude values.
 */
fun createCoordinatesTuple(coordStr: String): Pair<String, String> {
/**
 * Given a string with geographic coordinates, convert it into a nested tuple with latitude and longitude values.
 *
 * @param coordStr The string containing geographic coordinates in the format: "latitude,longitude"
 * @return A nested tuple with latitude and longitude values.
 */
fun createCoordinatesTuple(coordStr: String): Pair<String, String> {

    // Split the string by comma and strip whitespace from each coordinate
    val (lat, lon) = coordStr.split(",")
    val latTrimmed = lat.trim()
    val lonTrimmed = lon.trim()

    // Check if the latitude is within valid range (-90 to 90)
    if (latTrimmed.toDouble() < -90 || latTrimmed.toDouble() > 90) {
        return Pair("Invalid latitude value", "")
    }

    // Check if the longitude is within valid range (-180 to 180)
    if (lonTrimmed.toDouble() < -180 || lonTrimmed.toDouble() > 180) {
        return Pair("", "Invalid longitude value")
    }

    // Determine the hemisphere for latitude
    val latHemisphere = if (latTrimmed.toDouble() >= 0) "N" else "S"

    // Determine the hemisphere for longitude
    val lonHemisphere = if (lonTrimmed.toDouble() >= 0) "E" else "W"

    return Pair(latHemisphere, lonHemisphere)
}