use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.
the class GeoJsonSplitterTest method point.
/**
* Test if a Point can be split correctly
* @throws IOException if the test file could not be read
*/
@Test
public void point() throws IOException {
String filename = "point.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("Point", m1.getType());
JsonObject o1 = t1.v2;
assertEquals("Point", o1.getString("type"));
assertEquals(2, o1.getJsonArray("coordinates").size());
}
use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.
the class GeoJsonSplitterTest method extraAttributes.
/**
* Test if extra attributes not part of the standard are ignored
* @throws IOException if the test file could not be read
*/
@Test
public void extraAttributes() throws IOException {
String filename = "featurecollectionext.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 feature.
/**
* Test if a Feature can be split correctly
* @throws IOException if the test file could not be read
*/
@Test
public void feature() throws IOException {
String filename = "feature.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("Feature", m1.getType());
JsonObject o1 = t1.v2;
assertEquals("Feature", o1.getString("type"));
assertEquals("Fraunhofer IGD", o1.getJsonObject("properties").getString("name"));
}
use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.
the class GeoJsonSplitterTest method lineString.
/**
* Test if a LineString can be split correctly
* @throws IOException if the test file could not be read
*/
@Test
public void lineString() throws IOException {
String filename = "linestring.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("LineString", m1.getType());
JsonObject o1 = t1.v2;
assertEquals("LineString", o1.getString("type"));
assertEquals(13, o1.getJsonArray("coordinates").size());
}
use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.
the class MultiMergerTest method mixedInit.
/**
* Test if the merger fails if chunks with a different type should be merged
* @param context the Vert.x test context
*/
@Test
public void mixedInit(TestContext context) {
String strChunk1 = "{\"type\":\"Feature\"}";
String strChunk2 = XMLHEADER + "<root><test chunk=\"2\"></test></root>";
Buffer chunk1 = Buffer.buffer(strChunk1);
Buffer chunk2 = Buffer.buffer(strChunk2);
GeoJsonChunkMeta cm1 = new GeoJsonChunkMeta("Feature", "features", 0, chunk1.length());
XMLChunkMeta cm2 = new XMLChunkMeta(Arrays.asList(new XMLStartElement("root")), XMLHEADER.length() + 6, chunk2.length() - 7);
MultiMerger m = new MultiMerger();
Async async = context.async();
m.init(cm1).flatMap(v -> m.init(cm2)).subscribe(v -> {
context.fail();
}, err -> {
context.assertTrue(err instanceof IllegalStateException);
async.complete();
});
}
Aggregations