TBC Macros and Extensions

 View Only
Expand all | Collapse all

Honor Station Equations in Alignment Strings

  • 1.  Honor Station Equations in Alignment Strings

    Posted 08-03-2021 18:44

    Is there a simple built-in way to get the equation corrected distance along an Alignment String? i.e. when I want to compute points at even/given chainages  on an alignment that has station equations.
    Tried to compute points at 1660+995, 1660+996, 1660+997, 1660+998, 1660+999



    I was hoping to utilize the StationEdit from Trimble.Vce.UI.Controls to get me the corrected distance along the line.


    It works before the station equation as you can see on the ":1"


    But it fails after the station equation.



    Or do I really have to use Trimble.Vce.Alignment.Linestring.Linestring.StationToDistance(Trimble.Vce.Interfaces.Client.StationValue stationValue) where I have to figure out the zone on my own first in order to create the StationValue object.
    In the Remarks for StationToDistance it says:
    If the Zone field within the StationValue structure is set to -1. The first matching station value should be returned.
    But it actually throws an error with -1, "Station zones must be greater than or equal to zero (0)"



    ------------------------------
    Ronny Schneider
    ------------------------------


  • 2.  RE: Honor Station Equations in Alignment Strings

    Posted 08-04-2021 07:46
    The Station class has a helper method that will compute those locations.

    This is c# but you should be able to convert to python
    m_StationList = new List<double>();
    m_StationEqList = new List<double>();
    var staTable = ((ProfileView)m_Alignment).StationTable;
    Station s = new Station(0.0); // from Trimble.Vce.Alignment.Parameters
    s.DoActionsAtStations(staTable, interval, startStation, endStation, StationEqAction, StationAction, false);
    stationList.Add(new StationFeature(startStation, startStationString));
    for (int i = 0; i < m_StationList.Count; i++)
    {
    double sta = m_StationList[i];
    if (sta > startStation && sta < endStation)
        stationList.Add(new StationFeature(sta, stationType));
    }

    for (int i = 0; i < m_StationEqList.Count; i++)
    {
    double sta = m_StationEqList[i];
    if (sta > startStation && sta < endStation)
        stationList.Add(new StationFeature(sta, staEqString));
    }

    stationList.Add(new StationFeature(endStation, endStationString));

    You need to define two delegates.
    private double StationAction(double station, double stationInclEq, double lastStation)
    {
    m_StationList.Add(station);
    return lastStation;

    }
    private double StationEqAction(double station, double stationInclEq, double lastStation)
    {
    m_StationEqList.Add(station);
    return lastStation;

    }

    ------------------------------
    Gary Lantaff
    ------------------------------



  • 3.  RE: Honor Station Equations in Alignment Strings

    Posted 08-09-2021 04:21
    Thanks Gary,
    in the end I kept using the StationEdit. If I manually add the zone to the textstring the StationEdit delivers the correct PolySeg distance.
    I have to loop through all potential zones and see if it finds a valid solution, is not NaN. That way I can also cover for station equations that go backwards and create duplicate chainage sections.
    The code is rather compact doing it that way.
    truestation = StationEdit()
    truestation.StationProvider = o # o is the Alignment / Line
    
    truestationlist = []
    
    if o.HasEquations:
        for j in range (1, o.StationTable.Count + 2): # stationtable count is 1 less than we have zones
            truestation.ClientAreaText = stationlist[i][stationcolumn-1] + ":" + str(j) # takes the chainage string from the CSV and adds a zone, i.e. 1661000:1
            if not math.isnan(truestation.Distance): # checking if the StationEdit was able compute a true Distance along the Line
                truestationlist.Add(truestation.Distance)​
    
    if truestationlist.Count == 0:
        self.errortext.Content += "\ncouldn't find " + stationlist[i][stationcolumn-1] + " on Alignment"
    
    if truestationlist.Count > 1:
        self.errortext.Content += "\nfound " + stationlist[i][stationcolumn-1] + " multiple times on Alignment"
    


    ------------------------------
    Ronny Schneider
    ------------------------------