mil.nga.sf.util.ByteReader Java Examples
The following examples show how to use
mil.nga.sf.util.ByteReader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GeoPackageGeometryData.java From geopackage-core-java with MIT License | 4 votes |
/** * Populate the geometry data from the bytes * * @param bytes * geometry bytes */ public void fromBytes(byte[] bytes) { this.bytes = bytes; ByteReader reader = new ByteReader(bytes); // Get 2 bytes as the magic number and validate String magic = null; try { magic = reader.readString(2); } catch (UnsupportedEncodingException e) { throw new GeoPackageException( "Unexpected GeoPackage Geometry magic number character encoding: Expected: " + GeoPackageConstants.GEOMETRY_MAGIC_NUMBER); } if (!magic .equals(GeoPackageConstants.GEOMETRY_MAGIC_NUMBER)) { throw new GeoPackageException( "Unexpected GeoPackage Geometry magic number: " + magic + ", Expected: " + GeoPackageConstants.GEOMETRY_MAGIC_NUMBER); } // Get a byte as the version and validate, value of 0 = version 1 byte version = reader.readByte(); if (version != GeoPackageConstants.GEOMETRY_VERSION_1) { throw new GeoPackageException( "Unexpected GeoPackage Geometry version: " + version + ", Expected: " + GeoPackageConstants.GEOMETRY_VERSION_1); } // Get a flags byte and then read the flag values byte flags = reader.readByte(); int envelopeIndicator = readFlags(flags); reader.setByteOrder(byteOrder); // Read the 5th - 8th bytes as the srs id srsId = reader.readInt(); // Read the envelope envelope = readEnvelope(envelopeIndicator, reader); // Save off where the WKB bytes start wkbGeometryIndex = reader.getNextByte(); // Read the Well-Known Binary Geometry if not marked as empty if (!empty) { geometry = GeometryReader.readGeometry(reader); } }