public void CreateLocalTerrainFromBookmark(string bookmarkJson)
        {
            Bookmark               bookmark            = JsonConvert.DeserializeObject <Bookmark>(bookmarkJson, JsonConfig.SerializerSettings);
            BoundingBox            bbox                = BoundingBoxUtils.ParseBoundingBox(bookmark.BoundingBox);
            TerrainProductMetadata baseProductMetadata = new TerrainProductMetadata(bookmark.TexturesUUID[0], bbox, 0);
            // TODO Add additional product layers if present.

            TerrainModelManager terrainModelManager = TerrainModelManager.Instance;
            LocalTerrainModel   terrainModel        = terrainModelManager.CreateLocalModelFromBookmark(bbox, bookmark.DemUUID, bookmark.TexturesUUID);

            terrainModelManager.ShowTerrainModel(terrainModel);
        }
Beispiel #2
0
        /// <summary>
        ///     Retrieves the product from the Trek web services and saves it to a file. If the
        ///     requested file is already present on the file system, then it is loaded instead,
        ///     unless file redownload is forced.
        /// </summary>
        public void SubsetProduct(TerrainProductMetadata productInfo, bool forceRedownload, Action <string> callback)
        {
            if (productInfo.Format == 0)
            {
                productInfo.Format = ImageFileFormat.Tiff;
            }

            string filename = $"{productInfo.EncodeBase64()}.{FilePath.ProductFileExtension}";

            string         directory      = Path.Combine(FilePath.PersistentRoot, FilePath.Product);
            IList <string> availableFiles = FileUtils.ListFiles(directory, $"*.{FilePath.ProductFileExtension}", true);

            string filepath = Path.Combine(directory, filename);

            if (availableFiles.Contains(filename))
            {
                if (!forceRedownload)
                {
                    callback(filepath);
                    return;
                }

                File.Delete(filepath);
            }

            string baseUrlWithFormat = $"{BaseUrl}{SubsetUrl}/{productInfo.Format.FileExtension()}/subset";

            IDictionary <string, string> paramsMap = new Dictionary <string, string>()
            {
                { "itemUUID", productInfo.ProductUUID },
                { "bbox", productInfo.BoundingBox.ToString(",") },
                { "width", $"{productInfo.Width}" },
                { "height", $"{productInfo.Height}" }
            };

            string resourceUrl = HttpRequestUtils.AppendParams(baseUrlWithFormat, paramsMap, true);

            Debug.Log(resourceUrl);

            VerifyProductExists(productInfo, exists => {
                if (exists)
                {
                    HttpClient.DownloadFile(resourceUrl, filepath, callback);
                }
                else
                {
                    Debug.LogError($"Product UUID {productInfo.ProductUUID} is not a raster or does not exist.");
                }
            });
        }
Beispiel #3
0
 private void VerifyProductExists(TerrainProductMetadata productInfo, Action <bool> callback)
 {
     GetRasters(res => {
         foreach (SearchResultItem item in res.Items)
         {
             if (item.UUID == productInfo.ProductUUID)
             {
                 callback.Invoke(true);
                 return;
             }
         }
         callback.Invoke(false);
     });
 }
Beispiel #4
0
 /// <summary>
 ///     Retrieves the product from the Trek web services and saves it to a file. If the
 ///     requested file is already present on the file system, then it is loaded instead.
 /// </summary>
 public void SubsetProduct(TerrainProductMetadata productInfo, Action <string> callback)
 {
     SubsetProduct(productInfo, false, callback);
 }