Reformat whole codebase using Android Studio
This commit is contained in:
parent
d5322667d5
commit
c15913c1ab
161 changed files with 15124 additions and 18537 deletions
|
|
@ -14,29 +14,27 @@ import btools.codec.MicroCache;
|
|||
import btools.util.ByteDataReader;
|
||||
import btools.util.Crc32;
|
||||
|
||||
final public class PhysicalFile
|
||||
{
|
||||
final public class PhysicalFile {
|
||||
RandomAccessFile ra = null;
|
||||
long[] fileIndex = new long[25];
|
||||
int[] fileHeaderCrcs;
|
||||
|
||||
|
||||
private int fileIndexCrc;
|
||||
public long creationTime;
|
||||
|
||||
String fileName;
|
||||
|
||||
|
||||
public int divisor = 80;
|
||||
|
||||
public static void main( String[] args )
|
||||
{
|
||||
public static void main(String[] args) {
|
||||
MicroCache.debug = true;
|
||||
|
||||
try {
|
||||
checkFileIntegrity( new File( args[0] ) );
|
||||
checkFileIntegrity(new File(args[0]));
|
||||
} catch (IOException e) {
|
||||
System.err.println( "************************************" );
|
||||
System.err.println("************************************");
|
||||
e.printStackTrace();
|
||||
System.err.println( "************************************" );
|
||||
System.err.println("************************************");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -45,56 +43,46 @@ final public class PhysicalFile
|
|||
*
|
||||
* @return the error message if file corrupt, else null
|
||||
*/
|
||||
public static String checkFileIntegrity( File f ) throws IOException
|
||||
{
|
||||
public static String checkFileIntegrity(File f) throws IOException {
|
||||
PhysicalFile pf = null;
|
||||
try
|
||||
{
|
||||
try {
|
||||
DataBuffers dataBuffers = new DataBuffers();
|
||||
pf = new PhysicalFile( f, dataBuffers, -1, -1 );
|
||||
pf = new PhysicalFile(f, dataBuffers, -1, -1);
|
||||
int div = pf.divisor;
|
||||
for ( int lonDegree = 0; lonDegree < 5; lonDegree++ ) // does'nt really matter..
|
||||
for (int lonDegree = 0; lonDegree < 5; lonDegree++) // does'nt really matter..
|
||||
{
|
||||
for ( int latDegree = 0; latDegree < 5; latDegree++ ) // ..where on earth we are
|
||||
for (int latDegree = 0; latDegree < 5; latDegree++) // ..where on earth we are
|
||||
{
|
||||
OsmFile osmf = new OsmFile( pf, lonDegree, latDegree, dataBuffers );
|
||||
if ( osmf.hasData() )
|
||||
for ( int lonIdx = 0; lonIdx < div; lonIdx++ )
|
||||
for ( int latIdx = 0; latIdx < div; latIdx++ )
|
||||
osmf.createMicroCache( lonDegree * div + lonIdx, latDegree * div + latIdx, dataBuffers, null, null, MicroCache.debug, null );
|
||||
OsmFile osmf = new OsmFile(pf, lonDegree, latDegree, dataBuffers);
|
||||
if (osmf.hasData())
|
||||
for (int lonIdx = 0; lonIdx < div; lonIdx++)
|
||||
for (int latIdx = 0; latIdx < div; latIdx++)
|
||||
osmf.createMicroCache(lonDegree * div + lonIdx, latDegree * div + latIdx, dataBuffers, null, null, MicroCache.debug, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( pf != null )
|
||||
try
|
||||
{
|
||||
} finally {
|
||||
if (pf != null)
|
||||
try {
|
||||
pf.ra.close();
|
||||
}
|
||||
catch (Exception ee)
|
||||
{
|
||||
} catch (Exception ee) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PhysicalFile( File f, DataBuffers dataBuffers, int lookupVersion, int lookupMinorVersion ) throws IOException
|
||||
{
|
||||
public PhysicalFile(File f, DataBuffers dataBuffers, int lookupVersion, int lookupMinorVersion) throws IOException {
|
||||
fileName = f.getName();
|
||||
byte[] iobuffer = dataBuffers.iobuffer;
|
||||
ra = new RandomAccessFile( f, "r" );
|
||||
ra.readFully( iobuffer, 0, 200 );
|
||||
fileIndexCrc = Crc32.crc( iobuffer, 0, 200 );
|
||||
ByteDataReader dis = new ByteDataReader( iobuffer );
|
||||
for( int i=0; i<25; i++ )
|
||||
{
|
||||
ra = new RandomAccessFile(f, "r");
|
||||
ra.readFully(iobuffer, 0, 200);
|
||||
fileIndexCrc = Crc32.crc(iobuffer, 0, 200);
|
||||
ByteDataReader dis = new ByteDataReader(iobuffer);
|
||||
for (int i = 0; i < 25; i++) {
|
||||
long lv = dis.readLong();
|
||||
short readVersion = (short)(lv >> 48);
|
||||
if ( i == 0 && lookupVersion != -1 && readVersion != lookupVersion )
|
||||
{
|
||||
throw new IOException( "lookup version mismatch (old rd5?) lookups.dat="
|
||||
+ lookupVersion + " " + f. getAbsolutePath() + "=" + readVersion );
|
||||
short readVersion = (short) (lv >> 48);
|
||||
if (i == 0 && lookupVersion != -1 && readVersion != lookupVersion) {
|
||||
throw new IOException("lookup version mismatch (old rd5?) lookups.dat="
|
||||
+ lookupVersion + " " + f.getAbsolutePath() + "=" + readVersion);
|
||||
}
|
||||
fileIndex[i] = lv & 0xffffffffffffL;
|
||||
}
|
||||
|
|
@ -103,36 +91,30 @@ final public class PhysicalFile
|
|||
long len = ra.length();
|
||||
|
||||
long pos = fileIndex[24];
|
||||
int extraLen = 8 + 26*4;
|
||||
int extraLen = 8 + 26 * 4;
|
||||
|
||||
if ( len == pos ) return; // old format o.k.
|
||||
if (len == pos) return; // old format o.k.
|
||||
|
||||
if ( len < pos+extraLen ) // > is o.k. for future extensions!
|
||||
if (len < pos + extraLen) // > is o.k. for future extensions!
|
||||
{
|
||||
throw new IOException( "file of size " + len + " too short, should be " + (pos+extraLen) );
|
||||
throw new IOException("file of size " + len + " too short, should be " + (pos + extraLen));
|
||||
}
|
||||
|
||||
ra.seek( pos );
|
||||
ra.readFully( iobuffer, 0, extraLen );
|
||||
dis = new ByteDataReader( iobuffer );
|
||||
|
||||
ra.seek(pos);
|
||||
ra.readFully(iobuffer, 0, extraLen);
|
||||
dis = new ByteDataReader(iobuffer);
|
||||
creationTime = dis.readLong();
|
||||
|
||||
int crcData = dis.readInt();
|
||||
if ( crcData == fileIndexCrc )
|
||||
{
|
||||
if (crcData == fileIndexCrc) {
|
||||
divisor = 80; // old format
|
||||
}
|
||||
else if ( (crcData ^ 2) == fileIndexCrc )
|
||||
{
|
||||
} else if ((crcData ^ 2) == fileIndexCrc) {
|
||||
divisor = 32; // new format
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IOException( "top index checksum error" );
|
||||
} else {
|
||||
throw new IOException("top index checksum error");
|
||||
}
|
||||
fileHeaderCrcs = new int[25];
|
||||
for( int i=0; i<25; i++ )
|
||||
{
|
||||
for (int i = 0; i < 25; i++) {
|
||||
fileHeaderCrcs[i] = dis.readInt();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue