Class DoubleLinkedPoiCategory

java.lang.Object
org.mapsforge.poi.storage.DoubleLinkedPoiCategory
All Implemented Interfaces:
PoiCategory

public class DoubleLinkedPoiCategory extends Object implements PoiCategory
A POI category representation that stores a node, its parent node and its child nodes.
  • Constructor Details

    • DoubleLinkedPoiCategory

      public DoubleLinkedPoiCategory(String title, PoiCategory parent)
      Creates a new category without knowing its position in the final category tree. If all categories have been created you have to call calculateCategoryIDs(DoubleLinkedPoiCategory, int) to assign the IDs.
      Parameters:
      title - The category's unique title.
      parent - The category's parent category. For creating a root node, set the parent to null.
    • DoubleLinkedPoiCategory

      public DoubleLinkedPoiCategory(String title, PoiCategory parent, int id)
      Creates a new category. This constructor should only be called from PoiCategoryManager when reading a category configuration from a database or XML file. Otherwise call DoubleLinkedPoiCategory(String, PoiCategory).
      Parameters:
      title - The category's unique title.
      parent - The category's parent category. For creating a root node, set the parent to null.
      id - The category's position in the tree determined by left-order-dfs-traversal.
  • Method Details

    • calculateCategoryIDs

      public static int calculateCategoryIDs(DoubleLinkedPoiCategory rootNode, int maxValue)
      This method calculates a unique ID for all nodes in the tree. For each node's 'n' ID named 'ID_'n at depth 'd' the following invariants must be true:
      • ID > max(ID of all child nodes)
      • All nodes' IDs left of n must be < ID_n.
      • All nodes' IDs right of n must be > ID_n.
      Parameters:
      rootNode - The tree's root node. (Any other node will result in invalid IDs!)
      maxValue - Global maximum ID.
      Returns:
      The root node's ID.
    • deepChildren

      public Collection<PoiCategory> deepChildren()
      Specified by:
      deepChildren in interface PoiCategory
      Returns:
      All child categories of the category, including their children.
    • getChildren

      public Collection<PoiCategory> getChildren()
      Specified by:
      getChildren in interface PoiCategory
      Returns:
      All child categories of the category.
    • getGraphVizString

      public static String getGraphVizString(DoubleLinkedPoiCategory rootNode)
      Generates a GraphViz source representation as a tree having the current node as its root.
      Parameters:
      rootNode - The resulting graph's root node. (You can use any sub node to get a sub-graph).
      Returns:
      a GraphViz source representation as a tree having the current node as its root.
    • getID

      public int getID()
      Specified by:
      getID in interface PoiCategory
      Returns:
      The node's ID.
    • getParent

      public PoiCategory getParent()
      Specified by:
      getParent in interface PoiCategory
      Returns:
      The parent category of this category or null if this category has no parent.
    • getTitle

      public String getTitle()
      Specified by:
      getTitle in interface PoiCategory
      Returns:
      The title of this category.
    • setParent

      public void setParent(PoiCategory parent)
      Sets the category's parent category.
      Specified by:
      setParent in interface PoiCategory
      Parameters:
      parent - The category to be set as parent.
    • toString

      public String toString()
      Overrides:
      toString in class Object