public static void writeFile ( MapWriterConfiguration configuration , TileBasedDataProcessor dataProcessor ) throws IOException { EXECUTOR_SERVICE = Executors . newFixedThreadPool ( configuration . getThreads ( ) ) ; RandomAccessFile randomAccessFile = new RandomAccessFile ( configuration . getOutputFile ( ) , "rw" ) ; int amountOfZoomIntervals = dataProcessor . getZoomIntervalConfiguration ( ) . getNumberOfZoomIntervals ( ) ; ByteBuffer containerHeaderBuffer = ByteBuffer . allocate ( HEADER_BUFFER_SIZE ) ; // CONTAINER HEADER int totalHeaderSize = writeHeaderBuffer ( configuration , dataProcessor , containerHeaderBuffer ) ; // set to mark where zoomIntervalConfig starts containerHeaderBuffer . reset ( ) ; final LoadingCache < TDWay , Geometry > jtsGeometryCache = CacheBuilder . newBuilder ( ) . maximumSize ( JTS_GEOMETRY_CACHE_SIZE ) . concurrencyLevel ( Runtime . getRuntime ( ) . availableProcessors ( ) * 2 ) . build ( new JTSGeometryCacheLoader ( dataProcessor ) ) ; // SUB FILES // for each zoom interval write a sub file long currentFileSize = totalHeaderSize ; for ( int i = 0 ; i < amountOfZoomIntervals ; i ++ ) { // SUB FILE INDEX AND DATA long subfileSize = writeSubfile ( currentFileSize , i , dataProcessor , jtsGeometryCache , randomAccessFile , configuration ) ; // SUB FILE META DATA IN CONTAINER HEADER writeSubfileMetaDataToContainerHeader ( dataProcessor . getZoomIntervalConfiguration ( ) , i , currentFileSize , subfileSize , containerHeaderBuffer ) ; currentFileSize += subfileSize ; } randomAccessFile . seek ( 0 ) ; randomAccessFile . write ( containerHeaderBuffer . array ( ) , 0 , totalHeaderSize ) ; // WRITE FILE SIZE TO HEADER long fileSize = randomAccessFile . length ( ) ; randomAccessFile . seek ( OFFSET_FILE_SIZE ) ; randomAccessFile . writeLong ( fileSize ) ; randomAccessFile . close ( ) ; CacheStats stats = jtsGeometryCache . stats ( ) ; LOGGER . fine ( "Tag values stats:\n" + OSMUtils . logValueTypeCount ( ) ) ; LOGGER . info ( "JTS Geometry cache hit rate: " + stats . hitRate ( ) ) ; LOGGER . info ( "JTS Geometry total load time: " + stats . totalLoadTime ( ) / 1000 ) ; LOGGER . info ( "Finished writing file." ) ; }
Writes the map file according to the given configuration using the given data processor .