All Cadcorp SIS API Methods

MeasureRoute Method


Measures the best route between two positions.


Visual Basic
Public Function MeasureRoute( _
   ByVal x1 As Double, _
   ByVal y1 As Double, _
   ByVal z1 As Double, _
   ByVal x2 As Double, _
   ByVal y2 As Double, _
   ByVal z2 As Double, _
   ByVal propertyName As String, _
   ByVal filter As String, _
   ByVal locusNoGo As String, _
   ByVal bCreateLine As Integer _
) As Double



The x coordinate of the start point of the route.


The y coordinate of the start point of the route.


The z coordinate of the start point of the route.

The x coordinate of the end point of the route.
The y coordinate of the end point of the route.

The z coordinate of the end point of the route.


The expression (or simple property) to use in the route finding calculation as the "cost" of a Link item.


For example, using the simple property Length will find the shortest route and using the expression "_length#/Speed#", provided each Link has a user-defined Speed# property, will find the quickest route.

Any expression may be used (although if a string expression is used it must be a string representation of a numeric value.)


See Property Expressions Syntax for details.

This method can find a route over any geometry, not just Link/Node topology, by specifying an empty string for this argument. In this case, the shortest route is always found.


Optionally specifies a named Filter which all items must pass to be considered as part of the route.


Optionally specifies a named Spatial Filter through which the route cannot pass.

True    Create a LineString item which follows the route found.
False    Do not create a LineString item.

Using an OSRM Database

Usually MeasureRoute is used on a topological network but if an OSRM database has been created, this can be used for faster routing.

An example of using MeasureRoute with an OSRM database:


The first six parameters are x1, y1, z1, x2, y2 and z2 (as above).

The "File":"GBR.osrm" parameter is the name and location of the OSRM database you want to use.

If the OSRM database is in the default folder i.e. C:\Program Files\Cadcorp SIS Desktop 9\OSRM you only need to state the filename here. You can also use an absolute path if the OSRM database is located elsewhere.

VB.NET Example:

Return String.Format("{{""OSRM"":{{""File"":""{0}""}}}}", 
GvOsrmDb.Replace("\", "\\"))

where GvOsrmDb is a string variable containing the path of the .osrm file.

Return Type

The total of the expression results for each link in the route, e.g. with _length#/Speed#, the return value is the total time. If the default expression is used the return value is the length of the route found.

The named Spatial Filter used will normally have its testing mode set to exclude any items which cross it using a call similar to the following:



Available: GEO D OM OD OV SISpy



Distance = sis.MeasureRoute (100, 150, 0, 500, 300, 0, "_length#", "A Roads only", "NoGo", True)

You can use GetPosEx to generate a snap position.