Skip to content

Commit

Permalink
Merge pull request #149 from ptkis/alarm-gps
Browse files Browse the repository at this point in the history
Longitude and latitude to detection response
  • Loading branch information
thomedw authored Nov 10, 2023
2 parents 4edb43a + d4bfe9f commit 2fe2b31
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class AlarmController(
)
.toString(),
annotations = emptyList(),
longitude = camera.longitude.toBigDecimal(),
latitude = camera.latitude.toBigDecimal(),
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.servlet.support.ServletUriComponentsBuilder
import java.math.BigDecimal
import java.time.Instant
import java.time.LocalDate
import java.time.ZoneId
Expand Down Expand Up @@ -169,7 +170,9 @@ class DetectionController(
type = it.type,
value = it.value,
imageSrc = storageService.uri(it.snapshotImageId).toString(),
annotations = annotations
annotations = annotations,
longitude = it.snapshot.camera.longitude.toBigDecimal(),
latitude = it.snapshot.camera.latitude.toBigDecimal(),
)
)
)
Expand Down Expand Up @@ -383,7 +386,9 @@ class DetectionController(
type = it.type,
value = it.value,
imageSrc = storageService.uri(it.snapshotImageId).toString(),
annotations = annotationMap[Pair(it.snapshotImageId, it.type)] ?: emptyList()
annotations = annotationMap[Pair(it.snapshotImageId, it.type)] ?: emptyList(),
longitude = it.snapshot.camera.longitude.toBigDecimal(),
latitude = it.snapshot.camera.latitude.toBigDecimal(),
)
}
return PageImpl(list, pageRequest, Long.MAX_VALUE)
Expand Down Expand Up @@ -419,7 +424,9 @@ class DetectionController(
value = 3,
imageSrc = ServletUriComponentsBuilder.fromUri(appProperties.baseUri)
.path("/v1/image/${storageService.dummyId()}").toUriString(),
annotations = annotations
annotations = annotations,
longitude = BigDecimal.ONE,
latitude = BigDecimal.ONE,
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.katalisindonesia.banyuwangi.controller

import com.katalisindonesia.banyuwangi.model.Annotation
import com.katalisindonesia.banyuwangi.model.DetectionType
import java.math.BigDecimal
import java.time.Instant
import java.time.LocalDate

Expand All @@ -14,4 +15,6 @@ data class DetectionResponse(
val value: Int,
val imageSrc: String,
val annotations: List<Annotation>,
val longitude: BigDecimal,
val latitude: BigDecimal,
)
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ data class Camera(
var location: String,

@Column(nullable = false)
var latitude: Float = 0F,
var latitude: Double = 0.0,

@Column(nullable = false)
var longitude: Float = 0F,
var longitude: Double = 0.0,

@Column(nullable = false)
var host: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ data class SnapshotCount(
@Column(nullable = false)
var snapshotCameraLocation: String = snapshot.camera.location,

var snapshotCameraLongitude: Float? = snapshot.camera.longitude,
var snapshotCameraLatitude: Float? = snapshot.camera.latitude,
var snapshotCameraLongitude: Double? = snapshot.camera.longitude,
var snapshotCameraLatitude: Double? = snapshot.camera.latitude,

@Enumerated(EnumType.STRING)
@Column(nullable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ class LiveViewControllerTest(
channel = 1,
userName = "admin",
password = "Password123",
longitude = 2F,
latitude = 3F,
longitude = 2.0,
latitude = 3.0,
type = CameraType.HIKVISION,
)
mockMvc.post("/v1/camera") {
Expand Down

0 comments on commit 2fe2b31

Please sign in to comment.