现在的代码,全部粘进去把,改了点名字

package routingtile;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.HashMap;

public class TestMain {       
	    private static RoutingTileHeader header = new RoutingTileHeader();		
	    private static SimpleIntersectionList simpleIntersection = new SimpleIntersectionList();
		private static LinkList link = new LinkList();
		private static Readblom rb;
		//创建一个指针
		private static int pointer;
		
		public static void main(String[] agrs)throws Exception{
				//header赋值
				routingTileHeader();
				//调用交叉点方法
				simpleIntersection();
				//调用link方法
				link();
		}
		/**
		 * link方法,返回LinkList
		 * @throws IOException
		 */
		public static LinkList link() throws IOException{
		    //获取二进制文件
			StringBuilder strB = HexFinder.readData();
			//创建一个mp用于接收返回值
			HashMap<String, Integer> mp;
		    //初始化LinksOffset指针位置
			HexFinder.initialize(header.getLinksOffset());
			//numLinks
			LinkList linkList = new LinkList();
			mp = HexFinder.dicedall(16,pointer, strB);
			pointer = mp.get("pointer");
			int numnumLinks = mp.get("value");
			linkList.setNumnumLinks(numnumLinks);
			System.out.println("numLinks:" + linkList.getNumnumLinks());
			
			ArrayList<Link> links = new ArrayList<Link>();
			

			return link;
		}
		/**
		 * simpleIntersection方法,返回SimpleIntersectionList
		 * @throws IOException
		 */
		public static SimpleIntersectionList simpleIntersection() throws IOException{
			//获取二进制文件
			StringBuilder strB = HexFinder.readData();
			//创建一个mp用于接收返回值
			HashMap<String, Integer> mp;
			//初始化SimpleIntersectionOffset指针位置
			HexFinder.initialize(header.getSimpleIntersectionOffset());
			//numIntersections
			SimpleIntersectionList numIntersectionList = new SimpleIntersectionList();
			mp = HexFinder.dicedall(16,pointer, strB);
			pointer = mp.get("pointer");
			int numIntersection = mp.get("value");
			numIntersectionList.setNumIntersections(numIntersection);
			System.out.println(numIntersectionList.getNumIntersections());
			
			ArrayList<SimpleIntersection> simpleIntersections =new ArrayList<SimpleIntersection>();
			for(int i = 0; i<simpleIntersection.getNumIntersections(); i++) 
			{   
				// 放到CoordXYOffset对象中
				CoordXYOffset coordXYOffset = new CoordXYOffset();
				SimpleIntersection sIntersection = new SimpleIntersection();
				
				mp = HexFinder.dicedall(14,pointer, strB);
				pointer = mp.get("pointer");
				int dx = mp.get("value");
				if (14 < 64 && (dx & (1L << (14-1))) != 0) {
					dx |= (-1L << 14);
				}
				
				mp = HexFinder.dicedall(14,pointer, strB);
				pointer = mp.get("pointer");
				int dy = mp.get("value");
				if (14 < 64 && (dy & (1L << (14-1))) != 0) {
					dy |= (-1L << 14);
				}
				
				coordXYOffset.setDx(dx);
				coordXYOffset.setDy(dy);

				mp = HexFinder.dicedall(8,pointer, strB);
				pointer = mp.get("pointer");
				int numLinks = mp.get("value");

				sIntersection.setNumLinks(numLinks);
				sIntersection.setPosition(coordXYOffset);

				ArrayList<IntOrExtDirectedLinkReference> connectedLinks = new ArrayList<IntOrExtDirectedLinkReference>();
				for(int n = 0; n<sIntersection.getNumLinks(); n++) 
				{   
					DirectedLinkReference dLR= new DirectedLinkReference();
					ExternalDirectedLinkReference eDLR = new ExternalDirectedLinkReference();
					IntOrExtDirectedLinkReference iEDLR = new IntOrExtDirectedLinkReference();
					LinkReferenceChoice choice = new LinkReferenceChoice();

					mp = HexFinder.dicedall(1,pointer, strB);
					pointer = mp.get("pointer");
					int isExternalLinkReference = mp.get("value");					

					//IsExternalLinkReference等于false时
					if(isExternalLinkReference==0){
						iEDLR.setIsExternalLinkReference(false);

						mp = HexFinder.dicedall(1,pointer, strB);
						pointer = mp.get("pointer");

						boolean positiveLinkDirection;	
						if(mp.get("value") == 1){
							positiveLinkDirection = true;
						}else{
							positiveLinkDirection = false;
						}
						dLR.setPositiveLinkDirection(positiveLinkDirection);
						mp = HexFinder.dicedall(15,pointer, strB);
						pointer = mp.get("pointer");
						int linkId = mp.get("value");

						dLR.setLinkId(linkId);
						choice.setInternalLinkReference(dLR);
						choice.setExternalLinkReference(eDLR);
						iEDLR.setLinkReferenceChoice(choice);
						connectedLinks.add(iEDLR);	
					}else{       //true
						iEDLR.setIsExternalLinkReference(true);
						
						mp = HexFinder.dicedall(8,pointer, strB);
						pointer = mp.get("pointer");
						int extTileIdx = mp.get("value");

						mp = HexFinder.dicedall(1,pointer, strB);
						pointer = mp.get("pointer");
						boolean positiveLinkDirection;
						if(mp.get("value") == 1){
							positiveLinkDirection = true;
						}else{
							positiveLinkDirection = false;
						}
						dLR.setPositiveLinkDirection(positiveLinkDirection);
						
						mp = HexFinder.dicedall(15,pointer, strB);
						pointer = mp.get("pointer");
						int linkId = mp.get("value");

						dLR.setLinkId(linkId);
						eDLR.setTileExternalLinkReference(dLR);
						eDLR.setExtTileIdx(extTileIdx);
						eDLR.setTileExternalLinkReference(dLR);
						choice.setInternalLinkReference(dLR);
						choice.setExternalLinkReference(eDLR);
						iEDLR.setLinkReferenceChoice(choice);
						connectedLinks.add(iEDLR);
					}
				}
				sIntersection.setConnectedLinks(connectedLinks);
				simpleIntersections.add(sIntersection);
			}
			simpleIntersection.setSimpleIntersection(simpleIntersections);
			//输出所有值
			/*for (SimpleIntersection Intersection : simpleIntersections) {
			     System.out.println("\n"+"dx:" + Intersection.getPosition().getDx());
			     System.out.println("dy:" + Intersection.getPosition().getDy());
			     System.out.println("numLinks:" + Intersection.getNumLinks());
			     for (IntOrExtDirectedLinkReference Intorextdirectedlinkreference: Intersection.getConnectedLinks() ) {
			      System.out.println("isExternalLinkReference:" + Intorextdirectedlinkreference.getIsExternalLinkReference());
			      if (Intorextdirectedlinkreference.getIsExternalLinkReference()) {
			       System.out.println("extTileIdx:" + Intorextdirectedlinkreference.getLinkReferenceChoice().getExternalLinkReference().getExtTileIdx());
			       System.out.println("positiveLinkDirection:" + Intorextdirectedlinkreference.getLinkReferenceChoice().getExternalLinkReference().getTileExternalLinkReference().getPositiveLinkDirection());
			       System.out.println("LinkId:" + Intorextdirectedlinkreference.getLinkReferenceChoice().getExternalLinkReference().getTileExternalLinkReference().getLinkId());
			      }else {
			    	  System.out.println("positiveLinkDirection:" + Intorextdirectedlinkreference.getLinkReferenceChoice().getInternalLinkReference().getPositiveLinkDirection());
				      System.out.println("LinkId:" + Intorextdirectedlinkreference.getLinkReferenceChoice().getInternalLinkReference().getLinkId());
			         }
			     }
			    }*/
			
			    //取第几条
/*			    SimpleIntersection intersection = simpleIntersection.getSimpleIntersection().get(15);
			    System.out.println("dx:" + intersection.getPosition().getDx());
			    System.out.println("dy:" + intersection.getPosition().getDy());
			    System.out.println("NumLinks:" + intersection.getNumLinks());
			    ArrayList<IntOrExtDirectedLinkReference> connectedLinks = intersection.getConnectedLinks();
			    for (int i = 0; i < connectedLinks.size(); i++) {
			    	if (connectedLinks.get(i).getIsExternalLinkReference()) {
			    		   System.out.println("IsExternalLinkReference:" + connectedLinks.get(i).getIsExternalLinkReference());
					       System.out.println("extTileIdx:" + connectedLinks.get(i).getLinkReferenceChoice().getExternalLinkReference().getExtTileIdx());
					       System.out.println("positiveLinkDirection:" + connectedLinks.get(i).getLinkReferenceChoice().getExternalLinkReference().getTileExternalLinkReference().getPositiveLinkDirection());
					       System.out.println("LinkId:" + connectedLinks.get(i).getLinkReferenceChoice().getExternalLinkReference().getTileExternalLinkReference().getLinkId());
					      }else {
					    	  System.out.println("IsExternalLinkReference:" + connectedLinks.get(i).getIsExternalLinkReference());
					    	  System.out.println("positiveLinkDirection:" + connectedLinks.get(i).getLinkReferenceChoice().getInternalLinkReference().getPositiveLinkDirection());
						      System.out.println("LinkId:" + connectedLinks.get(i).getLinkReferenceChoice().getInternalLinkReference().getLinkId());
					         }
				}
*/
			return simpleIntersection;
	}
		/**
		 * routingTileHeader方法,给header赋值
		 * @throws IOException
		 */
		public static void routingTileHeader() throws IOException{
			RandomAccessFile in=new RandomAccessFile("first.dat","r");
			rb = new Readblom(2);
			in.read(rb.buffer, 0, 2);
			RoutingContentMask routingcontentmask = new RoutingContentMask();
			routingcontentmask.setHasFixedRoadAttributeSetList(rb.readBool());
			routingcontentmask.setHasSimpleIntersectionList(rb.readBool()); 	
			routingcontentmask.setHasLinkList(rb.readBool()); 		
			routingcontentmask.setHasRouteUpLinkList(rb.readBool()); 		
			routingcontentmask.setHasRouteDownLinkList(rb.readBool()); 		
			routingcontentmask.setHasLinkToTileList(rb.readBool()); 		
			routingcontentmask.setHasLinkIdRangeList(rb.readBool()); 		
			routingcontentmask.setHasSimpleIntersectionIdRangeList(rb.readBool()); 		
			routingcontentmask.setHasAttributeMaps(rb.readBool()); 		
			routingcontentmask.setHasExternalTileIdList(rb.readBool());
			header.setContentMask(routingcontentmask);
			if(header.getContentMask().getHasFixedRoadAttributeSetList() == true) 
			{
				header.setFixedRoadAttributeSetListOffset(in.readInt());
			}
			if(header.getContentMask().getHasSimpleIntersectionList() == true) 
			{
				header.setSimpleIntersectionOffset(in.readInt());
			}
			if(header.getContentMask().getHasLinkList()== true) 
			{
				header.setLinksOffset(in.readInt());
			}
			if(header.getContentMask().getHasRouteUpLinkList()== true) 
			{
				header.setRouteUpLinksOffset(in.readInt());
			}
			if(header.getContentMask().getHasRouteDownLinkList()== true) 
			{
				header.setRouteDownLinksOffset(in.readInt());
			}
			if(header.getContentMask().getHasLinkToTileList()== true) 
			{
				header.setLink2TileListOffset(in.readInt());
			}
			if(header.getContentMask().getHasLinkIdRangeList()== true) 
			{
				header.setLinkIdRangeListOffset(in.readInt());
			}
			if(header.getContentMask().getHasSimpleIntersectionIdRangeList()== true) 
			{
				header.setSimplIntIdRangeListOffset(in.readInt());
			}
			if(header.getContentMask().getHasAttributeMaps()== true) 
			{
				header.setAttributeMapsOffset(in.readInt());
			}
			if(header.getContentMask().getHasExternalTileIdList()== true) 
			{
				header.setExternalTileIdListOffset(in.readInt());
			}
		/*	System.out.println(
					+header.getFixedRoadAttributeSetListOffset() + "\r\n"
					+header.getSimpleIntersectionOffset() + "\r\n"
					+header.getLinksOffset() + "\r\n"
					+header.getRouteUpLinksOffset() + "\r\n"
					+header.getRouteDownLinksOffset() + "\r\n"
					+header.getLink2TileListOffset() + "\r\n"
					+header.getSimplIntIdRangeListOffset() + "\r\n"
					+header.getLinkIdRangeListOffset() + "\r\n"
					+header.getAttributeMapsOffset() + "\r\n"
					+header.getExternalTileIdListOffset() + "\r\n");
			*/
			in.seek(header.getSimpleIntersectionOffset());
			simpleIntersection.setNumIntersections(in.readShort());
		}
}

class Readblom{
	protected int bytePosition;
	protected int bitOffset;
	protected static final byte BYTE_MOD_MASK = 0x7;
	protected static final int BITS_PER_BYTE = 0x8;
	protected static final int BITS_PER_LONG = 0x40;
	public byte[] buffer;
	Readblom(int b)
	{
		buffer = new byte[b];
	}
	public long getBitPosition()
    {
        return BITS_PER_BYTE * bytePosition + bitOffset;
    }
	//设置bit位置
    public void setBitPosition(final long bitPosition) throws IOException
    {
        bitOffset = (int)(bitPosition % 8);
        bytePosition = (int)(bitPosition / BITS_PER_BYTE);
    }
	private byte nextByte() throws IOException
    {
        if (bytePosition >= buffer.length)
            throw new IOException("ByteArrayBitStreamReader: Unable to read byte on offset position " +
                    (bytePosition + 1) + ". It's beyond end of the stream with length " + buffer.length + ".");
        return buffer[bytePosition++];
    }
    /**
     * Returns the next unsigned byte without resetting the bit offset.
     *
     * @return Read next byte.
     *
     * @throws IOException If the reading failed.
     */
    private int nextUnsignedByte() throws IOException
    {
        return nextByte() & 0xff;
    }
	public boolean readBool() throws IOException
	{
	    return readBits(1) == 1;
	}
	//有符号位
	 public long readSignedBits(final int numBits) throws IOException
    {
        long result = readBits(numBits);
        /*
         * Perform a sign extension if needed.
         * 1L << 64 in Java is not 0L, but 1L, so treat numBits == 64 as a special case
         * (numBits == 64 does not need sign extension anyway)
         */
        if (numBits < 64 && (result & (1L << (numBits - 1))) != 0)
        {
            result |= (-1L << numBits);
        }
        return result;
    }
	 public long readBits(final int numBits) throws IOException
    {
        int bitsToRead = bitOffset + numBits;
        final int nextBitOffset = bitsToRead & BYTE_MOD_MASK;
        long accum = 0L;
        while (bitsToRead > 0)
        {
            accum = (accum << BITS_PER_BYTE) | nextUnsignedByte();
            bitsToRead -= BITS_PER_BYTE;
        }
        bitOffset = nextBitOffset;
        if (nextBitOffset != 0)
        {
            bytePosition--;
        }
        /*
         * Shift away unwanted bits on the right and mask out unwanted bits on
         * the left.
         */
        return (accum >>> -bitsToRead) & (-1L >>> (BITS_PER_LONG - numBits));
    }
}

class RoutingContentMask{
	private boolean hasFixedRoadAttributeSetList; 	
	private boolean hasSimpleIntersectionList; 		
	private boolean hasLinkList; 		
	private boolean hasRouteUpLinkList; 		
	private boolean hasRouteDownLinkList; 		
	private boolean hasLinkToTileList; 		
	private boolean hasLinkIdRangeList; 		
	private boolean hasSimpleIntersectionIdRangeList; 		
	private boolean hasAttributeMaps; 		
	private boolean hasExternalTileIdList;
	public RoutingContentMask() {}
	public void setHasFixedRoadAttributeSetList(boolean hasFixedRoadAttributeSetList) {
		this.hasFixedRoadAttributeSetList = hasFixedRoadAttributeSetList;
	}
	public boolean getHasFixedRoadAttributeSetList() {
		return hasFixedRoadAttributeSetList;
	}
	public void setHasSimpleIntersectionList(boolean hasSimpleIntersectionList) {
		this.hasSimpleIntersectionList = hasSimpleIntersectionList;
	}
	public boolean getHasSimpleIntersectionList() {
		return hasSimpleIntersectionList;
	}
	public void setHasLinkList(boolean hasLinkList) {
		this.hasLinkList = hasLinkList;
	}
	public boolean getHasLinkList() {
		return hasLinkList;
	}
	public void setHasRouteUpLinkList(boolean hasRouteUpLinkList) {
		this.hasRouteUpLinkList = hasRouteUpLinkList;
	}
	public boolean getHasRouteUpLinkList() {
		return hasRouteUpLinkList;
	}
	public void setHasRouteDownLinkList(boolean hasRouteDownLinkList) {
		this.hasRouteDownLinkList = hasRouteDownLinkList;
	}
	public boolean getHasRouteDownLinkList() {
		return hasRouteDownLinkList;
	}
	public void setHasLinkToTileList(boolean hasLinkToTileList) {
		this.hasLinkToTileList = hasLinkToTileList;
	}
	public boolean getHasLinkToTileList() {
		return hasLinkToTileList;
	}
	public void setHasLinkIdRangeList(boolean hasLinkIdRangeList) {
		this.hasLinkIdRangeList = hasLinkIdRangeList;
	}
	public boolean getHasLinkIdRangeList() {
		return hasLinkIdRangeList;
	}
	public void setHasSimpleIntersectionIdRangeList(boolean hasSimpleIntersectionIdRangeList) {
		this.hasSimpleIntersectionIdRangeList = hasSimpleIntersectionIdRangeList;
	}
	public boolean getHasSimpleIntersectionIdRangeList() {
		return hasSimpleIntersectionIdRangeList;
	}
	public void setHasAttributeMaps(boolean hasAttributeMaps) {
		this.hasAttributeMaps = hasAttributeMaps;
	}
	public boolean getHasAttributeMaps() {
		return hasAttributeMaps;
	}
	public void setHasExternalTileIdList(boolean hasExternalTileIdList) {
		this.hasExternalTileIdList = hasExternalTileIdList;
	}
	public boolean getHasExternalTileIdList() {
		return hasExternalTileIdList;
	}
}

 class RoutingTileHeader {
		RoutingContentMask  contentMask;
		int fixedRoadAttributeSetListOffset;
		int simpleIntersectionOffset;
		int linksOffset;
		int routeUpLinksOffset;
		int routeDownLinksOffset;
		int link2TileListOffset;
		int linkIdRangeListOffset;
		int simplIntIdRangeListOffset;
		int attributeMapsOffset;
		int externalTileIdListOffset;
		public RoutingTileHeader() {}
		public RoutingContentMask getContentMask() {
			return contentMask;
		}
		public void setContentMask(RoutingContentMask contentMask) {
			this.contentMask = contentMask;
		}
		public int getFixedRoadAttributeSetListOffset() {
			return fixedRoadAttributeSetListOffset;
		}
		public void setFixedRoadAttributeSetListOffset(int fixedRoadAttributeSetListOffset) {
			this.fixedRoadAttributeSetListOffset = fixedRoadAttributeSetListOffset;
		}
		public int getSimpleIntersectionOffset() {
			return simpleIntersectionOffset;
		}
		public void setSimpleIntersectionOffset(int simpleIntersectionOffset) {
			this.simpleIntersectionOffset = simpleIntersectionOffset;
		}
		public int getLinksOffset() {
			return linksOffset;
		}
		public void setLinksOffset(int linksOffset) {
			this.linksOffset = linksOffset;
		}
		public int getRouteUpLinksOffset() {
			return routeUpLinksOffset;
		}
		public void setRouteUpLinksOffset(int routeUpLinksOffset) {
			this.routeUpLinksOffset = routeUpLinksOffset;
		}
		public int getRouteDownLinksOffset() {
			return routeDownLinksOffset;
		}
		public void setRouteDownLinksOffset(int routeDownLinksOffset) {
			this.routeDownLinksOffset = routeDownLinksOffset;
		}
		public int getLink2TileListOffset() {
			return link2TileListOffset;
		}
		public void setLink2TileListOffset(int link2TileListOffset) {
			this.link2TileListOffset = link2TileListOffset;
		}
		public int getLinkIdRangeListOffset() {
			return linkIdRangeListOffset;
		}
		public void setLinkIdRangeListOffset(int linkIdRangeListOffset) {
			this.linkIdRangeListOffset = linkIdRangeListOffset;
		}
		public int getSimplIntIdRangeListOffset() {
			return simplIntIdRangeListOffset;
		}
		public void setSimplIntIdRangeListOffset(int simplIntIdRangeListOffset) {
			this.simplIntIdRangeListOffset = simplIntIdRangeListOffset;
		}
		public int getAttributeMapsOffset() {
			return attributeMapsOffset;
		}
		public void setAttributeMapsOffset(int attributeMapsOffset) {
			this.attributeMapsOffset = attributeMapsOffset;
		}

		public int getExternalTileIdListOffset() {
			return externalTileIdListOffset;
		}
		public void setExternalTileIdListOffset(int externalTileIdListOffset) {
			this.externalTileIdListOffset = externalTileIdListOffset;
		}
	}
 class SimpleIntersectionList {
		private int numIntersections;
		private ArrayList<SimpleIntersection> simpleIntersection;//simpleIntersection[numIntersections]	
		public SimpleIntersectionList() {}
		public int getNumIntersections() {
			return numIntersections;
		}
		public void setNumIntersections(int numIntersections) {
			this.numIntersections = numIntersections;
		}
		public ArrayList<SimpleIntersection> getSimpleIntersection() {
			return simpleIntersection;
		}
		public void setSimpleIntersection(ArrayList<SimpleIntersection> simpleIntersection) {
			this.simpleIntersection = simpleIntersection;   //simpleIntersection.addAll(simpleIntersection);
		}
	}

 class SimpleIntersection{
		private CoordXYOffset position;
		private int numLinks;
		private ExternalDirectedLinkReference externalLinkReference;
		private ArrayList<IntOrExtDirectedLinkReference> connectedLinks;//connectedLinks[numLinks]
        public SimpleIntersection() {}
		public CoordXYOffset getPosition() {
			return position;
		}
		public void setPosition(CoordXYOffset position) {
			this.position = position;
		}
		public int getNumLinks() {
			return numLinks;
		}
		public void setNumLinks(int numLinks) {
			this.numLinks = numLinks;
		}
		public ArrayList<IntOrExtDirectedLinkReference> getConnectedLinks() {
			return connectedLinks;
		}
		public void setConnectedLinks(ArrayList<IntOrExtDirectedLinkReference> connectedLinks) {
			this.connectedLinks = connectedLinks;    //connectedLinks.addAll(connectedLinks);
		}
		public ExternalDirectedLinkReference getExternalLinkReference() {
			return externalLinkReference;
		}
		public void setExternalLinkReference(
				ExternalDirectedLinkReference externalLinkReference) {
			this.externalLinkReference = externalLinkReference;
		}
	}	

 class CoordXYOffset{
			private int numBits;
			private int dx;
			private int dy;
			public CoordXYOffset() {}
			public int getNumBits() {
				return numBits;
			}
			public void setNumBits(int numBits) {
				this.numBits = numBits;
			}
			public int getDx() {
				return dx;
			}
			public void setDx(int dx) {
				this.dx = dx;
			}
			public int getDy() {
				return dy;
			}
			public void setDy(int dy) {
				this.dy = dy;
			}
		}

 class IntOrExtDirectedLinkReference{
			private boolean isExternalLinkReference;
			private LinkReferenceChoice linkReferenceChoice;
	    public IntOrExtDirectedLinkReference() {}
		public boolean getIsExternalLinkReference() {
			return isExternalLinkReference;
		}
		public void setIsExternalLinkReference(boolean isExternalLinkReference) {
			this.isExternalLinkReference = isExternalLinkReference;
		}
		public LinkReferenceChoice getLinkReferenceChoice() {
			return linkReferenceChoice;
		}
		public void setLinkReferenceChoice(LinkReferenceChoice linkReferenceChoice) {
			this.linkReferenceChoice = linkReferenceChoice;
		}
		}

 class LinkReferenceChoice{
	    	private DirectedLinkReference internalLinkReference;
	    	private ExternalDirectedLinkReference externalLinkReference;
	    	public LinkReferenceChoice() {}
			public DirectedLinkReference getInternalLinkReference() {
				return internalLinkReference;
			}
			public void setInternalLinkReference(DirectedLinkReference internalLinkReference) {
				this.internalLinkReference = internalLinkReference;
			}
			public ExternalDirectedLinkReference getExternalLinkReference() {
				return externalLinkReference;
			}
			public void setExternalLinkReference(ExternalDirectedLinkReference externalLinkReference) {
				this.externalLinkReference = externalLinkReference;
			}
		}

class DirectedLinkReference{
	    		private boolean positiveLinkDirection;
	    		private int linkId;
	    		public DirectedLinkReference() {}
				public boolean getPositiveLinkDirection() {
					return positiveLinkDirection;
				}
				public void setPositiveLinkDirection(boolean positiveLinkDirection) {
					this.positiveLinkDirection = positiveLinkDirection;
				}
				public int getLinkId() {
					return linkId;
				}
				public void setLinkId(int linkId2) {
					this.linkId = linkId2;
				}
			}

class LinkId{
	    			private byte linkId;
					public LinkId() {}
					public byte getLinkId() {
		               return linkId;
					}
					public void setLinkId(byte linkId) {
						this.linkId = linkId;
					}
	    		}

class ExternalDirectedLinkReference{
	        	private int extTileIdx;
	        	private DirectedLinkReference tileExternalLinkReference;
	        	public ExternalDirectedLinkReference() {}
				public int getExtTileIdx() {
					return extTileIdx;
				}
				public void setExtTileIdx(int extTileIdx2) {
					this.extTileIdx = extTileIdx2;
				}
				public DirectedLinkReference getTileExternalLinkReference() {
					return tileExternalLinkReference;
				}
				public void setTileExternalLinkReference(DirectedLinkReference tileExternalLinkReference) {
					this.tileExternalLinkReference = tileExternalLinkReference;
				}
	        }		

class SizeOfExternalTileIdList{
	private int SizeOfExternalTileIdList;
	public SizeOfExternalTileIdList() {}
	public int getSizeOfExternalTileIdList() {
		return SizeOfExternalTileIdList;
	}
	public void setSizeOfExternalTileIdList(int SizeOfExternalTileIdList) {
		this.SizeOfExternalTileIdList = SizeOfExternalTileIdList;
	}
}

class LinkList{
	private int numnumLinks;                 //uint16  16位
	private ArrayList<Link> link1; //有问题      //集合
	public LinkList() {}
	public int getNumnumLinks() {
		return numnumLinks;
	}
	public void setNumnumLinks(int numnumLinks) {
		this.numnumLinks = numnumLinks;
	}
	public ArrayList<Link> getLink1() {
		return link1;
	}
	public void setLink1(ArrayList<Link> link1) {
		this.link1 = link1;
	}
}

class Link{
	private FeatureLength length;
	private AttributeSource attrSource;
	private RoutingAttributeInfo attrInfo;
	private AverageSpeed averageSpeed;
	private LinkSector startAngle;
	private LinkSector endAngle;
	public Link() {}
	public FeatureLength getLength() {
		return length;
	}
	public void setLength(FeatureLength length) {
		this.length = length;
	}
	public AttributeSource getAttrSource() {
		return attrSource;
	}
	public void setAttrSource(AttributeSource attrSource) {
		this.attrSource = attrSource;
	}
	public RoutingAttributeInfo getAttrInfo() {
		return attrInfo;
	}
	public void setAttrInfo(RoutingAttributeInfo attrInfo) {
		this.attrInfo = attrInfo;
	}
	public AverageSpeed getAverageSpeed() {
		return averageSpeed;
	}
	public void setAverageSpeed(AverageSpeed averageSpeed) {
		this.averageSpeed = averageSpeed;
	}
	public LinkSector getStartAngle() {
		return startAngle;
	}
	public void setStartAngle(LinkSector startAngle) {
		this.startAngle = startAngle;
	}
	public LinkSector getEndAngle() {
		return endAngle;
	}
	public void setEndAngle(LinkSector endAngle) {
		this.endAngle = endAngle;
	}
}
class FeatureLength{
	private int length;                      //varuint32   24位可变
	public FeatureLength() {}
	public int getLength() {
		return length;
	}
	public void setLength(int length) {
		this.length = length;
	}
}
class AttributeSource{
	private byte INDEXED;                   //1bit   INDEXED = 0
	private byte EXPLICIT;                  //1bit   EXPLICIT = 1
	public AttributeSource() {}
	public byte getINDEXED() {
		return INDEXED;
	}
	public void setINDEXED(byte INDEXED) {
		this.INDEXED = INDEXED;
	}
	public byte getEXPLICIT() {
		return EXPLICIT;
	}
	public void setEXPLICIT(byte EXPLICIT) {
		this.EXPLICIT = EXPLICIT;
	}
}
class RoutingAttributeInfo{
	private FixedRoadAttributeSetListIndex fixedRoadAttributeSetListIndex;
	private FixedRoadAttributeSet fixedAttributes;
	public RoutingAttributeInfo() {}
	public FixedRoadAttributeSetListIndex getFixedRoadAttributeSetListIndex() {
		return fixedRoadAttributeSetListIndex;
	}
	public void setFixedRoadAttributeSetListIndex(FixedRoadAttributeSetListIndex fixedRoadAttributeSetListIndex) {
		this.fixedRoadAttributeSetListIndex = fixedRoadAttributeSetListIndex;
	}
	public FixedRoadAttributeSet getFixedAttributes() {
		return fixedAttributes;
	}
	public void setFixedAttributes(FixedRoadAttributeSet fixedAttributes) {
		this.fixedAttributes = fixedAttributes;
	}
}
class FixedRoadAttributeSetListIndex{          //1bit   INDEXED = 0时     
	private int fixedRoadAttributeSetListIndex;    //varuint16    8位
	public FixedRoadAttributeSetListIndex() {}
	public int getFixedRoadAttributeSetListIndex() {
		return fixedRoadAttributeSetListIndex;
	}
	public void setFixedRoadAttributeSetListIndex(int fixedRoadAttributeSetListIndex) {
		this.fixedRoadAttributeSetListIndex = fixedRoadAttributeSetListIndex;
	}
}
class FixedRoadAttributeSet{      //1bit   EXPLICIT = 1时
	private SharedRoadAttributes sharedAttr;
	private RoutingRoadAttributes routingAttr;
	public FixedRoadAttributeSet() {}
	public SharedRoadAttributes getSharedAttr() {
		return sharedAttr;
	}
	public void setSharedAttr(SharedRoadAttributes sharedAttr) {
		this.sharedAttr = sharedAttr;
	}
	public RoutingRoadAttributes getRoutingAttr() {
		return routingAttr;
	}
	public void setRoutingAttr(RoutingRoadAttributes routingAttr) {
		this.routingAttr = routingAttr;
	}
}
class SharedRoadAttributes{
	private PriorityRoadClass priorityRoadClass;
	private LinkType linkType;
	private Direction travelDirection;
	private boolean ferry;    //所有布尔:1bit
	private boolean tunnel;
	private boolean bridge;
	private Direction toll;
	private boolean controlledAccess;
	private boolean serviceArea;
	public SharedRoadAttributes() {}
	public PriorityRoadClass getPriorityRoadClass() {
		return priorityRoadClass;
	}
	public void setPriorityRoadClass(PriorityRoadClass priorityRoadClass) {
		this.priorityRoadClass = priorityRoadClass;
	}
	public LinkType getLinkType() {
		return linkType;
	}
	public void setLinkType(LinkType linkType) {
		this.linkType = linkType;
	}
	public Direction getTravelDirection() {
		return travelDirection;
	}
	public void setTravelDirection(Direction travelDirection) {
		this.travelDirection = travelDirection;
	}
	public boolean isFerry() {
		return ferry;
	}
	public void setFerry(boolean ferry) {
		this.ferry = ferry;
	}
	public boolean isTunnel() {
		return tunnel;
	}
	public void setTunnel(boolean tunnel) {
		this.tunnel = tunnel;
	}
	public boolean isBridge() {
		return bridge;
	}
	public void setBridge(boolean bridge) {
		this.bridge = bridge;
	}
	public Direction getToll() {
		return toll;
	}
	public void setToll(Direction toll) {
		this.toll = toll;
	}
	public boolean isControlledAccess() {
		return controlledAccess;
	}
	public void setControlledAccess(boolean controlledAccess) {
		this.controlledAccess = controlledAccess;
	}
	public boolean isServiceArea() {
		return serviceArea;
	}
	public void setServiceArea(boolean serviceArea) {
		this.serviceArea = serviceArea;
	}
}
class PriorityRoadClass{
	private byte priorityRoadClass;         //4bit
	public PriorityRoadClass() {}
	public byte getPriorityRoadClass() {
		return priorityRoadClass;
	}
	public void setPriorityRoadClass(byte priorityRoadClass) {
		this.priorityRoadClass = priorityRoadClass;
	}
}
class LinkType{
	private byte linkType;       //特殊:14中情况,0~D       4bit
	public LinkType() {}
	public byte getLinkType() {
		return linkType;
	}
	public void setLinkType(byte linkType) {
		this.linkType = linkType;
	}
}
class Direction{                    //特殊:四种情况:0~3 ,下面的两个不是都顺序输出的,两个东西   
	private byte travelDirection;   //2bit
	private byte toll;              //2bit
	public Direction() {}
	public byte getTravelDirection() {
		return travelDirection;
	}
	public void setTravelDirection(byte travelDirection) {
		this.travelDirection = travelDirection;
	}
	public byte getToll() {
		return toll;
	}
	public void setToll(byte toll) {
		this.toll = toll;
	}
}
class RoutingRoadAttributes {
	private FunctionalRoadClass functionalRoadClass;
	private boolean urban;
	private boolean complexIntersection;
	private boolean pluralJunction;
	private boolean motorway;
	public RoutingRoadAttributes() {}
	public FunctionalRoadClass getFunctionalRoadClass() {
		return functionalRoadClass;
	}
	public void setFunctionalRoadClass(FunctionalRoadClass functionalRoadClass) {
		this.functionalRoadClass = functionalRoadClass;
	}
	public boolean isUrban() {
		return urban;
	}
	public void setUrban(boolean urban) {
		this.urban = urban;
	}
	public boolean isComplexIntersection() {
		return complexIntersection;
	}
	public void setComplexIntersection(boolean complexIntersection) {
		this.complexIntersection = complexIntersection;
	}
	public boolean isPluralJunction() {
		return pluralJunction;
	}
	public void setPluralJunction(boolean pluralJunction) {
		this.pluralJunction = pluralJunction;
	}
	public boolean isMotorway() {
		return motorway;
	}
	public void setMotorway(boolean motorway) {
		this.motorway = motorway;
	}
}
class FunctionalRoadClass {
	private byte functionalRoadClass;          //3bit
	public FunctionalRoadClass() {}
	public byte getFunctionalRoadClass() {
		return functionalRoadClass;
	}
	public void setFunctionalRoadClass(byte functionalRoadClass) {
		this.functionalRoadClass = functionalRoadClass;
	}
}
class AverageSpeed{
	private int averageSpeed;      //uint8   8位
	public AverageSpeed() {}
	public int getAverageSpeed() {
		return averageSpeed;
	}
	public void setAverageSpeed(int averageSpeed) {
		this.averageSpeed = averageSpeed;
	}
}
class LinkSector{            //下面的两个不是都顺序输出的,两个东西  
	private byte startAngle;            //6bit
	private byte endAngle;              //6bit
	public LinkSector() {}
	public byte getStartAngle() {
		return startAngle;
	}
	public void setStartAngle(byte startAngle) {
		this.startAngle = startAngle;
	}
	public byte getEndAngle() {
		return endAngle;
	}
	public void setEndAngle(byte endAngle) {
		this.endAngle = endAngle;
	}
}

package routingtile;

import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;

public class HexFinder {
	public static String format(byte[] bt) {
		int line = 0;
		StringBuilder buf = new StringBuilder();
		for (byte d : bt) {
			if (line % 16 == 0)
			buf.append(String.format("%05x: ", line));
			buf.append(String.format("%02x ", d));
			line++;
			if (line % 16 == 0)
				buf.append("\n");
		}
		buf.append("\n");
		return buf.toString();
	}

	public static byte[] readFile(String file) throws IOException {
		InputStream is = new FileInputStream(file);
		int length = is.available();
		byte bt[] = new byte[length];
		is.read(bt);
		return bt;
	}

	/**
	 * 十六进制转二进制
	 * 
	 * @param hexString
	 * @return
	 */

	public static String hexString2binaryString(String hexString) {
		if (hexString == null || hexString.length() % 2 != 0)
			return null;
		String bString = "", tmp;
		for (int i = 0; i < hexString.length(); i++) {
			tmp = "0000"
					+ Integer.toBinaryString(Integer.parseInt(
							hexString.substring(i, i + 1), 16));
			bString += tmp.substring(tmp.length() - 4);
		}
		return bString;
	}

	/**
	 * 读取十六进制文件后转成二进制
	 * @return strB 
	 * @throws IOException
	 */
	public static StringBuilder readData() throws IOException{
		//读取十六进制文件
		byte[] bt = HexFinder.readFile("./first.dat");
		String hexData = HexFinder.format(bt);
		//按空格切割
		String[] re = hexData.split("\n");
		String sixData;
		StringBuilder strB = new StringBuilder();
		for (String string : re) {
			String[] result = string.split("\\s+");
			for (String s : result) {
				if(s.length()>5){
					continue;
				}else{
					//十六转二
					sixData = hexString2binaryString(s);
					strB.append(sixData);
				}	
			}	
		}
		return strB;	
	}
	protected static final int BITS_BYTE = 8;
	protected static int OFFSET = 0;
	private static Boolean flag = true;
	/**
	 * 将type数组按“:”切割,并截取strB中的位数
	 * @param type
	 * @param strB
	 * @return 
	 * @throws IOException
	 */
	public static HashMap<String, Integer> dicedall(int offset,int pointer,StringBuilder strB) throws IOException{
		HashMap<String, Integer> mp = new HashMap<String, Integer>();
		String a;
		int index;
		//从736开始读取交叉点二进制中的数据
		final int numbit = BITS_BYTE * OFFSET;
		//第一次从736开始读
		if(flag){
			//模拟指针
			index = numbit + offset;
			a = strB.substring(numbit,index).trim();
			flag = false;
		}else{
			//模拟指针
			index = pointer + offset;
			a = strB.substring(pointer,index).trim();
		}
		String lastValue = Long.valueOf(a,2).toString();
		//放入mp中
		mp.put("pointer", index);
		mp.put("value", Integer.parseInt(lastValue));
//		System.out.println(lastValue);
		return mp;
	}
	/**
	 * 初始化指针位置
	 * @param type
	 * @param strB
	 * @return 
	 * @return 
	 * @throws IOException
	 */
	public static void initialize(int offsett){
		OFFSET = offsett;
	}

	public static void write(String name,String hexString) throws IOException {
	/** 
     * 创建一个可以往文件中写入字符数据的字符流输出流对象 
     * 创建时必须明确文件的目的地 
     * 如果文件不存在,这回自动创建。如果文件存在,则会覆盖。 
     * 当路径错误时会抛异常 
     *  
     * 当在创建时加入true参数,回实现对文件的续写。 
     */  
    FileWriter fw = new FileWriter(".\\demo1.txt",true);  
    /** 
     * 调用该对象的write方法,向文件写入字符。 
     *  
     * 其实写入到了临时存储缓冲区中 
     */  
    fw.write(name+":"+hexString+"\r\n");//windows中的换行为\r\n   
    /** 
     * 进行刷新,将字符写到目的地中。 
     */  
    fw.flush();  
    /** 
     * 关闭流,关闭资源。在关闭前会调用flush方法 刷新缓冲区。关闭后在写的话,会抛IOException 
     */  
    fw.close();
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值