Search in sources :

Example 21 with IoxException

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();
        }
    }
}
Also used : ResultSetMetaData(java.sql.ResultSetMetaData) SQLException(java.sql.SQLException) Config(ch.ehi.ili2db.gui.Config) ResultSet(java.sql.ResultSet) File(java.io.File) IoxException(ch.interlis.iox.IoxException) SQLException(java.sql.SQLException) IoxException(ch.interlis.iox.IoxException) Test(org.junit.Test)

Example 22 with IoxException

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();
        }
    }
}
Also used : SQLException(java.sql.SQLException) Config(ch.ehi.ili2db.gui.Config) File(java.io.File) IoxException(ch.interlis.iox.IoxException) Test(org.junit.Test)

Example 23 with IoxException

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();
}
Also used : IomObject(ch.interlis.iom.IomObject) CompoundCurve(ch.interlis.iom_j.itf.impl.jtsext.geom.CompoundCurve) Iox2wkb(ch.interlis.iox_j.wkb.Iox2wkb) IOException(java.io.IOException) Envelope(com.vividsolutions.jts.geom.Envelope) IoxException(ch.interlis.iox.IoxException)

Example 24 with IoxException

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);
    }
}
Also used : ConverterException(ch.ehi.ili2db.converter.ConverterException) ParseException(com.vividsolutions.jts.io.ParseException) IoxException(ch.interlis.iox.IoxException)

Example 25 with IoxException

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);
    }
}
Also used : ConverterException(ch.ehi.ili2db.converter.ConverterException) ParseException(com.vividsolutions.jts.io.ParseException) IoxException(ch.interlis.iox.IoxException)

Aggregations

IoxException (ch.interlis.iox.IoxException)32 File (java.io.File)16 Test (org.junit.Test)16 SQLException (java.sql.SQLException)15 Config (ch.ehi.ili2db.gui.Config)14 Connection (java.sql.Connection)13 IomObject (ch.interlis.iom.IomObject)12 HashMap (java.util.HashMap)9 Ili2dbException (ch.ehi.ili2db.base.Ili2dbException)8 XtfReader (ch.interlis.iom_j.xtf.XtfReader)8 EndBasketEvent (ch.interlis.iox.EndBasketEvent)8 EndTransferEvent (ch.interlis.iox.EndTransferEvent)8 IoxEvent (ch.interlis.iox.IoxEvent)8 StartTransferEvent (ch.interlis.iox.StartTransferEvent)8 ConverterException (ch.ehi.ili2db.converter.ConverterException)7 ObjectEvent (ch.interlis.iox.ObjectEvent)7 StartBasketEvent (ch.interlis.iox.StartBasketEvent)7 ResultSet (java.sql.ResultSet)6 ResultSetMetaData (java.sql.ResultSetMetaData)6 ParseException (com.vividsolutions.jts.io.ParseException)5