Class MapDataStore

  • Direct Known Subclasses:
    MultiMapDataStore

    public abstract class MapDataStore
    extends java.lang.Object
    Base class for map data retrieval.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String preferredLanguage
      the preferred language when extracting labels from this data store.
    • Constructor Summary

      Constructors 
      Constructor Description
      MapDataStore()
      Ctor for MapDataStore that will use default language.
      MapDataStore​(java.lang.String language)
      Ctor for MapDataStore setting preferred language.
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract org.mapsforge.core.model.BoundingBox boundingBox()
      Returns the area for which data is supplied.
      abstract void close()  
      static java.lang.String extract​(java.lang.String s, java.lang.String language)
      Extracts substring of preferred language from multilingual string.
      Example multilingual string: "Base\ren\bEnglish\rjp\bJapan\rzh_py\bPin-yin".
      protected java.lang.String extractLocalized​(java.lang.String s)
      Extracts substring of preferred language from multilingual string using the preferredLanguage setting.
      abstract long getDataTimestamp​(org.mapsforge.core.model.Tile tile)
      Returns the timestamp of the data used to render a specific tile.
      MapReadResult readLabels​(org.mapsforge.core.model.Tile tile)
      Reads only labels for tile.
      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.
      abstract MapReadResult readMapData​(org.mapsforge.core.model.Tile tile)
      Reads data for tile.
      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.
      abstract MapReadResult readPoiData​(org.mapsforge.core.model.Tile tile)
      Reads only POI data for tile.
      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.
      abstract org.mapsforge.core.model.LatLong startPosition()
      Gets the initial map position.
      abstract java.lang.Byte startZoomLevel()
      Gets the initial zoom level.
      abstract boolean supportsTile​(org.mapsforge.core.model.Tile tile)
      Returns true if MapDatabase contains tile.
      boolean wayAsLabelTagFilter​(java.util.List<org.mapsforge.core.model.Tag> tags)
      Returns true if a way should be included in the result set for readLabels() By default only ways with names, house numbers or a ref are included in the result set of readLabels().
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • preferredLanguage

        protected java.lang.String preferredLanguage
        the preferred language when extracting labels from this data store. The actual implementation is up to the concrete implementation, which can also simply ignore this setting.
    • Constructor Detail

      • MapDataStore

        public MapDataStore()
        Ctor for MapDataStore that will use default language.
      • MapDataStore

        public MapDataStore​(java.lang.String language)
        Ctor for MapDataStore setting preferred language.
        Parameters:
        language - the preferred language or null if default language is used.
    • Method Detail

      • extract

        public static java.lang.String extract​(java.lang.String s,
                                               java.lang.String language)
        Extracts substring of preferred language from multilingual string.
        Example multilingual string: "Base\ren\bEnglish\rjp\bJapan\rzh_py\bPin-yin".

        Use '\r' delimiter among names and '\b' delimiter between each language and name.

      • boundingBox

        public abstract org.mapsforge.core.model.BoundingBox boundingBox()
        Returns the area for which data is supplied.
        Returns:
        bounding box of area.
      • close

        public abstract void close()
      • extractLocalized

        protected java.lang.String extractLocalized​(java.lang.String s)
        Extracts substring of preferred language from multilingual string using the preferredLanguage setting.
      • getDataTimestamp

        public abstract long getDataTimestamp​(org.mapsforge.core.model.Tile tile)
        Returns the timestamp of the data used to render a specific tile.
        Parameters:
        tile - A tile.
        Returns:
        the timestamp of the data used to render the tile
      • readLabels

        public MapReadResult readLabels​(org.mapsforge.core.model.Tile tile)
        Reads only labels for tile. Labels are pois as well as ways that carry a name tag. It is permissible for the MapDataStore to return more data. This default implementation returns all map data, which is inefficient, but works.
        Parameters:
        tile - tile for which data is requested.
        Returns:
        label data for the tile.
      • readLabels

        public 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. The default implementation combines the results from all tiles, a possibly inefficient solution. Precondition: upperLeft.tileX <= lowerRight.tileX && upperLeft.tileY <= lowerRight.tileY
        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 abstract MapReadResult readMapData​(org.mapsforge.core.model.Tile tile)
        Reads data for tile.
        Parameters:
        tile - tile for which data is requested.
        Returns:
        map data for the tile.
      • readMapData

        public 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. The default implementation combines the results from all tiles, a possibly inefficient solution. Precondition: upperLeft.tileX <= lowerRight.tileX && upperLeft.tileY <= lowerRight.tileY
        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 abstract MapReadResult readPoiData​(org.mapsforge.core.model.Tile tile)
        Reads only POI data for tile.
        Parameters:
        tile - tile for which data is requested.
        Returns:
        poi data for the tile.
      • readPoiData

        public 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. The default implementation combines the results from all tiles, a possibly inefficient solution. Precondition: upperLeft.tileX <= lowerRight.tileX && upperLeft.tileY <= lowerRight.tileY
        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.
      • startPosition

        public abstract org.mapsforge.core.model.LatLong startPosition()
        Gets the initial map position.
        Returns:
        the start position, if available.
      • startZoomLevel

        public abstract java.lang.Byte startZoomLevel()
        Gets the initial zoom level.
        Returns:
        the start zoom level.
      • supportsTile

        public abstract boolean supportsTile​(org.mapsforge.core.model.Tile tile)
        Returns true if MapDatabase contains tile.
        Parameters:
        tile - tile to be rendered.
        Returns:
        true if tile is part of database.
      • wayAsLabelTagFilter

        public boolean wayAsLabelTagFilter​(java.util.List<org.mapsforge.core.model.Tag> tags)
        Returns true if a way should be included in the result set for readLabels() By default only ways with names, house numbers or a ref are included in the result set of readLabels(). This is to reduce the set of ways as much as possible to save memory.
        Parameters:
        tags - the tags associated with the way
        Returns:
        true if the way should be included in the result set