berlin.softwaretechnik.geojsonrenderer.GeoBoundingBox.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geojsonrenderer_2.13 Show documentation
Show all versions of geojsonrenderer_2.13 Show documentation
A command line tool to render geojson file on top of map tiles.
The newest version!
package berlin.softwaretechnik.geojsonrenderer
import berlin.softwaretechnik.geojsonrenderer.Math._
case class GeoBoundingBox(west: Double,
south: Double,
east: Double,
north: Double) {
assert(-90 <= south && south <= north && north <= 90, s"Invalid or inconsistent latitudes: $this")
assert(-180 <= west && west <= 180, s"Invalid west longitude: $this")
assert(-180 <= east && east <= 180, s"Invalid east longitude: $this")
def upperLeft(): GeoCoord = GeoCoord(north, west)
def lowerRight(): GeoCoord = GeoCoord(south, east)
def centralLongitude: Double =
GeoCoord.normalizeLongitude(
west + floorMod(east - west, 360) / 2
)
}
object GeoBoundingBox {
def apply(coordinates: Seq[GeoCoord]): GeoBoundingBox = {
import Ordering.Double.IeeeOrdering
GeoBoundingBox(
west = GeoCoord.normalizeLongitude(coordinates.map(_.lon).min),
south = coordinates.map(_.lat).min,
east = GeoCoord.normalizeLongitude(coordinates.map(_.lon).max),
north = coordinates.map(_.lat).max
)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy