Class ShallowImmutablePointList

java.lang.Object
com.graphhopper.util.PointList
com.graphhopper.util.ShallowImmutablePointList
All Implemented Interfaces:
PointAccess, Iterable<GHPoint3D>

public final class ShallowImmutablePointList extends PointList
This is a shallow copy of a PointList. This class can be used to create a memory efficient copy of a PointList. You have to be aware, that if the wrapped PointList changes, the shallow copy will change as well. This can lead to unexpected results. We recommend making the wrapped PointList immutable PointList.makeImmutable().
Author:
Robin Boldt
  • Constructor Details

    • ShallowImmutablePointList

      public ShallowImmutablePointList(int fromOffset, int toOffset, PointList wrappedPointList)
  • Method Details

    • size

      public int size()
      Overrides:
      size in class PointList
    • getSize

      public int getSize()
    • isEmpty

      public boolean isEmpty()
      Overrides:
      isEmpty in class PointList
    • getIntervalString

      public String getIntervalString()
    • getLat

      public double getLat(int index)
      Specified by:
      getLat in interface PointAccess
      Overrides:
      getLat in class PointList
      Returns:
      the latitude at the specified node index
    • getLon

      public double getLon(int index)
      Specified by:
      getLon in interface PointAccess
      Overrides:
      getLon in class PointList
      Returns:
      the longitude at the specified node index
    • getEle

      public double getEle(int index)
      Description copied from interface: PointAccess
      Returns the elevation of the specified nodeId.
      Specified by:
      getEle in interface PointAccess
      Overrides:
      getEle in class PointList
    • setElevation

      public void setElevation(int index, double ele)
      Overrides:
      setElevation in class PointList
    • makeImmutable

      public PointList makeImmutable()
      Description copied from class: PointList
      Once immutable, there is no way to make this object mutable again. This is done to ensure the consistency of shallow copies. If you need to modify this object again, you have to create a deep copy of it.
      Overrides:
      makeImmutable in class PointList
    • isImmutable

      public boolean isImmutable()
      Overrides:
      isImmutable in class PointList
    • is3D

      public boolean is3D()
      Specified by:
      is3D in interface PointAccess
      Overrides:
      is3D in class PointList
      Returns:
      true if elevation data is stored and can be retrieved
    • getDimension

      public int getDimension()
      Specified by:
      getDimension in interface PointAccess
      Overrides:
      getDimension in class PointList
      Returns:
      3 if elevation enabled. 2 otherwise
    • ensureNode

      public void ensureNode(int nodeId)
      Description copied from interface: PointAccess
      This method ensures that the node with the specified index exists i.e. allocates space for it.
      Specified by:
      ensureNode in interface PointAccess
      Overrides:
      ensureNode in class PointList
    • setNode

      public void setNode(int nodeId, double lat, double lon, double ele)
      Description copied from interface: PointAccess
      This method ensures that the node with the specified index exists and prepares access to it. The index goes from 0 (inclusive) to graph.getNodes() (exclusive)

      This methods sets the latitude, longitude and elevation to the specified value.

      Specified by:
      setNode in interface PointAccess
      Overrides:
      setNode in class PointList
    • set

      public void set(int index, double lat, double lon, double ele)
      Overrides:
      set in class PointList
    • add

      public void add(double lat, double lon, double ele)
      Overrides:
      add in class PointList
    • add

      public void add(PointList points)
      Overrides:
      add in class PointList
    • removeLastPoint

      public void removeLastPoint()
      Overrides:
      removeLastPoint in class PointList
    • reverse

      public void reverse()
      Overrides:
      reverse in class PointList
    • clear

      public void clear()
      Overrides:
      clear in class PointList
    • trimToSize

      public void trimToSize(int newSize)
      Overrides:
      trimToSize in class PointList
    • parse2DJSON

      public void parse2DJSON(String str)
      Description copied from class: PointList
      Takes the string from a json array ala [lon1,lat1], [lon2,lat2], ... and fills the list from it.
      Overrides:
      parse2DJSON in class PointList