use of org.springframework.data.mongodb.core.geo.GeoJsonPoint in project ocvn by devgateway.
the class GeoJsonPointDeserializer method deserialize.
@Override
public GeoJsonPoint deserialize(final JsonParser jsonParser, final DeserializationContext ctxt) throws IOException {
ObjectCodec objectCodec = jsonParser.getCodec();
JsonNode jsonNode = objectCodec.readTree(jsonParser);
ArrayNode coordinate = (ArrayNode) jsonNode.get("coordinates");
return new GeoJsonPoint(coordinate.get(0).asDouble(), coordinate.get(1).asDouble());
}
use of org.springframework.data.mongodb.core.geo.GeoJsonPoint in project ocvn by devgateway.
the class LocationRowImporter method importRow.
@Override
public void importRow(final String[] row) throws ParseException {
VNLocation location = repository.findByDescription(getRowCell(row, 0));
if (location != null) {
throw new RuntimeException("Duplicate location name " + getRowCell(row, 0));
}
location = new VNLocation();
location.setId(getRowCell(row, 3));
location.setDescription(getRowCell(row, 0));
GeoJsonPoint coordinates = new GeoJsonPoint(getDouble(getRowCell(row, 2)), getDouble(getRowCell(row, 1)));
location.setGeometry(coordinates);
Gazetteer gazetteer = new Gazetteer();
gazetteer.getIdentifiers().add(getRowCell(row, 3));
location.setGazetteer(gazetteer);
location.setUri(location.getGazetteerPrefix() + getRowCell(row, 3));
repository.insert(location);
}
use of org.springframework.data.mongodb.core.geo.GeoJsonPoint in project ocvn by devgateway.
the class OCDSPopulatorService method randomizeLocation.
public void randomizeLocation(VNLocation l) {
l.setDescription("Location " + getRandomTxt());
l.setGeometry(new GeoJsonPoint(-94.578333d + getRandomGeo(), 39.099722d + getRandomGeo()));
locationRepository.save(l);
}
Aggregations