Package com.graphhopper.util
Class ShallowImmutablePointList
java.lang.Object
com.graphhopper.util.PointList
com.graphhopper.util.ShallowImmutablePointList
- All Implemented Interfaces:
PointAccess
,Iterable<GHPoint3D>
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
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionShallowImmutablePointList
(int fromOffset, int toOffset, PointList wrappedPointList) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double lat, double lon, double ele) void
void
clear()
void
ensureNode
(int nodeId) This method ensures that the node with the specified index exists i.e.int
double
getEle
(int index) Returns the elevation of the specified nodeId.double
getLat
(int index) double
getLon
(int index) int
getSize()
boolean
is3D()
boolean
isEmpty()
boolean
Once immutable, there is no way to make this object mutable again.void
parse2DJSON
(String str) Takes the string from a json array ala [lon1,lat1], [lon2,lat2], ...void
void
reverse()
void
set
(int index, double lat, double lon, double ele) void
setElevation
(int index, double ele) void
setNode
(int nodeId, double lat, double lon, double ele) This method ensures that the node with the specified index exists and prepares access to it.int
size()
void
trimToSize
(int newSize) Methods inherited from class com.graphhopper.util.PointList
add, add, add, clone, copy, equals, equalsEps, equalsEps, from, fromLineString, get, getCachedLineString, hashCode, iterator, shallowCopy, toLineString, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
Methods inherited from interface com.graphhopper.util.PointAccess
setNode
-
Constructor Details
-
ShallowImmutablePointList
-
-
Method Details
-
size
public int size() -
getSize
public int getSize() -
isEmpty
public boolean isEmpty() -
getIntervalString
-
getLat
public double getLat(int index) - Specified by:
getLat
in interfacePointAccess
- Overrides:
getLat
in classPointList
- Returns:
- the latitude at the specified node index
-
getLon
public double getLon(int index) - Specified by:
getLon
in interfacePointAccess
- Overrides:
getLon
in classPointList
- 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 interfacePointAccess
- Overrides:
getEle
in classPointList
-
setElevation
public void setElevation(int index, double ele) - Overrides:
setElevation
in classPointList
-
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 classPointList
-
isImmutable
public boolean isImmutable()- Overrides:
isImmutable
in classPointList
-
is3D
public boolean is3D()- Specified by:
is3D
in interfacePointAccess
- Overrides:
is3D
in classPointList
- Returns:
- true if elevation data is stored and can be retrieved
-
getDimension
public int getDimension()- Specified by:
getDimension
in interfacePointAccess
- Overrides:
getDimension
in classPointList
- 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 interfacePointAccess
- Overrides:
ensureNode
in classPointList
-
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 interfacePointAccess
- Overrides:
setNode
in classPointList
-
set
public void set(int index, double lat, double lon, double ele) -
add
public void add(double lat, double lon, double ele) -
add
-
removeLastPoint
public void removeLastPoint()- Overrides:
removeLastPoint
in classPointList
-
reverse
public void reverse() -
clear
public void clear() -
trimToSize
public void trimToSize(int newSize) - Overrides:
trimToSize
in classPointList
-
parse2DJSON
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 classPointList
-