mirror of
https://github.com/FoggedLens/deflock.git
synced 2026-10-11 01:18:44 +02:00
remove redundant scala modules
This commit is contained in:
1 parent
194289c206
commit
d3b8cb19a2
2 files changed
-49
No files matched your search
@@ -29,7 +29,6 @@ object ShotgunServer {
|
|||||||
implicit val executionContext: ExecutionContextExecutor = system.dispatcher
|
implicit val executionContext: ExecutionContextExecutor = system.dispatcher
|
||||||
val logging = Logging(system, getClass)
|
val logging = Logging(system, getClass)
|
||||||
|
|
||||||
val client = new services.OverpassClient()
|
|
||||||
val nominatim = new services.NominatimClient()
|
val nominatim = new services.NominatimClient()
|
||||||
val githubClient = new services.GithubClient()
|
val githubClient = new services.GithubClient()
|
||||||
|
|
||||||
@@ -56,16 +55,6 @@ object ShotgunServer {
|
|||||||
|
|
||||||
val apiRoutes = pathPrefix("api") {
|
val apiRoutes = pathPrefix("api") {
|
||||||
concat (
|
concat (
|
||||||
path("alpr") {
|
|
||||||
get {
|
|
||||||
parameters("minLat".as[Double], "minLng".as[Double], "maxLat".as[Double], "maxLng".as[Double]) { (minLat, minLng, maxLat, maxLng) =>
|
|
||||||
val bBox = services.BoundingBox(minLat, minLng, maxLat, maxLng)
|
|
||||||
onSuccess(client.getALPRs(bBox)) { json =>
|
|
||||||
complete(json)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
path("geocode") {
|
path("geocode") {
|
||||||
get {
|
get {
|
||||||
parameters("query".as[String]) { query =>
|
parameters("query".as[String]) { query =>
|
||||||
|
|||||||
@@ -1,38 +0,0 @@
|
|||||||
package services
|
|
||||||
|
|
||||||
import org.apache.pekko
|
|
||||||
import org.apache.pekko.actor.ActorSystem
|
|
||||||
import pekko.http.scaladsl.Http
|
|
||||||
import pekko.http.scaladsl.model._
|
|
||||||
import pekko.http.scaladsl.unmarshalling.Unmarshal
|
|
||||||
import spray.json._
|
|
||||||
import scala.concurrent.{ExecutionContextExecutor, Future}
|
|
||||||
|
|
||||||
case class BoundingBox(minLat: Double, minLng: Double, maxLat: Double, maxLng: Double)
|
|
||||||
|
|
||||||
class OverpassClient(implicit val system: ActorSystem, implicit val executionContext: ExecutionContextExecutor) {
|
|
||||||
val baseUrl = "https://overpass-api.de/api/interpreter"
|
|
||||||
|
|
||||||
def getALPRs(bBox: BoundingBox): Future[JsValue] = {
|
|
||||||
val query = s"""[out:json][bbox:${bBox.minLat},${bBox.minLng},${bBox.maxLat},${bBox.maxLng}];node["man_made"="surveillance"]["surveillance:type"="ALPR"];out body;>;out skel qt;"""
|
|
||||||
val formData = FormData("data" -> query).toEntity
|
|
||||||
val request = HttpRequest(
|
|
||||||
method = HttpMethods.POST,
|
|
||||||
uri = baseUrl,
|
|
||||||
entity = formData
|
|
||||||
)
|
|
||||||
|
|
||||||
Http().singleRequest(request).flatMap { response =>
|
|
||||||
response.status match {
|
|
||||||
case StatusCodes.OK =>
|
|
||||||
Unmarshal(response.entity).to[String].map { jsonString =>
|
|
||||||
jsonString.parseJson
|
|
||||||
}
|
|
||||||
case _ =>
|
|
||||||
response.discardEntityBytes()
|
|
||||||
Future.failed(new Exception(s"Failed to get ALPRs: ${response.status}"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user