Package org.ka2ddo.yaac.osm
Class OsmSegmenter
java.lang.Object
org.ka2ddo.yaac.osm.OsmSegmenter
- Direct Known Subclasses:
OsmPbfSegmenter
,OsmXmlSegmenter
Common code for different OpenStreetMap dataset file format loaders.
- Author:
- Andrew Pavlin, KA2DDO
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
This class provides a FileFilter for identifying the relevant temporary files for sorting the results of an OSM import.protected static class
static interface
Callback interface for OsmSegmenter instances reporting updates to a progress indicator.protected class
This class handles the logic of sorting a temporary .ways file into the proper order for correct rendering. -
Field Summary
Modifier and TypeFieldDescriptionstatic final long
Kilobytes of free disk space needed on the tile directory's partition to handle importing a new OSM file.static final long
Kilobytes of free disk space needed on the temporary directory's partition to handle importing a new OSM file.protected static final String[]
Filetypes for different types of Way files.protected static final int
Flag indicating OSM Ways not properly labeled for rendering.protected static final int
Flag indicating OSM Ways properly labeled for rendering.protected static final int
Maximum latitude in millionths of degrees.protected static final int
Maximum longitude in millionths of degrees.protected static final int
Minimum latitude in millionths of degrees.protected static final int
Minimum longitude in millionths of degrees.protected int
Counter of number of duplicate Ways deleted from the collection of Way files.protected int
Counter of processed Node files (used by common reporting code).protected int
Counter of failed sorts of Way and Node files.protected int
Counter of processed Way files (used by common reporting code).protected NonshareableBufferedDataOutputStream
Shared area for stream to planet.ways.tmp file.protected static final org.ka2ddo.yaac.osm.OsmSegmenter.RelationsStatsMapEntryComparator
protected static File
File identifying the directory used by YAAC to store map tile file latitude directories.protected final File
File identifying the directory used by OpenStreetMap importers for high-data-access-rate temporary files. -
Constructor Summary
ModifierConstructorDescriptionprotected
OsmSegmenter
(String rootTilePath) Abstract pre-constructor for any OSM file segmenter, -
Method Summary
Modifier and TypeMethodDescriptioncheckDiskSpace
(long filesize) Check if sufficient disk space is available to import the OSM file.protected static int
computeActiveQueueCount
(GenericTaggedQueue[] queues) Helper method to compute the current count of non-empty queues.protected static int
computeQueuesBacklog
(GenericTaggedQueue[] queues) Helper method to compute the current backlog count of queued objects.protected static GenericTaggedQueue
findBiggestQueue
(GenericTaggedQueue[] writerQueues, int upperLimitQueueSize) Helper method to find the queue with the largest backlog in an array of queues.protected abstract long
Report the minimum total size of data structures that will be simultaneously allocated during import.abstract void
parse
(FileInputStream fileInputStream, NonshareableCountingBufferedDataInputStream inputStream, File inputFile, boolean useFixMe, StatusListener listener) Parse a OpenStreetMap snapshot file into YAAC's version of OpenStreetMap tiles.protected String
produceSortStatusMessage
(File latDir) Generate a string reporting the current state of sorting the tile files.protected static void
Tell all map windows to redraw their maps based upon the updated map tile files.
-
Field Details
-
ESTIMATED_EXTRA_TILE_SPACE
public static final long ESTIMATED_EXTRA_TILE_SPACEKilobytes of free disk space needed on the tile directory's partition to handle importing a new OSM file.- See Also:
-
ESTIMATED_TEMP_TILE_SPACE
public static final long ESTIMATED_TEMP_TILE_SPACEKilobytes of free disk space needed on the temporary directory's partition to handle importing a new OSM file. The temporary directory is used instead of the tile directory when the Java system property alt.tile.dir is defined; if not defined, this usage is added to the tile directory's usage. -
MAX_LATITUDE
protected static final int MAX_LATITUDEMaximum latitude in millionths of degrees.- See Also:
-
MIN_LATITUDE
protected static final int MIN_LATITUDEMinimum latitude in millionths of degrees.- See Also:
-
MAX_LONGITUDE
protected static final int MAX_LONGITUDEMaximum longitude in millionths of degrees.- See Also:
-
MIN_LONGITUDE
protected static final int MIN_LONGITUDEMinimum longitude in millionths of degrees.- See Also:
-
FILETYPE_SUFFIXES
Filetypes for different types of Way files.- See Also:
-
FILETYPE_WAY
protected static final int FILETYPE_WAYFlag indicating OSM Ways properly labeled for rendering.- See Also:
-
FILETYPE_SWAY
protected static final int FILETYPE_SWAYFlag indicating OSM Ways not properly labeled for rendering.- See Also:
-
RELATIONS_STATS_MAP_ENTRY_COMPARATOR
protected static final org.ka2ddo.yaac.osm.OsmSegmenter.RelationsStatsMapEntryComparator RELATIONS_STATS_MAP_ENTRY_COMPARATOR -
tileRootDirectory
File identifying the directory used by YAAC to store map tile file latitude directories. -
tileTmpDirectory
File identifying the directory used by OpenStreetMap importers for high-data-access-rate temporary files. If not defined as a separate location, has the same value as tileRootDirectory.- See Also:
-
planetDos
Shared area for stream to planet.ways.tmp file. Used for ocean way processing. -
numWayFiles
protected transient int numWayFilesCounter of processed Way files (used by common reporting code). -
numNodeFiles
protected transient int numNodeFilesCounter of processed Node files (used by common reporting code). -
numSortFailures
protected transient int numSortFailuresCounter of failed sorts of Way and Node files. -
numDupWaysDeleted
protected transient int numDupWaysDeletedCounter of number of duplicate Ways deleted from the collection of Way files.
-
-
Constructor Details
-
OsmSegmenter
Abstract pre-constructor for any OSM file segmenter,- Parameters:
rootTilePath
- String pathname of the configured tile directory- Throws:
IOException
- if tile directory cannot be created
-
-
Method Details
-
getMinHeapRequired
protected abstract long getMinHeapRequired()Report the minimum total size of data structures that will be simultaneously allocated during import.- Returns:
- long byte count for estimated minimum heap
-
checkDiskSpace
Check if sufficient disk space is available to import the OSM file.- Parameters:
filesize
- long byte-count size of the OSM file to read (to estimate resulting tile size)- Returns:
- error message if not enough disk space, or null if no apparent problem
-
findBiggestQueue
protected static GenericTaggedQueue findBiggestQueue(GenericTaggedQueue[] writerQueues, int upperLimitQueueSize) Helper method to find the queue with the largest backlog in an array of queues.- Parameters:
writerQueues
- array of GenericTaggedQueuesupperLimitQueueSize
- int threshold of largest queue capacity, so scan can stop as soon as the fullest possible queue is found- Returns:
- fullest GenericTaggedQueue in array, or null if all queues are empty
-
computeQueuesBacklog
Helper method to compute the current backlog count of queued objects. This is not synchronized, so the count may be an approximation if other threads are inserting to or draining the queues.- Parameters:
queues
- array of GenericTaggedQueues- Returns:
- count of objects in all the queues in the array
-
computeActiveQueueCount
Helper method to compute the current count of non-empty queues. This is not synchronized, so the count may be an approximation if other threads are inserting to or draining the queues.- Parameters:
queues
- array of GenericTaggedQueues- Returns:
- count of non-empty queues in the array
-
produceSortStatusMessage
Generate a string reporting the current state of sorting the tile files.- Parameters:
latDir
- File of the latitude diectory currently being processed- Returns:
- formatted string of import progress
-
refreshMapWindows
protected static void refreshMapWindows()Tell all map windows to redraw their maps based upon the updated map tile files.