Skip to content

Commit 2fe2b31

Browse files
authored
Merge pull request #149 from ptkis/alarm-gps
Longitude and latitude to detection response
2 parents 4edb43a + d4bfe9f commit 2fe2b31

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

src/main/kotlin/com/katalisindonesia/banyuwangi/controller/AlarmController.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,8 @@ class AlarmController(
131131
)
132132
.toString(),
133133
annotations = emptyList(),
134+
longitude = camera.longitude.toBigDecimal(),
135+
latitude = camera.latitude.toBigDecimal(),
134136
)
135137
}
136138
)

src/main/kotlin/com/katalisindonesia/banyuwangi/controller/DetectionController.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.RequestMapping
3535
import org.springframework.web.bind.annotation.RequestParam
3636
import org.springframework.web.bind.annotation.RestController
3737
import org.springframework.web.servlet.support.ServletUriComponentsBuilder
38+
import java.math.BigDecimal
3839
import java.time.Instant
3940
import java.time.LocalDate
4041
import java.time.ZoneId
@@ -169,7 +170,9 @@ class DetectionController(
169170
type = it.type,
170171
value = it.value,
171172
imageSrc = storageService.uri(it.snapshotImageId).toString(),
172-
annotations = annotations
173+
annotations = annotations,
174+
longitude = it.snapshot.camera.longitude.toBigDecimal(),
175+
latitude = it.snapshot.camera.latitude.toBigDecimal(),
173176
)
174177
)
175178
)
@@ -383,7 +386,9 @@ class DetectionController(
383386
type = it.type,
384387
value = it.value,
385388
imageSrc = storageService.uri(it.snapshotImageId).toString(),
386-
annotations = annotationMap[Pair(it.snapshotImageId, it.type)] ?: emptyList()
389+
annotations = annotationMap[Pair(it.snapshotImageId, it.type)] ?: emptyList(),
390+
longitude = it.snapshot.camera.longitude.toBigDecimal(),
391+
latitude = it.snapshot.camera.latitude.toBigDecimal(),
387392
)
388393
}
389394
return PageImpl(list, pageRequest, Long.MAX_VALUE)
@@ -419,7 +424,9 @@ class DetectionController(
419424
value = 3,
420425
imageSrc = ServletUriComponentsBuilder.fromUri(appProperties.baseUri)
421426
.path("/v1/image/${storageService.dummyId()}").toUriString(),
422-
annotations = annotations
427+
annotations = annotations,
428+
longitude = BigDecimal.ONE,
429+
latitude = BigDecimal.ONE,
423430
)
424431
)
425432
}

src/main/kotlin/com/katalisindonesia/banyuwangi/controller/DetectionResponse.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.katalisindonesia.banyuwangi.controller
22

33
import com.katalisindonesia.banyuwangi.model.Annotation
44
import com.katalisindonesia.banyuwangi.model.DetectionType
5+
import java.math.BigDecimal
56
import java.time.Instant
67
import java.time.LocalDate
78

@@ -14,4 +15,6 @@ data class DetectionResponse(
1415
val value: Int,
1516
val imageSrc: String,
1617
val annotations: List<Annotation>,
18+
val longitude: BigDecimal,
19+
val latitude: BigDecimal,
1720
)

src/main/kotlin/com/katalisindonesia/banyuwangi/model/Camera.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ data class Camera(
3333
var location: String,
3434

3535
@Column(nullable = false)
36-
var latitude: Float = 0F,
36+
var latitude: Double = 0.0,
3737

3838
@Column(nullable = false)
39-
var longitude: Float = 0F,
39+
var longitude: Double = 0.0,
4040

4141
@Column(nullable = false)
4242
var host: String = "",

src/main/kotlin/com/katalisindonesia/banyuwangi/model/SnapshotCount.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ data class SnapshotCount(
5050
@Column(nullable = false)
5151
var snapshotCameraLocation: String = snapshot.camera.location,
5252

53-
var snapshotCameraLongitude: Float? = snapshot.camera.longitude,
54-
var snapshotCameraLatitude: Float? = snapshot.camera.latitude,
53+
var snapshotCameraLongitude: Double? = snapshot.camera.longitude,
54+
var snapshotCameraLatitude: Double? = snapshot.camera.latitude,
5555

5656
@Enumerated(EnumType.STRING)
5757
@Column(nullable = false)

src/test/kotlin/com/katalisindonesia/banyuwangi/controller/LiveViewControllerTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ class LiveViewControllerTest(
8787
channel = 1,
8888
userName = "admin",
8989
password = "Password123",
90-
longitude = 2F,
91-
latitude = 3F,
90+
longitude = 2.0,
91+
latitude = 3.0,
9292
type = CameraType.HIKVISION,
9393
)
9494
mockMvc.post("/v1/camera") {

0 commit comments

Comments
 (0)