Package org.ka2ddo.yaac.osm
Class OsmSegmenter.WayFileSorter
java.lang.Object
org.ka2ddo.yaac.osm.OsmSegmenter.WayFileSorter
- All Implemented Interfaces:
Runnable
- Enclosing class:
- OsmSegmenter
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 Summary
ConstructorDescriptionWayFileSorter
(StatusListener listener, byte[] buf, int latDirArrayLength, PrintStream out) Create a reusable WayFileSorter instance.WayFileSorter
(StatusListener listener, int bufSize, FastBlockingQueue<File> fileSource, PrintStream out) Create a reusable WayFileSorter instance. -
Method Summary
Modifier and TypeMethodDescriptionGet reason why this sorter crashed.int
Report the number of Way records deleted from the file as being exact duplicates or subsets of other Ways.int
Report the number of times the sort didn't succeed (usually due to file reading problems).void
run()
DO NOT CALL.void
setNoMoreFiles
(boolean noMoreFiles) Indicate to parallel way sorter thread that there are no more way files to be put into the queue.void
Sort a temporary ways file into the proper permanent order.
-
Constructor Details
-
WayFileSorter
Create a reusable WayFileSorter instance.- Parameters:
listener
- StatusListener to report progress of sortingbuf
- byte array to use for buffered reading and writing of ways filelatDirArrayLength
- 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 sortingbufSize
- size of byte array to use for buffered reading and writing of ways filefileSource
- FastBlockingQueue that can provide a sequence of File objects to sortout
- 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. -
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
Sort a temporary ways file into the proper permanent order.- Parameters:
wayFile
- File identifying the temporary file to sortlatIdx
- int array index of the latitude (used to calculate progress bar percentage)- Throws:
IOException
- if file could not be read or written
-
getFailureReason
Get reason why this sorter crashed.- Returns:
- Throwable why this sorter crashed or null if no failure
-