tsc_Alignment

This class holds a reference to an alignment in a road which has been loaded into Trimble Access. It may have been loaded manually using the Layer Manager form, or programmatically using the tsc_TrimbleRoad and tsc_JobMap classes.

Holding a reference to an alignment will prevent the road from being unloaded from the job until all references held by the plugin have been destroyed.

Please note that roading classes always use the currently open job in Trimble Access for coordinate systems and all other calculations. If no job is open, all results will be empty or null.

Coordinate geometry

Terminology is in accordance with the Trimble Access Help pages.

Note that a point on a skew is defined from a station value along the alignment, and by an offset along the skew. The skew angle is defined by a forward or backward delta angle to a line at right angles to the alignment, and may range from -180°  to +180° (other values will be normalised into this range).

Constructors

tsc_Alignment();  // Constructs an empty instance. Exists() will return false until a Set method is called..

tsc_Alignment (const tsc_Alignment& rhs);  // Copy constructor makes a reference to the rhs object.

tsc_Alignment& operator= (const tsc_Alignment& rhs);  // Makes a reference to rhs.

Public Methods

bool SetTo (const char* roadFilePath, const char* alignmentName);
Sets this instance to reference the alignment specified. The road must be already loaded into Trimble Access.
An empty alignmentName will match the first unnamed alignment defined in the road.
Returns true if a matching alignment was found.

bool SetTo (const char* roadFilePath, int alignment);
Sets this instance to reference the alignment specified. The road must be already loaded into Trimble Access.
The alignment parameter specifies which alignment definition to use in the road, zero being the first.
Returns true if a matching alignment was found.

bool SetToSelected ();
Sets this instance to reference the alignment currently selected in the map.
If no alignment is currently selected, this method will return false;

bool Exists ();
Returns true if this object references an actual alignment.

tsc_String GetName () const;
Returns the alignment name.
If the alignment is unnamed, returns an empty string.

tsc_String GetFilePath ();
Returns the full path of the source file.

double GetStartStation () const;
Returns the lowest station value for the alignment, being the start.

double GetLength () const;
Returns the length of the alignment in metres.

double ComputeSkewAngle (double stationOnAlignment, const tsc_Grid& pointOnSkewline);
Calculates the skew angle given a station position on the alignment and a grid coordinate on the skew line.
The skew angle is in radians.

tsc_Grid  ComputeGrid (const tsc_StationOffset& fromPoint, double skewAngle = 0.0);   (1)
tsc_Grid  ComputeGrid (const tsc_StationOffset& fromPoint, const tsc_Grid& pointOnSkew);   (2)
Calculates the corrected grid coordinates given a station, an offset, and (1) an optional skew angle, or (2) a grid point which, with the station point on the alignment, defines the skew line .
The returned grid elevation is calculated from the elevation at the station on the alignment plus fromPoint.VDist, or if fromPoint.VDist is set to double_Null then the returned grid elevation is the elevation of the road surface at the grid position.

tsc_StationOffset ComputeStationOffset (const tsc_Grid& fromPoint, double skewAngle = 0.0);
Calculates the stationing and offset, given a grid coordinate and an optional skew angle. Note that the computed station will be the nearest one to the alignment from the point, which may be incorrect in ambiguous situations.
The vertical distance (VDist) in the returned station/offset contains the grid elevation above the alignment, or if the grid elevation was double_Null then VDist is set to the elevation of the road surface at the grid coordinate.

bool ComputeXSNode(double stationChainage, int index, tsc_Grid& grid, tsc_String& code);
Calculates the node grid coordinate for the node on the template at the supplied station chainage and index.
A negative index means left, positive means right, and zero means center.
The return value is false if there is no template node at the supplied station and index.

Sample code

This simple example returns the station and offset values for the points selected in the map, relative to the alignment.

// Map object which has been defined elsewhere and attached to the map.

// See tsc_JobMap

tsc_JobMap jobMap;


tsc_StationOffset GetSelectedPointStationOffset (const char* rxlName)

{

    tsc_StationOffset stnOffset;


// Adds project directory if rxlName is not an absolute path.

    auto path = tsc_Path::Compose("$(ProjectDir)", rxlName);


    tsc_Alignment align;

    if (align.SetTo (path, 0))  // Set instance to first alignment in the road.

{

     tsc_PointList points = jobMap.GetSelections();


     if (points.Count() > 0)

     {

         tsc_Grid coord = points[0].CalculateGrid();

         stnOffset = align.ComputeStationOffset (coord);

     }

}

    return stnOffset;

}