Search in sources :

Example 6 with CompoundCurve

use of ch.interlis.iom_j.itf.impl.jtsext.geom.CompoundCurve in project ili2db by claeis.

the class Iox2fgdb method polyline2wkb.

public byte[] polyline2wkb(IomObject polylineObj, boolean isSurfaceOrArea, boolean asCompoundCurve, double p, int srsId) throws IoxException {
    if (polylineObj == null) {
        return null;
    }
    byte[] ret = null;
    CompoundCurve polyline = Iox2jtsext.polyline2JTS(polylineObj, false, p);
    os.reset();
    if (asCompoundCurve) {
        int shapeType = EsriShpConstants.ShapeGeneralPolyline;
        shapeType |= EsriShpConstants.shapeHasCurves;
        shapeType |= (outputDimension == 3 ? EsriShpConstants.shapeHasZs : 0);
        os.writeInt(shapeType);
    } else {
        if (outputDimension == 3) {
            os.writeInt(EsriShpConstants.ShapePolylineZ);
        } else {
            os.writeInt(EsriShpConstants.ShapePolyline);
        }
    }
    // boundingBox
    Envelope env = polyline.getEnvelopeInternal();
    os.writeDouble(env.getMinX());
    os.writeDouble(env.getMinY());
    os.writeDouble(env.getMaxX());
    os.writeDouble(env.getMaxY());
    // cParts The number of lines in the multiline.
    // cPoints The total number of points for all parts.
    int cPart = 1;
    int cPoints = getNumPoints(polyline);
    os.writeInt(cPart);
    os.writeInt(cPoints);
    int partStart = 0;
    os.writeInt(partStart);
    java.util.ArrayList<Arc> arcs = null;
    if (asCompoundCurve) {
        arcs = new java.util.ArrayList<Arc>();
    }
    java.util.ArrayList<Double> zv = null;
    if (outputDimension == 3) {
        zv = new java.util.ArrayList<Double>();
    }
    double[] zMin = new double[1];
    double[] zMax = new double[1];
    {
        Coordinate coord = polyline.getStartPoint().getCoordinate();
        if (outputDimension == 3) {
            zMin[0] = coord.z;
            zMax[0] = coord.z;
        }
    }
    int startPtIdx = 0;
    writePoints(polyline, false, zv, zMin, zMax, startPtIdx, arcs);
    if (outputDimension == 3) {
        // zMin
        os.writeDouble(zMin[0]);
        // zMax
        os.writeDouble(zMax[0]);
        // Zs[cPoints]
        for (Double z : zv) {
            os.writeDouble(z);
        }
    }
    if (asCompoundCurve) {
        writeArcs(arcs);
    }
    ret = os.toByteArray();
    return ret;
}
Also used : CompoundCurve(ch.interlis.iom_j.itf.impl.jtsext.geom.CompoundCurve) Coordinate(com.vividsolutions.jts.geom.Coordinate) Envelope(com.vividsolutions.jts.geom.Envelope)

Aggregations

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