Exemplo n.º 1
0
        public void TestSimplifyPath()
        {
            var r = SimplifyPath.Simplify("/a/./b/../../c/");

            Assert.AreEqual(r, "/c");
        }
Exemplo n.º 2
0
    public int RenderDay(MovesJson day)
    {
        int        renderedPoints = 0;
        GameObject dateGO         = Instantiate(new GameObject(), transform.position, transform.rotation);

        dateGO.transform.SetParent(gameObject.transform);
        dateGO.name = day.date;
        filterDays.Add(ReadJson.ReturnSimpleDate(day.date), dateGO);

        foreach (var item in day.segments)
        {
            if (item.place != null && !alreadyRenderedPlaces.Contains(item.place.id))
            {
                Vector2    position  = Conversion.LatLonToMeters(item.place.location.lat, item.place.location.lon);
                Vector3    finalPos  = new Vector3(position.x, position.y, 0);
                GameObject placeTemp = Instantiate(PlacePrefab, finalPos, transform.rotation);
                placeTemp.transform.SetParent(loactionsGO.transform);
                finalPos   = placeTemp.transform.position;
                finalPos.z = -3;
                placeTemp.transform.position = finalPos;
                if (item.place.name == null)
                {
                    placeTemp.name = "???";
                }
                else
                {
                    placeTemp.name = item.place.name;
                }
                placeTemp.GetComponent <Place>().SetupPlace(item.place);
                alreadyRenderedPlaces.Add(item.place.id);
            }
            else if (item.place == null)
            {
                foreach (var item2 in item.activities)
                {
                    if (item2.trackPoints.Length > 0)
                    {
                        GameObject lineTempGo = Instantiate(LinePrefab, transform.position, transform.rotation);
                        lineTempGo.transform.SetParent(dateGO.transform);
                        lineTempGo.name = item2.activity.ToString();
                        LineRenderer lineTemp = lineTempGo.GetComponent <LineRenderer>();

                        // Set Line points
                        List <Vector3> positions = new List <Vector3>();
                        foreach (var item3 in item2.trackPoints)
                        {
                            positions.Add(Conversion.LatLonToMeters(item3.lat, item3.lon));
                        }
                        if (item2.activity == ActivityType.walking || item2.activity == ActivityType.cycling || item2.activity == ActivityType.running)
                        {
                            positions = SimplifyPath.Simplify(positions, simplifyMultiplayerDetailed);
                        }
                        else
                        {
                            positions = SimplifyPath.Simplify(positions, simplifyMultiplayer);
                        }
                        renderedPoints += positions.Count;
                        Vector3[] positionsArray = positions.ToArray();
                        lineTemp.positionCount = positionsArray.Length;
                        lineTemp.SetPositions(positionsArray);

                        // Set lines color
                        lineTempGo.GetComponent <Renderer>().material = SetMaterial(item2.activity);

                        // Add line to filters
                        AddToFilterList(item2.activity, lineTempGo);
                        renderedLines.Add(lineTemp);
                        lineTempGo.SetActive(filterState[(int)TranslateActivityToFilter(item2.activity)]);
                        if (item2.distance < maxMetersForShortPath)
                        {
                            shortPaths.Add(lineTempGo);
                        }
                    }
                }
            }
        }
        return(renderedPoints);
    }