Package com.vividsolutions.jts.io

Examples of com.vividsolutions.jts.io.ByteOrderDataInStream


    public Geometry read(byte[] bytes) throws IOException {
        return read(new ByteArrayInStream(bytes));
    }

    public Geometry read(InStream is) throws IOException {
        ByteOrderDataInStream dis = new ByteOrderDataInStream(is);
        dis.setOrder(ByteOrderValues.LITTLE_ENDIAN);

        srid = dis.readInt();
        version = dis.readByte();
        serializationProps = dis.readByte();
        hasZ = (serializationProps & 1) == 1;
        hasM = (serializationProps & 2) == 2;
        singlePoint = (serializationProps & 8) == 8;
        singleLine = (serializationProps & 16) == 16;
        numberOfPoints = 1;
        if (singleLine) {
            numberOfPoints = 2;
        } else if (!singlePoint) {
            numberOfPoints = dis.readInt();
        }
        //dimensionalFlag = DimensionalFlag.XY;
        dimensionalFlag = DimensionalFlag.d2D;
        if (hasM) {
            if (hasZ) {
                //dimensionalFlag = DimensionalFlag.XYZM;
                dimensionalFlag = DimensionalFlag.d3DM;
            } else {
                //dimensionalFlag = DimensionalFlag.XYM;
                dimensionalFlag = DimensionalFlag.d2DM;
            }
        } else if (hasZ) {
            //dimensionalFlag = DimensionalFlag.XYZ;
            dimensionalFlag = DimensionalFlag.d3D;
        }

        // points
        points = readPoints(dis, numberOfPoints);
        if (hasZ) {
            zValues = readDoubles(dis, numberOfPoints);
        }
        if (hasM) {
            mValues = readDoubles(dis, numberOfPoints);
        }

        crsId = CrsId.valueOf(srid);
        if (singlePoint) {
            return createPoint(0);

        } else if (singleLine) {
            PointSequence points = createPoints(0, 2);
            return new LineString(points);

        } else {
            // figures
            int numberOfFigures = dis.readInt();
            figures = readFigures(dis, numberOfFigures);
            // shapes
            int numberOfShapes = dis.readInt();
            shapes = readShapes(dis, numberOfShapes);
            return decode(0);
        }
    }
View Full Code Here


    }
    ps = con.prepareStatement(GetWKBZTypes);
    rs = ps.executeQuery();
    rs.next();
    byte[] bytes = rs.getBytes(1);
    ByteOrderDataInStream dis = new ByteOrderDataInStream();
    dis.setInStream(new ByteArrayInStream(bytes));
    byte byteOrder = dis.readByte();
    // default is big endian
    if (byteOrder == WKBConstants.wkbNDR)
      dis.setOrder(ByteOrderValues.LITTLE_ENDIAN);

    int geometryType = dis.readInt();
    if (geometryType==1001)
        di.setHasOGCWkbZTyps(true);
    rs.close();
    ps.close();
    } catch (SQLException e) {
View Full Code Here

        // next byte flags
        h.flags = new Flags((byte)buf[3]);

        // set endianness
        ByteOrderDataInStream din = new ByteOrderDataInStream(in);
        din.setOrder(h.flags.getEndianess());

        // read the srid
        h.srid = din.readInt();

        // read the envlope
        if (h.flags.getEnvelopeIndicator() != EnvelopeType.NONE) {
            double x1 = din.readDouble();
            double x2 = din.readDouble();
            double y1 = din.readDouble();
            double y2 = din.readDouble();
   
            if (h.flags.getEnvelopeIndicator().value > 1) {
                // 2 = minz,maxz; 3 = minm,maxm - we ignore these for now
                din.readDouble();
                din.readDouble();
            }
   
            if (h.flags.getEnvelopeIndicator().value > 3) {
                // 4 = minz,maxz,minm,maxm - we ignore these for now
                din.readDouble();
                din.readDouble();
            }
   
            h.envelope = new Envelope(x1, x2, y1, y2);
        }
        return h;
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.io.ByteOrderDataInStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.