diff --git a/brouter-mapaccess/src/main/java/btools/mapaccess/DirectWeaver.java b/brouter-mapaccess/src/main/java/btools/mapaccess/DirectWeaver.java new file mode 100644 index 0000000..5b9acd9 --- /dev/null +++ b/brouter-mapaccess/src/main/java/btools/mapaccess/DirectWeaver.java @@ -0,0 +1,228 @@ +package btools.mapaccess; + +import btools.codec.DataBuffers; +import btools.codec.NoisyDiffCoder; +import btools.codec.StatCoderContext; +import btools.codec.TagValueCoder; +import btools.codec.TagValueValidator; +import btools.codec.TagValueWrapper; +import btools.codec.WaypointMatcher; +import btools.util.ByteDataWriter; +import btools.util.IByteArrayUnifier; + +/** + * MicroCache2 is the new format that uses statistical encoding and + * is able to do access filtering and waypoint matching during encoding + */ +public final class DirectWeaver extends ByteDataWriter +{ + private int lonBase; + private int latBase; + private int cellsize; + + protected int[] faid; + protected int size = 0; + + private static boolean debug = false; + + public DirectWeaver( DataBuffers dataBuffers, int lonIdx, int latIdx, int divisor, TagValueValidator wayValidator, WaypointMatcher waypointMatcher, OsmNodesMap hollowNodes ) throws Exception + { + super( null ); + cellsize = 1000000 / divisor; + lonBase = lonIdx*cellsize; + latBase = latIdx*cellsize; + + StatCoderContext bc = new StatCoderContext( dataBuffers.iobuffer ); + + TagValueCoder wayTagCoder = new TagValueCoder( bc, dataBuffers, wayValidator ); + TagValueCoder nodeTagCoder = new TagValueCoder( bc, dataBuffers, null ); + NoisyDiffCoder nodeIdxDiff = new NoisyDiffCoder( bc ); + NoisyDiffCoder nodeEleDiff = new NoisyDiffCoder( bc ); + NoisyDiffCoder extLonDiff = new NoisyDiffCoder(bc); + NoisyDiffCoder extLatDiff = new NoisyDiffCoder(bc); + NoisyDiffCoder transEleDiff = new NoisyDiffCoder( bc ); + + size = bc.decodeNoisyNumber( 5 ); + faid = size > dataBuffers.ibuf2.length ? new int[size] : dataBuffers.ibuf2; + + if ( debug ) System.out.println( "*** decoding cache of size=" + size + " for lonIdx=" + lonIdx + " latIdx=" + latIdx ); + + bc.decodeSortedArray( faid, 0, size, 0x20000000, 0 ); + + OsmNode[] nodes = new OsmNode[size]; + for( int n = 0; n> 32 ); + int ilat = (int) ( id & 0xffffffff ); + OsmNode node = hollowNodes.get( ilon, ilat ); + if ( node == null ) + { + node = new OsmNode( ilon, ilat ); + } + else + { + hollowNodes.remove( node ); + } + nodes[n] = node; + } + + int netdatasize = bc.decodeNoisyNumber( 10 ); // (not needed for direct weaving) + ab = dataBuffers.bbuf1; + aboffset = 0; + + int selev = 0; + for( int n=0; n