removed old format support

This commit is contained in:
Arndt 2015-08-28 17:49:35 +02:00
parent 87fe904e7b
commit 2cec35f3cc
10 changed files with 35 additions and 158 deletions

View file

@ -21,8 +21,6 @@ final class MicroCache extends ByteDataReader
private int delbytes = 0;
private int p2size; // next power of 2 of size
private boolean readVarLength;
// the object parsing position and length
private int aboffsetEnd;
@ -31,11 +29,9 @@ final class MicroCache extends ByteDataReader
boolean virgin = true;
boolean ghost = false;
public MicroCache( OsmFile segfile, int lonIdx80, int latIdx80, byte[] iobuffer, boolean readVarLength ) throws Exception
public MicroCache( OsmFile segfile, int lonIdx80, int latIdx80, byte[] iobuffer ) throws Exception
{
super( null );
this.readVarLength = readVarLength;
int lonDegree = lonIdx80/80;
int latDegree = latIdx80/80;
@ -67,30 +63,16 @@ final class MicroCache extends ByteDataReader
{
int ilon = readShort();
int ilat = readShort();
int bodySize = readVarLength ? readVarLengthUnsigned() : readInt();
int bodySize = readVarLengthUnsigned();
// kack for the old format crc
if ( !readVarLength && ilon == Short.MAX_VALUE && ilat == Short.MAX_VALUE )
{
int crc = Crc32.crc( ab, 0, aboffset-8 ); // old format crc
if ( crc != readInt() )
{
throw new IOException( "checkum-error" );
}
size = i;
break;
}
aboffset += bodySize;
nbytes += bodySize;
}
if ( readVarLength ) // new format crc
int crc = Crc32.crc( ab, 0, aboffset );
if ( crc != readInt() )
{
int crc = Crc32.crc( ab, 0, aboffset );
if ( crc != readInt() )
{
throw new IOException( "checkum error" );
}
throw new IOException( "checkum error" );
}
// new array with only net data
@ -111,7 +93,7 @@ final class MicroCache extends ByteDataReader
long nodeId = ((long)ilon)<<32 | ilat;
faid[i] = nodeId;
int bodySize = readVarLength ? readVarLengthUnsigned() : readInt();
int bodySize = readVarLengthUnsigned();
fapos[i] = noffset;
System.arraycopy( ab, aboffset, nab, noffset, bodySize );
aboffset += bodySize;
@ -189,7 +171,7 @@ final class MicroCache extends ByteDataReader
long id = node.getIdFromPos();
if ( getAndClear( id ) )
{
node.parseNodeBody( this, nodesMap, dc, readVarLength );
node.parseNodeBody( this, nodesMap, dc );
}
if ( doCollect && delcount > size / 2 ) // garbage collection

View file

@ -19,7 +19,6 @@ public final class NodesCache
private OsmNodesMap nodesMap;
private int lookupVersion;
private int lookupMinorVersion;
private boolean readVarLength;
private boolean carMode;
private boolean forceSecondaryData;
private String currentFileName;
@ -40,13 +39,12 @@ public final class NodesCache
private boolean garbageCollectionEnabled = false;
public NodesCache( String segmentDir, OsmNodesMap nodesMap, int lookupVersion, int minorVersion, boolean varLen, boolean carMode, boolean forceSecondaryData, NodesCache oldCache )
public NodesCache( String segmentDir, OsmNodesMap nodesMap, int lookupVersion, int minorVersion, boolean carMode, boolean forceSecondaryData, NodesCache oldCache )
{
this.segmentDir = new File( segmentDir );
this.nodesMap = nodesMap;
this.lookupVersion = lookupVersion;
this.lookupMinorVersion = minorVersion;
this.readVarLength = varLen;
this.carMode = carMode;
this.forceSecondaryData = forceSecondaryData;
@ -177,7 +175,7 @@ public final class NodesCache
checkEnableCacheCleaning();
segment = new MicroCache( osmf, lonIdx80, latIdx80, iobuffer, readVarLength );
segment = new MicroCache( osmf, lonIdx80, latIdx80, iobuffer );
cacheSum += segment.getDataSize();
osmf.microCaches[subIdx] = segment;
segmentList.add( segment );

View file

@ -105,7 +105,7 @@ public class OsmNode implements OsmPos
}
public void parseNodeBody( MicroCache is, OsmNodesMap hollowNodes, DistanceChecker dc, boolean readVarLength )
public void parseNodeBody( MicroCache is, OsmNodesMap hollowNodes, DistanceChecker dc )
{
ByteArrayUnifier abUnifier = hollowNodes.getByteArrayUnifier();
@ -116,9 +116,6 @@ public class OsmNode implements OsmPos
OsmLink firstHollowLink = firstlink;
firstlink = null;
int lonIdx = ilon/62500;
int latIdx = ilat/62500;
while( is.hasMoreData() )
{
int ilonref = ilon;
@ -133,44 +130,24 @@ public class OsmNode implements OsmPos
for(;;)
{
int bitField = is.readByte();
if ( readVarLength )
{
int dlon = is.readVarLengthUnsigned();
int dlat = is.readVarLengthUnsigned();
if ( (bitField & SIGNLON_BITMASK) != 0 ) { dlon = -dlon;}
if ( (bitField & SIGNLAT_BITMASK) != 0 ) { dlat = -dlat;}
linklon = ilonref + dlon;
linklat = ilatref + dlat;
ilonref = linklon;
ilatref = linklat;
}
else
{
if ( (bitField & EXTERNAL_BITMASK) != 0 )
{
// full position for external target
linklon = is.readInt();
linklat = is.readInt();
}
else
{
// reduced position for internal target
linklon = is.readShort();
linklat = is.readShort();
linklon += lonIdx*62500 + 31250;
linklat += latIdx*62500 + 31250;
}
}
int dlon = is.readVarLengthUnsigned();
int dlat = is.readVarLengthUnsigned();
if ( (bitField & SIGNLON_BITMASK) != 0 ) { dlon = -dlon;}
if ( (bitField & SIGNLAT_BITMASK) != 0 ) { dlat = -dlat;}
linklon = ilonref + dlon;
linklat = ilatref + dlat;
ilonref = linklon;
ilatref = linklat;
// read variable length or old 8 byte fixed, and ensure that 8 bytes is only fixed
if ( (bitField & WRITEDESC_BITMASK ) != 0 )
{
byte[] ab = new byte[readVarLength ? is.readByte() : 8 ];
byte[] ab = new byte[is.readByte()];
is.readFully( ab );
description = abUnifier.unify( ab );
}
if ( (bitField & NODEDESC_BITMASK ) != 0 )
{
byte[] ab = new byte[readVarLength ? is.readByte() : 8 ];
byte[] ab = new byte[is.readByte()];
is.readFully( ab );
nodeDescription = abUnifier.unify( ab );
}
@ -198,7 +175,7 @@ public class OsmNode implements OsmPos
trans.ilon = linklon;
trans.ilat = linklat;
trans.descriptionBitmap = description;
trans.selev = readVarLength ? (short)(selev + is.readVarLengthSigned()) : is.readShort();
trans.selev = (short)(selev + is.readVarLengthSigned());
if ( lastTransferNode == null )
{
firstTransferNode = trans;
@ -248,7 +225,6 @@ public class OsmNode implements OsmPos
OsmNode t = l.targetNode;
if ( t.ilon == linklon && t.ilat == linklat )
{
System.out.println( "found target in hollow links: " + t.getIdFromPos() );
tn = t;
break;
}
@ -265,8 +241,6 @@ System.out.println( "found target in hollow links: " + t.getIdFromPos() );
hollowNodes.put( targetNodeId, tn );
}
System.out.println( "registering : " + getIdFromPos() + " at hollow " + tn.getIdFromPos() );
OsmLink hollowLink = new OsmLink();
hollowLink.targetNode = this;
tn.addLink( hollowLink ); // make us known at the hollow link

View file

@ -39,7 +39,7 @@ final public class PhysicalFile
if ( osmf.microCaches != null )
for( int lonIdx80=0; lonIdx80<80; lonIdx80++ )
for( int latIdx80=0; latIdx80<80; latIdx80++ )
new MicroCache( osmf, lonIdx80, latIdx80, iobuffer, true ); // TODO: readVarLength ?
new MicroCache( osmf, lonIdx80, latIdx80, iobuffer );
}
}
catch( IllegalArgumentException iae )