commonMain.org.jetbrains.letsPlot.livemap.api.MapLocation.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of livemap-jvm Show documentation
Show all versions of livemap-jvm Show documentation
A part of the Lets-Plot library.
The newest version!
/*
* Copyright (c) 2023. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package org.jetbrains.letsPlot.livemap.api
import org.jetbrains.letsPlot.commons.intern.async.Async
import org.jetbrains.letsPlot.commons.intern.async.Asyncs
import org.jetbrains.letsPlot.commons.intern.spatial.GeoRectangle
import org.jetbrains.letsPlot.commons.intern.typedGeometry.Rect
import org.jetbrains.letsPlot.gis.geoprotocol.MapRegion
import org.jetbrains.letsPlot.livemap.World
import org.jetbrains.letsPlot.livemap.geocoding.MapLocationGeocoder
interface MapLocation {
fun getBBox(geocoder: MapLocationGeocoder): Async>
companion object {
fun create(geoRectangle: GeoRectangle): MapLocation {
return object : MapLocation {
override fun getBBox(geocoder: MapLocationGeocoder) =
Asyncs.constant(geocoder.calculateBBoxOfGeoRect(geoRectangle))
}
}
fun create(mapRegion: MapRegion): MapLocation {
return object : MapLocation {
override fun getBBox(geocoder: MapLocationGeocoder) =
geocoder.geocodeMapRegion(mapRegion)
}
}
}
}