public Geometry read(DataInput input) throws IOException { byte typeAndPrecision = input.readByte(); byte type = (byte) (typeAndPrecision & 0x0F); int basePrecision = TWKBUtils.zigZagDecode((typeAndPrecision & 0xF0) >> 4); byte metadata = input.readByte(); PrecisionReader precision; if ((metadata & TWKBUtils.EXTENDED_DIMENSIONS) != 0) { byte extendedDimensions = input.readByte(); precision = new ExtendedPrecisionReader(basePrecision, extendedDimensions); } else { precision = new PrecisionReader(basePrecision); } switch (type) { case TWKBUtils.POINT_TYPE: return readPoint(precision, metadata, input); case TWKBUtils.LINESTRING_TYPE: return readLineString(precision, metadata, input); case TWKBUtils.POLYGON_TYPE: return readPolygon(precision, metadata, input); case TWKBUtils.MULTIPOINT_TYPE: return readMultiPoint(precision, metadata, input); case TWKBUtils.MULTILINESTRING_TYPE: return readMultiLineString(precision, metadata, input); case TWKBUtils.MULTIPOLYGON_TYPE: return readMultiPolygon(precision, metadata, input); case TWKBUtils.GEOMETRYCOLLECTION_TYPE: return readGeometryCollection(input, metadata); } return null; }