Search in sources :

Example 1 with Point

use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.

the class Neo4jJsonCodecTest method testCartesianPointWriting.

@Test
public void testCartesianPointWriting() throws IOException {
    //Given
    Point value = new MockPoint(123.0, 456.0, mockCartesian());
    //When
    jsonCodec.writeValue(jsonGenerator, value);
    //Then
    verify(jsonGenerator, times(3)).writeEndObject();
}
Also used : Point(org.neo4j.graphdb.spatial.Point) Test(org.junit.Test)

Example 2 with Point

use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.

the class Neo4jJsonCodec method writeValue.

@Override
public void writeValue(JsonGenerator out, Object value) throws IOException {
    if (value instanceof PropertyContainer) {
        writePropertyContainer(out, (PropertyContainer) value, TransactionStateChecker.create(container));
    } else if (value instanceof Path) {
        writePath(out, ((Path) value).iterator(), TransactionStateChecker.create(container));
    } else if (value instanceof Iterable) {
        writeIterator(out, ((Iterable) value).iterator());
    } else if (value instanceof byte[]) {
        writeByteArray(out, (byte[]) value);
    } else if (value instanceof Map) {
        writeMap(out, (Map) value);
    } else if (value instanceof Geometry) {
        Geometry geom = (Geometry) value;
        Object coordinates = (geom instanceof Point) ? ((Point) geom).getCoordinate() : geom.getCoordinates();
        writeMap(out, genericMap(new LinkedHashMap<>(), "type", geom.getGeometryType(), "coordinates", coordinates, "crs", geom.getCRS()));
    } else if (value instanceof Coordinate) {
        Coordinate coordinate = (Coordinate) value;
        writeIterator(out, coordinate.getCoordinate().iterator());
    } else if (value instanceof CRS) {
        CRS crs = (CRS) value;
        writeMap(out, genericMap(new LinkedHashMap<>(), "name", crs.getType(), "type", "link", "properties", genericMap(new LinkedHashMap<>(), "href", crs.getHref() + "ogcwkt/", "type", "ogcwkt")));
    } else {
        super.writeValue(out, value);
    }
}
Also used : Path(org.neo4j.graphdb.Path) Geometry(org.neo4j.graphdb.spatial.Geometry) PropertyContainer(org.neo4j.graphdb.PropertyContainer) Coordinate(org.neo4j.graphdb.spatial.Coordinate) CRS(org.neo4j.graphdb.spatial.CRS) Point(org.neo4j.graphdb.spatial.Point) LinkedHashMap(java.util.LinkedHashMap) MapUtil.genericMap(org.neo4j.helpers.collection.MapUtil.genericMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with Point

use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.

the class Neo4jJsonCodecTest method testGeographic3DPointWriting.

@Test
void testGeographic3DPointWriting() throws IOException {
    // Given
    Point value = SpatialMocks.mockPoint(12.3, 45.6, 78.9, mockWGS84_3D());
    // When
    jsonCodec.writeValue(jsonGenerator, value);
    // Then
    verify(jsonGenerator, times(3)).writeEndObject();
}
Also used : Point(org.neo4j.graphdb.spatial.Point) Test(org.junit.jupiter.api.Test)

Example 4 with Point

use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.

the class Neo4jJsonCodecTest method testGeographicPointWriting.

@Test
void testGeographicPointWriting() throws IOException {
    // Given
    Point value = SpatialMocks.mockPoint(12.3, 45.6, mockWGS84());
    // When
    jsonCodec.writeValue(jsonGenerator, value);
    // Then
    verify(jsonGenerator, times(3)).writeEndObject();
}
Also used : Point(org.neo4j.graphdb.spatial.Point) Test(org.junit.jupiter.api.Test)

Example 5 with Point

use of org.neo4j.graphdb.spatial.Point in project neo4j by neo4j.

the class PrimitiveArrayWriting method writeTo.

public static <E extends Exception> void writeTo(ValueWriter<E> writer, Point[] values) throws E {
    writer.beginArray(values.length, ValueWriter.ArrayType.POINT);
    for (Point x : values) {
        PointValue value = Values.point(x);
        writer.writePoint(value.getCoordinateReferenceSystem(), value.coordinate());
    }
    writer.endArray();
}
Also used : Point(org.neo4j.graphdb.spatial.Point)

Aggregations

Point (org.neo4j.graphdb.spatial.Point)29 Test (org.junit.jupiter.api.Test)20 Transaction (org.neo4j.graphdb.Transaction)15 Result (org.neo4j.graphdb.Result)7 CRS (org.neo4j.graphdb.spatial.CRS)4 Map (java.util.Map)3 TemporalAmount (java.time.temporal.TemporalAmount)2 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Test (org.junit.Test)2 Coordinate (org.neo4j.graphdb.spatial.Coordinate)2 CoordinateReferenceSystem (org.neo4j.values.storable.CoordinateReferenceSystem)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Duration (java.time.Duration)1 LocalDate (java.time.LocalDate)1 LocalDateTime (java.time.LocalDateTime)1 LocalTime (java.time.LocalTime)1 OffsetTime (java.time.OffsetTime)1 Period (java.time.Period)1 ZonedDateTime (java.time.ZonedDateTime)1