Skip to content

Commit

Permalink
Added Map Count Endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Wiens committed Apr 29, 2024
1 parent 7fd4eeb commit 7def768
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -125,6 +124,10 @@ public List<IntersectionReferenceData> 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"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,27 @@ public ResponseEntity<List<ProcessedMap>> findMaps(
}
}

@CrossOrigin(origins = "http://localhost:3000")
@RequestMapping(value = "/map/count", method = RequestMethod.GET, produces = "application/json")
@PreAuthorize("hasRole('USER') || hasRole('ADMIN')")
public ResponseEntity<Long> 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);

}
}


}

0 comments on commit 7def768

Please sign in to comment.