AnyLogic
Expand
Font size
All Implemented Interfaces:
AggregatableAnimationElement, AnimationMovingLocationProvider, AnimationStaticLocationProvider, INetworkMarkupElement, IPath<GISNode>, SVGElement, Serializable, Iterable<GISMarkupSegment>

public class GISRoute
extends GISMarkupElement
implements IPath<GISNode>, Iterable<GISMarkupSegment>
Implementation of IPath for network in GIS space.
Author:
AnyLogic North America, LLC https://anylogic.com
See Also:
Serialized Form

Constructor Summary

ConstructorDescription
GISRoute(ShapeGISMap owner, boolean bidirectional, GISMarkupSegment... segments)
Creates GIS route based on the array of segments.
GISRoute(ShapeGISMap owner, boolean isPermanent, Paint lineColor, double lineWidth, LineStyle lineStyle, boolean bidirectional, GISNode source, GISNode target, GISMarkupSegmentDescriptor... segmentDescriptors)
Creates GIS route based on the array of segments with specific drawing attributes.
GISRoute(ShapeGISMap owner, boolean isPermanent, Paint lineColor, double lineWidth, LineStyle lineStyle, boolean bidirectional, GISNode source, GISNode target, GISMarkupSegment... segments)
Creates GIS route based on the array of segments with specific drawing attributes.
GISRoute(ShapeGISMap map, Curve<? extends GISMarkupSegment> curve)
Creates unidirectional GIS route based on curve.
GISRoute(ShapeGISMap map, Curve<? extends GISMarkupSegment> curve, boolean bidirectional)
Creates GIS route based on curve.
GISRoute(ShapeGISMap map, Curve<? extends GISMarkupSegment> curve, GISPoint source, GISPoint target, boolean bidirectional)
Creates GIS route for network.
GISRoute(ShapeGISMap owner, GISMarkupSegment... segments)
Creates unidirectional GIS route based on the array of segments.

Method Summary

Modifier and TypeMethodDescription
voidaddSegment(GISMarkupSegment segment)
Adds segment to this markup element
booleancontains(double lat, double lon)
Check this element contains a point with given coordinates.
booleancontains(double lat, double lon, double distance)
Test if GIS Route contains the point with the given coordinates, using the given tolerance
booleancontainsSq(double lat, double lon, double squareDistance)
Test if GIS Route contains the point with the given coordinates, using the given tolerance
com.bbn.openmap.omGraphics.OMGraphiccreateOMGraphicObject()
Deprecated.
PointgetEndPoint()
Returns the location of the end point
PointgetEndPoint(Point out)
Returns the location of the end point
PositiongetEndPosition(Position position)
Returns the end position
doublegetNearestPoint(double lat, double lon, Point out)
Calculates (using the out object) the point in GIS Route element nearest to the given point.
doublegetNearestPoint(Point givenPoint, Point out)
Calculates (using the output object) the point in this space markup element nearest to the given point.
GISNodegetOtherNode(GISNode n)
If the given node is source of this path, returns path's target, otherwise returns source.
PositiongetPosition(double value, double maxValue, Position out)
Returns position with offset corresponding to the given value, assuming that 0 is start and maxValue is end
PositiongetPosition(int index, int totalNumber, Position out)
Returns the item position with the given index.
In case of any wrong argument returns zero-index position (position for index=0 with totalNumber=1).
PositiongetPositionAtOffset(double offset, LengthUnits units, Position out)
Returns the point (+rotations) located on the markup element with the given offset distance calculated from start point.
PositiongetPositionAtOffset(double offset, Position out)
Returns the point (+rotations) located on the markup element with the given offset distance calculated from start point.
GISMarkupSegmentgetSegment(int index)
Returns the segment by its index
intgetSegmentCount()
Returns the number of segments
GISNodegetSource()
Returns source node of this path.
PointgetStartPoint()
Returns the location of the start point
PointgetStartPoint(Point out)
Returns the location of the start point
PositiongetStartPosition(Position position)
Returns the start position
GISNodegetTarget()
Returns target node of this path.
booleanisBidirectional()
Returns the 'bidirectional' property (true by default).
Iterator<GISMarkupSegment>iterator()
Creates and returns read-only iterator over segments
final doublelength()
Returns the length of markup element, used e.g.
final doublelength(LengthUnits units)
Returns the length of markup element, used e.g.
final PointrandomPointInside(Random rng, Point out)
Returns the randomly chosen point inside/along the given space markup element.
voidsetBidirectional(boolean bidirectional)
Sets the 'bidirectional' property (true by default).
voidsetSource(GISNode node)
Sets source node of this path.
voidsetTarget(GISNode node)
Sets source node of this path.

Methods inherited from class java.lang.Object

equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods inherited from interface com.anylogic.engine.markup.AggregatableAnimationElement

postInitialize

Methods inherited from interface com.anylogic.engine.markup.AnimationStaticLocationProvider

getSpace

Methods inherited from interface com.anylogic.engine.markup.INetworkMarkupElement

getNetwork, getSpace, randomPointInside, randomPointInside, randomPointInside

Methods inherited from interface com.anylogic.engine.markup.IPath

getLineColor, getLineTexture, getLineWidth, getName, getPathEnd, setLineColor, setLineWidth

Methods inherited from interface java.lang.Iterable

forEach, spliterator

Constructor Details

GISRoute

public GISRoute(ShapeGISMap map,
 Curve<? extends GISMarkupSegment> curve,
 boolean bidirectional)
Creates GIS route based on curve.
Parameters:
map - GIS map for drawing this markup element
curve - the curve consisting of GIS segments.
bidirectional - true if edge of the network would be bidirectional

GISRoute

public GISRoute(ShapeGISMap map,
 Curve<? extends GISMarkupSegment> curve)
Creates unidirectional GIS route based on curve.
Parameters:
map - GIS map for drawing this markup element
curve - the curve consisting of GIS segments.

GISRoute

public GISRoute(ShapeGISMap map,
 Curve<? extends GISMarkupSegment> curve,
 GISPoint source,
 GISPoint target,
 boolean bidirectional)
Creates GIS route for network.
Parameters:
map - GIS map for drawing this markup element
curve - the curve consisting of GIS segments.
source - the source node in network
target - the target node in network
bidirectional - true if edge of the network would be bidirectional

GISRoute

public GISRoute(ShapeGISMap owner,
 boolean bidirectional,
 GISMarkupSegment... segments)
Creates GIS route based on the array of segments. Notice that the order of segments is valuable.
Parameters:
owner - GIS map for drawing this markup element
bidirectional - true if edge of the network would be bidirectional
segments - the array of segments

GISRoute

public GISRoute(ShapeGISMap owner,
 GISMarkupSegment... segments)
Creates unidirectional GIS route based on the array of segments. Notice that the order of segments is valuable.
Parameters:
owner - GIS map for drawing this markup element
segments - the array of segments

GISRoute

@AnyLogicInternalCodegenAPI
public GISRoute(ShapeGISMap owner,
 boolean isPermanent,
 Paint lineColor,
 double lineWidth,
 LineStyle lineStyle,
 boolean bidirectional,
 GISNode source,
 GISNode target,
 GISMarkupSegmentDescriptor... segmentDescriptors)
Creates GIS route based on the array of segments with specific drawing attributes. Notice that the order of segments is valuable.
Parameters:
owner -
isPermanent -
lineColor - the color of route
lineWidth - the width of route in pixels
lineStyle - the style of drawing
bidirectional - true if edge of the network would be bidirectional
source - the source node in network
target - the target node in network
segmentDescriptors - the array of segments

GISRoute

public GISRoute(ShapeGISMap owner,
 boolean isPermanent,
 Paint lineColor,
 double lineWidth,
 LineStyle lineStyle,
 boolean bidirectional,
 GISNode source,
 GISNode target,
 GISMarkupSegment... segments)
Creates GIS route based on the array of segments with specific drawing attributes. Notice that the order of segments is valuable.
Parameters:
owner -
isPermanent -
lineColor - the color of route
lineWidth - the width of route in pixels
lineStyle - the style of drawing
bidirectional - true if edge of the network would be bidirectional
source - the source node in network
target - the target node in network
segments - the array of segments

Method Details

getNearestPoint

public double getNearestPoint(double lat,
 double lon,
 Point out)
Calculates (using the out object) the point in GIS Route element nearest to the given point. Returns the square of distance to the point.
Parameters:
lat - the latitude of the point
measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
lon - the y coordinate of the point
measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
out - the output point to write result to.
Returns:
the square of distance to the nearest point

getNearestPoint

public double getNearestPoint(Point givenPoint,
 Point out)
Description copied from interface: INetworkMarkupElement
Calculates (using the output object) the point in this space markup element nearest to the given point. Returns the square of distance to the point.
Specified by:
getNearestPoint in interface INetworkMarkupElement
Parameters:
givenPoint - given point
out - the output point to write result to.
Returns:
the square of distance to the nearest point

contains

public boolean contains(double lat,
 double lon)
Description copied from interface: INetworkMarkupElement
Check this element contains a point with given coordinates. measured in degrees (-90 ... (South) ... 0 ... (North) ... +90), y coordinate is the longitude of the current location, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180),
Specified by:
contains in interface INetworkMarkupElement
Parameters:
lat - the x coordinate of the given point.
In case of GIS environment this is the longitude of the given point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
Returns:

containsSq

public boolean containsSq(double lat,
 double lon,
 double squareDistance)
Test if GIS Route contains the point with the given coordinates, using the given tolerance
Parameters:
lat - the latitude of the point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
lon - the y coordinate of the point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
squareDistance - the square of distance tolerance to determine whether the given point lies on the markup element line or not
Returns:
true if the shape contains the point with the given coordinates

contains

public boolean contains(double lat,
 double lon,
 double distance)
Test if GIS Route contains the point with the given coordinates, using the given tolerance
Parameters:
lat - the latitude of the point, measured in degrees (-90 ... (South) ... 0 ... (North) ... +90)
lon - the y coordinate of the point, measured in degrees (-180 ... (West) ... 0 ... (East) ... +180)
distance - the distance tolerance to determine whether the given point lies on the markup element line or not
Returns:
true if the shape contains the point with the given coordinates

isBidirectional

public boolean isBidirectional()
Description copied from interface: IPath
Returns the 'bidirectional' property (true by default).
Specified by:
isBidirectional in interface IPath<GISNode>
Returns:
true for paths which allow movements in both directions, false for paths which allow movements from source to target only

setSource

public void setSource(GISNode node)
Description copied from interface: IPath
Sets source node of this path. This method should be called before initialize() method.
Specified by:
setSource in interface IPath<GISNode>
Parameters:
node - instance of com.anylogic.engine.markup.INode interface

getSource

public GISNode getSource()
Description copied from interface: IPath
Returns source node of this path.
Specified by:
getSource in interface IPath<GISNode>
Returns:
instance of com.anylogic.engine.markup.INode interface

setTarget

public void setTarget(GISNode node)
Description copied from interface: IPath
Sets source node of this path. This method should be called before initialize() method.
Specified by:
setTarget in interface IPath<GISNode>
Parameters:
node - instance of com.anylogic.engine.markup.INode interface

getTarget

public GISNode getTarget()
Description copied from interface: IPath
Returns target node of this path.
Specified by:
getTarget in interface IPath<GISNode>
Returns:
instance of com.anylogic.engine.markup.INode interface

setBidirectional

public void setBidirectional(boolean bidirectional)
Description copied from interface: IPath
Sets the 'bidirectional' property (true by default).
Specified by:
setBidirectional in interface IPath<GISNode>
Parameters:
bidirectional - true for paths which allow movements in both directions, false for paths which allow movements from source to target only
See Also:
IPath.isBidirectional()

getStartPoint

public Point getStartPoint()
Description copied from interface: IPath
Returns the location of the start point
Specified by:
getStartPoint in interface IPath<GISNode>
Returns:
the Point object with coordinates of the first point

getStartPoint

public Point getStartPoint(Point out)
Description copied from interface: IPath
Returns the location of the start point
Specified by:
getStartPoint in interface IPath<GISNode>
Parameters:
out - output object to write to, may be null
Returns:
the Point object with coordinates of the first point

getEndPoint

public Point getEndPoint()
Description copied from interface: IPath
Returns the location of the end point
Specified by:
getEndPoint in interface IPath<GISNode>
Returns:
the Point object with coordinates of the last point

getEndPoint

public Point getEndPoint(Point out)
Description copied from interface: IPath
Returns the location of the end point
Specified by:
getEndPoint in interface IPath<GISNode>
Parameters:
out - output object to write to, may be null
Returns:
the Point object with coordinates of the last point

getSegmentCount

public int getSegmentCount()
Description copied from interface: IPath
Returns the number of segments
Specified by:
getSegmentCount in interface IPath<GISNode>
Returns:
the number of segments

getOtherNode

public GISNode getOtherNode(GISNode n)
Description copied from interface: IPath
If the given node is source of this path, returns path's target, otherwise returns source. Note that this function doesn't check that the given is either source or target: this is the responsibility of user calling this function. The ordinal use case is calling this method for some path connected to some node.
Specified by:
getOtherNode in interface IPath<GISNode>
Parameters:
n - the node (one of the path endings)
Returns:
the node of the other end of this path

length

public final double length()
Returns the length of markup element, used e.g. for desired speed calculation
Specified by:
length in interface AnimationMovingLocationProvider
Returns:
the length of markup element (measured in meters)

length

public final double length(LengthUnits units)
Description copied from interface: AnimationMovingLocationProvider
Returns the length of markup element, used e.g. for desired speed calculation
Specified by:
length in interface AnimationMovingLocationProvider
Returns:
the length of markup element

getSegment

public GISMarkupSegment getSegment(int index)
Description copied from interface: IPath
Returns the segment by its index
Specified by:
getSegment in interface IPath<GISNode>
Parameters:
index - the segment index, [0 .. IPath.getSegmentCount() - 1]
Returns:
the segment

iterator

public Iterator<GISMarkupSegment> iterator()
Creates and returns read-only iterator over segments
Specified by:
iterator in interface IPath<GISNode>
Specified by:
iterator in interface Iterable<GISMarkupSegment>

getPositionAtOffset

public Position getPositionAtOffset(double offset,
 Position out)
Description copied from interface: IPath
Returns the point (+rotations) located on the markup element with the given offset distance calculated from start point.
Specified by:
getPositionAtOffset in interface IPath<GISNode>
Parameters:
offset - offset, non-negative value, should be less or equal to the full length.
out - output object to write to, may be null
Returns:
the Position object with coordinates of the point with the given offset and orientation along markup element line at this point

getPositionAtOffset

public Position getPositionAtOffset(double offset,
 LengthUnits units,
 Position out)
Description copied from interface: IPath
Returns the point (+rotations) located on the markup element with the given offset distance calculated from start point.
Specified by:
getPositionAtOffset in interface IPath<GISNode>
Parameters:
offset - offset, non-negative value, should be less or equal to the full length.
units - the length units
out - output object to write to, may be null
Returns:
the Position object with coordinates of the point with the given offset and orientation along markup element line at this point

getStartPosition

public Position getStartPosition(Position position)
Description copied from interface: IPath
Returns the start position
Specified by:
getStartPosition in interface IPath<GISNode>
Parameters:
position - output object to write to, may be null
Returns:
the Position object with coordinates of the first position

getEndPosition

public Position getEndPosition(Position position)
Description copied from interface: IPath
Returns the end position
Specified by:
getEndPosition in interface IPath<GISNode>
Parameters:
position - output object to write to, may be null
Returns:
the Position object with coordinates of the last position

createOMGraphicObject

@AnyLogicInternalAPI
@Deprecated
public com.bbn.openmap.omGraphics.OMGraphic createOMGraphicObject()
Deprecated.
Specified by:
createOMGraphicObject in class GISMarkupElement

getPosition

public Position getPosition(double value,
 double maxValue,
 Position out)
Description copied from interface: AnimationMovingLocationProvider
Returns position with offset corresponding to the given value, assuming that 0 is start and maxValue is end
Specified by:
getPosition in interface AnimationMovingLocationProvider
Returns:
position by offset

getPosition

public Position getPosition(int index,
 int totalNumber,
 Position out)
Description copied from interface: AnimationStaticLocationProvider
Returns the item position with the given index.
In case of any wrong argument returns zero-index position (position for index=0 with totalNumber=1).
Specified by:
getPosition in interface AnimationStaticLocationProvider
Parameters:
index - the index of some item positions, should be not negative and less than totalNumber
totalNumber - the total number of item positions, should be positive
out - output object to write to, may be null
Returns:
the Position object with coordinates of the requested item position

randomPointInside

public final Point randomPointInside(Random rng,
 Point out)
Description copied from interface: INetworkMarkupElement
Returns the randomly chosen point inside/along the given space markup element. This method utilises the given Random Number Generator.
Specified by:
randomPointInside in interface INetworkMarkupElement
Parameters:
rng - the random number generator.
out - output object to write to, may be null
Returns:
the randomly chosen point

addSegment

public void addSegment(GISMarkupSegment segment)
Adds segment to this markup element
Parameters:
segment - the segment, should be initialized if was created using no-argument constructor