Application Setup

From Maria GDK Wiki
Revision as of 15:31, 26 February 2025 by Ths (talk | contribs)
Jump to navigation Jump to search

The following is an overview of which classes need to be set up before adding any layers to the geo controls.

MariaGeoDataManager

This class manages the common structures for geo data in the application. It needs not be a singleton, but usually an application will have only one of these, shared between multiple GeoContols. This class is responsible for:

Map service clients

The MariaGeoDataManger has clients for map templates, map catalog, and map data services. It also manages the MapServiceResolver which looks up data services based on map queries.

Tile cache

The Tile Cache is central to all the map layers as well as elevation data. The MariaGeoDataManager also includes methods for accessing and adding custom tiled data providers to the tile cache manager.

Elevation Data

The MariaGeoDataManager contains an ElevationDataViewModel as well as an ElevationData interface for making elevation queries. The ElevationDataViewModel controls the active layers in the ElevationData. This ElevationData is used for all common elevation operations in the MapLayer and 3D views, such as elevation shading, elevation profiles etc.


GeoControlViewModel

The GeoControlViewModel is the main hub of all the geo layers. It has the GeoLayerManager which gives access to (among other things) the following:

* Layer List
* Location and scale of the map view (GeoNavigator, GeoContext)
* Interaction tools such as panning and zooming (GeoToolManager)
* Geo Units settings
* Item selection
* Undo/Redo stack.

Complete example (2D)

   // Set up service clients.
   IBindingFactory bindingFactory = new BindingFactory();
   IEndpointAddressFactory endpointAddressFactory = new EndpointAddressFactory();

   var mapCatalogServiceClient = new MapCatalogServiceClient(bindingFactory.NewFromConfigurationFile("MapCatalogService"), endpointAddressFactory.NewFromConfigurationFile("MapCatalogService"), 1000);
   
   var mapTemplateServiceClient = new MapTemplateServiceClientFactory(bindingFactory, endpointAddressFactory).New("TemplateService");

   // Set up common data manager with the required service clients.
   var geoDataManager = new MariaGeoDataManager(mapCatalogServiceClient, mapTemplateServiceClient);

   // The GeoControlViewModel is the main hub of all geo layer management.
   var geoControlViewModelFactory = new GeoControlViewModelFactory(MariaApplication.Instance.NativeRenderingManager, geoDataManager.TileCacheManager);
   var geoControlViewModel = geoControlViewModelFactory.New();

   // Set up symbol service client and request processing queue.
   var symbolPointServiceClient = new SymbolPointServiceClient(bindingFactory.NewFromConfigurationFile("SymbolPointService"), endpointAddressFactory.NewFromConfigurationFile("SymbolPointService"), 1000);
   var symbolRequestProcessor = new SymbolRequestProcessor(SymbolPointServiceClient);

   // Create some layers
   var mapLayer = new MapLayer(geoControlViewModel, geoDataManager);
   var gridLayer = new GridLayer(geoControlViewModel);			
   var trackLayer = new TrackLayer(geoControlViewModel, symbolRequestProcessor);

MariaApplication singleton

The TPG.GDK.Maria.Common.MariaApplication is a Singleton class which sets up some application wide properties and facilities, such as data paths and logging. This class need not be explicitly instantiated unless you have particular requirements for the input parameters. See the code doc for list of available constructor parameters.

Application shutdown

To ensure a clean shutdown you should call MariaApplication.Shutdown() before on application exit. For example:

        public ICommand ExitCommand
        {
            get { return new DelegateCommand(x => ApplicationShutdown()); }
        }

        private void ApplicationShutdown()
        {
            MariaApplication.Instance.Shutdown();
            Application.Current.Shutdown();
        }