Beispiel #1
0
    // Use this for initialization
    void Start()
    {
        ServiceGapslabsClient client = ServicePropertiesClass.GetGapslabsService(ServicePropertiesClass.ServiceUri);
        var go            = GameObject.Find("AramGISBoundaries");
        var mapboundaries = go.GetComponent <MapBoundaries>();

        CoordinateConvertor.Initialize(client, mapboundaries);
    }
    /// <summary>
    /// Starts the script.
    /// </summary>
    void Start()
    {
        log.Info("Map boundaries : MaxLat " + maxLat + ", MinLat " + minLat + ", MaxLon " + maxLon + ", MinLon " + minLon);

        //Initialize the coordinate convertor (need it for running the game!)
        ServiceGapslabsClient client = ServicePropertiesClass.GetGapslabsService(ServicePropertiesClass.ServiceUri);

        CoordinateConvertor.Initialize(client, this);
    }
 public Vector3 GetPoint()
 {
     if (lat != 0 || lon != 0)
     {
         CoordinateConvertor.Initialize();
         return(CoordinateConvertor.LatLonToVector3(lat, lon));
     }
     else
     {
         return(new Vector3(x, y, z));
     }
 }
Beispiel #4
0
    /// <summary>
    /// Coroutine for drawing the points in the map.
    /// </summary>
    IEnumerator DrawPoints()
    {
        while (!pointsReadyToBeDrawn)
        {
            yield return(new WaitForSeconds(0.1f));
        }

        ServiceGapslabsClient client = ServicePropertiesClass.GetGapslabsService(ServicePropertiesClass.ServiceUri);

        CoordinateConvertor.Initialize(client, FindObjectOfType <MapBoundaries>());

        for (int i = 0; i < points.Count; i++)
        {
            Vector3 V        = points[i];
            Vector3 position = CoordinateConvertor.LatLonToVector3(V.x, V.y);

            var newPoint = Instantiate(pointObject, position, Quaternion.identity) as GameObject;

            newPoint.name             = "fixPoint" + i;
            newPoint.transform.parent = pointHolder.transform;

            var pointInfo = newPoint.GetComponent <VVisFixPointInfo>();

            if (pointInfo != null)
            {
                List <string> info = new List <string>();
                info.Add("count: " + V.z.ToString());
                pointInfo.StorePointInfo(info);
            }

            newPoint.SetActive(true);
        }

        if (hidePointsAfterLoading)
        {
            HideLoadedPoints();
        }

        pointsReadyToBeDrawn = false;
    }
    static void SaveStationsAndLines()
    {
        var sgos = GameObject.FindGameObjectsWithTag("TransStation");

        if (sgos.Length < 1)
        {
            Debug.Log("no stations to save.");
            return;
        }
        var lgos = GameObject.FindGameObjectsWithTag("TransLine");

        if (lgos.Length < 1)
        {
            Debug.Log("no lines to save.");
            return;
        }

        var path = EditorUtility.SaveFilePanel("Save XML Data", "Assets/Transportations", "", "xml");

        if (path.Length == 0)
        {
            EditorUtility.DisplayDialog("Saving Cancelled", "No file was provided", "OK");
            return;
        }

        List <BaseStation> stations = new List <BaseStation>();

        foreach (var go in sgos)
        {
            CoordinateConvertor.Initialize();
            float[] latLon = CoordinateConvertor.Vector3ToLatLon(go.transform.position);

            var sc = go.GetComponent <StationController>();
            var bs = new BaseStation
            {
                id   = int.Parse(sc.name),
                lat  = latLon[0],
                lon  = latLon[1],
                x    = go.transform.position.x,
                y    = go.transform.position.y,
                z    = go.transform.position.z,
                name = sc.stationName,
            };
            stations.Add(bs);
        }

        List <BaseLine> lines = new List <BaseLine>();

        foreach (var go in lgos)
        {
            var lc = go.GetComponent <LineController>();
            var bl = LineController.CreateBaseLine(lc);
            lines.Add(bl);
        }

        var container = new TrafficContainer();

        container.stations = stations;
        container.lines    = lines;
        container.Save(path);
        string stationStats = string.Format("{0} stations saved.", container.stations.Count);
        string lineStats    = string.Format("{0} lines saved.", container.lines.Count);

        EditorUtility.DisplayDialog("Saving Finished", stationStats + "\n" + lineStats + "\n to: " + path, "OK");
    }