private static void LogPathInformation(
        LatLong inputPositionA,
        LatLong inputPositionB,
        TransportPathfindResult pathfindResult,
        List <TransportWay> pathResultWays,
        List <TransportNode> pathResultNodes)
    {
        Debug.Log(string.Format("Found path from {0} to {1}: distance {2:0.00}m",
                                inputPositionA.ToString(),
                                inputPositionB.ToString(),
                                pathfindResult.DistanceMeters));

        foreach (var way in pathResultWays)
        {
            Debug.Log(string.Format("Way id [{0}] has classification {1}, length {2:0.00}m, width {3:0.00}m",
                                    Api.Instance.TransportApi.WayIdToString(way.Id),
                                    way.Classification,
                                    way.LengthMeters,
                                    way.HalfWidthMeters * 2
                                    ));
        }

        foreach (var node in pathResultNodes)
        {
            Debug.Log(string.Format("Node id [{0}] at {1} has {2} incident edges",
                                    Api.Instance.TransportApi.NodeIdToString(node.Id),
                                    LatLongAltitude.FromECEF(node.Point).ToString(),
                                    node.IncidentDirectedEdges.Count
                                    ));
        }
    }
示例#2
0
 internal LatLongAltitude WorldToGeographicPoint(Vector3 position, Camera camera)
 {
     if (m_coordinateSystem == CoordinateSystem.UnityWorld)
     {
         return(m_frame.LocalSpaceToLatLongAltitude(position));
     }
     else
     {
         var ecefPosition = m_originECEF + position;
         return(LatLongAltitude.FromECEF(ecefPosition));
     }
 }
示例#3
0
        internal LatLongAltitude WorldToGeographicPoint(Vector3 position)
        {
            var mapSpacePoint = m_root.transform.InverseTransformPoint(position);

            if (m_coordinateSystem == CoordinateSystem.UnityWorld)
            {
                return(m_frame.LocalSpaceToLatLongAltitude(mapSpacePoint));
            }
            else
            {
                var ecefPosition = m_originECEF + mapSpacePoint;
                return(LatLongAltitude.FromECEF(ecefPosition));
            }
        }
示例#4
0
        internal LatLongAltitude ViewportToGeographicPoint(Vector3 viewportSpacePosition, UnityEngine.Camera camera)
        {
            var unityWorldSpacePosition = camera.ViewportToWorldPoint(viewportSpacePosition);

            if (m_coordinateSystem == CoordinateSystem.UnityWorld)
            {
                return(m_frame.LocalSpaceToLatLongAltitude(unityWorldSpacePosition));
            }
            else
            {
                var finalPositionECEF = m_originECEF + unityWorldSpacePosition;

                return(LatLongAltitude.FromECEF(finalPositionECEF));
            }
        }
示例#5
0
    private void UpdatePointOnPath()
    {
        if (m_pathfindResult == null)
        {
            return;
        }

        var parameterizedDistanceAlongPath = CalcParameterizedDistanceAlongPath(m_time, m_prevSampleTime, m_currentSampleTime);
        var pointEcef      = m_transportApi.GetPointEcefOnPath(m_pathfindResult, parameterizedDistanceAlongPath);
        var directionEcef  = m_transportApi.GetDirectionEcefOnPath(m_pathfindResult, parameterizedDistanceAlongPath);
        var headingDegrees = m_spacesApi.HeadingDegreesFromDirectionAtPoint(directionEcef, pointEcef);

        m_capsule.SetActive(true);
        m_capsule.transform.localPosition    = m_spacesApi.GeographicToWorldPoint(LatLongAltitude.FromECEF(pointEcef));
        m_capsule.transform.localEulerAngles = new Vector3(90.0f, (float)headingDegrees, 0.0f);
    }
示例#6
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);
        }
    }
    private void CreatePathLines(TransportPathfindResult result)
    {
        var points = new List <Vector3>();

        foreach (var pointEcef in result.PathPoints)
        {
            var lla = LatLongAltitude.FromECEF(pointEcef);
            lla.SetAltitude(lla.GetAltitude() + m_lineVerticalOffsetMeters);
            var worldPoint = Api.Instance.SpacesApi.GeographicToWorldPoint(lla);
            points.Add(worldPoint);
        }

#if UNITY_5_6_OR_NEWER
        m_pathLineRenderer.positionCount = points.Count;
#else
        m_pathLineRenderer.numPositions = points.Count;
#endif
        m_pathLineRenderer.SetPositions(points.ToArray());
    }
    private Mesh CreateMeshForLinks(IList <TransportDirectedEdge> directedEdges)
    {
        Mesh mesh = new Mesh();

        if (!directedEdges.Any())
        {
            return(mesh);
        }

        var vertices = new List <Vector3>();
        var indices  = new List <int>();

        const float unlinkedCellBoundaryIndicatorLength = 50.0f;
        const float nodeIndicatorLength = 5.0f;

        foreach (var directedEdge in directedEdges)
        {
            bool isUnlinkedCellBoundary = (directedEdge.NodeIdB.LocalNodeId < 0);
            var  indicatorLength        = isUnlinkedCellBoundary ? unlinkedCellBoundaryIndicatorLength : nodeIndicatorLength;

            TransportNode node;
            if (m_transportApi.TryGetNode(directedEdge.NodeIdA, out node))
            {
                var pointA = Api.Instance.SpacesApi.GeographicToWorldPoint(LatLongAltitude.FromECEF(node.Point));

                indices.Add(vertices.Count);
                indices.Add(vertices.Count + 1);
                vertices.Add(pointA);
                vertices.Add(pointA + Vector3.up * indicatorLength);
            }
        }

        mesh.Clear();
        mesh.vertices = vertices.ToArray();
        mesh.SetIndices(indices.ToArray(), MeshTopology.Lines, 0);
        mesh.RecalculateBounds();
        return(mesh);
    }
 private IList <Vector3> WayCenterLinePointsToWorldPoints(TransportWay way)
 {
     return(way.CenterLinePoints
            .Select(lla => Api.Instance.SpacesApi.GeographicToWorldPoint(LatLongAltitude.FromECEF(lla)))
            .ToList());
 }