Search in sources :

Example 26 with GeoJsonChunkMeta

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

the class GeoJsonMergerTest method geometryAndFeature.

/**
 * Test if two geometries and a feature can be merged to a feature collection
 * @param context the Vert.x test context
 */
@Test
public void geometryAndFeature(TestContext context) {
    String strChunk1 = "{\"type\":\"Polygon\"}";
    String strChunk2 = "{\"type\":\"Feature\"}";
    Buffer chunk1 = Buffer.buffer(strChunk1);
    Buffer chunk2 = Buffer.buffer(strChunk2);
    GeoJsonChunkMeta cm1 = new GeoJsonChunkMeta("Polygon", "geometries", 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\":[{\"type\":\"Feature\",\"geometry\":" + strChunk1 + "}," + strChunk2 + "]}");
}
Also used : Buffer(io.vertx.core.buffer.Buffer) GeoJsonChunkMeta(io.georocket.storage.GeoJsonChunkMeta) Test(org.junit.Test)

Example 27 with GeoJsonChunkMeta

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

the class GeoJsonMergerTest method featureAndGeometry.

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

Example 28 with GeoJsonChunkMeta

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

the class GeoJsonMergerTest method twoFeaturesAndAGeometry.

/**
 * Test if two geometries and a feature can be merged to a feature collection
 * @param context the Vert.x test context
 */
@Test
public void twoFeaturesAndAGeometry(TestContext context) {
    String strChunk1 = "{\"type\":\"Feature\"}";
    String strChunk2 = "{\"type\":\"Feature\",\"properties\":{}}";
    String strChunk3 = "{\"type\":\"Point\"}";
    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("Point", "geometries", 0, chunk3.length());
    doMerge(context, Observable.just(chunk1, chunk2, chunk3), Observable.just(cm1, cm2, cm3), "{\"type\":\"FeatureCollection\",\"features\":[" + strChunk1 + "," + strChunk2 + ",{\"type\":\"Feature\",\"geometry\":" + 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