Example #1
0
        private InMemoryGridFeatureLayer GetGridFeatureLayer()
        {
            //Get the line breaks
            Collection <double> isoLineBreaks = GridIsoLineLayer.GetIsoLineLevels(wellDepthPointData, Convert.ToInt32(txtGridIsoLineLevelCount.Text));

            //Load a new GridFeatureLayer based on the current grid file
            InMemoryGridFeatureLayer gridFeatureLayer = new InMemoryGridFeatureLayer(gridCellMatrix);

            //Create a series of colors from blue to red that we will use for the breaks
            Collection <GeoColor> colors = GeoColor.GetColorsInQualityFamily(GeoColor.StandardColors.Blue, GeoColor.StandardColors.Red, isoLineBreaks.Count, ColorWheelDirection.CounterClockwise);

            //Create a class break style
            ClassBreakStyle classBreakLineStyle = new ClassBreakStyle(gridFeatureLayer.DataValueColumnName);

            //Setup a class break style based on the isoline levels and the colors
            AreaStyle firstStyle = new AreaStyle(new GeoPen(GeoColor.FromArgb(50, colors[0]), 1), new GeoSolidBrush(GeoColor.FromArgb(50, colors[0])));

            classBreakLineStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, firstStyle));
            for (int i = 1; i < colors.Count - 1; i++)
            {
                AreaStyle style = new AreaStyle(new GeoPen(GeoColor.FromArgb(50, colors[i]), 1), new GeoSolidBrush(GeoColor.FromArgb(50, colors[i])));
                classBreakLineStyle.ClassBreaks.Add(new ClassBreak(isoLineBreaks[i], style));
            }

            gridFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakLineStyle);
            gridFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            return(gridFeatureLayer);
        }
        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();
        }