Search in sources :

Example 41 with InstanceCollection

use of eu.esdihumboldt.hale.common.instance.model.InstanceCollection in project hale by halestudio.

the class SurfaceGeometryTest method testSurfaceGml32_Grid.

/**
 * Test surface geometries read from a GML 3.2 file. Geometry coordinates
 * will be moved to the universal grid
 *
 * @throws Exception if an error occurs
 */
@Test
public void testSurfaceGml32_Grid() throws Exception {
    InstanceCollection instances = AbstractHandlerTest.loadXMLInstances(getClass().getResource("/data/gml/geom-gml32.xsd").toURI(), getClass().getResource("/data/surface/sample-surface-gml32.xml").toURI(), gridConfig);
    // one instance expected
    ResourceIterator<Instance> it = instances.iterator();
    try {
        // PolygonPatch with LinearRings defined through coordinates
        assertTrue("First sample feature missing", it.hasNext());
        Instance instance = it.next();
        checkSingleGeometry(instance, gridChecker);
    } finally {
        it.close();
    }
}
Also used : Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) Test(org.junit.Test) AbstractHandlerTest(eu.esdihumboldt.hale.io.gml.geometry.handler.internal.AbstractHandlerTest)

Example 42 with InstanceCollection

use of eu.esdihumboldt.hale.common.instance.model.InstanceCollection in project hale by halestudio.

the class SurfaceGeometryTest method testSurfaceGml3_Grid.

/**
 * Test surface geometries read from a GML 3 file. Geometry coordinates will
 * be moved to the universal grid
 *
 * @throws Exception if an error occurs
 */
@Test
public void testSurfaceGml3_Grid() throws Exception {
    InstanceCollection instances = AbstractHandlerTest.loadXMLInstances(getClass().getResource("/data/gml/geom-gml3.xsd").toURI(), getClass().getResource("/data/surface/sample-surface-gml3.xml").toURI(), gridConfig);
    // one instance expected
    ResourceIterator<Instance> it = instances.iterator();
    try {
        // PolygonPatch with LinearRings defined through coordinates
        assertTrue("First sample feature missing", it.hasNext());
        Instance instance = it.next();
        checkSingleGeometry(instance, gridChecker);
    } finally {
        it.close();
    }
}
Also used : Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) Test(org.junit.Test) AbstractHandlerTest(eu.esdihumboldt.hale.io.gml.geometry.handler.internal.AbstractHandlerTest)

Example 43 with InstanceCollection

use of eu.esdihumboldt.hale.common.instance.model.InstanceCollection in project hale by halestudio.

the class SurfaceGeometryTest method testSurfaceGml32.

/**
 * Test surface geometries read from a GML 3.2 file
 *
 * @throws Exception if an error occurs
 */
@Test
public void testSurfaceGml32() throws Exception {
    InstanceCollection instances = AbstractHandlerTest.loadXMLInstances(getClass().getResource("/data/gml/geom-gml32.xsd").toURI(), getClass().getResource("/data/surface/sample-surface-gml32.xml").toURI());
    // one instance expected
    ResourceIterator<Instance> it = instances.iterator();
    try {
        // PolygonPatch with LinearRings defined through coordinates
        assertTrue("First sample feature missing", it.hasNext());
        Instance instance = it.next();
        checkSingleGeometry(instance, checker);
    } finally {
        it.close();
    }
}
Also used : Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) Test(org.junit.Test) AbstractHandlerTest(eu.esdihumboldt.hale.io.gml.geometry.handler.internal.AbstractHandlerTest)

Example 44 with InstanceCollection

use of eu.esdihumboldt.hale.common.instance.model.InstanceCollection in project hale by halestudio.

the class SurfaceGeometryTest method testSurfaceArcsGml32_grid.

/**
 * Test surface geometries read from a GML 3.2 file
 *
 * @throws Exception if an error occurs
 */
@Stories("Arcs")
@Test
public void testSurfaceArcsGml32_grid() throws Exception {
    InstanceCollection instances = AbstractHandlerTest.loadXMLInstances(getClass().getResource("/data/gml/geom-gml32.xsd").toURI(), getClass().getResource("/data/surface/sample-surface-arcs.xml").toURI(), gridConfig);
    // three instance expected
    ResourceIterator<Instance> it = instances.iterator();
    try {
        List<GeometryProperty<?>> geoms = new ArrayList<>();
        assertTrue("First sample feature missing", it.hasNext());
        Instance instance1 = it.next();
        geoms.addAll(checkSingleGeometry(instance1, null));
        assertTrue("Second sample feature missing", it.hasNext());
        Instance instance2 = it.next();
        geoms.addAll(checkSingleGeometry(instance2, null));
        assertTrue("Third sample feature missing", it.hasNext());
        Instance instance3 = it.next();
        geoms.addAll(checkSingleGeometry(instance3, null));
        assertEquals("Unexpected number of geometries", 3, geoms.size());
        Geometry geom1 = geoms.get(0).getGeometry();
        Geometry geom2 = geoms.get(1).getGeometry();
        Geometry geom3 = geoms.get(2).getGeometry();
        Envelope envelope = new Envelope();
        envelope.expandToInclude(geom1.getEnvelopeInternal());
        envelope.expandToInclude(geom2.getEnvelopeInternal());
        envelope.expandToInclude(geom3.getEnvelopeInternal());
        PaintSettings settings = new PaintSettings(envelope, 1000, 10);
        SVGPainter svg = new SVGPainter(settings);
        svg.setColor(Color.BLACK);
        svg.drawGeometry(geom1);
        svg.setColor(Color.BLUE);
        svg.drawGeometry(geom2);
        svg.setColor(Color.RED);
        svg.drawGeometry(geom3);
        saveDrawing(svg);
        // ensure that polygons could be created
        assertTrue(Polygon.class.isAssignableFrom(geom1.getClass()));
        assertTrue(Polygon.class.isAssignableFrom(geom2.getClass()));
        assertTrue(Polygon.class.isAssignableFrom(geom3.getClass()));
    // XXX how to test?
    // assertTrue("Geometries intersect", geom1.touches(geom2));
    // assertTrue("Geometries intersect", geom2.touches(geom3));
    } finally {
        it.close();
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryProperty(eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty) SVGPainter(eu.esdihumboldt.util.svg.test.SVGPainter) Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) ArrayList(java.util.ArrayList) Envelope(com.vividsolutions.jts.geom.Envelope) PaintSettings(eu.esdihumboldt.util.svg.test.PaintSettings) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Test(org.junit.Test) AbstractHandlerTest(eu.esdihumboldt.hale.io.gml.geometry.handler.internal.AbstractHandlerTest) Stories(ru.yandex.qatools.allure.annotations.Stories)

Example 45 with InstanceCollection

use of eu.esdihumboldt.hale.common.instance.model.InstanceCollection in project hale by halestudio.

the class SurfaceGeometryTest method testSurfaceArcsGml32.

/**
 * Test surface geometries read from a GML 3.2 file
 *
 * @throws Exception if an error occurs
 */
@Stories("Arcs")
@Test
public void testSurfaceArcsGml32() throws Exception {
    InstanceCollection instances = AbstractHandlerTest.loadXMLInstances(getClass().getResource("/data/gml/geom-gml32.xsd").toURI(), getClass().getResource("/data/surface/sample-surface-arcs.xml").toURI(), InterpolationConfigurations.segment(maxPositionalError));
    // three instance expected
    ResourceIterator<Instance> it = instances.iterator();
    try {
        List<GeometryProperty<?>> geoms = new ArrayList<>();
        assertTrue("First sample feature missing", it.hasNext());
        Instance instance1 = it.next();
        geoms.addAll(checkSingleGeometry(instance1, null));
        assertTrue("Second sample feature missing", it.hasNext());
        Instance instance2 = it.next();
        geoms.addAll(checkSingleGeometry(instance2, null));
        assertTrue("Third sample feature missing", it.hasNext());
        Instance instance3 = it.next();
        geoms.addAll(checkSingleGeometry(instance3, null));
        assertEquals("Unexpected number of geometries", 3, geoms.size());
        Geometry geom1 = geoms.get(0).getGeometry();
        Geometry geom2 = geoms.get(1).getGeometry();
        Geometry geom3 = geoms.get(2).getGeometry();
        Envelope envelope = new Envelope();
        envelope.expandToInclude(geom1.getEnvelopeInternal());
        envelope.expandToInclude(geom2.getEnvelopeInternal());
        envelope.expandToInclude(geom3.getEnvelopeInternal());
        PaintSettings settings = new PaintSettings(envelope, 1000, 10);
        SVGPainter svg = new SVGPainter(settings);
        svg.setColor(Color.BLACK);
        svg.drawGeometry(geom1);
        svg.setColor(Color.BLUE);
        svg.drawGeometry(geom2);
        svg.setColor(Color.RED);
        svg.drawGeometry(geom3);
        saveDrawing(svg);
        // ensure that polygons could be created
        assertTrue(Polygon.class.isAssignableFrom(geom1.getClass()));
        assertTrue(Polygon.class.isAssignableFrom(geom2.getClass()));
        assertTrue(Polygon.class.isAssignableFrom(geom3.getClass()));
    // XXX how to test?
    // intersection area cannot be computed
    // double interArea1 = geom1.intersection(geom2).getArea();
    // double interArea2 = geom2.intersection(geom3).getArea();
    } finally {
        it.close();
    }
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) GeometryProperty(eu.esdihumboldt.hale.common.schema.geometry.GeometryProperty) SVGPainter(eu.esdihumboldt.util.svg.test.SVGPainter) Instance(eu.esdihumboldt.hale.common.instance.model.Instance) InstanceCollection(eu.esdihumboldt.hale.common.instance.model.InstanceCollection) ArrayList(java.util.ArrayList) Envelope(com.vividsolutions.jts.geom.Envelope) PaintSettings(eu.esdihumboldt.util.svg.test.PaintSettings) MultiPolygon(com.vividsolutions.jts.geom.MultiPolygon) Polygon(com.vividsolutions.jts.geom.Polygon) Test(org.junit.Test) AbstractHandlerTest(eu.esdihumboldt.hale.io.gml.geometry.handler.internal.AbstractHandlerTest) Stories(ru.yandex.qatools.allure.annotations.Stories)

Aggregations

InstanceCollection (eu.esdihumboldt.hale.common.instance.model.InstanceCollection)151 Instance (eu.esdihumboldt.hale.common.instance.model.Instance)131 Test (org.junit.Test)116 AbstractHandlerTest (eu.esdihumboldt.hale.io.gml.geometry.handler.internal.AbstractHandlerTest)97 Schema (eu.esdihumboldt.hale.common.schema.model.Schema)17 TypeDefinition (eu.esdihumboldt.hale.common.schema.model.TypeDefinition)17 DefaultInstance (eu.esdihumboldt.hale.common.instance.model.impl.DefaultInstance)11 ArrayList (java.util.ArrayList)10 Geometry (com.vividsolutions.jts.geom.Geometry)9 MutableInstance (eu.esdihumboldt.hale.common.instance.model.MutableInstance)9 IOException (java.io.IOException)9 MultiPolygon (com.vividsolutions.jts.geom.MultiPolygon)8 Polygon (com.vividsolutions.jts.geom.Polygon)8 QName (javax.xml.namespace.QName)8 Coordinate (com.vividsolutions.jts.geom.Coordinate)7 IOReport (eu.esdihumboldt.hale.common.core.io.report.IOReport)7 DefaultInstanceCollection (eu.esdihumboldt.hale.common.instance.model.impl.DefaultInstanceCollection)7 IOProviderConfigurationException (eu.esdihumboldt.hale.common.core.io.IOProviderConfigurationException)6 IOMessageImpl (eu.esdihumboldt.hale.common.core.io.report.impl.IOMessageImpl)6 TypeFilter (eu.esdihumboldt.hale.common.instance.model.TypeFilter)6