private async void Initialize() { // Create a new map centered on Aurora Colorado. _myMapView.Map = new Map(BasemapType.Streets, 39.7294, -104.73, 11); // Get the full path to the GeoPackage on the device. string myGeoPackagePath = GetGeoPackagePath(); try { // Open the GeoPackage. GeoPackage myGeoPackage = await GeoPackage.OpenAsync(myGeoPackagePath); // Get the read only list of GeoPackageRasters from the GeoPackage. IReadOnlyList <GeoPackageRaster> myReadOnlyListOfGeoPackageRasters = myGeoPackage.GeoPackageRasters; // Loop through each GeoPackageRaster. foreach (GeoPackageRaster oneGeoPackageRaster in myReadOnlyListOfGeoPackageRasters) { // Create a RasterLayer from the GeoPackageRaster. RasterLayer myRasterLayer = new RasterLayer(oneGeoPackageRaster) { // Set the opacity on the RasterLayer to partially visible. Opacity = 0.55 }; // Add the layer to the map. _myMapView.Map.OperationalLayers.Add(myRasterLayer); } // Get the read only list of GeoPackageFeatureTabless from the GeoPackage. IReadOnlyList <GeoPackageFeatureTable> myReadOnlyListOfGeoPackageFeatureTables = myGeoPackage.GeoPackageFeatureTables; // Loop through each GeoPackageFeatureTable. foreach (GeoPackageFeatureTable oneGeoPackageFeatureTable in myReadOnlyListOfGeoPackageFeatureTables) { // Create a FeatureLayer from the GeoPackageFeatureLayer. FeatureLayer myFeatureLayer = new FeatureLayer(oneGeoPackageFeatureTable); // Add the layer to the map. _myMapView.Map.OperationalLayers.Add(myFeatureLayer); } } catch (Exception e) { new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show(); } }
private async void Initialize() { // Create a new map centered on Aurora Colorado. MyMapView.Map = new Map(BasemapType.Streets, 39.7294, -104.73, 11); // Get the full path to the GeoPackage on the device. string myGeoPackagePath = DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg"); try { // Open the GeoPackage. GeoPackage myGeoPackage = await GeoPackage.OpenAsync(myGeoPackagePath); // Loop through each GeoPackageRaster. foreach (GeoPackageRaster oneGeoPackageRaster in myGeoPackage.GeoPackageRasters) { // Create a RasterLayer from the GeoPackageRaster. RasterLayer myRasterLayer = new RasterLayer(oneGeoPackageRaster) { // Set the opacity on the RasterLayer to partially visible. Opacity = 0.55 }; // Add the raster layer to the map. MyMapView.Map.OperationalLayers.Add(myRasterLayer); } // Loop through each GeoPackageFeatureTable. foreach (GeoPackageFeatureTable oneGeoPackageFeatureTable in myGeoPackage.GeoPackageFeatureTables) { // Create a FeatureLayer from the GeoPackageFeatureLayer. FeatureLayer myFeatureLayer = new FeatureLayer(oneGeoPackageFeatureTable); // Add the layer to the map. MyMapView.Map.OperationalLayers.Add(myFeatureLayer); } } catch (Exception e) { await new MessageDialog(e.ToString(), "Error").ShowAsync(); } }
private async void Initialize() { // Create a new map centered on Aurora Colorado. _myMapView.Map = new Map(BasemapType.Streets, 39.7294, -104.70, 11); // Get the full path to the GeoPackage on the device. string geoPackagePath = DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg"); try { // Open the GeoPackage. GeoPackage geoPackage = await GeoPackage.OpenAsync(geoPackagePath); // Loop through each GeoPackageRaster. foreach (GeoPackageRaster oneGeoPackageRaster in geoPackage.GeoPackageRasters) { // Create a RasterLayer from the GeoPackageRaster. RasterLayer rasterLayer = new RasterLayer(oneGeoPackageRaster) { // Set the opacity on the RasterLayer to partially visible. Opacity = 0.55 }; // Add the layer to the map. _myMapView.Map.OperationalLayers.Add(rasterLayer); } // Loop through each GeoPackageFeatureTable from the GeoPackage. foreach (GeoPackageFeatureTable oneGeoPackageFeatureTable in geoPackage.GeoPackageFeatureTables) { // Create a FeatureLayer from the GeoPackageFeatureLayer. FeatureLayer featureLayer = new FeatureLayer(oneGeoPackageFeatureTable); // Add the layer to the map. _myMapView.Map.OperationalLayers.Add(featureLayer); } } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private async void Initialize() { // Create a new map MyMapView.Map = new Map(Basemap.CreateLightGrayCanvas()); // Get the full path string geoPackagePath = GetGeoPackagePath(); try { // Open the GeoPackage GeoPackage myGeoPackage = await GeoPackage.OpenAsync(geoPackagePath); // Read the raster images and get the first one Raster gpkgRaster = myGeoPackage.GeoPackageRasters.FirstOrDefault(); // Make sure an image was found in the package if (gpkgRaster == null) { return; } // Create a layer to show the raster RasterLayer newLayer = new RasterLayer(gpkgRaster); await newLayer.LoadAsync(); // Set the viewpoint await MyMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent)); // Add the image as a raster layer to the map (with default symbology) MyMapView.Map.OperationalLayers.Add(newLayer); } catch (Exception e) { await((Page)Parent).DisplayAlert("Error", e.ToString(), "OK"); } }
private async void Initialize() { // Create a new map. _myMapView.Map = new Map(BasemapStyle.ArcGISLightGray); // Get the GeoPackage path. string geoPackagePath = DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg"); try { // Open the GeoPackage. GeoPackage geoPackage = await GeoPackage.OpenAsync(geoPackagePath); // Read the raster images and get the first one. Raster gpkgRaster = geoPackage.GeoPackageRasters.FirstOrDefault(); // Make sure an image was found in the package. if (gpkgRaster == null) { return; } // Create a layer to show the raster. RasterLayer newLayer = new RasterLayer(gpkgRaster); await newLayer.LoadAsync(); // Set the viewpoint. await _myMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent)); // Add the image as a raster layer to the map (with default symbology). _myMapView.Map.OperationalLayers.Add(newLayer); } catch (Exception e) { new UIAlertView("Error", e.ToString(), (IUIAlertViewDelegate)null, "OK", null).Show(); } }
private async void Initialize() { // Create a new map _myMapView.Map = new Map(BasemapStyle.ArcGISLightGray); // Get the full path string geoPackagePath = GetGeoPackagePath(); try { // Open the GeoPackage GeoPackage myGeoPackage = await GeoPackage.OpenAsync(geoPackagePath); // Read the raster images and get the first one Raster gpkgRaster = myGeoPackage.GeoPackageRasters.FirstOrDefault(); // Make sure an image was found in the package if (gpkgRaster == null) { return; } // Create a layer to show the raster RasterLayer newLayer = new RasterLayer(gpkgRaster); await newLayer.LoadAsync(); // Set the viewpoint await _myMapView.SetViewpointAsync(new Viewpoint(newLayer.FullExtent)); // Add the image as a raster layer to the map (with default symbology) _myMapView.Map.OperationalLayers.Add(newLayer); } catch (Exception e) { new AlertDialog.Builder(this).SetMessage(e.ToString()).SetTitle("Error").Show(); } }
public void TestGeoPackage(string file) { if (!File.Exists(file)) { throw new IgnoreException(string.Format("Test data not present: '{0}'!", file)); } GeoPackage gpkg = null; Assert.DoesNotThrow(() => gpkg = GeoPackage.Open(file), "Opened did not prove to be a valid geo package"); Assert.Greater(gpkg.Features.Count + gpkg.Tiles.Count, 0); foreach (var feature in gpkg.Features) { IProvider p = null; Assert.DoesNotThrow(() => p = gpkg.GetFeatureProvider(feature)); TestProvider(p, feature); ILayer l = null; Assert.DoesNotThrow(() => l = gpkg.GetFeatureLayer(feature)); } }
private async void InitializeMap() { string geoPackagePath = GetOfflinePackagePath(@"full.gpkg"); try { //MyMapView.Map = new Map(BasemapType.OpenStreetMap, 0, 0, 10); var tileInfo = FGTiltInfoFactory.GetOpenStreetMapTileInfo(); var center = new MapPoint(12886578.9273218, -3753475.38812722, new SpatialReference(3857)); var extend = new Envelope(center, 100000000.0, 100000000.0); var aerial = new FGBaseMapTiledLayer( tileInfo, extend ); var basemap = new Basemap(aerial); MyMapView.Map = new Map(basemap); await MyMapView.SetViewpointCenterAsync(center, ScaleByZoomLevel(16)); MyMapView.ViewpointChanged += ViewpointChangedHandler; MyMapView.GeoViewTapped += GeoViewTappedHandler; // Open the GeoPackage this.MyGeoPackage = await GeoPackage.OpenAsync(geoPackagePath); //LoadByFeatureCollectionLayer(); LoadByFeatureLayer(); //SetViewpointBasedOnOperationalLayers(); } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Error", e.ToString(), "OK"); } }
private async void Initialize() { // Create a new map centered on Aurora Colorado MyMapView.Map = new Map(BasemapType.Streets, 39.7294, -104.8319, 11); // Get the full path to the GeoPackage on the device string myGeoPackagePath = DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg"); // Open the GeoPackage GeoPackage myGeoPackage = await GeoPackage.OpenAsync(myGeoPackagePath); // Loop through each GeoPackageRaster foreach (GeoPackageRaster oneGeoPackageRaster in myGeoPackage.GeoPackageRasters) { // Create a RasterLayer from the GeoPackageRaster RasterLayer myRasterLayer = new RasterLayer(oneGeoPackageRaster) { // Set the opacity on the RasterLayer to partially visible Opacity = 0.55 }; // Load the RasterLayer - that way we can get to it's properties await myRasterLayer.LoadAsync(); // Create a string variable to hold the name of the RasterLayer for display // in the ListBox and the Dictionary - it will initially be an empty string string myRasterLayerName = ""; if (myRasterLayer.Name != "") { // We have a good name for the RasterLayer that came from // the RasterLayer.Name property myRasterLayerName = myRasterLayer.Name; } else if (oneGeoPackageRaster.Path.Split('/').Last() != "") { // We did not get a good name from the RasterLayer from the .Name // property, get the good name from the GeoPackageRaster.Path instead myRasterLayerName = oneGeoPackageRaster.Path.Split('/').Last(); } // Append the 'type of layer' to the myRasterLayerName string to display in the // ListBox and as the key for the Dictionary myRasterLayerName = myRasterLayerName + " - RasterLayer"; // Add the name of the RasterLayer and the RasterLayer itself into the Dictionary _nameToLayerDictionary[myRasterLayerName] = myRasterLayer; // Add the name of the RasterLayer to the ListBox of layers not in map LayersNotInTheMap.Items.Add(myRasterLayerName); } // Loop through each GeoPackageFeatureTable foreach (GeoPackageFeatureTable oneGeoPackageFeatureTable in myGeoPackage.GeoPackageFeatureTables) { // Create a FeatureLayer from the GeoPackageFeatureLayer FeatureLayer myFeatureLayer = new FeatureLayer(oneGeoPackageFeatureTable); // Load the FeatureLayer - that way we can get to it's properties await myFeatureLayer.LoadAsync(); // Create a string variable to hold the human-readable name of the FeatureLayer for // display in the ListBox and the Dictionary string myFeatureLayerName = myFeatureLayer.Name; // Append the 'type of layer' to the myFeatureLayerName string to display in the // ListBox and as the key for the Dictionary myFeatureLayerName = myFeatureLayerName + " - FeatureLayer"; // Add the name of the FeatureLayer and the FeatureLayer itself into the Dictionary _nameToLayerDictionary[myFeatureLayerName] = myFeatureLayer; // Add the name of the FeatureLayer to the ListBox of layers not in map LayersNotInTheMap.Items.Add(myFeatureLayerName); } }
private async void Initialize() { // Create a new map centered on Aurora Colorado MyMapView.Map = new Map(BasemapType.Streets, 39.7294, -104.8319, 11); // Get the full path to the GeoPackage on the device string myGeoPackagePath = GetGeoPackagePath(); try { // Open the GeoPackage GeoPackage myGeoPackage = await GeoPackage.OpenAsync(myGeoPackagePath); // Get the read only list of GeoPackageRasters from the GeoPackage IReadOnlyList <GeoPackageRaster> myReadOnlyListOfGeoPackageRasters = myGeoPackage.GeoPackageRasters; // Loop through each GeoPackageRaster int idx = 0; foreach (GeoPackageRaster oneGeoPackageRaster in myReadOnlyListOfGeoPackageRasters) { // Create a RasterLayer from the GeoPackageRaster RasterLayer myRasterLayer = new RasterLayer(oneGeoPackageRaster) { // Set the opacity on the RasterLayer to partially visible Opacity = 0.55 }; // Load the RasterLayer - that way we can get to it's properties await myRasterLayer.LoadAsync(); // Create a string variable to hold the human-readable name of the RasterLayer for display // in the ListBox and the HybridDictonary - it will initially be an empty string string myRasterLayerName = ""; if (myRasterLayer.Name != "") { // We have a good human-readable name for the RasterLayer that came from // the RasterLayer.Name property myRasterLayerName = myRasterLayer.Name; } else if (oneGeoPackageRaster.Path.Split('/').Last() != "") { // We did not get a good human-readable name from the RasterLayer from the .Name // property, get the good human-readable name from the GeoPackageRaster.Path instead myRasterLayerName = oneGeoPackageRaster.Path.Split('\\').Last(); } // Append the 'type of layer' to the myRasterLayerName string to display in the // ListBox and as the key for the HybridDictonary myRasterLayerName = myRasterLayerName + " - RasterLayer " + ++idx; // Add the name of the RasterLayer and the RasterLayer itself into the HybridDictionary _myHybridDictionary_Layers.Add(myRasterLayerName, myRasterLayer); // Add the name of the RasterLayer to the ListBox of layers not in map LayersNotInTheMapList.Items.Add(myRasterLayerName); } // Get the read only list of GeoPackageFeatureTabless from the GeoPackage IReadOnlyList <GeoPackageFeatureTable> myReadOnlyListOfGeoPackageFeatureTables = myGeoPackage.GeoPackageFeatureTables; // Loop through each GeoPackageFeatureTable foreach (GeoPackageFeatureTable oneGeoPackageFeatureTable in myReadOnlyListOfGeoPackageFeatureTables) { // Create a FeatureLayer from the GeoPackageFeatureLayer FeatureLayer myFeatureLayer = new FeatureLayer(oneGeoPackageFeatureTable); // Load the FeatureLayer - that way we can get to it's properties await myFeatureLayer.LoadAsync(); // Create a string variable to hold the human-readable name of the FeatureLayer for // display in the ListBox and the HybridDictonary string myFeatureLayerName = myFeatureLayer.Name; // Append the 'type of layer' to the myFeatureLayerName string to display in the // ListBox and as the key for the HybridDictonary myFeatureLayerName = myFeatureLayerName + " - FeatureLayer"; // Add the name of the FeatureLayer and the FeatureLayer itself into the HybridDictionary _myHybridDictionary_Layers.Add(myFeatureLayerName, myFeatureLayer); // Add the name of the FeatureLayer to the ListBox of layers not in map LayersNotInTheMapList.Items.Add(myFeatureLayerName); } } catch (Exception e) { MessageBox.Show(e.ToString(), "Error"); } }
private async void Initialize() { // Create a new map centered on Aurora Colorado _myMapView.Map = new Map(BasemapType.Streets, 39.7294, -104.8319, 11); // Get the full path to the GeoPackage on the device string myGeoPackagePath = GetGeoPackagePath(); // Open the GeoPackage GeoPackage myGeoPackage = await GeoPackage.OpenAsync(myGeoPackagePath); // Get the read only list of GeoPackageRasters from the GeoPackage IReadOnlyList <GeoPackageRaster> myReadOnlyListOfGeoPackageRasters = myGeoPackage.GeoPackageRasters; // Loop through each GeoPackageRaster foreach (GeoPackageRaster oneGeoPackageRaster in myReadOnlyListOfGeoPackageRasters) { // Create a RasterLayer from the GeoPackageRaster RasterLayer myRasterLayer = new RasterLayer(oneGeoPackageRaster) { // Set the opacity on the RasterLayer to partially visible Opacity = 0.55 }; // Load the RasterLayer - that way we can get to it's properties await myRasterLayer.LoadAsync(); // Create a string variable to hold the human-readable name of the RasterLayer for display // in the ListBox and the HybridDictonary - it will initially be an empty string string myRasterLayerName = ""; if (myRasterLayer.Name != "") { // We have a good human-readable name for the RasterLayer that came from // the RasterLayer.Name property myRasterLayerName = myRasterLayer.Name; } else if (oneGeoPackageRaster.Path.Split('/').Last() != "") { // We did not get a good human-readable name from the RasterLayer from the .Name // property, get the good human-readable name from the GeoPackageRaster.Path instead myRasterLayerName = oneGeoPackageRaster.Path.Split('/').Last(); } // Append the 'type of layer' to the myRasterLayerName string to display in the // ListBox and as the key for the HybridDictonary myRasterLayerName = myRasterLayerName + " - RasterLayer"; // Add the name of the RasterLayer and the RasterLayer itself into the HybridDictionary _myHybridDictionary_Layers.Add(myRasterLayerName, myRasterLayer); // Add the name of the RasterLayer to _myObservableCollection_LayerNamesNotInTheMap // which displays the human-readable layer names used by the _myListView_LayersNotInTheMap _myObservableCollection_LayerNamesNotInTheMap.Add(myRasterLayerName); } // Get the read only list of GeoPackageFeatureTabless from the GeoPackage IReadOnlyList <GeoPackageFeatureTable> myReadOnlyListOfGeoPackageFeatureTables = myGeoPackage.GeoPackageFeatureTables; // Loop through each GeoPackageFeatureTable foreach (GeoPackageFeatureTable oneGeoPackageFeatureTable in myReadOnlyListOfGeoPackageFeatureTables) { // Create a FeatureLayer from the GeoPackageFeatureLayer FeatureLayer myFeatureLayer = new FeatureLayer(oneGeoPackageFeatureTable); // Load the FeatureLayer - that way we can get to it's properties await myFeatureLayer.LoadAsync(); // Create a string variable to hold the human-readable name of the FeatureLayer for // display in the ListBox and the HybridDictonary string myFeatureLayerName = myFeatureLayer.Name; // Append the 'type of layer' to the myFeatureLayerName string to display in the // ListBox and as the key for the HybridDictonary myFeatureLayerName = myFeatureLayerName + " - FeatureLayer"; // Add the name of the FeatureLayer and the FeatureLayer itself into the HybridDictionary _myHybridDictionary_Layers.Add(myFeatureLayerName, myFeatureLayer); // Add the name of the RasterLayer to _myObservableCollection_LayerNamesNotInTheMap // which displays the human-readable layer names used by the _myListView_LayersNotInTheMap _myObservableCollection_LayerNamesNotInTheMap.Add(myFeatureLayerName); } // Create a simple string array of the human-readable layer names from the ObservableCollection string[] myStringArray_LayerNamesNotInTheMap = _myObservableCollection_LayerNamesNotInTheMap.ToArray(); // Create an ArrayAdapter from the simple string array ArrayAdapter myArrayAdapter_LayerNamesNotInTheMap = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, myStringArray_LayerNamesNotInTheMap); // Set the _myListView_LayersNotInTheMap.Adapter to the myArrayAdapter_LayerNamesNotInTheMap // This allows the human-readable layer names to be displayed a ListView _myListView_LayersNotInTheMap.Adapter = myArrayAdapter_LayerNamesNotInTheMap; }
private async void Initialize() { // Create a new map centered on Aurora Colorado. _myMapView.Map = new Map(BasemapType.Streets, 39.7294, -104.8319, 11); // Get the full path to the GeoPackage on the device. string geoPackagePath = DataManager.GetDataFolder("68ec42517cdd439e81b036210483e8e7", "AuroraCO.gpkg"); // Open the GeoPackage. GeoPackage geoPackage = await GeoPackage.OpenAsync(geoPackagePath); // Loop through each GeoPackageRaster. foreach (GeoPackageRaster oneGeoPackageRaster in geoPackage.GeoPackageRasters) { // Create a RasterLayer from the GeoPackageRaster. RasterLayer rasterLayer = new RasterLayer(oneGeoPackageRaster) { // Set the opacity on the RasterLayer to partially visible. Opacity = 0.55 }; // Load the RasterLayer - that way we can get to its properties. await rasterLayer.LoadAsync(); // Create a string variable to hold the human-readable name of the RasterLayer for display. string rasterLayerName = ""; if (rasterLayer.Name != "") { // We have a good human-readable name for the RasterLayer that came from the RasterLayer.Name property. rasterLayerName = rasterLayer.Name; } else if (oneGeoPackageRaster.Path.Split('/').Last() != "") { // We did not get a good human-readable name from the RasterLayer from the .Name // property, get the good human-readable name from the GeoPackageRaster.Path instead. rasterLayerName = oneGeoPackageRaster.Path.Split('/').Last(); } // Append the 'type of layer' to the raster layer name string to display in the // ListBox and as the key for the dictionary. rasterLayerName = $"{rasterLayerName} - RasterLayer"; // Add the name of the RasterLayer and the RasterLayer itself into the dictionary. _nameToLayerDictionary[rasterLayerName] = rasterLayer; // Add the name of the RasterLayer to the layers not in the map collection // which displays the human-readable layer names used by the UISegmentedControl. _layersNotInMap.Add(rasterLayerName); } // Loop through each GeoPackageFeatureTable from the GeoPackage. foreach (GeoPackageFeatureTable oneGeoPackageFeatureTable in geoPackage.GeoPackageFeatureTables) { // Create a FeatureLayer from the GeoPackageFeatureLayer. FeatureLayer featureLayer = new FeatureLayer(oneGeoPackageFeatureTable); // Load the FeatureLayer - that way we can get to its properties. await featureLayer.LoadAsync(); // Create a string variable to hold the human-readable name of the FeatureLayer for // display in the UISegmentedControl and the dictionary. string featureLayerName = featureLayer.Name; // Append the 'type of layer' to the feature layer name string to display in the // ListBox and as the key for the dictionary. featureLayerName = $"{featureLayerName} - FeatureLayer"; // Add the name of the FeatureLayer and the FeatureLayer itself into the dictionary. _nameToLayerDictionary[featureLayerName] = featureLayer; // Add the name of the RasterLayer to the collection of layers not in the map. // which displays the human-readable layer names used by the UISegmentedControl. _layersNotInMap.Add(featureLayerName); } }