Select to view content in your preferred language

Multiple RPF Datasets and App Performance

377
13
4 weeks ago
Labels (3)
Jeffrey_McNeal
Emerging Contributor

My team is working on an application that ingests multiple RPF datasets of different granularity/detail.  When all these datasets are loaded all at once, the app slows way down when zooming in or out.  Any suggestions on how to alleviate this behavior?

My RPF ingest follows the pattern:

foreach file in dataset 
{
    Raster newRasterFile = new file;
    rasterLayer = new RasterLayer(newRasterFile);
    GeoMap?.OperationalLayers.Add(rasterLayer);
    await rasterLayer.LoadAsync();
}

 

0 Kudos
13 Replies
dotMorten_esri
Esri Notable Contributor
Jeffrey_McNeal
Emerging Contributor

@dotMorten_esri I have been playing around with MosaicDatasetRaster and I am able to create the .sql database with the RPF tiles.  Unfortunately, the MosaicDatasetRaster will not display on my map.  Here is my code:

        private async void DisplayRPFDataSetMosaic(string directory)
        {
            string localStorage = @"C:\temp\test.geodatabase";
            MosaicDatasetRaster rasterMosaic = MosaicDatasetRaster.Create(localStorage, "RPF", SpatialReferences.Wgs84);

            rasterMosaic.LoadStatusChanged += async (s, e) =>
            {
                if (e.Status == Esri.ArcGISRuntime.LoadStatus.Loaded)
                {
                    AddRastersParameters parameters = new AddRastersParameters
                    {
                        InputDirectory = directory,
                    };                   
                    await rasterMosaic.AddRastersAsync(parameters);
                }
            };
            await rasterMosaic.LoadAsync();
            RasterLayer? rasterLayer = new RasterLayer(rasterMosaic);
            MyMap?.OperationalLayers.Add(rasterLayer);
        }

 Any ideas on what the issue could be?

0 Kudos
SomeGISGuy
Occasional Contributor

Hard to say. What is happening (or not happening)?
Is there a reason you use the loadstatuschanged event, rather than just adding the rasters after the loadasync call? Are all your raster files in wgs84? Are you able to add the rasters before the load?

0 Kudos
Jeffrey_McNeal
Emerging Contributor

@SomeGISGuy 

Try to answer your questions as best I can:

What is happening (or not happening)?

RPF map packages won't appear on the base map using MosaicDatasetRaster

 Is there a reason you use the loadstatuschanged event?

No reason.  That was the from the example I found on developers.argis.com

Are all your raster files in WGS84?

I am assuming yes.  These raster packages are being sourced by NGA.  My definition of raster package is a bunch of RPF files that define a specific region in the world.

 Are you able to add the rasters before the load?

I just tried that, and it hangs up my basemap where you can't zoom in and out anymore.  ( I am not sure if I am implementing the MosaicDatasetRaster correctly - I am piecing together different examples trying to get something to work)

 

 

0 Kudos
dotMorten_esri
Esri Notable Contributor

Another thing to note is to make sure your map itself is using the same spatial reference as your raster mosaic. You can set that explicitly in the Map constructor.
It's also worth checking both the layer.LoadStatus as well as MapView.DrawStatus events for any indication why a layer might not render (generally this should also be written to the output window while debugging).


It's also worth ensuring your source dataset is actually wgs84/epsg4326 - it's fairly rare rasters aren't in a projected coordinate system

0 Kudos
Jeffrey_McNeal
Emerging Contributor

@dotMorten_esri My basemap is WGS84 and the RPF map packages are also WGS84.  Let me throw this out there: my basemap is a Mobile Map Package.  Does that have any bearing on what I am trying to do?

 

layer.LoadStatus/MapView.DrawStatus

Verified that layer.LoadStatus is "loaded". 

MapView.DrawStatus.  This is where I might be doing things wrong.  I am adding the new layer to Map.OperationalLayers.  Is this not correct? 

 

0 Kudos
dotMorten_esri
Esri Notable Contributor

No that's fine but perhaps try without a basemap, just to exclude the chance you're hitting reprojection issues. However that's why I'm asking about the DrawStatus event - this one will tell you if there are issues with rendering any of the layers.

0 Kudos
Jeffrey_McNeal
Emerging Contributor

@dotMorten_esri 

with this line of code I can see that DrawStatus = Completed:

ConnectedView?.Dispatcher.Invoke(() => ConnectedMapView?.Map?.OperationalLayers.Add(newLayer));

But....  The map does not render and then the Basemap becomes unresponsive (you can no longer zoom in/out).  No exceptions thrown and no warnings.  

0 Kudos
dotMorten_esri
Esri Notable Contributor

I'm sorry. I brainfarted and said DrawStatus event, but I really mean LayerViewStateChanged: https://developers.arcgis.com/net/api-reference/api/netwin/wpf/Esri.ArcGISRuntime.UI.Controls.GeoVie...

Also monitor your debuggers' output window for any indication of layer rendering issues.

Btw. I'd rewrite the layer load code (the code in the doc isn't ideal and I've asked to get it fixed). Instead of doing it in the event, just wait for loadasync and then add your rasters. It simplifies the flow and should give you better error propagation as well:

MosaicDatasetRaster rasterMosaic = MosaicDatasetRaster.Create(@"C:\Data\mosaic.sqlite", "Shasta", SpatialReferences.WebMercator);
await rasterMosaic.LoadAsync();
AddRastersParameters parameters = new AddRastersParameters
{
    InputDirectory = @"..\incoming\data\rasters"
};
await rasterMosaic.AddRastersAsync(parameters);

It would be a good idea to just step through the code to see if the hang is occurring anywhere in your code and what line that might be causing it, or whether it happens somewhere else.

Lastly, as mentioned please try without specifying a basemap.

0 Kudos