/* * WellKnownBinary.java * * Created on February 1, 2001, 3:39 PM */ package uk.ac.leeds.ccg.simplefeature; import java.io.*; import cmp.LEDataStream.*; /** * * @author jamesm * @version */ public class WellKnownBinary extends Object { private final static boolean DEBUG=true; Geometry geom; /** Creates new WellKnownBinary */ public WellKnownBinary() { } public WellKnownBinary(byte[] bytes){ if(DEBUG)System.out.println("---->uk.ac.leeds.ccg.simplefeature.WellKnownBinary constructed. will identify itself as WKB->"); if(DEBUG)System.out.println("WKB->Building from byte array"); try{ ByteArrayInputStream in = new ByteArrayInputStream(bytes); LEDataInputStream stream = new LEDataInputStream(in); byte order = stream.readByte(); stream.setLittleEndianMode(order==1); if(DEBUG)System.out.println("WKB->Byte order is "+order); int type = stream.readInt(); if(DEBUG)System.out.println("WKB->Feature type is "+type); switch(type){ case Geometry.wkbLineString: case Geometry.wkbMultiLineString: case Geometry.wkbGeometryCollection: case Geometry.wkbMultiPolygon: System.out.println("WKB->Shape type "+type+" not supported"); break; case Geometry.wkbMultiPoint: geom = new WKBMultiPoint(stream); break; case Geometry.wkbPoint: geom = new WKBPoint(stream); break; case Geometry.wkbPolygon: geom = new WKBPolygon(stream); } } catch(IOException e){ System.err.println("WKB-> "+e); } } public Geometry getGeometry(){ return geom; } }