Beispiel #1
0
    void LoadData()
    {
        try
        {
            if (dataFile.EndsWith(TrafficIO.BINARY_VEHICLES_EXTENSION) || dataFile.EndsWith(TrafficIO.BINARY_PEDESTRIANS_EXTENSION))
            {
                data = TrafficIO.LoadBinary(dataFile, firstFrameIsStartTime);
            }
            else if (dataFile.EndsWith(TrafficIO.VISSIM_VEHICLES_EXTENSION) || dataFile.EndsWith(TrafficIO.VISSIM_PEDESTRIANS_EXTENSION))
            {
                data = TrafficIO.Load(dataFile, columnSeparator, vectorSeparator, firstFrameIsStartTime);
            }
            else
            {
                Debug.LogError("Invalid traffic data extension: " + System.IO.Path.GetFileName(dataFile));
            }
        }
        catch (Exception e)
        {
            Debug.LogError(e, this);
        }

        if (data == null)
        {
            Debug.LogWarning("Could not load traffic data for " + name);
            enabled = false;
            return;
        }

        animationLength = (data.frameOffsets.Length - 2) / TIME_TO_FRAME;

        // Check if loaded data has asset types that were not setup in the traffic asset replacement lists.
        trafficAssets.Check(data.assetTypes, true);
    }
Beispiel #2
0
    private void GenerateHeatmap(string filename)
    {
        if (cyclists == null)
        {
            cyclists    = new AssetType[1];
            cyclists[0] = AssetType.Cyclist;
        }

        if (area == null)
        {
            Debug.LogError("Can't generate heatmap with unassigned area");
            return;
        }

        Bounds aabb = new Bounds(area.position, area.localScale);

        if (filename.EndsWith(TrafficIO.VISSIM_VEHICLES_EXTENSION))
        {
            TrafficData data = TrafficIO.Load(filename, columnSeparator, vectorSeparator, true);
            if (data == null)
            {
                return;
            }
            Heatmap.GenerateHeatmap(data, trafficMgr.transform.position, resolution, pointSize * 0.5f, aabb, logarithmic, "Vehicles_Heatmap", cyclists, false);
            Heatmap.GenerateHeatmap(data, trafficMgr.transform.position, resolution, pointSize * 0.5f, aabb, logarithmic, "Cyclists_Heatmap", cyclists, true);
        }
        else if (filename.EndsWith(TrafficIO.VISSIM_PEDESTRIANS_EXTENSION))
        {
            TrafficData data = TrafficIO.Load(filename, columnSeparator, vectorSeparator, true);
            if (data == null)
            {
                return;
            }
            Heatmap.GenerateHeatmap(data, trafficMgr.transform.position, resolution, pointSize * 0.5f, aabb, logarithmic, "Pedestrians_Heatmap");
        }
        else if (filename.EndsWith(TrafficIO.BINARY_VEHICLES_EXTENSION))
        {
            TrafficData data = TrafficIO.LoadBinary(filename, true);
            if (data == null)
            {
                return;
            }
            Heatmap.GenerateHeatmap(data, trafficMgr.transform.position, resolution, pointSize * 0.5f, aabb, logarithmic, "Vehicles_Heatmap", cyclists, false);
            Heatmap.GenerateHeatmap(data, trafficMgr.transform.position, resolution, pointSize * 0.5f, aabb, logarithmic, "Cyclists_Heatmap", cyclists, true);
        }
        else if (filename.EndsWith(TrafficIO.BINARY_PEDESTRIANS_EXTENSION))
        {
            TrafficData data = TrafficIO.LoadBinary(filename, true);
            if (data == null)
            {
                return;
            }
            Heatmap.GenerateHeatmap(data, trafficMgr.transform.position, resolution, pointSize * 0.5f, aabb, logarithmic, "Pedestrians_Heatmap");
        }
        AssetDatabase.Refresh();
    }
Beispiel #3
0
 private void ConvertToBinary(string filename)
 {
     if (filename.EndsWith(TrafficIO.VISSIM_VEHICLES_EXTENSION))
     {
         TrafficData data = TrafficIO.Load(filename, columnSeparator, vectorSeparator, true);
         if (data == null)
         {
             return;
         }
         filename = filename.Remove(filename.Length - TrafficIO.VISSIM_VEHICLES_EXTENSION.Length) + TrafficIO.BINARY_VEHICLES_EXTENSION;
         TrafficIO.SaveBinary(data, filename);
     }
     else if (filename.EndsWith(TrafficIO.VISSIM_PEDESTRIANS_EXTENSION))
     {
         TrafficData data = TrafficIO.Load(filename, columnSeparator, vectorSeparator, true);
         if (data == null)
         {
             return;
         }
         filename = filename.Remove(filename.Length - TrafficIO.VISSIM_PEDESTRIANS_EXTENSION.Length) + TrafficIO.BINARY_PEDESTRIANS_EXTENSION;
         TrafficIO.SaveBinary(data, filename);
     }
 }