예제 #1
0
    void Awake()
    {
        //Get MapBoundaries
        var globalO = GameObject.Find("AramGISBoundaries");

        if (globalO == null)
        {
            Debug.LogError("ProtoWorld Essentials are missing! To add ProtoWorld Essentials go to menu: ProtoWorldEditor > ProtoWorld Essentials > Add Essentials");
            return;
        }

        mapproperties = globalO.GetComponent <MapBoundaries>();

        //Fill coordinates
        coordinates[0] = mapproperties.minLat;
        coordinates[1] = mapproperties.maxLat;
        coordinates[2] = mapproperties.minLon;
        coordinates[3] = mapproperties.maxLon;

        //Fill db information
        dbConnection[0] = mapproperties.serverAddress;
        dbConnection[1] = mapproperties.serverPort;
        dbConnection[2] = mapproperties.serverUserId;
        dbConnection[3] = mapproperties.serverDatabaseName;
        dbConnection[4] = mapproperties.serverPassword;
    }
예제 #2
0
    public void CalculateLatLon(MapBoundaries mb)
    {
        var latlon = new Vector3[4];

        for (int i = 0; i < vertices.Length; i++)
        {
            var res = CoordinateConvertor.Vector3ToLatLon(vertices[i], mb);
            latlon[i] = new Vector3(res[0], 0, res[1]);
        }
        var bounds = GetBounds(latlon);

        minLat = bounds[0];
        maxLat = bounds[1];
        minLon = bounds[2];
        maxLon = bounds[3];

        if (verbose)
        {
            for (int i = 0; i < vertices.Length; i++)
            {
                var convVert = CoordinateConvertor.LatLonToVector3(latlon[i].x, latlon[i].z, latlon[i].y, mb);
                Debug.Log("vertice: " + vertices[i] + " converted back: " + convVert);
            }
        }
    }
예제 #3
0
    // Start is called before the first frame update
    void Start()
    {
        BoundsInt cellBounds = ground.cellBounds;

        MapCell min = new MapCell(cellBounds.min.x, cellBounds.min.y);
        MapCell max = new MapCell(cellBounds.max.x - 1, cellBounds.max.y - 1);

        GroundMapBoundaries = new MapBoundaries(min, max);
    }
예제 #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>
    /// 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;
    }
예제 #6
0
    public static Vector3 LatLonToVector3(double Lat, double Lon, float height, MapBoundaries mb)
    {
        var databaseBounds = new BoundsWCF()
        {
            minlat = mb.dbBoundMinLat,
            maxlat = mb.dbBoundMaxLat,
            minlon = mb.dbBoundMinLon,
            maxlon = mb.dbBoundMaxLon
        };

        float[] MinPointOnArea = SimpleInterpolation((float)mb.minLat, (float)mb.minLon, databaseBounds, mb.minMaxX, mb.minMaxY);
        var     MinPointOnMap  = new Vector3(direction * MinPointOnArea[0], 0, MinPointOnArea[1]);

        var     result = SimpleInterpolation((float)Lat, (float)Lon, databaseBounds, mb.minMaxX, mb.minMaxY);
        var     ret    = new Vector3(direction * (float)result[0], height, (float)result[1]) - MinPointOnMap;
        Vector3 scale  = new Vector3(mb.Scale.x, 1, mb.Scale.y);

        ret.Scale(scale);
        return(ret);
    }
예제 #7
0
        private static void SetupBoundaries()
        {
            var mapBounds    = MapBoundaries.GetMapBoundaries();
            var zoneTileSets = ZoneBoundaries.GetZoneTileSets();

            for (var i = 0; i < s_MapTemplates.Length; i++)
            {
                var mapInfo = s_MapTemplates[i];
                if (mapInfo != null)
                {
                    if (mapBounds != null && mapBounds.Length > i)
                    {
                        mapInfo.Bounds = mapBounds[i];
                    }
                    if (zoneTileSets != null && zoneTileSets.Length > i)
                    {
                        mapInfo.ZoneTileSet = zoneTileSets[i];
                    }
                }
            }
        }
예제 #8
0
    /// <summary>
    /// Converts a unity 3d space position to latitude/longitude given the MapBoundaries object.
    /// </summary>
    /// <param name="position">Unity position.</param>
    /// <param name="mb">MapBoundaries object.</param>
    /// <returns>WGS84 [latitude, longitude].</returns>
    public static float[] Vector3ToLatLon(Vector3 position, MapBoundaries mb)
    {
        var databaseBounds = new BoundsWCF()
        {
            minlat = mb.dbBoundMinLat,
            maxlat = mb.dbBoundMaxLat,
            minlon = mb.dbBoundMinLon,
            maxlon = mb.dbBoundMaxLon
        };

        float[] MinPointOnArea = SimpleInterpolation((float)mb.minLat, (float)mb.minLon, databaseBounds, mb.minMaxX, mb.minMaxY);
        var     MinPointOnMap  = new Vector3(direction * MinPointOnArea[0], 0, MinPointOnArea[1]);

        Vector3 reversescale = new Vector3(1f / mb.Scale.x, 1, 1f / mb.Scale.y);

        position.Scale(reversescale);
        position = position + MinPointOnMap;
        position = new Vector3(direction * position.x, 0, position.z);
        var calclat = Interpolations.linear(position.x, mb.minMaxX[0], mb.minMaxX[1], (float)mb.dbBoundMinLat, (float)mb.dbBoundMaxLat);
        var calclon = Interpolations.linear(position.z, mb.minMaxY[0], mb.minMaxY[1], (float)mb.dbBoundMinLon, (float)mb.dbBoundMaxLon);

        return(new float[] { calclat, calclon });
    }
예제 #9
0
    void Awake()
    {
        timeController = FindObjectOfType <TimeController>();

        trafficDB = FindObjectOfType <TrafficIntegrationData>();
        if (trafficDB == null)
        {
            Debug.Log("TrafficIntegrationData NOT found. ");
            return;
        }

        trafficController = FindObjectOfType <TrafficIntegrationController>();
        if (trafficController == null)
        {
            Debug.Log("TrafficIntegrationController NOT found. ");
            return;
        }

        aramGisBoundaries = FindObjectOfType <MapBoundaries>();
        if (aramGisBoundaries == null)
        {
            Debug.Log("MapBoundaries NOT found. ");
            return;
        }

        var reader = FindSimulationReader();

        reader.SetTrafficDB(trafficDB);

        switch (trafficController.typeOfIntegration)
        {
        case TrafficIntegrationController.TypeOfIntegration.SumoLiveIntegration:
            SetUseNetworkStream(true);
            reader.SetIO(new SumoIO());
            break;

        case TrafficIntegrationController.TypeOfIntegration.SumoFCDFile:
            SetUseNetworkStream(false);
            reader.SetFileName(trafficController.pathSumoFCDFile);
            reader.SetIO(new SumoIO());
            break;

        case TrafficIntegrationController.TypeOfIntegration.VissimFZPFile:
            SetUseNetworkStream(false);
            reader.SetFileName(trafficController.pathVissimFZPFile);
            reader.SetIO(new VissimIO());
            break;

        case TrafficIntegrationController.TypeOfIntegration.MatsimDatabase:
            reader.SetConnectionString(aramGisBoundaries.GetOverridenConnectionString());
            reader.SetIO(new MatsimIO());
            break;

        case TrafficIntegrationController.TypeOfIntegration.PWSimPWSFile:
            SetUseNetworkStream(false);
            reader.SetFileName(trafficController.pathPWSimMetaFile);
            reader.SetIO(new ProtoMetaIO());
            break;

        case TrafficIntegrationController.TypeOfIntegration.DecisionTreeIntegration:
            return;

        case TrafficIntegrationController.TypeOfIntegration.NoTrafficIntegration:
            return;
        }

        reader.ThreadUpdate();
    }
예제 #10
0
 void OnEnable()
 {
     mb = FindObjectOfType <MapBoundaries>();
 }