Example #1
0
    private void OnPointOnGraphChanged()
    {
        if (m_needCurrentMatched &&
            m_transportPositioner.IsMatched())
        {
            m_prevSampleTime      = m_currentSampleTime;
            m_currentSampleTime   = m_nextSampleTime;
            m_prevPointOnGraph    = new TransportPositionerPointOnGraph(m_currentPointOnGraph);
            m_currentPointOnGraph = m_transportPositioner.GetPointOnGraph();
            m_needCurrentMatched  = false;
        }

        if (m_needPathfind &&
            m_currentPointOnGraph.IsMatched &&
            m_prevPointOnGraph.IsMatched)
        {
            var pathfindResult = m_transportApi.FindShortestPath(new TransportPathfindOptionsBuilder()
                                                                 .SetPointOnGraphA(m_prevPointOnGraph)
                                                                 .SetPointOnGraphB(m_currentPointOnGraph)
                                                                 .Build());

            if (pathfindResult.IsPathFound)
            {
                m_needPathfind   = false;
                m_pathfindResult = pathfindResult;
            }
        }
    }
    private void OnPointOnGraphChanged()
    {
        if (m_foundPath)
        {
            return;
        }

        if (!m_transportPositionerA.IsMatched() || !m_transportPositionerB.IsMatched())
        {
            return;
        }

        var pathfindOptions = new TransportPathfindOptionsBuilder()
                              .SetPointOnGraphA(m_transportPositionerA.GetPointOnGraph())
                              .SetPointOnGraphB(m_transportPositionerB.GetPointOnGraph())
                              .Build();

        var pathfindResult = Api.Instance.TransportApi.FindShortestPath(pathfindOptions);

        if (pathfindResult.IsPathFound)
        {
            m_foundPath = true;

            CreatePathLines(pathfindResult);

            var pathResultDirectedEdges = BuildPathResultDirectedEdges(pathfindResult);
            var pathResultWays          = BuildPathResultWays(pathResultDirectedEdges);
            var pathResultNodes         = BuildPathResultNodes(pathResultDirectedEdges);
            LogPathInformation(m_inputPositionA, m_inputPositionB, pathfindResult, pathResultWays, pathResultNodes);
        }
    }
Example #3
0
    private void OnPointOnGraphChanged()
    {
        if (m_transportPositioner.IsMatched())
        {
            var pointOnGraph = m_transportPositioner.GetPointOnGraph();

            var          outputLLA      = LatLongAltitude.FromECEF(pointOnGraph.PointOnWay);
            const double verticalOffset = 1.0;
            outputLLA.SetAltitude(outputLLA.GetAltitude() + verticalOffset);
            var outputPosition = Api.Instance.SpacesApi.GeographicToWorldPoint(outputLLA);

            m_sphereOutput.transform.position = outputPosition;
            m_directionIndicatorOutput.transform.localPosition = outputPosition;
            m_directionIndicatorOutput.transform.eulerAngles   = new Vector3(0.0f, (float)pointOnGraph.HeadingOnWayDegrees, 0.0f);

            m_sphereOutput.SetActive(true);
            m_directionIndicatorOutput.SetActive(true);
        }
    }