private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk. TileCache tileCache = new TileCache(DataManager.GetDataFolder("3f1bbf0ec70b409a975f5c91f363fe7d", "SanFrancisco.tpk")); // Create the corresponding layer based on the tile cache. ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache. Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap. Map myMap = new Map(sfBasemap); // Assign the map to the MapView. MyMapView.Map = myMap; // Create a new symbol for the extent graphic. SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Color.Red, 2); // Create a graphics overlay for the extent graphic and apply a renderer. GraphicsOverlay extentOverlay = new GraphicsOverlay { Renderer = new SimpleRenderer(lineSymbol) }; // Add graphics overlay to the map view. MyMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes. MyMapView.ViewpointChanged += MapViewExtentChanged; // Create a task for generating a geodatabase (GeodatabaseSyncTask). _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map. foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the URL for this particular layer. Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable. ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load. await onlineTable.LoadAsync(); // Add the layer to the map's operational layers if load succeeds. if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the graphic - needed in case the user decides not to interact before pressing the button. UpdateMapExtent(); // Enable the generate button. MyGenerateButton.IsEnabled = true; }
private async void InitMap() { //지도위치 및 스케일 초기화 await mapView.SetViewpointCenterAsync(_ulsanCoords, _ulsanScale); //Base맵 초기화 Console.WriteLine("this._map.SpatialReference - " + this._map.SpatialReference); //this._map.Basemap = Basemap.CreateOpenStreetMap(); //타일맵 TileCache tileCache = new TileCache(BizUtil.GetDataFolder("tile", "korea.tpk")); ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); this._map.Basemap = new Basemap(tileLayer); //울산행정구역표시 ShowShapeLayer(mapView, "BML_GADM_AS", true); //맵뷰 클릭이벤트 설정 mapView.GeoViewTapped -= handlerGeoViewTappedMoveFeature; mapView.GeoViewTapped -= handlerGeoViewTappedAddFeature; mapView.GeoViewTapped -= handlerGeoViewTapped; mapView.GeoViewTapped += handlerGeoViewTapped; // Create graphics overlay to display sketch geometry _sketchOverlay = new GraphicsOverlay(); mapView.GraphicsOverlays.Add(_sketchOverlay); }
private void Initialize() { // Create the scene. MySceneView.Scene = new Scene(Basemap.CreateImagery()); // Get the path to the elevation tile package. string packagePath = DataManager.GetDataFolder("cce37043eb0440c7a5c109cf8aad5500", "MontereyElevation.tpk"); // Create the elevation source from the tile cache. TileCache elevationCache = new TileCache(packagePath); ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(elevationCache); // Create a surface to display the elevation source. Surface elevationSurface = new Surface(); // Add the elevation source to the surface. elevationSurface.ElevationSources.Add(elevationSource); // Add the surface to the scene. MySceneView.Scene.BaseSurface = elevationSurface; // Set an initial camera viewpoint. Camera camera = new Camera(36.525, -121.80, 300.0, 180, 80.0, 0.0); MySceneView.SetViewpointCamera(camera); }
/// <summary> /// Creates a new rendering instance. /// </summary> /// <param name="cache">The cache.</param> public RenderingInstance(TileCache cache) { _targetsPerScale = new Dictionary <int, Tuple <Bitmap, Graphics> >(); _renderer = new MapRenderer <Graphics>(new GraphicsRenderer2D()); _map = new Map(new WebMercator()); _cache = cache; }
private async void InitMap() { //지도위치 및 스케일 초기화 await mapView.SetViewpointCenterAsync(GisCmm._hsCoords, GisCmm._ulsanScale2); //Base맵 초기화 Console.WriteLine("this._map.SpatialReference - " + this._map.SpatialReference); //this._map.Basemap = Basemap.CreateOpenStreetMap(); //타일맵 //TileCache tileCache = new TileCache(BizUtil.GetDataFolder("tile", "korea.tpk")); string tile_paht = @"c:\GTI\korea.tpk"; TileCache tileCache = new TileCache(tile_paht); ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); this._map.Basemap = new Basemap(tileLayer); //맵뷰 클릭이벤트 설정 mapView.GeoViewTapped -= handlerGeoViewTappedMoveFeature; mapView.GeoViewTapped -= handlerGeoViewTappedAddFeature; mapView.GeoViewTapped -= handlerGeoViewTapped; mapView.GeoViewTapped += handlerGeoViewTapped; // Create graphics overlay to display sketch geometry _sketchOverlay = new GraphicsOverlay(); mapView.GraphicsOverlays.Add(_sketchOverlay); }
private async Task HandleExportComplete(ExportTileCacheJob job, TileCache cache) { // Update the view if the job is complete. if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded) { // Show the exported tiles on the preview map. await UpdatePreviewMap(cache); // Show the preview window. MyPreviewMapView.Visibility = Visibility.Visible; // Show the 'close preview' button. MyClosePreviewButton.Visibility = Visibility.Visible; // Hide the 'export tiles' button. MyExportButton.Visibility = Visibility.Collapsed; // Hide the progress bar. MyProgressBar.Visibility = Visibility.Collapsed; // Enable the 'export tiles' button. MyExportButton.IsEnabled = true; } else if (job.Status == Esri.ArcGISRuntime.Tasks.JobStatus.Failed) { // Notify the user. ShowStatusMessage("Job failed"); // Hide the progress bar. MyProgressBar.Visibility = Visibility.Collapsed; } }
private async void Initialize() { // Create a tile cache and load it with the SanFrancisco streets tpk TileCache tileCache = new TileCache(await GetTpkPath()); // Create the corresponding layer based on the tile cache ArcGISTiledLayer tileLayer = new ArcGISTiledLayer(tileCache); // Create the basemap based on the tile cache Basemap sfBasemap = new Basemap(tileLayer); // Create the map with the tile-based basemap Map myMap = new Map(sfBasemap); // Assign the map to the MapView MyMapView.Map = myMap; // Create a new symbol for the extent graphic SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, Colors.Red, 2); // Create graphics overlay for the extent graphic and apply a renderer GraphicsOverlay extentOverlay = new GraphicsOverlay(); extentOverlay.Renderer = new SimpleRenderer(lineSymbol); // Add graphics overlay to the map view MyMapView.GraphicsOverlays.Add(extentOverlay); // Set up an event handler for when the viewpoint (extent) changes MyMapView.ViewpointChanged += MapViewExtentChanged; // Create a task for generating a geodatabase (GeodatabaseSyncTask) _gdbSyncTask = await GeodatabaseSyncTask.CreateAsync(_featureServiceUri); // Add all graphics from the service to the map foreach (IdInfo layer in _gdbSyncTask.ServiceInfo.LayerInfos) { // Get the Uri for this particular layer Uri onlineTableUri = new Uri(_featureServiceUri + "/" + layer.Id); // Create the ServiceFeatureTable ServiceFeatureTable onlineTable = new ServiceFeatureTable(onlineTableUri); // Wait for the table to load await onlineTable.LoadAsync(); // Add the layer to the map's operational layers if load succeeds if (onlineTable.LoadStatus == Esri.ArcGISRuntime.LoadStatus.Loaded) { myMap.OperationalLayers.Add(new FeatureLayer(onlineTable)); } } // Update the extent graphic so that it is valid before user interaction UpdateMapExtent(); // Enable the generate button now that the sample is ready MyGenerateButton.IsEnabled = true; }
public async Task SetTileCacheStarted(Guid id) { TileCache tileCache = await Context.TileCaches.SingleAsync(x => x.TileCacheId == id); tileCache.ProcessingStarted = DateTime.Now; await Context.SaveChangesAsync(); }
public override TileData GetTile(TiledMapSession.Key key, IMapRenderer renderer, System.Threading.WaitCallback callback, object state) { if (key == Key.Root && !TileCache.ContainsKey(key)) { TileCache.Add(Key.Root, new TileData(new StandardBitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream("TiledMaps.VirtualEarth.msvesatellite.png")))); } return(base.GetTile(key, renderer, callback, state)); }
public override void OnClick() { var mxdoc = (IMxDocument)_application.Document; IActiveView view = mxdoc.ActiveView; var tilecache = new TileCache(view); tilecache.ShowDialog(new ArcMapWindow(_application)); }
public async Task <TileCache> CreateTileCache(TileCache tileCache) { await Context.TileCaches.AddAsync(tileCache); await Context.SaveChangesAsync(); return(tileCache); }
public override void InitNode() { Cache = GetComponent <TileCache>(); Cache.InitNode(); Capacity = Cache.Capacity; InitSlots(); }
/// <summary> /// Creates a new rendering instance. /// </summary> public RenderingInstance(TileCache cache, int oversamplingFactor = 2) { _targetsPerScale = new Dictionary <int, Tuple <Bitmap, Graphics> >(); _renderer = new MapRenderer <Graphics>(new GraphicsRenderer2D(oversamplingFactor)); _map = new Map(new WebMercator()); _cache = cache; _oversampling = oversamplingFactor; }
public async Task SetTileCacheFinished(Guid id, string fileName) { TileCache tileCache = await Context.TileCaches.SingleAsync(x => x.TileCacheId == id); tileCache.ProcessingFinished = DateTime.Now; tileCache.Filename = fileName; await Context.SaveChangesAsync(); }
public async Task SetTileCacheError(Guid id) { TileCache tileCache = await Context.TileCaches.SingleAsync(x => x.TileCacheId == id); tileCache.ProcessingFinished = DateTime.Now; tileCache.ProcessingError = true; await Context.SaveChangesAsync(); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <returns></returns> async Task <Stream> IWMS.GetTileImagePNG(int x, int y, int z) { await _tileCache.ReadStateAsync(); TileCache cache = _tileCache.State.TILECACHE.Find(p => p.x == x && p.y == y && p.z == z); Stream sm = await Helper.QueryBitmap(cache?.pngId); return(sm); }
public async Task <IActionResult> Post([FromBody] CreateTileCacheViewModel viewModel) { TileCache tileCache = await TileCacheRepository.CreateTileCache(Mapper.Map <TileCache>(viewModel)); return(CreatedAtAction(nameof(Get), new { tileCacheId = tileCache.TileCacheId, }, Mapper.Map <TileCacheViewModel>(tileCache))); }
private void HandleExportCompletion(ExportTileCacheJob job, TileCache cache) { // Hide the progress bar. _myProgressBar.StopAnimating(); switch (job.Status) { // Update the view if the job is complete. case Esri.ArcGISRuntime.Tasks.JobStatus.Succeeded: // Dispatcher is necessary due to the threading implementation; // this method is called from a thread other than the UI thread. InvokeOnMainThread(async() => { // Show the exported tiles on the preview map. try { await UpdatePreviewMap(cache); // Show the preview window. _myPreviewMapView.Hidden = false; // Change the export button text. _myExportButton.SetTitle("Close preview", UIControlState.Normal); // Re-enable the button. _myExportButton.Enabled = true; // Set the preview open flag. _previewOpen = true; } catch (Exception ex) { ShowStatusMessage(ex.ToString()); } }); break; case Esri.ArcGISRuntime.Tasks.JobStatus.Failed: // Notify the user. ShowStatusMessage("Job failed"); // Dispatcher is necessary due to the threading implementation; // this method is called from a thread other than the UI thread. InvokeOnMainThread(() => { // Change the export button text. _myExportButton.SetTitle("Export Tiles", UIControlState.Normal); // Re-enable the export button. _myExportButton.Enabled = true; // Set the preview open flag. _previewOpen = false; }); break; } }
private async Task UpdatePreviewMap(TileCache cache) { // Load the cache. await cache.LoadAsync(); // Create a tile layer with the cache. ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache); // Apply the map to the preview mapview. MyPreviewMapView.Map = new Map(new Basemap(myLayer)); }
private async Task UpdatePreviewMap(TileCache cache) { // Load the cache. await cache.LoadAsync(); // Create a tile layer from the tile cache. ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache); // Show the layer in a new map. MyPreviewMapView.Map = new Map(new Basemap(myLayer)); }
public void DrawRegions(MapArgs args, List <DotSpatial.Data.Extent> regions, bool selected) { BruTile.Extent extent = ToBrutileExtent(args.GeographicExtents); var pixelSize = extent.Width / args.ImageRectangle.Width; var level = Utilities.GetNearestLevel(TileSource.Schema.Resolutions, pixelSize); var tiles = TileSource.Schema.GetTileInfos(extent, level); IList <WaitHandle> waitHandles = new List <WaitHandle>(); foreach (TileInfo info in tiles) { if (TileCache.Find(info.Index) != null) { continue; } AutoResetEvent waitHandle = new AutoResetEvent(false); waitHandles.Add(waitHandle); ThreadPool.QueueUserWorkItem(GetTileOnThread, new object[] { TileSource, info, TileCache, waitHandle }); } foreach (WaitHandle handle in waitHandles) { handle.WaitOne(); } foreach (TileInfo info in tiles) { using (Image bitmap = System.Drawing.Image.FromStream(new MemoryStream(TileCache.Find(info.Index)))) { PointF min = args.ProjToPixel(new Coordinate(info.Extent.MinX, info.Extent.MinY)); PointF max = args.ProjToPixel(new Coordinate(info.Extent.MaxX, info.Extent.MaxY)); min = new PointF((float)Math.Round(min.X), (float)Math.Round(min.Y)); max = new PointF((float)Math.Round(max.X), (float)Math.Round(max.Y)); ColorMatrix matrix = new ColorMatrix { Matrix33 = 0.45f }; // Symbolizer.Opacity using (var attributes = new ImageAttributes()) { attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); args.Device.DrawImage(bitmap , new Rectangle((int)min.X, (int)max.Y, (int)(max.X - min.X), (int)(min.Y - max.Y)) , 0 , 0 , TileSource.Schema.GetTileWidth(info.Index.Level) , TileSource.Schema.GetTileHeight(info.Index.Level) , GraphicsUnit.Pixel , attributes); } } } }
public async Task <IActionResult> Get(Guid tileCacheId) { TileCache tileCache = await TileCacheRepository.GetTileCacheWithId(tileCacheId); if (tileCache == null) { return(NotFound()); } return(Ok(Mapper.Map <TileCacheViewModel>(tileCache))); }
private async Task UpdatePreviewMap(TileCache cache) { // Load the cache. await cache.LoadAsync(); // Create a tile layer with the cache. ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache); // Show the exported tiles in new map. _myPreviewMapView.Map = new Map(new Basemap(myLayer)); }
public void Initialize(string mapboxToken, string storyTagCatalogName = null) { m_tileCache = new TileCache(StorageManager.EnsureCacheFolder("mapboxPoiTileCache"), TileCacheSize, TileCacheSize * 2, TimeSpan.FromDays(7)); m_mapboxToken = mapboxToken; Catalog <LocationTypeMap> osmMap = null; Catalog <LocationTypeMap> makiMap = null; IEnumerable <StoryTagLocationType> storyTags = null; Motive.WebServices.Instance.AddCatalogLoad <LocationTypeMap>("motive.ar", "maki_location_type_map", (catalog) => { makiMap = catalog; }, false); Motive.WebServices.Instance.AddCatalogLoad <LocationTypeMap>("motive.ar", "osm_location_type_map", (catalog) => { osmMap = catalog; }, false); if (storyTagCatalogName != null) { Motive.WebServices.Instance.AddCatalogLoad <StoryTagLocationType>(storyTagCatalogName, (catalog) => { storyTags = catalog; }); } AppManager.Instance.OnLoadComplete((callback) => { m_osmMapper = new LocationTypeMapper(osmMap); m_makiMapper = new LocationTypeMapper(makiMap); if (storyTagCatalogName == null) { storyTags = ScriptObjectDirectory.Instance.GetAllObjects <StoryTagLocationType>(); } if (storyTags != null) { m_storyTagMap = new StoryTagLocationTypeMap(storyTags); } m_locationTracker = UserLocationService.Instance.CreateLocationTracker(25); m_locationTracker.UpdateDistance = 25; m_locationTracker.Updated += t_Updated; m_locationTracker.Start(); callback(); }); }
protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); TileCache.LoadContent(Content); Line.LoadContent(Content, spriteBatch); var proc = Process.GetProcessesByName("wow"); ObjectManager.Initialize(proc[0]); ObjectManager.Pulse(); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = inflater.Inflate(Resource.Layout.fragment_map, container, false); Log.Debug($"Create mapControl"); mapControl = view.FindViewById <MapControl>(Resource.Id.mapcontrol); map = new Mapsui.Map { CRS = "EPSG:3857", //https://epsg.io/3857 Transformation = new MinimalTransformation(), }; mapControl.Map = map; Log.Debug($"Cache downloaded tiles"); var tileSource = TileCache.GetOSMBasemap(MainActivity.rootPath + "/CacheDB.mbtiles"); var tileLayer = new TileLayer(tileSource) { Name = "OSM", }; map.Layers.Add(tileLayer); Log.Debug($"Import all offline maps"); OfflineMaps.LoadAllOfflineMaps(); Log.Debug($"Add scalebar"); map.Widgets.Add(new ScaleBarWidget(map) { MaxWidth = 300, ShowEnvelop = true, Font = new Font { FontFamily = "sans serif", Size = 20 }, TickLength = 15, TextColor = new Color(0, 0, 0, 255), Halo = new Color(0, 0, 0, 0), HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Bottom, TextAlignment = Alignment.Left, ScaleBarMode = ScaleBarMode.Both, UnitConverter = MetricUnitConverter.Instance, SecondaryUnitConverter = NauticalUnitConverter.Instance, MarginX = 10, MarginY = 20, }); Log.Debug($"Set Zoom"); mapControl.Navigator.ZoomTo(PrefsActivity.MaxZoom); return(view); }
private async Task UpdatePreviewMap(TileCache cache) { // Load the cache. await cache.LoadAsync(); // Create a tile layer with the cache. ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache); // Show the tiles in a new map. _myMapView.Map = new Map(new Basemap(myLayer)); // Set the margin. SetMapviewMargin(40); }
private async Task UpdatePreviewMap(TileCache cache) { // Load the cache. await cache.LoadAsync(); // Create a tile layer with the cache. ArcGISTiledLayer myLayer = new ArcGISTiledLayer(cache); // Show the layer in a new map. MyMapView.Map = new Map(new Basemap(myLayer)); // Re-size the mapview. MyMapView.Margin = new Thickness(40); }
protected override void Initialize() { LoadIcons(); basicFont = Content.Load <SpriteFont>("basicFont"); windowWidth = GraphicsDevice.PresentationParameters.BackBufferWidth; windowHeight = GraphicsDevice.PresentationParameters.BackBufferHeight; TileCache.Boot(); Camera = new Camera(); MapManager = new MapManager(); Line = new LineDrawer(); base.Initialize(); }
public virtual void ClearTileCache() { if (TileCache == null) { return; } foreach (TileData data in TileCache.Values) { if (data != null && data.Bitmap != null) { data.Bitmap.Dispose(); } } TileCache.Clear(); }