}
}
private static void load() throws Exception
{
SpatialDatabaseService spatialService = new SpatialDatabaseService( db );
try (Transaction tx = db.beginTx()) {
loadTestOsmData( "two-street.osm", 100 );
osmLayer = spatialService.getLayer( "two-street.osm" );
boxesLayer = (EditableLayerImpl) spatialService.getOrCreateEditableLayer( "boxes" );
boxesLayer.setExtraPropertyNames( new String[] { "name" } );
boxesLayer.setCoordinateReferenceSystem(DefaultEngineeringCRS.GENERIC_2D);
WKTReader reader = new WKTReader( boxesLayer.getGeometryFactory() );
boxesLayer.add(
reader.read( "POLYGON ((12 26, 12 27, 13 27, 13 26, 12 26))" ),
new String[] { "name" }, new Object[] { "A" } );
boxesLayer.add( reader.read( "POLYGON ((2 3, 2 5, 6 5, 6 3, 2 3))" ),
new String[] { "name" }, new Object[] { "B" } );
concaveLayer = (EditableLayerImpl) spatialService.getOrCreateEditableLayer( "concave" );
concaveLayer.setCoordinateReferenceSystem(DefaultEngineeringCRS.GENERIC_2D);
reader = new WKTReader( concaveLayer.getGeometryFactory() );
concaveLayer.add( reader.read( "POLYGON ((0 0, 2 5, 0 10, 10 10, 10 0, 0 0))" ) );
intersectionLayer = (EditableLayerImpl) spatialService.getOrCreateEditableLayer( "intersection" );
intersectionLayer.setCoordinateReferenceSystem(DefaultEngineeringCRS.GENERIC_2D);
reader = new WKTReader( intersectionLayer.getGeometryFactory() );
intersectionLayer.add( reader.read( "POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))" ) );
intersectionLayer.add( reader.read( "POLYGON ((4 4, 4 10, 10 10, 10 4, 4 4))" ) );
intersectionLayer.add( reader.read( "POLYGON ((2 2, 2 6, 6 6, 6 2, 2 2))" ) );
equalLayer = (EditableLayerImpl) spatialService.getOrCreateEditableLayer( "equal" );
equalLayer.setExtraPropertyNames( new String[] { "id", "name" } );
equalLayer.setCoordinateReferenceSystem(DefaultEngineeringCRS.GENERIC_2D);
reader = new WKTReader( intersectionLayer.getGeometryFactory() );
equalLayer.add( reader.read( "POLYGON ((0 0, 0 5, 5 5, 5 0, 0 0))" ),
new String[] { "id", "name" }, new Object[] { 1, "equal" } );
equalLayer.add( reader.read( "POLYGON ((0 0, 0.1 5, 5 5, 5 0, 0 0))" ),
new String[] { "id", "name" }, new Object[] { 2, "tolerance" } );
equalLayer.add( reader.read( "POLYGON ((0 5, 5 5, 5 0, 0 0, 0 5))" ),
new String[] { "id", "name" }, new Object[] { 3,
"different order" } );
equalLayer.add(
reader.read( "POLYGON ((0 0, 0 2, 0 4, 0 5, 5 5, 5 3, 5 2, 5 0, 0 0))" ),
new String[] { "id", "name" }, new Object[] { 4, "topo equal" } );
linesLayer = (EditableLayerImpl) spatialService.getOrCreateEditableLayer( "lines" );
linesLayer.setCoordinateReferenceSystem(DefaultEngineeringCRS.GENERIC_2D);
reader = new WKTReader( intersectionLayer.getGeometryFactory() );
linesLayer.add( reader.read( "LINESTRING (12 26, 15 27, 18 32, 20 38, 23 34)" ) );
tx.success();