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 TypeMethodDescriptionvoidadd(double lat, double lon, double ele) voidvoidclear()voidensureNode(int nodeId) This method ensures that the node with the specified index exists i.e.intdoublegetEle(int index) Returns the elevation of the specified nodeId.doublegetLat(int index) doublegetLon(int index) intgetSize()booleanis3D()booleanisEmpty()booleanOnce immutable, there is no way to make this object mutable again.voidparse2DJSON(String str) Takes the string from a json array ala [lon1,lat1], [lon2,lat2], ...voidvoidreverse()voidset(int index, double lat, double lon, double ele) voidsetElevation(int index, double ele) voidsetNode(int nodeId, double lat, double lon, double ele) This method ensures that the node with the specified index exists and prepares access to it.intsize()voidtrimToSize(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, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods 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:
getLatin interfacePointAccess- Overrides:
getLatin classPointList- Returns:
- the latitude at the specified node index
-
getLon
public double getLon(int index) - Specified by:
getLonin interfacePointAccess- Overrides:
getLonin classPointList- Returns:
- the longitude at the specified node index
-
getEle
public double getEle(int index) Description copied from interface:PointAccessReturns the elevation of the specified nodeId.- Specified by:
getElein interfacePointAccess- Overrides:
getElein classPointList
-
setElevation
public void setElevation(int index, double ele) - Overrides:
setElevationin classPointList
-
makeImmutable
Description copied from class:PointListOnce 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:
makeImmutablein classPointList
-
isImmutable
public boolean isImmutable()- Overrides:
isImmutablein classPointList
-
is3D
public boolean is3D()- Specified by:
is3Din interfacePointAccess- Overrides:
is3Din classPointList- Returns:
- true if elevation data is stored and can be retrieved
-
getDimension
public int getDimension()- Specified by:
getDimensionin interfacePointAccess- Overrides:
getDimensionin classPointList- Returns:
- 3 if elevation enabled. 2 otherwise
-
ensureNode
public void ensureNode(int nodeId) Description copied from interface:PointAccessThis method ensures that the node with the specified index exists i.e. allocates space for it.- Specified by:
ensureNodein interfacePointAccess- Overrides:
ensureNodein classPointList
-
setNode
public void setNode(int nodeId, double lat, double lon, double ele) Description copied from interface:PointAccessThis 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:
setNodein interfacePointAccess- Overrides:
setNodein 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:
removeLastPointin classPointList
-
reverse
public void reverse() -
clear
public void clear() -
trimToSize
public void trimToSize(int newSize) - Overrides:
trimToSizein classPointList
-
parse2DJSON
Description copied from class:PointListTakes the string from a json array ala [lon1,lat1], [lon2,lat2], ... and fills the list from it.- Overrides:
parse2DJSONin classPointList
-