Пример #1
0
    /// <summary>
    /// Initializes the convertor.
    /// </summary>
    public static void Initialize()
    {
        ServiceGapslabsClient client = ServicePropertiesClass.GetGapslabsService(ServicePropertiesClass.ServiceUri);
        var go            = GameObject.Find("AramGISBoundaries");
        var mapboundaries = go.GetComponent <MapBoundaries>();

        Initialize(client, mapboundaries);
    }
Пример #2
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);
    }
Пример #3
0
    /// <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);
    }
Пример #4
0
    void Start()
    {
        client  = ServicePropertiesClass.GetGapslabsService(ServicePropertiesClass.ServiceUri);
        geoinfo = transform.GetComponent <GeoInfo>();

        var go = GameObject.Find("AramGISBoundaries");

        mapBoundaries = go.GetComponent <MapBoundaries>();
        wcfCon        = mapBoundaries.OverrideDatabaseConnection ? mapBoundaries.GetOverridenConnectionString() : ServicePropertiesClass.ConnectionPostgreDatabase;

        boundsTemp = client.GetBounds(wcfCon);
        // Temporary - it appears the data for sweden includes some data that go to the north pole and it ruins all interpolations.
        boundsTemp.maxlon = 32;

        MinMaxLat = new float[2];
        MinMaxLon = new float[2];
        // Setting local values for target boundaries (Openstreetmap database). Used in interpolation as destination boundary.
        MinMaxLat[0] = (float)boundsTemp.minlat;
        MinMaxLat[1] = (float)boundsTemp.maxlat;
        MinMaxLon[0] = (float)boundsTemp.minlon;
        MinMaxLon[1] = (float)boundsTemp.maxlon;



        // Setting local values for 3d world boundaries. Used in interpolation as source boundary
        GameBoundaries        = new BoundsWCF();
        GameBoundaries.minlat = mapBoundaries.minMaxX[0];
        GameBoundaries.maxlat = mapBoundaries.minMaxX[1];
        GameBoundaries.minlon = mapBoundaries.minMaxY[0];
        GameBoundaries.maxlon = mapBoundaries.minMaxY[1];
        GameBoundLat          = new float[2];
        GameBoundLat[0]       = (float)GameBoundaries.minlat;
        GameBoundLat[1]       = (float)GameBoundaries.maxlat;
        GameBoundLon          = new float[2];
        GameBoundLon[0]       = (float)GameBoundaries.minlon;
        GameBoundLon[1]       = (float)GameBoundaries.maxlon;



        float[] MinPointOnArea =
            Interpolations.SimpleInterpolation(
                (float)mapBoundaries.minLat,
                (float)mapBoundaries.minLon,
                boundsTemp,
                GameBoundLat, GameBoundLon);
        MinPointOnMap = new Vector3(MinPointOnArea[0], 0, MinPointOnArea[1]);
    }
Пример #5
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;
    }
Пример #6
0
    string wcfCon = ServicePropertiesClass.ConnectionPostgreDatabase; // .ConnectionDatabase;
    // Use this for initialization
    void Start()
    {
        locatorArrowA = GameObject.CreatePrimitive(PrimitiveType.Cube);
        locatorArrowA.transform.localScale = new Vector3(0.5f, 100, 0.5f);
        locatorArrowA.transform.position   = Vector3.zero;
        locatorArrowA.GetComponent <Renderer>().material = Resources.Load("A") as Material;
        locatorArrowA.name = "A";
        Object.DestroyImmediate(locatorArrowA.GetComponent <BoxCollider>());
        previousPositionA = Vector3.zero;

        locatorArrowB = GameObject.CreatePrimitive(PrimitiveType.Cube);
        locatorArrowB.transform.localScale = new Vector3(0.5f, 100, 0.5f);
        locatorArrowB.transform.position   = Vector3.zero;
        locatorArrowB.GetComponent <Renderer>().material = Resources.Load("B") as Material;
        Object.DestroyImmediate(locatorArrowB.GetComponent <BoxCollider>());
        locatorArrowB.name = "B";
        previousPositionB  = Vector3.zero;

        var go         = GameObject.Find("AramGISBoundaries");
        var connection = go.GetComponent <MapBoundaries>();

        wcfCon = connection.OverrideDatabaseConnection ? connection.GetOverridenConnectionString() : ServicePropertiesClass.ConnectionPostgreDatabase;

        client = ServicePropertiesClass.GetGapslabsService(ServicePropertiesClass.ServiceUri);

        Interpolations.MyLog("init Router");
        try
        {
            client.InitializeRouter(wcfCon);
        }
        catch (System.TimeoutException timeout)
        {
            Debug.LogException(timeout);
        }
        Interpolations.MyLog("Router initialized successfully.");
    }
Пример #7
0
    static string wcfCon = ServicePropertiesClass.ConnectionPostgreDatabase;     //.ConnectionDatabase;

    //[MenuItem("Gapslabs GIS Package/Get More Info from database %#i")]
    static void OSMMoreInfoFromDatabaseMenu()
    {
        var go         = GameObject.Find("AramGISBoundaries");
        var connection = go.GetComponent <MapBoundaries>();

        wcfCon = connection.OverrideDatabaseConnection ? connection.GetOverridenConnectionString() : ServicePropertiesClass.ConnectionPostgreDatabase;

        if (Selection.activeTransform == null)
        {
            EditorUtility.DisplayDialog("No objects selected", "Please select an object from hierarchy tab.", "Ok");
        }
        else
        {
            var name = Selection.activeTransform.name;
            ServiceGapslabsClient client = ServicePropertiesClass.GetGapslabsService(ServicePropertiesClass.ServiceUri);

            var ret = "";
            if (!name.Contains("|"))
            {
                DisplayInfo("Not an OpenStreetMap object.");
                return;
            }
            var o = name.Split(new char[] { '|' }, System.StringSplitOptions.RemoveEmptyEntries);
            ret += "Type: " + o[0] + "\n";
            ret += "id: " + o[2] + "\n";
            switch (o[1])
            {
            case "0":                     // Node
            {
                var selectedNode = client.GetNodeInfo(o[2], wcfCon);
                var nodeTags     = client.GetNodeTags(o[2], wcfCon);
                ret += "Position: " + "Lat=" + selectedNode.lat + " Lon=" + selectedNode.lon + "\n";
                foreach (var tag in nodeTags)
                {
                    ret += "Tag info: " + tag.KeyValue[0] + "=" + tag.KeyValue[1] + "\n";
                }
                break;
            }

            case "1":                     // Line
            case "2":                     // Polygon
            {
                var WayTags = client.GetWayTags(o[2], wcfCon);
                foreach (var tag in WayTags)
                {
                    ret += "Tag info: " + tag.KeyValue[0] + "=" + tag.KeyValue[1] + "\n";
                }
                //					foreach (var node in way.Nodes)
                //					{
                //						ret += "Node: "+"ID="+node.id+" Lat="+ node.Position.Lat+" Lon=" + node.Position.Lon+"\n";
                //					}

                break;
            }

            case "3":
            {
                // TODO
                //var selectedPolygon = source.Nodes.Where(i => i.Attribute("id").Value == o[2]).Single();
                ret += "Relations have not been implemented yet.";
                break;
            }
            }
            DisplayInfo(ret);
        }
    }