Package org.mapsforge.map.reader
Class MapFile
java.lang.Object
org.mapsforge.map.datastore.MapDataStore
org.mapsforge.map.reader.MapFile
public class MapFile
extends org.mapsforge.map.datastore.MapDataStore
A class for reading binary map files.
The readMapData method is now thread safe, but care should be taken that not too much data is
read at the same time (keep simultaneous requests to minimum)
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final MapFile
static int
static boolean
Way filtering reduces the number of ways returned to only those that are relevant for the tile requested, leading to performance gains, but can cause line clipping artifacts (particularly at higher zoom levels).Fields inherited from class org.mapsforge.map.datastore.MapDataStore
preferredLanguage
-
Constructor Summary
ConstructorDescriptionOpens the given map file, reads its header data and validates them.MapFile
(FileInputStream mapFileInputStream) Opens the given map file input stream, reads its header data and validates them.MapFile
(FileInputStream mapFileInputStream, long lastModified, String language) Opens the given map file input stream, reads its header data and validates them.MapFile
(FileInputStream mapFileInputStream, String language) Opens the given map file input stream, reads its header data and validates them.Opens the given map file, reads its header data and validates them.Opens the given map file, reads its header data and validates them.Opens the given map file, reads its header data and validates them.MapFile
(FileChannel mapFileChannel) Opens the given map file channel, reads its header data and validates them.MapFile
(FileChannel mapFileChannel, long lastModified, String language) Opens the given map file channel, reads its header data and validates them.MapFile
(FileChannel mapFileChannel, String language) Opens the given map file channel, reads its header data and validates them. -
Method Summary
Modifier and TypeMethodDescriptionorg.mapsforge.core.model.BoundingBox
void
close()
long
getDataTimestamp
(org.mapsforge.core.model.Tile tile) Returns the creation timestamp of the map file.String[]
org.mapsforge.map.datastore.MapReadResult
readLabels
(org.mapsforge.core.model.Tile tile) Reads only labels for tile.org.mapsforge.map.datastore.MapReadResult
readLabels
(org.mapsforge.core.model.Tile upperLeft, org.mapsforge.core.model.Tile lowerRight) Reads data for an area defined by the tile in the upper left and the tile in the lower right corner.org.mapsforge.map.datastore.MapReadResult
readMapData
(org.mapsforge.core.model.Tile tile) Reads all map data for the area covered by the given tile at the tile zoom level.org.mapsforge.map.datastore.MapReadResult
readMapData
(org.mapsforge.core.model.Tile upperLeft, org.mapsforge.core.model.Tile lowerRight) Reads data for an area defined by the tile in the upper left and the tile in the lower right corner.org.mapsforge.map.datastore.MapReadResult
readPoiData
(org.mapsforge.core.model.Tile tile) Reads only POI data for tile.org.mapsforge.map.datastore.MapReadResult
readPoiData
(org.mapsforge.core.model.Tile upperLeft, org.mapsforge.core.model.Tile lowerRight) Reads POI data for an area defined by the tile in the upper left and the tile in the lower right corner.void
restrictToZoomRange
(byte minZoom, byte maxZoom) Restricts returns of data to zoom level range specified.org.mapsforge.core.model.LatLong
boolean
supportsTile
(org.mapsforge.core.model.Tile tile) Methods inherited from class org.mapsforge.map.datastore.MapDataStore
extract, extractLocalized, wayAsLabelTagFilter
-
Field Details
-
TEST_MAP_FILE
-
wayFilterEnabled
public static boolean wayFilterEnabledWay filtering reduces the number of ways returned to only those that are relevant for the tile requested, leading to performance gains, but can cause line clipping artifacts (particularly at higher zoom levels). The risk of clipping can be reduced by either turning way filtering off or by increasing the wayFilterDistance which governs how large an area surrounding the requested tile will be returned. For most use cases the standard settings should be sufficient. -
wayFilterDistance
public static int wayFilterDistance
-
-
Constructor Details
-
MapFile
Opens the given map file, reads its header data and validates them. Uses default language.- Parameters:
mapFile
- the map file.- Throws:
MapFileException
- if the given map file is null or invalid.
-
MapFile
Opens the given map file, reads its header data and validates them.- Parameters:
mapFile
- the map file.language
- the language to use (may be null).- Throws:
MapFileException
- if the given map file is null or invalid.
-
MapFile
Opens the given map file input stream, reads its header data and validates them.- Parameters:
mapFileInputStream
- the map file input stream.- Throws:
MapFileException
- if the given map file is null or invalid.
-
MapFile
Opens the given map file input stream, reads its header data and validates them.- Parameters:
mapFileInputStream
- the map file input stream.language
- the language to use (may be null).- Throws:
MapFileException
- if the given map file is null or invalid.
-
MapFile
Opens the given map file input stream, reads its header data and validates them.- Parameters:
mapFileInputStream
- the map file input stream.language
- the language to use (may be null).- Throws:
MapFileException
- if the given map file is null or invalid.
-
MapFile
Opens the given map file channel, reads its header data and validates them.- Parameters:
mapFileChannel
- the map file channel.- Throws:
MapFileException
- if the given map file channel is null or invalid.
-
MapFile
Opens the given map file channel, reads its header data and validates them.- Parameters:
mapFileChannel
- the map file channel.language
- the language to use (may be null).- Throws:
MapFileException
- if the given map file channel is null or invalid.
-
MapFile
Opens the given map file channel, reads its header data and validates them.- Parameters:
mapFileChannel
- the map file channel.language
- the language to use (may be null).- Throws:
MapFileException
- if the given map file channel is null or invalid.
-
MapFile
Opens the given map file, reads its header data and validates them. Uses default language.- Parameters:
mapPath
- the path of the map file.- Throws:
MapFileException
- if the given map file is null or invalid.
-
MapFile
Opens the given map file, reads its header data and validates them.- Parameters:
mapPath
- the path of the map file.language
- the language to use (may be null).- Throws:
MapFileException
- if the given map file is null or invalid or IOException if the file cannot be opened.
-
-
Method Details
-
boundingBox
public org.mapsforge.core.model.BoundingBox boundingBox()- Specified by:
boundingBox
in classorg.mapsforge.map.datastore.MapDataStore
-
close
public void close()- Specified by:
close
in classorg.mapsforge.map.datastore.MapDataStore
-
getDataTimestamp
public long getDataTimestamp(org.mapsforge.core.model.Tile tile) Returns the creation timestamp of the map file.- Specified by:
getDataTimestamp
in classorg.mapsforge.map.datastore.MapDataStore
- Parameters:
tile
- not used, as all tiles will shared the same creation date.- Returns:
- the creation timestamp inside the map file.
-
getMapFileHeader
- Returns:
- the header data for the current map file.
-
getMapFileInfo
- Returns:
- the metadata for the current map file.
-
getMapLanguages
- Returns:
- the map file supported languages (may be null).
-
readLabels
public org.mapsforge.map.datastore.MapReadResult readLabels(org.mapsforge.core.model.Tile tile) Reads only labels for tile.- Overrides:
readLabels
in classorg.mapsforge.map.datastore.MapDataStore
- Parameters:
tile
- tile for which data is requested.- Returns:
- label data for the tile.
-
readLabels
public org.mapsforge.map.datastore.MapReadResult readLabels(org.mapsforge.core.model.Tile upperLeft, org.mapsforge.core.model.Tile lowerRight) Reads data for an area defined by the tile in the upper left and the tile in the lower right corner. Precondition: upperLeft.tileX <= lowerRight.tileX && upperLeft.tileY <= lowerRight.tileY- Overrides:
readLabels
in classorg.mapsforge.map.datastore.MapDataStore
- Parameters:
upperLeft
- tile that defines the upper left corner of the requested area.lowerRight
- tile that defines the lower right corner of the requested area.- Returns:
- map data for the tile.
-
readMapData
public org.mapsforge.map.datastore.MapReadResult readMapData(org.mapsforge.core.model.Tile tile) Reads all map data for the area covered by the given tile at the tile zoom level.- Specified by:
readMapData
in classorg.mapsforge.map.datastore.MapDataStore
- Parameters:
tile
- defines area and zoom level of read map data.- Returns:
- the read map data.
-
readMapData
public org.mapsforge.map.datastore.MapReadResult readMapData(org.mapsforge.core.model.Tile upperLeft, org.mapsforge.core.model.Tile lowerRight) Reads data for an area defined by the tile in the upper left and the tile in the lower right corner. Precondition: upperLeft.tileX <= lowerRight.tileX && upperLeft.tileY <= lowerRight.tileY- Overrides:
readMapData
in classorg.mapsforge.map.datastore.MapDataStore
- Parameters:
upperLeft
- tile that defines the upper left corner of the requested area.lowerRight
- tile that defines the lower right corner of the requested area.- Returns:
- map data for the tile.
-
readPoiData
public org.mapsforge.map.datastore.MapReadResult readPoiData(org.mapsforge.core.model.Tile tile) Reads only POI data for tile.- Specified by:
readPoiData
in classorg.mapsforge.map.datastore.MapDataStore
- Parameters:
tile
- tile for which data is requested.- Returns:
- POI data for the tile.
-
readPoiData
public org.mapsforge.map.datastore.MapReadResult readPoiData(org.mapsforge.core.model.Tile upperLeft, org.mapsforge.core.model.Tile lowerRight) Reads POI data for an area defined by the tile in the upper left and the tile in the lower right corner. This implementation takes the data storage of a MapFile into account for greater efficiency.- Overrides:
readPoiData
in classorg.mapsforge.map.datastore.MapDataStore
- Parameters:
upperLeft
- tile that defines the upper left corner of the requested area.lowerRight
- tile that defines the lower right corner of the requested area.- Returns:
- map data for the tile.
-
restrictToZoomRange
public void restrictToZoomRange(byte minZoom, byte maxZoom) Restricts returns of data to zoom level range specified. This can be used to restrict the use of this map data base when used in MultiMapDatabase settings.- Parameters:
minZoom
- minimum zoom level supportedmaxZoom
- maximum zoom level supported
-
startPosition
public org.mapsforge.core.model.LatLong startPosition()- Specified by:
startPosition
in classorg.mapsforge.map.datastore.MapDataStore
-
startZoomLevel
- Specified by:
startZoomLevel
in classorg.mapsforge.map.datastore.MapDataStore
-
supportsTile
public boolean supportsTile(org.mapsforge.core.model.Tile tile) - Specified by:
supportsTile
in classorg.mapsforge.map.datastore.MapDataStore
-