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();
}
}
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();
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations