From 7def7685f380fb9ea0a6cd1bb7b5aad53933d91a Mon Sep 17 00:00:00 2001 From: John-Wiens Date: Mon, 29 Apr 2024 16:19:07 -0600 Subject: [PATCH] Added Map Count Endpoint --- .../map/ProcessedMapRepositoryImpl.java | 5 ++++- .../ode/api/controllers/MapController.java | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/jpo-conflictvisualizer-api/src/main/java/us/dot/its/jpo/ode/api/accessors/map/ProcessedMapRepositoryImpl.java b/jpo-conflictvisualizer-api/src/main/java/us/dot/its/jpo/ode/api/accessors/map/ProcessedMapRepositoryImpl.java index 49e83d1ca..05570538c 100644 --- a/jpo-conflictvisualizer-api/src/main/java/us/dot/its/jpo/ode/api/accessors/map/ProcessedMapRepositoryImpl.java +++ b/jpo-conflictvisualizer-api/src/main/java/us/dot/its/jpo/ode/api/accessors/map/ProcessedMapRepositoryImpl.java @@ -36,7 +36,6 @@ import us.dot.its.jpo.geojsonconverter.pojos.geojson.map.ProcessedMap; import us.dot.its.jpo.ode.api.ConflictMonitorApiProperties; -import us.dot.its.jpo.ode.api.controllers.AssessmentController; import us.dot.its.jpo.ode.api.models.IDCount; import us.dot.its.jpo.ode.api.models.IntersectionReferenceData; import us.dot.its.jpo.geojsonconverter.DateJsonMapper; @@ -125,6 +124,10 @@ public List getIntersectionIDs() { data.setIntersectionID(intersectionId); data.setRoadRegulatorID("-1"); data.setRsuIP(properties.getString("originIp")); + + if(properties.getString("intersectionName").isEmpty()){ + + } data.setIntersectionName(properties.getString("intersectionName")); if (refPoint != null) { data.setLatitude(refPoint.getDouble("latitude")); diff --git a/jpo-conflictvisualizer-api/src/main/java/us/dot/its/jpo/ode/api/controllers/MapController.java b/jpo-conflictvisualizer-api/src/main/java/us/dot/its/jpo/ode/api/controllers/MapController.java index f56d88517..b94b2d936 100644 --- a/jpo-conflictvisualizer-api/src/main/java/us/dot/its/jpo/ode/api/controllers/MapController.java +++ b/jpo-conflictvisualizer-api/src/main/java/us/dot/its/jpo/ode/api/controllers/MapController.java @@ -59,5 +59,27 @@ public ResponseEntity> findMaps( } } + @CrossOrigin(origins = "http://localhost:3000") + @RequestMapping(value = "/map/count", method = RequestMethod.GET, produces = "application/json") + @PreAuthorize("hasRole('USER') || hasRole('ADMIN')") + public ResponseEntity countMaps( + @RequestParam(name = "intersection_id", required = false) Integer intersectionID, + @RequestParam(name = "start_time_utc_millis", required = false) Long startTime, + @RequestParam(name = "end_time_utc_millis", required = false) Long endTime, + @RequestParam(name= "latest", required = false, defaultValue = "false") boolean latest, + @RequestParam(name = "test", required = false, defaultValue = "false") boolean testData) { + + if (testData) { + return ResponseEntity.ok(5L); + } else { + Query query = processedMapRepo.getQuery(intersectionID, startTime, endTime, latest); + long count = processedMapRepo.getQueryResultCount(query); + + logger.info("Found: " + count + "Processed Map Messages"); + return ResponseEntity.ok(count); + + } + } + } \ No newline at end of file