Search in sources :

Example 1 with Iox2wkb

use of ch.interlis.iox_j.wkb.Iox2wkb in project ili2db by claeis.

the class Iox2gpkg method multicoord2wkb.

public Object multicoord2wkb(IomObject obj, int srsId) throws Iox2wkbException {
    if (obj == null) {
        return null;
    }
    try {
        os.reset();
        writeGeoPackageBinaryHeader(srsId, null);
        // wkb
        Iox2wkb helper = new Iox2wkb(outputDimension, os.order());
        os.write(helper.multicoord2wkb(obj));
    } catch (IOException e) {
        throw new RuntimeException("Unexpected IO exception: " + e.getMessage());
    }
    return os.toByteArray();
}
Also used : Iox2wkb(ch.interlis.iox_j.wkb.Iox2wkb) IOException(java.io.IOException)

Example 2 with Iox2wkb

use of ch.interlis.iox_j.wkb.Iox2wkb in project ili2db by claeis.

the class Iox2gpkg method polyline2wkb.

/**
 * Converts a POLYLINE to a JTS CoordinateList.
 * @param polylineObj INTERLIS POLYLINE structure
 * @param isSurfaceOrArea true if called as part of a SURFACE conversion.
 * @param p maximum stroke to use when removing ARCs
 * @return JTS CoordinateList
 * @throws Iox2wkbException
 */
public byte[] polyline2wkb(IomObject obj, boolean isSurfaceOrArea, boolean asCompoundCurve, double p, int srsId) throws Iox2wkbException {
    if (obj == null) {
        return null;
    }
    try {
        os.reset();
        CompoundCurve surface = Iox2jtsext.polyline2JTS(obj, false, p);
        writeGeoPackageBinaryHeader(srsId, surface.getEnvelopeInternal());
        // wkb
        Iox2wkb helper = new Iox2wkb(outputDimension, os.order());
        os.write(helper.polyline2wkb(obj, isSurfaceOrArea, 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 : CompoundCurve(ch.interlis.iom_j.itf.impl.jtsext.geom.CompoundCurve) Iox2wkb(ch.interlis.iox_j.wkb.Iox2wkb) IOException(java.io.IOException) IoxException(ch.interlis.iox.IoxException)

Example 3 with Iox2wkb

use of ch.interlis.iox_j.wkb.Iox2wkb in project ili2db by claeis.

the class Iox2gpkg method surface2wkb.

/**
 * Converts a SURFACE to a JTS Polygon.
 * @param obj INTERLIS SURFACE structure
 * @param strokeP maximum stroke to use when removing ARCs
 * @return JTS Polygon
 * @throws Iox2wkbException
 */
public byte[] surface2wkb(// SurfaceOrAreaType type)
IomObject obj, // SurfaceOrAreaType type)
boolean asCurvePolygon, // SurfaceOrAreaType type)
double strokeP, // SurfaceOrAreaType type)
int srsId) throws Iox2wkbException {
    if (obj == null) {
        return null;
    }
    try {
        os.reset();
        Polygon surface = Iox2jtsext.surface2JTS(obj, strokeP);
        writeGeoPackageBinaryHeader(srsId, surface.getEnvelopeInternal());
        // wkb
        Iox2wkb helper = new Iox2wkb(outputDimension, os.order());
        os.write(helper.surface2wkb(obj, asCurvePolygon, strokeP));
    } 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 : Iox2wkb(ch.interlis.iox_j.wkb.Iox2wkb) IOException(java.io.IOException) Polygon(com.vividsolutions.jts.geom.Polygon) IoxException(ch.interlis.iox.IoxException)

Example 4 with Iox2wkb

use of ch.interlis.iox_j.wkb.Iox2wkb in project ili2db by claeis.

the class Iox2gpkg method coord2wkb.

/**
 * Converts a COORD to a JTS Coordinate.
 * @param value INTERLIS COORD structure.
 * @return JTS Coordinate.
 * @throws Iox2wkbException
 */
public byte[] coord2wkb(IomObject obj, int srsId) throws Iox2wkbException {
    if (obj == null) {
        return null;
    }
    try {
        os.reset();
        writeGeoPackageBinaryHeader(srsId, null);
        // wkb
        Iox2wkb helper = new Iox2wkb(outputDimension, os.order());
        os.write(helper.coord2wkb(obj));
    } catch (IOException e) {
        throw new RuntimeException("Unexpected IO exception: " + e.getMessage());
    }
    return os.toByteArray();
}
Also used : Iox2wkb(ch.interlis.iox_j.wkb.Iox2wkb) IOException(java.io.IOException)

Example 5 with Iox2wkb

use of ch.interlis.iox_j.wkb.Iox2wkb in project ili2db by claeis.

the class Iox2gpkg method multisurface2wkb.

public byte[] multisurface2wkb(// SurfaceOrAreaType type)
IomObject obj, // SurfaceOrAreaType type)
boolean asCurvePolygon, // SurfaceOrAreaType type)
double strokeP, // SurfaceOrAreaType type)
int srsId) throws Iox2wkbException {
    if (obj == null) {
        return null;
    }
    try {
        os.reset();
        writeGeoPackageBinaryHeader(srsId, null);
        // wkb
        Iox2wkb helper = new Iox2wkb(outputDimension, os.order());
        os.write(helper.multisurface2wkb(obj, asCurvePolygon, strokeP));
    } catch (IOException e) {
        throw new RuntimeException("Unexpected IO exception: " + e.getMessage());
    }
    return os.toByteArray();
}
Also used : Iox2wkb(ch.interlis.iox_j.wkb.Iox2wkb) IOException(java.io.IOException)

Aggregations

Iox2wkb (ch.interlis.iox_j.wkb.Iox2wkb)6 IOException (java.io.IOException)6 IoxException (ch.interlis.iox.IoxException)3 CompoundCurve (ch.interlis.iom_j.itf.impl.jtsext.geom.CompoundCurve)2 IomObject (ch.interlis.iom.IomObject)1 Envelope (com.vividsolutions.jts.geom.Envelope)1 Polygon (com.vividsolutions.jts.geom.Polygon)1