コード例 #1
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]);
    }
コード例 #2
0
    /// <summary>
    /// Initializes the convertor using the WCF service and the mapboundaries object.
    /// </summary>
    /// <param name="client">The GaPSLabs WCF webservice</param>
    /// <param name="mapboundaries">The AramGISBoundaries component.</param>
    public static void Initialize(ServiceGapslabsClient client, MapBoundaries mapboundaries)
    {
        BoundsWCF SelectedArea = new BoundsWCF();

        mapboundary         = mapboundaries;
        SelectedArea.minlat = mapboundaries.minLat;
        SelectedArea.maxlat = mapboundaries.maxLat;
        SelectedArea.minlon = mapboundaries.minLon;
        SelectedArea.maxlon = mapboundaries.maxLon;
        minmaxX             = mapboundaries.minMaxX;
        minmaxY             = mapboundaries.minMaxY;

        //if (mapboundaries.CorrectAspectRatio)
        //{
        //    var aspectRatio = System.Math.Abs(SelectedArea.maxlat - SelectedArea.minlat) / System.Math.Abs(SelectedArea.maxlon - SelectedArea.minlon);
        //    minmaxY[1] = (float)(minmaxX[1] / aspectRatio);
        //}

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

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

        //If UseLocalDatabaseBounds, WCF won't be used (for portability) -- Miguel R. C.
        if (mapboundaries.UseLocalDatabaseBounds)
        {
            databaseBounds = new BoundsWCF()
            {
                minlat = mapboundaries.dbBoundMinLat,
                maxlat = mapboundaries.dbBoundMaxLat,
                minlon = mapboundaries.dbBoundMinLon,
                maxlon = mapboundaries.dbBoundMaxLon
            };
        }
        else
        {
            databaseBounds = client.GetBounds(wcfCon);
        }

        float[] MinPointOnArea = SimpleInterpolation((float)SelectedArea.minlat, (float)SelectedArea.minlon, databaseBounds, minmaxX, minmaxY);
        MinPointOnMap = new Vector3(direction * MinPointOnArea[0], 0, MinPointOnArea[1]);
        isInitialized = true;
    }