private void UpdateLayer_LoadedGpxFiles() { var newFeatures = new List <IFeature>(); foreach (var actTour in _loadedTours) { foreach (var actTourSegment in actTour.Segments) { var actGeometry = actTourSegment.Points.GpxWaypointsToMapsuiGeometry(actTour, actTourSegment); if (actGeometry == null) { continue; } newFeatures.Add(new Feature() { Geometry = actGeometry, Styles = { this.GetLineStyle(actTour.RawTourExtensionData.State) } }); } } _layerLoadedGpxFilesProvider.ReplaceFeatures(newFeatures); _layerLoadedGpxFiles.DataHasChanged(); }
private void UpdateLayer_Points() { var newFeaturesNormalPoints = new List <IFeature>(); var selectedTour = _selectedTours.FirstOrDefault(); if ((selectedTour != null) && (_selectedTours.Count == 1)) { foreach (var actWaypoint in selectedTour.Waypoints) { // Create point var point = SphericalMercator.FromLonLat( actWaypoint.RawWaypointData.Longitude, actWaypoint.RawWaypointData.Latitude); var feature = new Feature(); feature.Geometry = point; feature.Styles.Add(new LabelStyle() { Text = actWaypoint.RawWaypointData.Name, Opacity = 0.8f, Offset = new Offset(0, 1.0, isRelative: true) }); newFeaturesNormalPoints.Add(feature); } } _layerPointsProvider.ReplaceFeatures(newFeaturesNormalPoints); _layerPoints.DataHasChanged(); }
private void Rasterize() { if (!Enabled) { return; } if (_busy) { return; } _busy = true; _modified = false; lock (_syncLock) { try { if (double.IsNaN(_resolution) || _resolution <= 0) { return; } if (_extent.Width <= 0 || _extent.Height <= 0) { return; } var viewport = CreateViewport(_extent, _resolution, _renderResolutionMultiplier, _overscan); _currentViewport = viewport; _rasterizer = _rasterizer ?? DefaultRendererFactory.Create(); var bitmapStream = _rasterizer.RenderToBitmapStream(viewport, new[] { _layer }); RemoveExistingFeatures(); if (bitmapStream != null) { _cache.ReplaceFeatures(new Features { new Feature { Geometry = new Raster(bitmapStream, viewport.Extent) } }); Logger.Log(LogLevel.Debug, $"Memory after rasterizing layer {GC.GetTotalMemory(true):N0}"); OnDataChanged(new DataChangedEventArgs()); } if (_modified) { RestartTimer(); } } finally { _busy = false; } } }
private void FetchCompleted(IEnumerable <IFeature> features, Exception exception) { lock (_lockRoot) { if (exception == null) { _cache.ReplaceFeatures(_transformer.Transform(features)); } Busy = _modified; DataChanged?.Invoke(this, new DataChangedEventArgs(exception, false, null)); } }
public void AddOffer(string name, double longitude, double latitude) { if (!featureMap.ContainsKey(name)) { var polygon = new Polygon(new LinearRing()); var point = SphericalMercator.FromLonLat(longitude, latitude); var feature = new Feature(); feature.Geometry = point; feature["name"] = name; feature["offers"] = 0; feature.Styles.Add(CreateOfferLabelStyle(name)); var features = new List <IFeature>(offerMemoryProvider.Features); features.Add(feature); offerMemoryProvider.ReplaceFeatures(features); featureMap.Add(name, feature); } offerLayer.RefreshData(offerLayer.Envelope, 1, true); }
private void UpdateLayer_SelectedGpxFiles() { var boxBuilder = new NavigationBoundingBoxBuilder(); var newFeatures = new List <IFeature>(); foreach (var actTour in _selectedTours) { foreach (var actTourSegment in actTour.Segments) { var actGeometry = actTourSegment.Points.GpxWaypointsToMapsuiGeometry(actTour, actTourSegment); if (actGeometry == null) { continue; } boxBuilder.AddGeometry(actGeometry); newFeatures.Add(new Feature() { Geometry = actGeometry, Styles = { _lineStyleSelected } }); } } _layerSelectedGpxFilesProvider.ReplaceFeatures(newFeatures); _layerSelectedGpxFiles.DataHasChanged(); var currentViewPort = this.TryGetCurrentViewport(); var selectedRouteBox = boxBuilder.TryBuild(); if ((selectedRouteBox != null) && (currentViewPort != null) && (!currentViewPort.Contains(selectedRouteBox))) { this.ResetCamera(_selectedTours); } }