insert lamp: add id as parameter
This commit is contained in:
1 parent
07c11d6c3b
commit
f68af51a48
2 files changed
+7
-6
No files matched your search
@@ -35,9 +35,9 @@ public class GisController {
|
||||
gisdbApi.getLampCoordinates(id) : Collections.emptyList();
|
||||
}
|
||||
|
||||
@RequestMapping(value = APIServicePaths.PUT_LAMP, method = RequestMethod.PUT)
|
||||
@RequestMapping(value = APIServicePaths.PUT_LAMP + "/{id}", method = RequestMethod.PUT)
|
||||
@ResponseBody
|
||||
int putLamp(@RequestBody Location location) {
|
||||
return gisdbApi.putLamp(location.getX(), location.getY());
|
||||
int putLamp(@RequestBody Location location, @PathVariable("id") Long id) {
|
||||
return gisdbApi.putLamp(id, location.getX(), location.getY());
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import java.util.List;
|
||||
public class GisdbApi {
|
||||
|
||||
private static final String GET_ALL_LAMPS_COORDINATES = "SELECT osm_id,st_transform(way,4326) FROM planet_osm_point WHERE highway='street_lamp'";
|
||||
private static String PUT_LAMP = "INSERT INTO public.gis_points(gis_points_id, way, highway) VALUES (1, st_geomfromtext('POINT(@ @)',4326), 'street_lamp');";
|
||||
private static String PUT_LAMP = "INSERT INTO public.gis_points(gis_points_id, way, highway) VALUES (@, st_geomfromtext('POINT(@ @)',4326), 'street_lamp');";
|
||||
private static final String GET_POINT_COORDINATES = "SELECT st_transform(way,900913) FROM gis_points WHERE gis_points_id = ?;";
|
||||
|
||||
JdbcTemplate gisJdbcTemplate;
|
||||
@@ -38,10 +38,11 @@ public class GisdbApi {
|
||||
}
|
||||
|
||||
public List<GisPoint> getLampCoordinates(long id) {
|
||||
return gisJdbcTemplate.query(GET_POINT_COORDINATES, new Object[] { id }, new PointRowMapper());
|
||||
return gisJdbcTemplate.query(GET_POINT_COORDINATES, new Object[]{id}, new PointRowMapper());
|
||||
}
|
||||
|
||||
public int putLamp(double x, double y) {
|
||||
public int putLamp(long id, double x, double y) {
|
||||
PUT_LAMP = PUT_LAMP.replaceFirst("@", Long.toString(id));
|
||||
PUT_LAMP = PUT_LAMP.replaceFirst("@", Double.toString(x));
|
||||
PUT_LAMP = PUT_LAMP.replaceFirst("@", Double.toString(y));
|
||||
return gisJdbcTemplate.update(PUT_LAMP, x, y);
|
||||
|
||||
Reference in new issue
Block a user