public Vector3 GetPositionOnMapByLatLon(Helper.WGS84 limits, float lat, float lon)
    {
        double horizontalSize = limits.east - limits.west;
        double verticalSize   = limits.north - limits.south;

        double auxLong = lon - limits.west;
        double auxLat  = lat - limits.south;

        double calculatedX = terrain.GetTexture().width *auxLong / horizontalSize;
        double calculatedY = terrain.GetTexture().height *auxLat / verticalSize;

        Vector2 diffFromTex = terrain.GetDifferenceFromTexture();

        if (centrilize)
        {
            calculatedX = calculatedX + diffFromTex.x;
            calculatedY = calculatedY + diffFromTex.y;
        }

        float auxHeight = terrain.GetTexture().GetPixel((int)calculatedX, (int)calculatedY).r;

        Vector3 pos = new Vector3((float)calculatedX, auxHeight * maxHeight, (float)calculatedY);

        return(pos);
    }
    public void LoadMapFromOpenTopography()
    {
        SO_PackageData.Init();

        //TODO: AQUI EH A CHAMADA PRA QUANDO QUISER FAZER LOAD DE NOVA AREA A PARTIR DA INTERACAO COM O MAPA
        Helper.WGS84 coordinates = new Helper.WGS84(-119.65227127075197, 37.69903420794415, -119.52283859252931, 37.77804178967591);
        LoadFromOpenTopography(coordinates);
    }
    private void LoadFromOpenTopography(Helper.WGS84 coordinates)
    {
        loadingFromOpenTopography = true;
        loadingFinished           = false;
        OpenTopographyAPI.OpenTopographyElement element = new OpenTopographyAPI.OpenTopographyElement(coordinates);

        StartCoroutine(OpenTopographyAPI.DownloadGeoTiff(element, "C:/", "myFile", DownloadedGeoTiffCallback));
    }
    public void LoadPackage(string path)
    {
        ClearScene();
        rootPath = SO_PackageData.SelectPackage(path);
        SO_PackageData.Init();

        //If the package don't contains a geotiff image, load packages on worldMap
        if (string.IsNullOrEmpty(SO_PackageData.instance.geoTiffPath))
        {
            limits = new Helper.WGS84(-180, -90, 180, 90);
            LoadWorldMap();
        }
        else
        {
            //Read Geotiff image downloaded, set the coordinates and the heightTexture
            Texture2D tex;

            Helper.LoadGeotiffData(rootPath + SO_PackageData.instance.geoTiffPath, out limits, out tex);
            terrainManager.LoadTerrain(tex);
        }

        CreateGDCs();
        //CreateLineRendererRoute();
    }
    public void LoadPackages()
    {
        ClearScene();
        LoadWorldMap();

        string root = "";

#if UNITY_EDITOR
        root = "C:\\MOSIS_LAB\\Packages";
#else
        root = Application.dataPath + "\\" + Packages;
#endif

        //Check if packages directory exists, if not, create!
        if (!Directory.Exists(root))
        {
            Directory.CreateDirectory(root);
        }

        string[] packagesPaths = Directory.GetDirectories(root);

        foreach (var item in packagesPaths)
        {
            //If the folder don't contains a package.json, so it isn't a valid package
            if (!File.Exists(item + "\\gdcPackage.json"))
            {
                continue;
            }

            //TODO: VER AQUI PRA ADAPTAR O SO_PACKAGEDATA PARA UMA LISTA DE PACKAGES

            //Get Json properties using SO
            rootPath = SO_PackageData.SelectPackage(item + "\\gdcPackage.json");
            SO_PackageData.Init();

            GameObject go = Instantiate(Resources.Load("PackagePin", typeof(GameObject)) as GameObject);

            Package package = go.AddComponent <Package>();

            package.Initialize(SO_PackageData.instance);
            package.SetFullPath(item + "\\gdcPackage.json");

            //Get PackagePin script to Load data to Prefab
            PackagePin packagePin = go.GetComponent <PackagePin>();
            packagePin.LoadPanel(this, package);


            go.name = "PIN_" + package.name;

            Helper.WGS84 worldLimits = new Helper.WGS84(-180, -90, 180, 90);
            float        lat         = package.latitude;
            float        lon         = package.longitude;
            Vector3      pos         = terrainManager.GetPositionOnMapByLatLon(worldLimits, lat, lon);

            //Put element inside of map to positionate correctly
            go.transform.SetParent(terrainManager.transform);
            go.transform.localPosition = pos;

            //then put element out to correct scale
            go.transform.SetParent(loadedElementsTransform);

            packages.Add(package);
        }
    }
Example #6
0
 public OpenTopographyElement(Helper.WGS84 coordinates, RasterDataset dataset = RasterDataset.SRTMGL1, OutputFormat outputFormat = OutputFormat.GTiff)
 {
     this.coordinates  = coordinates;
     this.dataset      = dataset;
     this.outputFormat = outputFormat;
 }