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));
}
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);
}
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());
}
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;
}
Aggregations