throw new MapyrusException(MapyrusMessages.get(MapyrusMessages.INVALID_OGC_WKB));
{ throw new MapyrusException(MapyrusMessages.get(MapyrusMessages.INVALID_OGC_WKB) + ": " + convertToHexDigits(order, byteBuffer)); }
	private static int parseGeometry(ByteBuffer byteBuffer,		double []geometry, int geometryIndex) throws MapyrusException	{		int index = geometryIndex;		int nPoints, nLines, nRings, nPolygons, nGeometries;		/*		 * Parse byte order of this geometry.		 */		byte order = byteBuffer.get();		if (order == BIG_ENDIAN)			byteBuffer.order(ByteOrder.BIG_ENDIAN);		else if (order == LITTLE_ENDIAN)			byteBuffer.order(ByteOrder.LITTLE_ENDIAN);		else			throw new MapyrusException(MapyrusMessages.get(MapyrusMessages.INVALID_OGC_WKB));		/*		 * Find type of geometry in buffer, then extract it from buffer.		 */		int wkbType = byteBuffer.getInt();		if (wkbType == WKB_POINT)		{			geometry[index++] = Argument.GEOMETRY_POINT;			geometry[index++] = 1;			geometry[index++] = Argument.MOVETO;			geometry[index++] = byteBuffer.getDouble();			geometry[index++] = byteBuffer.getDouble();		}		else if (wkbType == WKB_LINESTRING)		{			geometry[index++] = Argument.GEOMETRY_LINESTRING;			geometry[index++] = nPoints = byteBuffer.getInt();			int operation = Argument.MOVETO;			for (int i = 0; i < nPoints; i++)			{				geometry[index++] = operation;				geometry[index++] = byteBuffer.getDouble();				geometry[index++] = byteBuffer.getDouble();				operation = Argument.LINETO;			}		}		else if (wkbType == WKB_POLYGON)		{			geometry[index++] = Argument.GEOMETRY_POLYGON;			int nPointsIndex = index++;			int totalPoints = 0;			nRings = byteBuffer.getInt();			for (int j = 0; j < nRings; j++)			{				nPoints = byteBuffer.getInt();				totalPoints += nPoints;				int operation = Argument.MOVETO;				for (int i = 0; i < nPoints; i++)				{					geometry[index++] = operation;					geometry[index++] = byteBuffer.getDouble();					geometry[index++] = byteBuffer.getDouble();					operation = Argument.LINETO;				}			}			geometry[nPointsIndex] = totalPoints;		}		else if (wkbType == WKB_MULTIPOINT)		{			geometry[index++] = Argument.GEOMETRY_MULTIPOINT;			geometry[index++] = nPoints = byteBuffer.getInt();			for (int i = 0; i < nPoints; i++)			{				int nEls = parseGeometry(byteBuffer, geometry, index);				index += nEls;			}		}		else if (wkbType == WKB_MULTILINESTRING)		{			geometry[index++] = Argument.GEOMETRY_MULTILINESTRING;			geometry[index++] = nLines = byteBuffer.getInt();			for (int i = 0; i < nLines; i++)			{				int nEls = parseGeometry(byteBuffer, geometry, index);				index += nEls;			}		}		else if (wkbType == WKB_MULTIPOLYGON)		{			geometry[index++] = Argument.GEOMETRY_MULTIPOLYGON;			geometry[index++] = nPolygons = byteBuffer.getInt();			for (int i = 0; i < nPolygons; i++)			{				int nEls = parseGeometry(byteBuffer, geometry, index);				index += nEls;			}		}		else if (wkbType == WKB_GEOMETRY_COLLECTION)		{			geometry[index++] = Argument.GEOMETRY_COLLECTION;			geometry[index++] = nGeometries = byteBuffer.getInt();			for (int i = 0; i < nGeometries; i++)			{				int nEls = parseGeometry(byteBuffer, geometry, index);				index += nEls;			}		}		else		{			throw new MapyrusException(MapyrusMessages.get(MapyrusMessages.INVALID_OGC_WKB));		}		/*		 * Return number of slots filled by this geometry.		 */		return(index - geometryIndex);	}