Search in sources :

Example 21 with GeoJsonChunkMeta

use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.

the class MultiMergerTest method geoJsonTwoFeatures.

/**
 * Test if two GeoJSON features can be merged to a feature collection
 * @param context the Vert.x test context
 */
@Test
public void geoJsonTwoFeatures(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());
    doMerge(context, Observable.just(chunk1, chunk2), Observable.just(cm1, cm2), "{\"type\":\"FeatureCollection\",\"features\":[" + strChunk1 + "," + strChunk2 + "]}");
}
Also used : Buffer(io.vertx.core.buffer.Buffer) GeoJsonChunkMeta(io.georocket.storage.GeoJsonChunkMeta) Test(org.junit.Test)

Example 22 with GeoJsonChunkMeta

use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.

the class GeoJsonMergerTest method twoFeatures.

/**
 * Test if two features can be merged to a feature collection
 * @param context the Vert.x test context
 */
@Test
public void twoFeatures(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());
    doMerge(context, Observable.just(chunk1, chunk2), Observable.just(cm1, cm2), "{\"type\":\"FeatureCollection\",\"features\":[" + strChunk1 + "," + strChunk2 + "]}");
}
Also used : Buffer(io.vertx.core.buffer.Buffer) GeoJsonChunkMeta(io.georocket.storage.GeoJsonChunkMeta) Test(org.junit.Test)

Example 23 with GeoJsonChunkMeta

use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.

the class GeoJsonMergerTest method oneGeometry.

/**
 * Test if one geometry is rendered directly
 * @param context the Vert.x test context
 */
@Test
public void oneGeometry(TestContext context) {
    String strChunk1 = "{\"type\":\"Polygon\"}";
    Buffer chunk1 = Buffer.buffer(strChunk1);
    GeoJsonChunkMeta cm1 = new GeoJsonChunkMeta("Polygon", "geometries", 0, chunk1.length());
    doMerge(context, Observable.just(chunk1), Observable.just(cm1), strChunk1);
}
Also used : Buffer(io.vertx.core.buffer.Buffer) GeoJsonChunkMeta(io.georocket.storage.GeoJsonChunkMeta) Test(org.junit.Test)

Example 24 with GeoJsonChunkMeta

use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.

the class GeoJsonMergerTest method threeFeatures.

/**
 * Test if three features can be merged to a feature collection
 * @param context the Vert.x test context
 */
@Test
public void threeFeatures(TestContext context) {
    String strChunk1 = "{\"type\":\"Feature\"}";
    String strChunk2 = "{\"type\":\"Feature\",\"properties\":{}}";
    String strChunk3 = "{\"type\":\"Feature\",\"geometry\":[]}";
    Buffer chunk1 = Buffer.buffer(strChunk1);
    Buffer chunk2 = Buffer.buffer(strChunk2);
    Buffer chunk3 = Buffer.buffer(strChunk3);
    GeoJsonChunkMeta cm1 = new GeoJsonChunkMeta("Feature", "features", 0, chunk1.length());
    GeoJsonChunkMeta cm2 = new GeoJsonChunkMeta("Feature", "features", 0, chunk2.length());
    GeoJsonChunkMeta cm3 = new GeoJsonChunkMeta("Feature", "features", 0, chunk3.length());
    doMerge(context, Observable.just(chunk1, chunk2, chunk3), Observable.just(cm1, cm2, cm3), "{\"type\":\"FeatureCollection\",\"features\":[" + strChunk1 + "," + strChunk2 + "," + strChunk3 + "]}");
}
Also used : Buffer(io.vertx.core.buffer.Buffer) GeoJsonChunkMeta(io.georocket.storage.GeoJsonChunkMeta) Test(org.junit.Test)

Example 25 with GeoJsonChunkMeta

use of io.georocket.storage.GeoJsonChunkMeta in project georocket by georocket.

the class GeoJsonMergerTest method threeGeometries.

/**
 * Test if three geometries can be merged to a geometry collection
 * @param context the Vert.x test context
 */
@Test
public void threeGeometries(TestContext context) {
    String strChunk1 = "{\"type\":\"Polygon\"}";
    String strChunk2 = "{\"type\":\"Point\"}";
    String strChunk3 = "{\"type\":\"MultiPoint\"}";
    Buffer chunk1 = Buffer.buffer(strChunk1);
    Buffer chunk2 = Buffer.buffer(strChunk2);
    Buffer chunk3 = Buffer.buffer(strChunk3);
    GeoJsonChunkMeta cm1 = new GeoJsonChunkMeta("Polygon", "geometries", 0, chunk1.length());
    GeoJsonChunkMeta cm2 = new GeoJsonChunkMeta("Point", "geometries", 0, chunk2.length());
    GeoJsonChunkMeta cm3 = new GeoJsonChunkMeta("MultiPoint", "geometries", 0, chunk3.length());
    doMerge(context, Observable.just(chunk1, chunk2, chunk3), Observable.just(cm1, cm2, cm3), "{\"type\":\"GeometryCollection\",\"geometries\":[" + strChunk1 + "," + strChunk2 + "," + strChunk3 + "]}");
}
Also used : Buffer(io.vertx.core.buffer.Buffer) GeoJsonChunkMeta(io.georocket.storage.GeoJsonChunkMeta) Test(org.junit.Test)

Aggregations

GeoJsonChunkMeta (io.georocket.storage.GeoJsonChunkMeta)28 Test (org.junit.Test)27 Buffer (io.vertx.core.buffer.Buffer)17 JsonObject (io.vertx.core.json.JsonObject)11 Tuple2 (org.jooq.lambda.tuple.Tuple2)11 ChunkReadStream (io.georocket.storage.ChunkReadStream)5 BufferWriteStream (io.georocket.util.io.BufferWriteStream)5 DelegateChunkReadStream (io.georocket.util.io.DelegateChunkReadStream)5 Async (io.vertx.ext.unit.Async)5 TestContext (io.vertx.ext.unit.TestContext)5 RunTestOnContext (io.vertx.ext.unit.junit.RunTestOnContext)5 VertxUnitRunner (io.vertx.ext.unit.junit.VertxUnitRunner)5 Pair (org.apache.commons.lang3.tuple.Pair)5 Rule (org.junit.Rule)5 RunWith (org.junit.runner.RunWith)5 Observable (rx.Observable)5 ChunkMeta (io.georocket.storage.ChunkMeta)2 XMLChunkMeta (io.georocket.storage.XMLChunkMeta)2 XMLStartElement (io.georocket.util.XMLStartElement)2 Arrays (java.util.Arrays)2