Skip to content
Snippets Groups Projects

Cleanup

Merged Jonathan Schneider requested to merge cleanup into main
16 files
+ 138
129
Compare changes
  • Side-by-side
  • Inline
Files
16
package de.scads.privacy.privateroutes.point;
import de.scads.privacy.privateroutes.dto.DtoService;
import de.scads.privacy.privateroutes.dto.output.PointDto;
import de.scads.privacy.privateroutes.dto.output.PointWithMeasurementDto;
import org.geolatte.geom.G2D;
import org.geolatte.geom.Polygon;
import org.geolatte.geom.crs.CoordinateReferenceSystem;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.stream.Collectors;
import static org.geolatte.geom.builder.DSL.*;
import static org.geolatte.geom.builder.DSL.g;
@Service
@RequestMapping("api/point")
public class PointController {
private final PointService pointService;
private final ModelMapper modelMapper;
@Autowired
CoordinateReferenceSystem<G2D> crs;
@@ -33,10 +29,9 @@ public class PointController {
@Autowired
public PointController(PointService pointService, DtoService dtoService, ModelMapper modelMapper) {
public PointController(PointService pointService, DtoService dtoService) {
this.pointService = pointService;
this.dtoService = dtoService;
this.modelMapper = modelMapper;
}
@@ -46,31 +41,17 @@ public class PointController {
}
@GetMapping("")
public List<PointDto> getAllPoints() {
public List<PointWithMeasurementDto> getAllPoints() {
return pointService.getAllPoints().stream()
.map(dtoService::convertPoint)
.collect(Collectors.toList());
}
@GetMapping("stops")
public List<PointDto> getAllStops() {
return pointService.getAllStops()
.stream()
.map(dtoService::convertPoint)
.collect(Collectors.toList());
}
@GetMapping(path = "{id}")
public PointDto getPointById(@PathVariable("id") Long id) {
public PointWithMeasurementDto getPointById(@PathVariable("id") Long id) {
return pointService.getPointById(id)
.map(dtoService::convertPoint)
.orElse(null);
}
@GetMapping("testSpatial")
public List<Point> testSpatialQuery() {
Polygon<G2D> polygon = polygon(crs, ring(g(-8.642196, 41.160114), g(-8.61, 41.16), g(-8.62506, 41.144805), g(-8.642196, 41.160114)));
return pointService.getPointsWithin(polygon);
}
}
Loading