use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.
the class GeoJsonMergerTest method twoGeometries.
/**
* Test if two geometries can be merged to a geometry collection
* @param context the Vert.x test context
*/
@Test
public void twoGeometries(TestContext context) {
String strChunk1 = "{\"type\":\"Polygon\"}";
String strChunk2 = "{\"type\":\"Point\"}";
Buffer chunk1 = Buffer.buffer(strChunk1);
Buffer chunk2 = Buffer.buffer(strChunk2);
GeoJsonChunkMeta cm1 = new GeoJsonChunkMeta("Polygon", "geometries", 0, chunk1.length());
GeoJsonChunkMeta cm2 = new GeoJsonChunkMeta("Point", "geometries", 0, chunk2.length());
doMerge(context, Observable.just(chunk1, chunk2), Observable.just(cm1, cm2), "{\"type\":\"GeometryCollection\",\"geometries\":[" + strChunk1 + "," + strChunk2 + "]}");
}
use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.
the class GeoJsonMergerTest method notEnoughInits.
/**
* Test if the merger fails if {@link GeoJsonMerger#init(GeoJsonChunkMeta)} has
* not been called often enough
* @param context the Vert.x test context
*/
@Test
public void notEnoughInits(TestContext context) {
String strChunk1 = "{\"type\":\"Feature\"}";
String strChunk2 = "{\"type\":\"Feature\",\"properties\":{}}";
Buffer chunk1 = Buffer.buffer(strChunk1);
Buffer chunk2 = Buffer.buffer(strChunk2);
GeoJsonChunkMeta cm1 = new GeoJsonChunkMeta("Feature", "features", 0, chunk1.length());
GeoJsonChunkMeta cm2 = new GeoJsonChunkMeta("Feature", "features", 0, chunk2.length());
GeoJsonMerger m = new GeoJsonMerger();
BufferWriteStream bws = new BufferWriteStream();
Async async = context.async();
m.init(cm1).flatMap(v -> m.merge(new DelegateChunkReadStream(chunk1), cm1, bws)).flatMap(v -> m.merge(new DelegateChunkReadStream(chunk2), cm2, bws)).last().subscribe(v -> {
context.fail();
}, err -> {
context.assertTrue(err instanceof IllegalStateException);
async.complete();
});
}
use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.
the class GeoJsonSplitterTest method muliLineString.
/**
* Test if a MultiLineString can be split correctly
* @throws IOException if the test file could not be read
*/
@Test
public void muliLineString() throws IOException {
String filename = "multilinestring.json";
long size = getFileSize(filename);
List<Tuple2<GeoJsonChunkMeta, JsonObject>> chunks = split(filename);
assertEquals(1, chunks.size());
Tuple2<GeoJsonChunkMeta, JsonObject> t1 = chunks.get(0);
GeoJsonChunkMeta m1 = t1.v1;
assertNull(m1.getParentFieldName());
assertEquals(0, m1.getStart());
assertEquals(size, m1.getEnd());
assertEquals("MultiLineString", m1.getType());
JsonObject o1 = t1.v2;
assertEquals("MultiLineString", o1.getString("type"));
assertEquals(3, o1.getJsonArray("coordinates").size());
}
use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.
the class GeoJsonSplitterTest method featureCollection.
/**
* Test if a FeatureCollection can be split correctly
* @throws IOException if the test file could not be read
*/
@Test
public void featureCollection() throws IOException {
String filename = "featurecollection.json";
List<Tuple2<GeoJsonChunkMeta, JsonObject>> chunks = split(filename);
assertEquals(2, chunks.size());
Tuple2<GeoJsonChunkMeta, JsonObject> t1 = chunks.get(0);
GeoJsonChunkMeta m1 = t1.v1;
assertEquals("features", m1.getParentFieldName());
assertEquals(0, m1.getStart());
assertEquals(307, m1.getEnd());
assertEquals("Feature", m1.getType());
JsonObject o1 = t1.v2;
assertEquals("Feature", o1.getString("type"));
assertEquals("Fraunhofer IGD", o1.getJsonObject("properties").getString("name"));
Tuple2<GeoJsonChunkMeta, JsonObject> t2 = chunks.get(1);
GeoJsonChunkMeta m2 = t2.v1;
assertEquals("features", m2.getParentFieldName());
assertEquals(0, m2.getStart());
assertEquals(305, m2.getEnd());
assertEquals("Feature", m2.getType());
JsonObject o2 = t2.v2;
assertEquals("Feature", o2.getString("type"));
assertEquals("Darmstadtium", o2.getJsonObject("properties").getString("name"));
}
use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.
the class GeoJsonSplitterTest method multiPoint.
/**
* Test if a MultiPoint can be split correctly
* @throws IOException if the test file could not be read
*/
@Test
public void multiPoint() throws IOException {
String filename = "multipoint.json";
long size = getFileSize(filename);
List<Tuple2<GeoJsonChunkMeta, JsonObject>> chunks = split(filename);
assertEquals(1, chunks.size());
Tuple2<GeoJsonChunkMeta, JsonObject> t1 = chunks.get(0);
GeoJsonChunkMeta m1 = t1.v1;
assertNull(m1.getParentFieldName());
assertEquals(0, m1.getStart());
assertEquals(size, m1.getEnd());
assertEquals("MultiPoint", m1.getType());
JsonObject o1 = t1.v2;
assertEquals("MultiPoint", o1.getString("type"));
assertEquals(2, o1.getJsonArray("coordinates").size());
}
Aggregations