Search in sources :

Example 1 with CoordinateSequence

use of com.vividsolutions.jts.geom.CoordinateSequence in project GeoGig by boundlessgeo.

the class PointCacheTest method testLargeSequences.

private void testLargeSequences(final int numNodes) {
    List<Long> nodeIds = new ArrayList<Long>(numNodes / 6);
    Stopwatch sw = Stopwatch.createStarted();
    for (int n = 0; n < numNodes; n++) {
        if (n % 20 == 0) {
            nodeIds.add(Long.valueOf(n));
        }
        cache.put((long) n, coord(n, n));
    }
    System.err.printf("%,d nodes added in %s\n", numNodes, sw.stop());
    Collections.shuffle(nodeIds);
    sw.reset().start();
    CoordinateSequence sequence = cache.get(nodeIds);
    System.err.printf("requested %,d coordinates in %s\n", nodeIds.size(), sw.stop());
    assertNotNull(sequence);
    assertEquals(nodeIds.size(), sequence.size());
    long approxDbSize = caclDbSize();
    System.err.printf("Approx db size: %,f MB\n\n", ((double) approxDbSize / 1024D / 1024D));
}
Also used : OSMCoordinateSequence(org.locationtech.geogig.osm.internal.OSMCoordinateSequence) CoordinateSequence(com.vividsolutions.jts.geom.CoordinateSequence) ArrayList(java.util.ArrayList) AtomicLong(java.util.concurrent.atomic.AtomicLong) Stopwatch(com.google.common.base.Stopwatch)

Example 2 with CoordinateSequence

use of com.vividsolutions.jts.geom.CoordinateSequence in project GeoGig by boundlessgeo.

the class PointCacheTest method testGet.

@Test
public void testGet() {
    cache.put(3L, coord(3, 3));
    cache.put(2L, coord(2, 2));
    cache.put(1L, coord(1, 1));
    List<Long> ids = ImmutableList.<Long>of(1L, 2L, 3L);
    CoordinateSequence sequence = cache.get(ids);
    assertNotNull(sequence);
    assertEquals(3, sequence.size());
    assertEquals(1D, sequence.getOrdinate(0, 0), 1E-9);
    assertEquals(1D, sequence.getOrdinate(0, 1), 1E-9);
    assertEquals(2D, sequence.getOrdinate(1, 0), 1E-9);
    assertEquals(2D, sequence.getOrdinate(1, 1), 1E-9);
    assertEquals(3D, sequence.getOrdinate(2, 0), 1E-9);
    assertEquals(3D, sequence.getOrdinate(2, 1), 1E-9);
}
Also used : OSMCoordinateSequence(org.locationtech.geogig.osm.internal.OSMCoordinateSequence) CoordinateSequence(com.vividsolutions.jts.geom.CoordinateSequence) AtomicLong(java.util.concurrent.atomic.AtomicLong) Test(org.junit.Test)

Example 3 with CoordinateSequence

use of com.vividsolutions.jts.geom.CoordinateSequence in project GeoGig by boundlessgeo.

the class PointCacheTest method testGetEmpty.

@Test
public void testGetEmpty() {
    CoordinateSequence coords = cache.get(ImmutableList.<Long>of());
    assertNotNull(coords);
    assertEquals(0, coords.size());
}
Also used : OSMCoordinateSequence(org.locationtech.geogig.osm.internal.OSMCoordinateSequence) CoordinateSequence(com.vividsolutions.jts.geom.CoordinateSequence) Test(org.junit.Test)

Example 4 with CoordinateSequence

use of com.vividsolutions.jts.geom.CoordinateSequence in project GeoGig by boundlessgeo.

the class GeometrySerializer method read.

@Override
public Geometry read(DataInput in) throws IOException {
    final int typeAndMasks = readUnsignedVarInt(in);
    Geometry geom;
    if ((typeAndMasks & POINT) == POINT) {
        geom = GEOMFAC.createPoint(EncodingSequenceFilter.readCoordinate(in));
    } else if ((typeAndMasks & LINESTRING) == LINESTRING) {
        CoordinateSequence cs = EncodingSequenceFilter.read(in);
        geom = GEOMFAC.createLineString(cs);
    } else {
        throw new UnsupportedOperationException();
    }
    return geom;
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) CoordinateSequence(com.vividsolutions.jts.geom.CoordinateSequence) Point(com.vividsolutions.jts.geom.Point) MultiPoint(com.vividsolutions.jts.geom.MultiPoint)

Aggregations

CoordinateSequence (com.vividsolutions.jts.geom.CoordinateSequence)4 OSMCoordinateSequence (org.locationtech.geogig.osm.internal.OSMCoordinateSequence)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Test (org.junit.Test)2 Stopwatch (com.google.common.base.Stopwatch)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 MultiPoint (com.vividsolutions.jts.geom.MultiPoint)1 Point (com.vividsolutions.jts.geom.Point)1 ArrayList (java.util.ArrayList)1