use of ch.interlis.iox.IoxException in project ili2db by claeis.
the class Datatypes23Test method importXtfSurface.
@Test
public void importXtfSurface() throws Exception {
try {
Class driverClass = Class.forName("org.postgresql.Driver");
jdbcConnection = DriverManager.getConnection(dburl, dbuser, dbpwd);
stmt = jdbcConnection.createStatement();
stmt.execute("DROP SCHEMA IF EXISTS " + DBSCHEMA + " CASCADE");
File data = new File(TEST_OUT + "Datatypes23Surface.xtf");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setFunction(Config.FC_IMPORT);
config.setCreateFk(config.CREATE_FK_YES);
config.setCreateNumChecks(true);
config.setTidHandling(Config.TID_HANDLING_PROPERTY);
config.setBasketHandling(config.BASKET_HANDLING_READWRITE);
config.setCatalogueRefTrafo(null);
config.setMultiSurfaceTrafo(null);
config.setMultilingualTrafo(null);
config.setInheritanceTrafo(null);
// Ili2db.readSettingsFromDb(config);
try {
Ili2db.run(config, null);
} catch (Exception ex) {
EhiLogger.logError(ex);
Assert.fail();
}
// imported surface
{
ResultSet rs = stmt.executeQuery("SELECT st_asewkt(surfacearcs2d) FROM datatypes23.surface2 WHERE t_ili_tid = 'Surface2.0';");
ResultSetMetaData rsmd = rs.getMetaData();
assertEquals(1, rsmd.getColumnCount());
while (rs.next()) {
assertEquals(null, rs.getObject(1));
}
}
{
ResultSet rs = stmt.executeQuery("SELECT st_asewkt(surfacearcs2d) FROM datatypes23.surface2 WHERE t_ili_tid = 'Surface2.1';");
ResultSetMetaData rsmd = rs.getMetaData();
assertEquals(1, rsmd.getColumnCount());
while (rs.next()) {
// 2460001 1045001
assertEquals("SRID=21781;CURVEPOLYGON(COMPOUNDCURVE((2460001 1045001,2460020 1045015),CIRCULARSTRING(2460020 1045015,2460010 1045018,2460001 1045015),(2460001 1045015,2460001 1045001)),COMPOUNDCURVE((2460005 1045005,2460010 1045010),CIRCULARSTRING(2460010 1045010,2460007 1045009,2460005 1045010),(2460005 1045010,2460005 1045005)))", rs.getObject(1));
}
}
{
ResultSet rs = stmt.executeQuery("SELECT st_asewkt(surface2d) FROM datatypes23.simplesurface2 WHERE t_ili_tid = 'SimpleSurface2.0';");
ResultSetMetaData rsmd = rs.getMetaData();
assertEquals(1, rsmd.getColumnCount());
while (rs.next()) {
assertEquals(null, rs.getObject(1));
}
}
{
ResultSet rs = stmt.executeQuery("SELECT st_asewkt(surface2d) FROM datatypes23.simplesurface2 WHERE t_ili_tid = 'SimpleSurface2.1';");
ResultSetMetaData rsmd = rs.getMetaData();
assertEquals(1, rsmd.getColumnCount());
while (rs.next()) {
assertEquals("SRID=21781;CURVEPOLYGON(COMPOUNDCURVE((2460005 1045005,2460010 1045010,2460005 1045010,2460005 1045005)))", rs.getObject(1));
}
}
{
ResultSet rs = stmt.executeQuery("SELECT st_asewkt(surface2d) FROM datatypes23.simplesurface2 WHERE t_ili_tid = 'SimpleSurface2.2';");
ResultSetMetaData rsmd = rs.getMetaData();
assertEquals(1, rsmd.getColumnCount());
while (rs.next()) {
assertEquals("SRID=21781;CURVEPOLYGON(COMPOUNDCURVE((2460001 1045001,2460020 1045015,2460001 1045015,2460001 1045001)),COMPOUNDCURVE((2460005 1045005,2460010 1045010,2460005 1045010,2460005 1045005)))", rs.getObject(1));
}
}
{
ResultSet rs = stmt.executeQuery("SELECT st_asewkt(surface2d) FROM datatypes23.simplesurface2 WHERE t_ili_tid = 'SimpleSurface2.3';");
ResultSetMetaData rsmd = rs.getMetaData();
assertEquals(1, rsmd.getColumnCount());
while (rs.next()) {
assertEquals("SRID=21781;CURVEPOLYGON(COMPOUNDCURVE((2460005 1045005,2460010 1045010,2460005 1045010,2460005 1045005)))", rs.getObject(1));
}
}
} catch (SQLException e) {
throw new IoxException(e);
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
use of ch.interlis.iox.IoxException in project ili2db by claeis.
the class Datatypes23Test method importIli.
@Test
public void importIli() throws Exception {
try {
Class driverClass = Class.forName("org.postgresql.Driver");
jdbcConnection = DriverManager.getConnection(dburl, dbuser, dbpwd);
stmt = jdbcConnection.createStatement();
stmt.execute("DROP SCHEMA IF EXISTS " + DBSCHEMA + " CASCADE");
File data = new File(TEST_OUT + "Datatypes23.ili");
Config config = initConfig(data.getPath(), DBSCHEMA, data.getPath() + ".log");
config.setFunction(Config.FC_SCHEMAIMPORT);
config.setCreateFk(config.CREATE_FK_YES);
config.setCreateNumChecks(true);
config.setTidHandling(Config.TID_HANDLING_PROPERTY);
config.setBasketHandling(config.BASKET_HANDLING_READWRITE);
config.setCatalogueRefTrafo(null);
config.setMultiSurfaceTrafo(null);
config.setMultilingualTrafo(null);
config.setInheritanceTrafo(null);
// Ili2db.readSettingsFromDb(config);
Ili2db.run(config, null);
} catch (SQLException e) {
throw new IoxException(e);
} finally {
if (jdbcConnection != null) {
jdbcConnection.close();
}
}
}
use of ch.interlis.iox.IoxException in project ili2db by claeis.
the class Iox2gpkg method multiline2wkb.
public byte[] multiline2wkb(IomObject obj, boolean asCompoundCurve, double p, int srsId) throws Iox2wkbException {
if (obj == null) {
return null;
}
try {
os.reset();
int polylinec = obj.getattrvaluecount(Wkb2iox.ATTR_POLYLINE);
Envelope env = new Envelope();
for (int polylinei = 0; polylinei < polylinec; polylinei++) {
IomObject polyline = obj.getattrobj(Wkb2iox.ATTR_POLYLINE, polylinei);
CompoundCurve curve = Iox2jtsext.polyline2JTS(polyline, false, p);
env.expandToInclude(curve.getEnvelopeInternal());
}
writeGeoPackageBinaryHeader(srsId, env);
Iox2wkb helper = new Iox2wkb(outputDimension, os.order());
for (int polylinei = 0; polylinei < polylinec; polylinei++) {
IomObject polyline = obj.getattrobj(Wkb2iox.ATTR_POLYLINE, polylinei);
os.write(helper.polyline2wkb(polyline, false, asCompoundCurve, p));
}
} catch (IOException e) {
throw new RuntimeException("Unexpected IO exception: " + e.getMessage());
} catch (IoxException e) {
throw new RuntimeException("Unexpected exception: " + e.getMessage());
}
return os.toByteArray();
}
use of ch.interlis.iox.IoxException in project ili2db by claeis.
the class FgdbColumnConverter method toIomMultiSurface.
@Override
public IomObject toIomMultiSurface(Object geomobj, String sqlAttrName, boolean is3D) throws SQLException, ConverterException {
byte[] bv = (byte[]) geomobj;
Fgdb2iox conv = new Fgdb2iox();
try {
return conv.read(bv);
} catch (ParseException e) {
throw new ConverterException(e);
} catch (IoxException e) {
throw new ConverterException(e);
}
}
use of ch.interlis.iox.IoxException in project ili2db by claeis.
the class FgdbColumnConverter method toIomCoord.
@Override
public IomObject toIomCoord(Object geomobj, String sqlAttrName, boolean is3D) throws SQLException, ConverterException {
byte[] bv = (byte[]) geomobj;
Fgdb2iox conv = new Fgdb2iox();
try {
return conv.read(bv);
} catch (ParseException e) {
throw new ConverterException(e);
} catch (IoxException e) {
throw new ConverterException(e);
}
}
Aggregations