Search in sources :

Example 1 with GeoJsonPoint

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());
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectCodec(com.fasterxml.jackson.core.ObjectCodec) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) GeoJsonPoint(org.springframework.data.mongodb.core.geo.GeoJsonPoint)

Example 2 with GeoJsonPoint

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);
}
Also used : VNLocation(org.devgateway.ocvn.persistence.mongo.dao.VNLocation) Gazetteer(org.devgateway.ocds.persistence.mongo.Gazetteer) GeoJsonPoint(org.springframework.data.mongodb.core.geo.GeoJsonPoint)

Example 3 with GeoJsonPoint

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);
}
Also used : GeoJsonPoint(org.springframework.data.mongodb.core.geo.GeoJsonPoint)

Aggregations

GeoJsonPoint (org.springframework.data.mongodb.core.geo.GeoJsonPoint)3 ObjectCodec (com.fasterxml.jackson.core.ObjectCodec)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 Gazetteer (org.devgateway.ocds.persistence.mongo.Gazetteer)1 VNLocation (org.devgateway.ocvn.persistence.mongo.dao.VNLocation)1