<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Estimating Map downloadable size while Caching the map in ArcGIS Runtime SDK for iOS Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1408952#M7752</link>
    <description>&lt;P&gt;Thank you so much Ting for the help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's working now. but its not getting changed frequently as it should(please see attached screenshot). Any idea how can i get hold off the status for longer time?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-04-12 at 6.25.45 PM.jpeg" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/100784i92974FEAD2998700/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-04-12 at 6.25.45 PM.jpeg" alt="Screenshot 2024-04-12 at 6.25.45 PM.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Apr 2024 13:00:42 GMT</pubDate>
    <dc:creator>AjiteshUpadhyaya</dc:creator>
    <dc:date>2024-04-12T13:00:42Z</dc:date>
    <item>
      <title>Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1407926#M7748</link>
      <description>&lt;P&gt;Hello Experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;We would need to show the Estimated time to complete the caching of map. This can be done if we have some reference on how much is already downloaded to the device and the total size of the map.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For the same, i have written code something like below, but not getting how can i calculate/get how much has been downloaded.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;-(void) cacheBasemapParameters:(AGSExportTileCacheParameters *)params withSteps:(int) steps
{
	[self deleteExistingTPKFile];

    // Use a weak variable for self within the blocks
    __weak EsriMapViewController *weakSelf = self;

    // temp file
    NSURL *tempFileDirectoryUrl = [[NSFileManager.defaultManager temporaryDirectory] URLByAppendingPathComponent:NSProcessInfo.processInfo.globallyUniqueString];
	NSURL* docDirectoryURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
																 inDomains:NSUserDomainMask] lastObject];

    [NSFileManager.defaultManager createDirectoryAtURL:tempFileDirectoryUrl withIntermediateDirectories:YES attributes:nil error:nil];

    NSString *extension = @".tpk";
    if (self.tileCacheTask.mapServiceInfo.exportTileCacheCompactV2Allowed)
	{
        extension = @".tpkx";
    }
    NSURL *tempFileUrl = [docDirectoryURL URLByAppendingPathComponent:[@"myTileCache" stringByAppendingString:extension]];

    // Kick-off operation
    AGSExportTileCacheJob *job = [self.tileCacheTask exportTileCacheJobWithParameters:params downloadFileURL:tempFileUrl];
    self.cacheJob = job;
    [self.cacheJob startWithStatusHandler:^(AGSJobStatus status) {
        //Print the job status
        
        DLog(@"%d", status);
        //NSArray *allMessages =  [userInfo objectForKey:@"messages"];
        
        //Display download progress if we are fetching result
        /*if (status == 3) {
            NSNumber* totalBytesDownloaded = userInfo[@"AGSDownloadProgressTotalBytesDownloaded"];
            NSNumber* totalBytesExpected = userInfo[@"AGSDownloadProgressTotalBytesExpected"];
            if(totalBytesDownloaded!=nil &amp;amp;&amp;amp; totalBytesExpected!=nil){
                double dPercentage = (double)([totalBytesDownloaded doubleValue]/[totalBytesExpected doubleValue]) * 100;
                [weakSelf showProgressWithMessage:[NSString stringWithFormat:@"%@\n%.2f%% %@", statusMessageTitle, dPercentage, [weakSelf.dataSource textValueForKey:@"DownloadStatus"]]];
                
            }
        }else if ( allMessages.count) {
            [weakSelf showProgressWithMessage:[self extractMostRecentMessage:allMessages]];
        } */
        
        
    } completion:^(AGSTileCache * _Nullable result, NSError * _Nullable error) {
        if (error){
            [weakSelf hideProgress];

            //alert the user
            [ViewUtils showSimpleAlertWithTitle:[self.dataSource textValueForKey:@"Error"]
                                        message:[self.dataSource textValueForKey:@"BasemapDownloadError"]
                              cancelButtonTitle:[self.dataSource textValueForKey:@"Ok"]];
            
            // no need to proceed further if basemaps cannot be downloaded.
        }
        else{
            DLog(@"Successfully downloaded basemap");
            // start downloading feature layers
            if(weakSelf.featureLayersToCache.count &amp;gt; 0){
                // delete all cached feature layers
                [self deleteCachedGeodatabases];
                [self.gdbFeatureLayerMap removeAllObjects];
            }
            [weakSelf cacheNextFeatureLayer];
        }
    }];
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea on how to get it done?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ajitesh&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 12:35:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1407926#M7748</guid>
      <dc:creator>AjiteshUpadhyaya</dc:creator>
      <dc:date>2024-04-10T12:35:00Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1408238#M7749</link>
      <description>&lt;P&gt;Feel free to poke around the &lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_estimate_tile_cache_size_result.html" target="_self"&gt;AGSEstimateTileCacheSizeResult&lt;/A&gt; API.&lt;/P&gt;&lt;P&gt;Unfortunately I don't have an example code snippet handy, so you can give it a try and let me know if you have any trouble.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grimacing_face:"&gt;😬&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Please note, this API only works with image tiles, not vector tiles. We currently don't have a way to estimate the vector tile cache export size yet.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Apr 2024 22:41:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1408238#M7749</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2024-04-10T22:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1408451#M7750</link>
      <description>&lt;P&gt;Thank you Ting for your quick response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;With&amp;nbsp;&lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_estimate_tile_cache_size_result.html" target="_self" rel="nofollow noopener noreferrer"&gt;AGSEstimateTileCacheSizeResult&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;, if i read it correctly, it doesnt have any option to save the cache file locally for future uses(My application has offline capabilities).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Still, i tried writing the code as below it doesnt do anything.. also, i believe it returns the file size only when it goes to 'Completion' method.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;any help on this is really helpful.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;[self.tileCacheTask exportTileCacheParametersWithAreaOfInterest:extent minScale:minScale maxScale:maxScale completion:^(AGSExportTileCacheParameters * _Nullable exportTileCacheParameters, NSError * _Nullable error) {
        if (error) {
            //TODO: display error
        } else {
           
            AGSEstimateTileCacheSizeJob *job = [self.tileCacheTask estimateTileCacheSizeJobWithParameters:exportTileCacheParameters];
            [job startWithStatusHandler:^(AGSJobStatus status) {
                DLog(@"estimation status: %ld", (long)status);
                NSString * statusMessageTitle = [NSString stringWithFormat:@"%@ %@",[self.dataSource textValueForKey:@"DownloadPrepare"], basemap];
                
                [self showProgressWithMessage:statusMessageTitle];
            } completion:^( AGSEstimateTileCacheSizeResult * _Nullable result, NSError * _Nullable error) {
                DLog(@"estimated file size: %llu", result.fileSize);
                NSString * statusMessageTitle = [NSString stringWithFormat:@"%@ %@",[self.dataSource textValueForKey:@"DownloadPrepare"], basemap];
                [self showProgressWithMessage:statusMessageTitle];
                //[self cacheBasemapParameters:exportTileCacheParameters withSteps:steps];
            }];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 11:14:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1408451#M7750</guid>
      <dc:creator>AjiteshUpadhyaya</dc:creator>
      <dc:date>2024-04-11T11:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1408836#M7751</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;P&gt;With&amp;nbsp;&lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_estimate_tile_cache_size_result.html" target="_self" rel="nofollow noopener noreferrer"&gt;AGSEstimateTileCacheSizeResult&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;, if i read it correctly, it doesnt have any option to save the cache file locally for future uses(My application has offline capabilities).&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;That is correct. This API is only for estimating the file size and tile count. You'll still need to create a&amp;nbsp;&lt;A href="https://developers.arcgis.com/ios/api-reference/interface_a_g_s_export_tile_cache_job.html" target="_blank" rel="noopener"&gt;AGSExportTileCacheJob&lt;/A&gt; to download the tile cache.&lt;/SPAN&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;Still, i tried writing the code as below it doesn't do anything..&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This is a typically problem for async &lt;EM&gt;AGSJob&lt;/EM&gt;s. Because the jobs runs asynchronously, once the job variable is assigned, it needs to have a lifespan longer than its asynchronous completion block, in order to get the results.&lt;/P&gt;&lt;P&gt;The common pattern is to hold the job as an instance property, such as (self.estimateJob = …)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;exportTask.exportTileCacheParameters(
    withAreaOfInterest: areaOfInterest,
    minScale: minScale,
    maxScale: maxScale
) { [weak self, unowned exportTask] (params: AGSExportTileCacheParameters?, error: Error?) in
    guard let self else { return }
    if let params = params {
        let job = exportTask.estimateTileCacheSizeJob(with: params)
        self.estimateJob = job
        job.start(statusHandler: nil) { result, error in
            if let result {
                print("Tile count", result.tileCount)
                let formatter = ByteCountFormatter()
                formatter.allowedUnits = .useAll
                formatter.countStyle = .file
                formatter.includesUnit = true
                formatter.isAdaptive = true
                print("File size", formatter.string(fromByteCount: Int64(result.fileSize)))
            } else if let error {
                print(error.localizedDescription)
            }
        }
        // Below export tiles logics…
    } else if let error = error {
        print(error.localizedDescription)
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have much template code for ObjC, so bear with my Swift answer. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;also, i believe it returns the file size only when it goes to 'Completion' method.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This is correct. Because the estimation happens on the server side, this method is asynchronous. The code is messy with ObjC and completion block, but is much nicer with Swift Concurrency async/await. Hope you can start using it soon!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please see &lt;A href="https://developers.arcgis.com/ios/programming-patterns/tasks-and-jobs/" target="_self"&gt;this&lt;/A&gt; article for the completion handler async programming pattern.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Apr 2024 23:52:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1408836#M7751</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2024-04-11T23:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1408952#M7752</link>
      <description>&lt;P&gt;Thank you so much Ting for the help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's working now. but its not getting changed frequently as it should(please see attached screenshot). Any idea how can i get hold off the status for longer time?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2024-04-12 at 6.25.45 PM.jpeg" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/100784i92974FEAD2998700/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2024-04-12 at 6.25.45 PM.jpeg" alt="Screenshot 2024-04-12 at 6.25.45 PM.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Apr 2024 13:00:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1408952#M7752</guid>
      <dc:creator>AjiteshUpadhyaya</dc:creator>
      <dc:date>2024-04-12T13:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1409276#M7753</link>
      <description>&lt;P&gt;Can you elaborate on what you means? Did you intend to upload a GIF?&lt;/P&gt;&lt;P&gt;Do you mean you want more frequent progress value updates, or want to show the status/progress spinner for a longer period of time?&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2024 00:45:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1409276#M7753</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2024-04-13T00:45:11Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1409289#M7754</link>
      <description>&lt;P&gt;I mean, to show the more frequent progress value updates.&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the progress bar, i'm showing 61KB/36.6 MB downloaded(as per above screenshot). When it downloads more data to the device the value of 61KB should get changed and should show the updated values..&lt;/P&gt;&lt;P&gt;Any idea how to achieve this? Is it possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 13 Apr 2024 05:00:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1409289#M7754</guid>
      <dc:creator>AjiteshUpadhyaya</dc:creator>
      <dc:date>2024-04-13T05:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1409848#M7755</link>
      <description>&lt;P&gt;Thanks for the details. Upon my tests, the progress does jump from 11% to 89% without any fraction values in between. We'll see if it is a known issue or not.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2024 17:46:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1409848#M7755</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2024-04-15T17:46:17Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1410761#M7757</link>
      <description>&lt;P&gt;This is interesting..In my case, when it started it was on 291 bytes and it stays as it is till the download gets completed. Please see attached video.&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6351085030112w720h540r51" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6351085030112" data-account="6161463677001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6161463677001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6351085030112w720h540r51');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://community.esri.com/t5/video/gallerypage/video-id/6351085030112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2024 06:20:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1410761#M7757</guid>
      <dc:creator>AjiteshUpadhyaya</dc:creator>
      <dc:date>2024-04-17T06:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1411978#M7760</link>
      <description>&lt;P&gt;Can you share the code snippet you use to retrieve the file size downloaded?&lt;/P&gt;&lt;P&gt;Instead of monitoring the file size, I suggest observing the&amp;nbsp;&lt;EM&gt;exportTileCacheJob&lt;SPAN class=""&gt;.&lt;/SPAN&gt;&lt;/EM&gt;&lt;SPAN class=""&gt;&lt;EM&gt;progress&lt;/EM&gt; instead. Sth like below&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="swift"&gt;jobProgressObservation = exportTileCacheJob.progress.observe(\.fractionCompleted, options: .new) { [weak self] (progress, _) in
    print(progress.fractionCompleted)
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While it doesn't tell how much file size has been downloaded, it gives you a series of percentage of the job's current progress.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, below is the extent I tried to export.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="extent.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/101463i27CDEB4260D1E532/image-size/medium?v=v2&amp;amp;px=400" role="button" title="extent.png" alt="extent.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P class=""&gt;Tile count:&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;321, File size:&lt;SPAN class=""&gt;&amp;nbsp; &lt;/SPAN&gt;7.1 MB&lt;/P&gt;&lt;P class=""&gt;&lt;EM&gt;progress.fractionCompleted&lt;/EM&gt; output: 0.01, 0.02, 0.03, 0.04, 0.06, 0.07, 0.09, 0.11, 0.12, 0.17, 0.27, 0.39, 0.6, 0.8, 1.0&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 18 Apr 2024 23:23:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1411978#M7760</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2024-04-18T23:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1412100#M7761</link>
      <description>&lt;P&gt;Thanks Ting, for looking into it. Please find below my code snippet for the complete method for caching.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;[self initCacheTaskForUrl:abo.basemapURL];
    
    double minScale = self.mapView.mapScale;
    //double maxScale = self.tileCacheTask.mapServiceInfo.maxScale;
    double maxScale = self.mapView.map.basemap.baseLayers.firstObject.maxScale;
    if (minScale &amp;lt; maxScale) {
        minScale = maxScale;
    }
    if (isnan(maxScale)) {
        maxScale = minScale;
    }
    
    AGSEnvelope *extent = [self.mapView visibleArea].extent;
    
    [self.tileCacheTask exportTileCacheParametersWithAreaOfInterest:extent minScale:minScale maxScale:maxScale completion:^(AGSExportTileCacheParameters * _Nullable exportTileCacheParameters, NSError * _Nullable error) {
        if (error) {
            //TODO: display error
        } else {
//            AGSEstimateTileCacheSizeJob *job = [self.tileCacheTask estimateTileCacheSizeJobWithParameters:exportTileCacheParameters];
//            [job startWithStatusHandler:^(AGSJobStatus status) {
//                DLog(@"estimation status: %ld", (long)status);
//            } completion:^( AGSEstimateTileCacheSizeResult * _Nullable result, NSError * _Nullable error) {
//                DLog(@"estimated file size: %llu", result.fileSize);
//                [self cacheBasemapParameters:exportTileCacheParameters withSteps:steps];
//            }];
            
            //EWU2-9, EWU2-12 Cache Progress indicator does not exist
           NSString * statusMessageTitle = [NSString stringWithFormat:@"%@ %@",[self.dataSource textValueForKey:@"DownloadPrepare"], basemap];
            
            _currentActivity = GISActivityCachingMaps;
            [self showProgressWithMessage:statusMessageTitle];
            
            [self deleteExistingTPKFile];
            
            // Use a weak variable for self within the blocks
            __weak EsriMapViewController *weakSelf = self;

            // temp file
            NSURL *tempFileDirectoryUrl = [[NSFileManager.defaultManager temporaryDirectory] URLByAppendingPathComponent:NSProcessInfo.processInfo.globallyUniqueString];
            NSURL* docDirectoryURL = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory
                                                                         inDomains:NSUserDomainMask] lastObject];

            [NSFileManager.defaultManager createDirectoryAtURL:tempFileDirectoryUrl withIntermediateDirectories:YES attributes:nil error:nil];

            NSString *extension = @".tpk";
            if (self.tileCacheTask.mapServiceInfo.exportTileCacheCompactV2Allowed)
            {
                extension = @".tpkx";
            }
            NSURL *tempFileUrl = [docDirectoryURL URLByAppendingPathComponent:[@"myTileCache" stringByAppendingString:extension]];
            //DLog(@"%d", status);
            AGSEstimateTileCacheSizeJob *jobCacheSize = [self.tileCacheTask estimateTileCacheSizeJobWithParameters:exportTileCacheParameters];
            self.estimateJob = jobCacheSize;
            [jobCacheSize startWithStatusHandler:nil completion:^(AGSEstimateTileCacheSizeResult *result, NSError *error) {
                if (result) {
                    DLog(@"Tile count: %lld", result.tileCount);
                    
                    NSByteCountFormatter *formatter = [[NSByteCountFormatter alloc] init];
                    formatter.allowedUnits = NSByteCountFormatterUseAll;
                    formatter.countStyle = NSByteCountFormatterCountStyleFile;
                    formatter.includesUnit = YES;
                    formatter.adaptive = YES;
                    
                    DLog(@"Tile count: %lld", [formatter stringFromByteCount:result.tileCount]);
                    DLog(@"File size: %@", [formatter stringFromByteCount:result.fileSize]);
                    
                    NSNumber* totalBytesDownloaded = [formatter stringFromByteCount:result.tileCount];
                    NSNumber* totalBytesExpected = [formatter stringFromByteCount:result.fileSize];
                    
                    // Convert NSNumber objects to strings
                    NSString* downloadedString = [totalBytesDownloaded stringValue];
                    NSString* expectedString = [totalBytesExpected stringValue];
                    
                    // Create the desired format: 'totalBytesDownloaded/totalBytesExpected'
                    NSString* ratioString = [NSString stringWithFormat:@"%@/%@", downloadedString, expectedString];
                    //double dPercentage = (double)([totalBytesDownloaded doubleValue]/[totalBytesExpected doubleValue]) * 100;
                    [weakSelf showProgressWithMessage:[NSString stringWithFormat:@"%@\n %@ %@", statusMessageTitle, ratioString, [weakSelf.dataSource textValueForKey:@"DownloadStatus"]]];
                    
                    //[self cacheBasemapParameters:exportTileCacheParameters withSteps:steps];
                } else if (error) {
                    DLog(@"%@", error.localizedDescription);
                }
            }];
            // Kick-off operation
            AGSExportTileCacheJob *job = [self.tileCacheTask exportTileCacheJobWithParameters:exportTileCacheParameters downloadFileURL:tempFileUrl];
            self.cacheJob = job;
            [self.cacheJob startWithStatusHandler:^(AGSJobStatus status) {
              
                
            } completion:^(AGSTileCache * _Nullable result, NSError * _Nullable error) {
                if (error){
                    [weakSelf hideProgress];

                    //alert the user
                    [ViewUtils showSimpleAlertWithTitle:[self.dataSource textValueForKey:@"Error"]
                                                message:[self.dataSource textValueForKey:@"BasemapDownloadError"]
                                      cancelButtonTitle:[self.dataSource textValueForKey:@"Ok"]];
                    
                    // no need to proceed further if basemaps cannot be downloaded.
                }
                else{
                    DLog(@"Successfully downloaded basemap");
                    // start downloading feature layers
                    if(weakSelf.featureLayersToCache.count &amp;gt; 0){
                        // delete all cached feature layers
                        [self deleteCachedGeodatabases];
                        [self.gdbFeatureLayerMap removeAllObjects];
                    }
                    [weakSelf cacheNextFeatureLayer];
                }
            }];&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 19 Apr 2024 06:27:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1412100#M7761</guid>
      <dc:creator>AjiteshUpadhyaya</dc:creator>
      <dc:date>2024-04-19T06:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1412386#M7762</link>
      <description>&lt;PRE&gt;                    NSNumber* totalBytesDownloaded = [formatter stringFromByteCount:result.tileCount];
                    NSNumber* totalBytesExpected = [formatter stringFromByteCount:result.fileSize];&lt;/PRE&gt;&lt;P&gt;This is not correct. The estimate job only gives you the estimation of total amount of tiles to be downloaded, and the estimated file size from the server. It doesn't provide real time update for the progress.&lt;/P&gt;&lt;P&gt;What you have here is showing the static tileCount/fileSize, which doesn't have a real meaning.&lt;/P&gt;&lt;P&gt;For fraction completed of the&amp;nbsp;&lt;EM&gt;AGSExportTileCacheJob&lt;/EM&gt;, see my previous comment.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Apr 2024 16:57:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1412386#M7762</guid>
      <dc:creator>Ting</dc:creator>
      <dc:date>2024-04-19T16:57:53Z</dc:date>
    </item>
    <item>
      <title>Re: Estimating Map downloadable size while Caching the map</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1413980#M7763</link>
      <description>&lt;P&gt;This worked, Thanks a lot Ting for the help.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Apr 2024 07:01:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-ios-questions/estimating-map-downloadable-size-while-caching-the/m-p/1413980#M7763</guid>
      <dc:creator>AjiteshUpadhyaya</dc:creator>
      <dc:date>2024-04-23T07:01:32Z</dc:date>
    </item>
  </channel>
</rss>

