Class OsmSegmenter.WayFileSorter

java.lang.Object
org.ka2ddo.yaac.osm.OsmSegmenter.WayFileSorter
All Implemented Interfaces:
Runnable
Enclosing class:
OsmSegmenter

protected class OsmSegmenter.WayFileSorter extends Object implements Runnable
This class handles the logic of sorting a temporary .ways file into the proper order for correct rendering. Because it returns multiple data items, it had to be made into a method object.
  • Constructor Details

    • WayFileSorter

      public WayFileSorter(StatusListener listener, byte[] buf, int latDirArrayLength, PrintStream out)
      Create a reusable WayFileSorter instance.
      Parameters:
      listener - StatusListener to report progress of sorting
      buf - byte array to use for buffered reading and writing of ways file
      latDirArrayLength - the number of latitude directories to be searched through (for computing percentage progress)
      out - PrintStream for OsmSegmenter log file
    • WayFileSorter

      public WayFileSorter(StatusListener listener, int bufSize, FastBlockingQueue<File> fileSource, PrintStream out)
      Create a reusable WayFileSorter instance.
      Parameters:
      listener - StatusListener to report progress of sorting
      bufSize - size of byte array to use for buffered reading and writing of ways file
      fileSource - FastBlockingQueue that can provide a sequence of File objects to sort
      out - PrintStream for OsmSegmenter log file
  • Method Details

    • run

      public void run()
      DO NOT CALL. Reserved for parallel processing of Way file sorting after use of WayFileSorter(StatusListener, int, FastBlockingQueue<File>, PrintStream) constructor.
      Specified by:
      run in interface Runnable
    • setNoMoreFiles

      public void setNoMoreFiles(boolean noMoreFiles)
      Indicate to parallel way sorter thread that there are no more way files to be put into the queue.
      Parameters:
      noMoreFiles - boolean true if we are out of unsorted way files
    • getNumSortFailures

      public int getNumSortFailures()
      Report the number of times the sort didn't succeed (usually due to file reading problems).
      Returns:
      number of sort failures (normally 0, may be 1)
    • getNumDupWaysDeleted

      public int getNumDupWaysDeleted()
      Report the number of Way records deleted from the file as being exact duplicates or subsets of other Ways.
      Returns:
      count of deleted Way records
    • sortFile

      public void sortFile(File wayFile, int latIdx) throws IOException
      Sort a temporary ways file into the proper permanent order.
      Parameters:
      wayFile - File identifying the temporary file to sort
      latIdx - int array index of the latitude (used to calculate progress bar percentage)
      Throws:
      IOException - if file could not be read or written
    • getFailureReason

      public Throwable getFailureReason()
      Get reason why this sorter crashed.
      Returns:
      Throwable why this sorter crashed or null if no failure