From 11871ee4d7b78f6fac8ec97a7facaca6b282f6d7 Mon Sep 17 00:00:00 2001 From: Arndt Brenschede Date: Fri, 16 Oct 2015 19:42:25 +0200 Subject: [PATCH] uups-fix --- ReadSizes.java | 62 +++++++++++++++++++ .../java/btools/router/RoutingEngine.java | 5 -- .../main/java/btools/mapaccess/OsmFile.java | 1 + 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 ReadSizes.java diff --git a/ReadSizes.java b/ReadSizes.java new file mode 100644 index 0000000..2ef5323 --- /dev/null +++ b/ReadSizes.java @@ -0,0 +1,62 @@ +import java.io.*; + +public class ReadSizes +{ + private static int[] tileSizes = new int[72*36]; + + protected static String baseNameForTile( int tileIndex ) + { + int lon = (tileIndex % 72 ) * 5 - 180; + int lat = (tileIndex / 72 ) * 5 - 90; + String slon = lon < 0 ? "W" + (-lon) : "E" + lon; + String slat = lat < 0 ? "S" + (-lat) : "N" + lat; + return slon + "_" + slat; + } + + private static int tileForBaseName( String basename ) + { + String uname = basename.toUpperCase(); + int idx = uname.indexOf( "_" ); + if ( idx < 0 ) return -1; + String slon = uname.substring( 0, idx ); + String slat = uname.substring( idx+1 ); + int ilon = slon.charAt(0) == 'W' ? -Integer.valueOf( slon.substring(1) ) : + ( slon.charAt(0) == 'E' ? Integer.valueOf( slon.substring(1) ) : -1 ); + int ilat = slat.charAt(0) == 'S' ? -Integer.valueOf( slat.substring(1) ) : + ( slat.charAt(0) == 'N' ? Integer.valueOf( slat.substring(1) ) : -1 ); + if ( ilon < -180 || ilon >= 180 || ilon % 5 != 0 ) return -1; + if ( ilat < - 90 || ilat >= 90 || ilat % 5 != 0 ) return -1; + return (ilon+180) / 5 + 72*((ilat+90)/5); + } + + + private static void scanExistingFiles( File dir ) + { + String[] fileNames = dir.list(); + if ( fileNames == null ) return; + String suffix = ".rd5"; + for( String fileName : fileNames ) + { + if ( fileName.endsWith( suffix ) ) + { + String basename = fileName.substring( 0, fileName.length() - suffix.length() ); + int tidx = tileForBaseName( basename ); + tileSizes[tidx] = (int)new File( dir, fileName ).length(); + } + } + } + + + public static void main(String[] args) + { + scanExistingFiles( new File( args[0] ) ); + StringBuilder sb = new StringBuilder(); + for( int tidx=0; tidx < tileSizes.length; tidx++ ) + { + if ( ( tidx % 12 ) == 0 ) sb.append( "\n " ); + sb.append( tileSizes[tidx] ).append(','); + } + System.out.println( sb ); + } + +} diff --git a/brouter-core/src/main/java/btools/router/RoutingEngine.java b/brouter-core/src/main/java/btools/router/RoutingEngine.java index b2d56d7..895b97c 100644 --- a/brouter-core/src/main/java/btools/router/RoutingEngine.java +++ b/brouter-core/src/main/java/btools/router/RoutingEngine.java @@ -363,13 +363,8 @@ public class RoutingEngine extends Thread MatchedWaypoint mwp = unmatchedWaypoints.get(i); if ( mwp.crosspoint == null ) { - System.out.println( "name=" + mwp.waypoint.name + " NOT matched r=" + mwp.radius * 111894. ); unmatchedWaypoints.set(i, matchNodeForPosition( mwp.waypoint ) ); } - else - { - System.out.println( "name=" + mwp.waypoint.name + " matched r=" + mwp.radius * 111894. ); - } } } diff --git a/brouter-mapaccess/src/main/java/btools/mapaccess/OsmFile.java b/brouter-mapaccess/src/main/java/btools/mapaccess/OsmFile.java index 9c1b381..567b453 100644 --- a/brouter-mapaccess/src/main/java/btools/mapaccess/OsmFile.java +++ b/brouter-mapaccess/src/main/java/btools/mapaccess/OsmFile.java @@ -145,6 +145,7 @@ final class OsmFile { ab = new byte[asize]; asize = getDataInputForSubIdx( subIdx, ab ); + dataBuffers = new DataBuffers( ab ); } // hack: the checksum contains the information // which type of microcache we have