private void CreateGridCellMatrix() { //Get the current extent since we use that to gerenate the grid. Of course this is just for //the demo and in the real world you can use any extent you like RectangleShape currentDrawingExtent = ExtentHelper.GetDrawingExtent(Map1.CurrentExtent, (float)Map1.ActualWidth, (float)Map1.ActualHeight); //Calculate the cell size based on how many rows and columns you specified double cellSize = Math.Min(currentDrawingExtent.Width / double.Parse(txtGridIsoLineCellColumnCount.Text), currentDrawingExtent.Height / Int32.Parse(txtGridIsoLineCellRowCount.Text)); //Greate the grid definition based on the extent, cell size etc. GridDefinition gridDefinition = new GridDefinition(currentDrawingExtent, cellSize, -9999, wellDepthPointData); //Generate the grid based on Inverse Distance Weighted interpolation model. You can define your own model if needed. gridCellMatrix = GridFeatureSource.GenerateGridMatrix(gridDefinition, new InverseDistanceWeightedGridInterpolationModel(2, double.MaxValue)); }
protected override void DrawCore(GeoCanvas canvas, Collection <SimpleCandidate> labelsInAllLayers) { double resolution = GetResolutionFromScale(canvas.CurrentScale, canvas.MapUnit); double cellSize = Math.Min(cellHeightInPixel * resolution, cellWidthInPixel * resolution); GridDefinition gridDefinition = new GridDefinition(canvas.CurrentWorldExtent, cellSize, NoDataValue, wellDepthPoints); GridCell[,] gridMatrix = GridFeatureSource.GenerateGridMatrix(gridDefinition, InterpolationModel); this.GridMatrix = gridMatrix; this.FeatureSource.Close(); this.FeatureSource.Open(); base.DrawCore(canvas, labelsInAllLayers); }
private void mapView_Loaded(object sender, RoutedEventArgs e) { //Load the well depth points and depth data from a text file into the dictionary //We cache this at the class level to prevent form loading it multiple times string wellDepthPointDataFilePath = SampleHelper.Get("GrayCountyIrrigationWellDepths.csv"); Dictionary <PointShape, double> wellDepthPointData = GetWellDepthPointDataFromCSV(wellDepthPointDataFilePath); //Get the current extent since we use that to gerenate the grid. Of course this is just for //the demo and in the real world you can use any extent you like RectangleShape currentDrawingExtent = MapUtil.GetDrawingExtent(mapView.CurrentExtent, (float)mapView.ActualWidth, (float)mapView.ActualHeight); //Calculate the cell size based on how many rows and columns you specified double cellSize = Math.Min(currentDrawingExtent.Width / 4, currentDrawingExtent.Height / 4); //Greate the grid definition based on the extent, cell size etc. GridDefinition gridDefinition = new GridDefinition(currentDrawingExtent, cellSize, -9999, wellDepthPointData); //Generate the grid based on Inverse Distance Weighted interpolation model. You can define your own model if needed. GridCell[,] gridCellMatrix = GridFeatureSource.GenerateGridMatrix(gridDefinition, new InverseDistanceWeightedGridInterpolationModel(2, double.MaxValue)); //Load a new GridFeatureLayer based on the current grid file InMemoryGridFeatureLayer gridFeatureLayer = new InMemoryGridFeatureLayer(gridCellMatrix); gridFeatureLayer.Open(); var currentExtent = gridFeatureLayer.GetBoundingBox(); gridFeatureLayer.Close(); gridFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyle.CreateSimpleAreaStyle(GeoColors.Transparent, GeoColors.Black); gridFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; //Add the grid layer, the grid cells, and the well points to the map LayerOverlay layerOverlay = new LayerOverlay(); layerOverlay.Layers.Add(gridFeatureLayer); mapView.ZoomLevelSet = new ThinkGeoCloudMapsZoomLevelSet(); mapView.CurrentExtent = currentExtent; mapView.MapUnit = GeographyUnit.Meter; mapView.Overlays.Add(layerOverlay); mapView.Refresh(); }