Exemple #1
0
        internal void SetColorScheme(ClassBreakStyle modelClassBreakStyle)
        {
            Width = 0;
            flpLegendItems.Controls.Clear();
            foreach (ClassBreak classBreak in modelClassBreakStyle.ClassBreaks)
            {
                GeoColor gc = classBreak.DefaultAreaStyle.FillSolidBrush.Color;

                Color color = Color.FromArgb(gc.AlphaComponent, gc.RedComponent, gc.GreenComponent, gc.BlueComponent);
                if (gc != GeoColor.SimpleColors.Transparent)
                {
                    MapLegendItem mapLegendItem = new MapLegendItem(LegendItemType.Scale)
                    {
                        LegendItemBackColor = color,
                        LegendItemValue     = Convert.ToInt32(classBreak.Value).ToString(),
                        Padding             = new Padding(0, 0, 0, 0),
                        Margin = new Padding(0, 0, 0, 0)
                    };
                    mapLegendItem.MouseDown   += Legends_MouseDown;
                    mapLegendItem.OnMouseDown += mapLegendItem_OnMouseDown;
                    Width += mapLegendItem.Width + 3;
                    flpLegendItems.Controls.Add(mapLegendItem);
                }
            }
        }
        public ClassBreakChartView(Context context, IAttributeSet attrs, ClassBreakStyle classBreakStyle)
            : base(context, attrs)
        {
            this.classBreakStyle = classBreakStyle;
            this.Alpha           = .9f;

            float ratio = context.Resources.DisplayMetrics.Density;

            paddingTop    = 2 * ratio;
            paddingLeft   = 2 * ratio;
            paddingRight  = 2 * ratio;
            paddingBottom = 2 * ratio;
            segmentWidth  = 40 * ratio;
            segmentHeight = 20 * ratio;
            textMargin    = 4 * ratio;

            textPaint           = new TextPaint();
            textPaint.Color     = Color.Black;
            textPaint.AntiAlias = true;
            textPaint.TextSize  = 9 * ratio;

            maxTextWidth = classBreakStyle.ClassBreaks.Select(c => MeasureText(c.Value.ToString("R0"), textPaint).Width).Max();
            offsetX      = 5 * ratio;
            offsetY      = -5 * ratio;
        }
        protected override void DrawCore(GeoCanvas geoCanvas, Style style)
        {
            Bitmap          bitmap          = new Bitmap(35, 20);
            ClassBreakStyle classBreakStyle = style as ClassBreakStyle;
            RectangleShape  worldExtent     = new RectangleShape(-180, 90, 180, -90);

            // Draw Icon
            geoCanvas.BeginDrawing(bitmap, worldExtent, GeographyUnit.DecimalDegree);
            if (StartClassBreak.DefaultAreaStyle != null)
            {
                StartClassBreak.DefaultAreaStyle.Draw(new BaseShape[] { worldExtent }, geoCanvas, new System.Collections.ObjectModel.Collection <SimpleCandidate>(), new System.Collections.ObjectModel.Collection <SimpleCandidate>());
            }
            geoCanvas.DrawArea(worldExtent, new GeoPen(GeoColor.FromHtml("#cccccc"), 2), DrawingLevel.LabelLevel);
            geoCanvas.EndDrawing();

            this.Image = bitmap;
            if (EndClassBreak != null)
            {
                this.Title = string.Format("{0:#,0.####} ~ {1:#,0.####}",
                                           MapSuiteSampleHelper.GetFormatedStringForLegendItem(classBreakStyle.ColumnName, StartClassBreak.Value),
                                           MapSuiteSampleHelper.GetFormatedStringForLegendItem(classBreakStyle.ColumnName, EndClassBreak.Value));
            }
            else
            {
                this.Title = string.Format("> {0:#,0.####}",
                                           MapSuiteSampleHelper.GetFormatedStringForLegendItem(classBreakStyle.ColumnName, StartClassBreak.Value));
            }
        }
Exemple #4
0
        private void AddThematicLegendItems(DemographicStyleBuilder styleBuilder, LegendAdornmentLayer legendAdornmentLayer, Map map)
        {
            ShapeFileFeatureLayer statesLayer   = map.DynamicOverlay.Layers["usStatesLayer"] as ShapeFileFeatureLayer;
            ClassBreakStyle       thematicStyle = (ClassBreakStyle)styleBuilder.GetStyle(statesLayer.FeatureSource);

            for (int i = 0; i < thematicStyle.ClassBreaks.Count; i++)
            {
                LegendItem legendItem = new LegendItem();

                if (i < thematicStyle.ClassBreaks.Count)
                {
                    legendItem.ImageStyle       = thematicStyle.ClassBreaks[i].DefaultAreaStyle;
                    legendItem.ImageWidth       = 20;
                    legendItem.TextRightPadding = 5;
                    legendItem.RightPadding     = 5;

                    string text = string.Empty;
                    if (i != thematicStyle.ClassBreaks.Count - 1)
                    {
                        text = string.Format("{0:#,0.####} ~ {1:#,0.####}",
                                             DemographicStyleTextFormatter.GetFormatedStringForLegendItem(thematicStyle.ColumnName, thematicStyle.ClassBreaks[i].Value),
                                             DemographicStyleTextFormatter.GetFormatedStringForLegendItem(thematicStyle.ColumnName, thematicStyle.ClassBreaks[i + 1].Value));
                    }
                    else
                    {
                        text = string.Format("> {0:#,0.####}",
                                             DemographicStyleTextFormatter.GetFormatedStringForLegendItem(thematicStyle.ColumnName, thematicStyle.ClassBreaks[i].Value));
                    }
                    legendItem.TextStyle = new TextStyle(text, new GeoFont("Segoe UI", 10), new GeoSolidBrush(GeoColor.SimpleColors.Black));
                }
                legendAdornmentLayer.LegendItems.Add(legendItem);
            }
        }
Exemple #5
0
        protected override Style GetStyleCore(FeatureSource featureSource)
        {
            Collection <GeoColor> familyColors = GeoColor.GetColorsInQualityFamily(Color, EndColor, classBreakCount, ColorWheelDirection);

            featureSource.Open();
            int featureCount = featureSource.GetCount();

            double[] values = new double[featureCount];
            for (int i = 0; i < featureCount; i++)
            {
                Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns);
                double  columnValue;
                double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue);
                values[i] = columnValue;
            }
            featureSource.Close();

            ClassBreakStyle classBreakStyle = new ClassBreakStyle(SelectedColumns[0])
            {
                BreakValueInclusion = BreakValueInclusion.IncludeValue
            };

            double[] classBreakValues = GetClusterClassBreaks(values, ClassBreaksCount - 1);
            for (int i = 0; i < classBreakValues.Length; i++)
            {
                ClassBreak classBreak = new ClassBreak(classBreakValues[i], AreaStyles.CreateSimpleAreaStyle(new GeoColor(this.Opacity, familyColors[i]), GeoColor.FromHtml("#f05133"), 1));
                classBreakStyle.ClassBreaks.Add(classBreak);
            }

            return(classBreakStyle);
        }
Exemple #6
0
        private void Refresh()
        {
            ShapefileLayer areaLayer = Map1.FindLayer <ShapefileLayer>("countries-900913");

            if (areaLayer == null)
            {
                return;
            }
            areaLayer.Styles.Clear();
            ClassBreakStyle classBreakStyle = ClassBreakStyle.Create(columnName, 281396894, 5000000, 11, DimensionType.Area, colorFamily, new GeoColor(50, 100, 200, 150), 0.01f);

            classBreakStyle.ClassBreaks[0].Value = 0;
            areaLayer.Styles.Add(classBreakStyle);

            LegendTitleTextBlock.Text = "The population of countries";
            ClassBreak[] classBreaks = classBreakStyle.ClassBreaks.OrderBy(i => i.Value).ToArray();
            for (int i = 0; i < classBreaks.Length; i++)
            {
                ClassBreak fromClassBreak = classBreaks[i];
                ClassBreak toClassBreak   = i + 1 < classBreaks.Length ? classBreaks[i + 1] : null;
                foreach (var style in fromClassBreak.Styles)
                {
                    if (toClassBreak != null)
                    {
                        style.Name = $"{(fromClassBreak.Value / 1000000).ToString("N0")} ~ {(toClassBreak.Value / 1000000).ToString("N0")} million";
                    }
                    else
                    {
                        style.Name = $">= {(fromClassBreak.Value / 1000000).ToString("N0")} million";
                    }
                }
            }
            LegendView.Update(classBreaks.SelectMany(i => i.Styles));
            Map1.Refresh(RefreshType.Redraw);
        }
Exemple #7
0
        /// <summary>
        /// Adds a ClassBreakStyle to the housingUnitsLayer that changes colors based on the numerical value of the H_UNITS column as they fall within the range of a ClassBreak
        /// </summary>
        private static void AddClassBreakStyle(ShapeFileFeatureLayer layer, LegendAdornmentLayer legend)
        {
            // Create the ClassBreakStyle based on the H_UNITS numerical column
            var housingUnitsStyle = new ClassBreakStyle("H_UNITS");

            var classBreakIntervals = new double[] { 0, 1000, 2000, 3000, 4000, 5000 };
            var colors = GeoColor.GetColorsInHueFamily(GeoColors.Red, classBreakIntervals.Count()).Reverse().ToList();

            // Create ClassBreaks for each of the classBreakIntervals
            for (var i = 0; i < classBreakIntervals.Count(); i++)
            {
                // Create the classBreak using one of the intervals and colors defined above
                var classBreak = new ClassBreak(classBreakIntervals[i], AreaStyle.CreateSimpleAreaStyle(new GeoColor(192, colors[i]), GeoColors.White));

                // Add the classBreak to the housingUnitsStyle ClassBreaks collection
                housingUnitsStyle.ClassBreaks.Add(classBreak);

                // Add a LegendItem to the legend adornment to represent the classBreak
                var legendItem = new LegendItem()
                {
                    ImageStyle = classBreak.DefaultAreaStyle,
                    TextStyle  = new TextStyle($@">{classBreak.Value} units", new GeoFont("Verdana", 10), GeoBrushes.Black)
                };
                legend.LegendItems.Add(legendItem);
            }

            // Add and apply the ClassBreakStyle to the housingUnitsLayer
            layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(housingUnitsStyle);
            layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
        }
        private void AddThematicLegendItems(LegendAdornmentLayer legendAdornmentLayer)
        {
            ClassBreakStyle thematicStyle = (ClassBreakStyle)currentStyleBuilder.GetStyles(currentFeatureLayer.FeatureSource)[0];

            for (int i = 0; i < thematicStyle.ClassBreaks.Count; i++)
            {
                LegendItem legendItem = new LegendItem();

                if (i < thematicStyle.ClassBreaks.Count)
                {
                    legendItem.ImageStyle       = thematicStyle.ClassBreaks[i].DefaultAreaStyle;
                    legendItem.ImageWidth       = 20;
                    legendItem.TextRightPadding = 5;
                    legendItem.RightPadding     = 5;

                    string text = string.Empty;
                    if (i != thematicStyle.ClassBreaks.Count - 1)
                    {
                        text = string.Format("{0:#,0.####} ~ {1:#,0.####}",
                                             TextFormatter.GetFormatedStringForLegendItem(thematicStyle.ColumnName, thematicStyle.ClassBreaks[i].Value),
                                             TextFormatter.GetFormatedStringForLegendItem(thematicStyle.ColumnName, thematicStyle.ClassBreaks[i + 1].Value));
                    }
                    else
                    {
                        text = string.Format("> {0:#,0.####}",
                                             TextFormatter.GetFormatedStringForLegendItem(thematicStyle.ColumnName, thematicStyle.ClassBreaks[i].Value));
                    }
                    legendItem.TextStyle = new TextStyle(text, new GeoFont("Segoe UI", 10), new GeoSolidBrush(GeoColor.SimpleColors.Black));
                }
                legendAdornmentLayer.LegendItems.Add(legendItem);
            }
        }
Exemple #9
0
        private void LoadGrid(string filename)
        {
            //Shows how to set the class breaks to display grid cell with color according to its value.
            GridFeatureLayer gridFeatureLayer    = new GridFeatureLayer(filename);
            ClassBreakStyle  gridClassBreakStyle = new ClassBreakStyle("CellValue");
            int Alpha = 150;

            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Transparent))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(6.2, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 255, 0, 0)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(6.83, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 255, 128, 0)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.0, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 245, 210, 10)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.08, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 225, 255, 0)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.15, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 224, 251, 132)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.21, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 128, 255, 128)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.54, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(Alpha, 0, 255, 0)))));
            gridFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(gridClassBreakStyle);
            gridFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay layerOverlay = winformsMap1.Overlays["GridFeatureOverlay"] as LayerOverlay;

            if (layerOverlay.Layers.Contains("GridFeatureLayer"))
            {
                layerOverlay.Layers.Remove("GridFeatureLayer");
            }
            layerOverlay.Layers.Insert(0, "GridFeatureLayer", gridFeatureLayer);

            btnGRID.Enabled = false;

            winformsMap1.Refresh();
        }
        private void mapView_Loaded(object sender, RoutedEventArgs e)
        {
            mapView.MapUnit = GeographyUnit.Meter;

            LayerOverlay        layerOverlay = new LayerOverlay();
            UsgsDemFeatureLayer layer        = new UsgsDemFeatureLayer(SampleHelper.Get("mobile-e.dem"));

            layer.DrawingQuality = DrawingQuality.HighSpeed;

            layer.Open();
            DataTable informations = CreateInformationTable((UsgsDemFeatureSource)layer.FeatureSource);

            informationDataGrid.ItemsSource = informations.DefaultView;

            ClassBreakStyle classBreakStyle = new ClassBreakStyle();

            classBreakStyle.ColumnName = layer.DataValueColumnName;
            Collection <GeoColor> colors = GeoColor.GetColorsInQualityFamily(GeoColors.Blue, 100);
            double cellValue             = (layer.MaxElevation - layer.MinElevation) / 100;

            for (int i = 0; i < colors.Count; i++)
            {
                classBreakStyle.ClassBreaks.Add(new ClassBreak(layer.MinElevation + cellValue * i, new AreaStyle(new GeoSolidBrush(colors[i]))));
            }

            layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
            layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            layerOverlay.Layers.Add(layer);
            mapView.Overlays.Add(layerOverlay);

            mapView.CurrentExtent = layer.GetBoundingBox();
            mapView.Refresh();
        }
Exemple #11
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayMapView);

            ClassBreakStyle classBreakStyle = new ClassBreakStyle("POP1990");

            classBreakStyle.ClassBreaks.Add(new ClassBreak(453588, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Green)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(6314875, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.LightYellow)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(12176161, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Yellow)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(18037448, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Crimson)));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(23898734, AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Red)));

            ShapeFileFeatureLayer statesLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"SampleData/states.shp"));

            statesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 233, 232, 214), GeoColor.FromArgb(255, 118, 138, 69)));
            statesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
            statesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(statesLayer);

            WorldMapKitOverlay worldMapKitOverlay = new WorldMapKitOverlay();

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.DecimalDegree;
            androidMap.CurrentExtent = new RectangleShape(-131.22, 55.05, -54.03, 16.91);
            androidMap.Overlays.Add(worldMapKitOverlay);
            androidMap.Overlays.Add(layerOverlay);

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
Exemple #12
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 DrawThematicFeatures_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            // Draw thematic features
            ClassBreakStyle classBreakStyle = new ClassBreakStyle("POP_CNTRY");

            classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, AreaStyles.Grass1));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(1000000, AreaStyles.Evergreen2));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(10000000, AreaStyles.Evergreen1));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(50000000, AreaStyles.Crop1));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(100000000, AreaStyles.Forest1));

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(Samples.RootDirectory + @"Data\Countries02.shp");

            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.Country1);
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            worldLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);

            LayerOverlay worldOverlay = new LayerOverlay();

            worldOverlay.Layers.Add("WorldLayer", worldLayer);
            winformsMap1.Overlays.Add(worldOverlay);

            winformsMap1.ZoomLevelSnapping = ZoomLevelSnappingMode.Default;
            winformsMap1.CurrentExtent     = new RectangleShape(-143.4, 109.3, 116.7, -76.3);
            winformsMap1.Refresh();
        }
        private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
            wpfMap1.CurrentExtent = new RectangleShape(-96.115612954611919, 29.954823851075187, -96.105810851850961, 29.947472274004468);

            WorldMapKitWmsWpfOverlay worldMapKitOverlay = new WorldMapKitWmsWpfOverlay();
            wpfMap1.Overlays.Add(worldMapKitOverlay);

            ClassBreakStyle gridClassBreakStyle = new ClassBreakStyle("CellValue");
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Transparent))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(6.2, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 255, 0, 0)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(6.83, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 255, 128, 0)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.0, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 245, 210, 10)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.08, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 225, 255, 0)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.15, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 224, 251, 132)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.21, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 128, 255, 128)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.54, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 0, 255, 0)))));

            GridFeatureLayer gridFeatureLayer = new GridFeatureLayer(@"..\..\SampleData\Data\PhValues.grd");
            gridFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(gridClassBreakStyle);
            gridFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay staticOverlay = new LayerOverlay();
            staticOverlay.TileType = TileType.SingleTile;
            staticOverlay.Layers.Add("GridFeatureLayer", gridFeatureLayer);
            wpfMap1.Overlays.Add(staticOverlay);

            wpfMap1.Refresh();
        }
Exemple #15
0
        /// <summary>
        /// Update the colors for the housing units layers
        /// </summary>
        private void UpdateHousingUnitsLayerColors(Collection <GeoColor> colors)
        {
            // Get the housing units layer from the MapView
            LayerOverlay          housingUnitsOverlay = (LayerOverlay)mapView.Overlays["Frisco Housing Units Overlay"];
            ShapeFileFeatureLayer housingUnitsLayer   = (ShapeFileFeatureLayer)housingUnitsOverlay.Layers["Frisco Housing Units"];

            // Clear the previous style from the housing units layer
            housingUnitsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear();

            // Create a new ClassBreakStyle to showcase the color family generated
            ClassBreakStyle         classBreakStyle = new ClassBreakStyle();
            Collection <ClassBreak> classBreaks     = new Collection <ClassBreak>();

            // Different features will be styled differently based on the 'H_UNITS' attribute of the features
            classBreakStyle.ColumnName = "H_UNITS";
            double[] classBreaksIntervals = new double[] { 0, 1000, 2000, 3000, 4000, 5000 };
            for (int i = 0; i < colors.Count; i++)
            {
                // Create a differently colored area style for housing units counts of 0, 1000, 2000, etc
                AreaStyle areaStyle = new AreaStyle(new GeoSolidBrush(colors[colors.Count - i - 1]));
                classBreakStyle.ClassBreaks.Add(new ClassBreak(classBreaksIntervals[i], areaStyle));
                classBreaks.Add(new ClassBreak(classBreaksIntervals[i], areaStyle));
            }

            // Add the ClassBreakStyle to the housing units layer
            housingUnitsLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
            housingUnitsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            GenerateNewLegendItems(classBreaks);

            // Refresh the overlay to redraw the features
            housingUnitsOverlay.Refresh();
        }
Exemple #16
0
        private DynamicGridFeatureLayer GetDynamicGridFeatureLayer()
        {
            DynamicGridFeatureLayer dynamicGridFeatureLayer = new DynamicGridFeatureLayer(wellDepthPointData);

            dynamicGridFeatureLayer.CellHeightInPixel = Map1.ActualHeight / double.Parse(txtDynamicIsoLineCellRowCount.Text);
            dynamicGridFeatureLayer.CellWidthInPixel  = Map1.ActualWidth / double.Parse(txtDynamicIsoLineCellColumnCount.Text);

            Collection <double> isoLineBreaks = GridIsoLineLayer.GetIsoLineLevels(wellDepthPointData, Convert.ToInt32(txtGridIsoLineLevelCount.Text));

            //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(dynamicGridFeatureLayer.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));
            }

            dynamicGridFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakLineStyle);
            dynamicGridFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            return(dynamicGridFeatureLayer);
        }
        private void LoadAGridFeatureLayer_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit       = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-96.115612954611919, 29.954823851075187, -96.105810851850961, 29.947472274004468);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.StandardColors.Snow);

            WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay();

            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            ClassBreakStyle gridClassBreakStyle = new ClassBreakStyle("CellValue");

            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Transparent))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(6.2, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 255, 0, 0)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(6.83, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 255, 128, 0)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.0, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 245, 210, 10)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.08, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 225, 255, 0)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.15, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 224, 251, 132)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.21, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 128, 255, 128)))));
            gridClassBreakStyle.ClassBreaks.Add(new ClassBreak(7.54, new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, 0, 255, 0)))));

            GridFeatureLayer gridFeatureLayer = new GridFeatureLayer(Samples.RootDirectory + @"Data\PhValues.grd");

            gridFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(gridClassBreakStyle);
            gridFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay staticOverlay = new LayerOverlay();

            staticOverlay.Layers.Add("GridFeatureLayer", gridFeatureLayer);
            winformsMap1.Overlays.Add(staticOverlay);

            winformsMap1.Refresh();
        }
Exemple #18
0
        private static ClassBreakStyle GetClassBreakStyleFromColors(Color[] colors)
        {
            //seems the old app handled color scales differently. We need to invert the order in the colors array.
            colors = colors.Reverse().ToArray();

            ClassBreakStyle cbs = new ClassBreakStyle();

            AreaStyle defaultAreaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Transparent));

            GeoBrush gb = new GeoSolidBrush(GeoColor.StandardColors.LightGray);
            GeoPen   gp = new GeoPen(gb)
            {
                DashStyle = LineDashStyle.Solid
            };

            defaultAreaStyle.OutlinePen = gp;
            cbs.ClassBreaks.Add(new ClassBreak(0, defaultAreaStyle));



            int i = 1;

            foreach (Color color in colors)
            {
                GeoSolidBrush gsb = new GeoSolidBrush(new GeoColor(color.A, color.R, color.G, color.B));
                AreaStyle     ss  = new AreaStyle(gsb)
                {
                    OutlinePen = gp
                };
                cbs.ClassBreaks.Add(new ClassBreak(i, ss));
                i++;
            }

            return(cbs);
        }
Exemple #19
0
        public void Draw(double mapScale)
        {
            LegendItems.Clear();
            if (featureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Count > 0)
            {
                Style style = featureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles[0];

                if (style is CustomDotDensityStyle)
                {
                    LegendItems.Add(new DotDensityLegendItem(5));
                    LegendItems.Add(new DotDensityLegendItem(10));
                    LegendItems.Add(new DotDensityLegendItem(20));
                    LegendItems.Add(new DotDensityLegendItem(40));
                }
                else if (style is PieZedGraphStyle)
                {
                    PieZedGraphStyle zedGraphStyle = (PieZedGraphStyle)style;

                    foreach (KeyValuePair <string, GeoColor> item in zedGraphStyle.PieSlices)
                    {
                        AreaStyle          fillStyle  = new AreaStyle(new GeoSolidBrush(item.Value));
                        PieChartLegendItem legendItem = new PieChartLegendItem(fillStyle, item.Key);
                        this.LegendItems.Add(legendItem);
                    }
                }
                else if (style is ValueCircleStyle)
                {
                    LegendItems.Add(new ValueCircleLegendItem(80));
                    LegendItems.Add(new ValueCircleLegendItem(16));
                    LegendItems.Add(new ValueCircleLegendItem(32));
                    LegendItems.Add(new ValueCircleLegendItem(64));
                    LegendItems.Add(new ValueCircleLegendItem(1280));
                }
                else if (style is ClassBreakStyle)
                {
                    ClassBreakStyle thematicStyle = (ClassBreakStyle)style;

                    for (int i = 0; i < thematicStyle.ClassBreaks.Count; i++)
                    {
                        ThematicLegendItem thematicLegendItem;
                        if (i < thematicStyle.ClassBreaks.Count - 1)
                        {
                            thematicLegendItem = new ThematicLegendItem(thematicStyle.ClassBreaks[i], thematicStyle.ClassBreaks[i + 1]);
                        }
                        else
                        {
                            thematicLegendItem = new ThematicLegendItem(thematicStyle.ClassBreaks[i], null);
                        }
                        LegendItems.Add(thematicLegendItem);
                    }
                }

                foreach (var legendItem in LegendItems)
                {
                    legendItem.Draw(style);
                }
            }
        }
Exemple #20
0
        private InMemoryGridIsoLineLayer GetGridIsoLineLayer()
        {
            //Create a grid cell matrix based on the textboxes and the current extent
            CreateGridCellMatrix();

            //Load the grid we just created into the GridIsoLineLayer using the number of breaks defines
            //on the screen
            Collection <double>      isoLineLevels = GridIsoLineLayer.GetIsoLineLevels(wellDepthPointData, Convert.ToInt32(txtGridIsoLineLevelCount.Text));
            InMemoryGridIsoLineLayer isoLineLayer  = new InMemoryGridIsoLineLayer(gridCellMatrix, isoLineLevels);

            if (rdoLinesOnlyType.IsChecked.Value.Equals(true))
            {
                isoLineLayer.IsoLineType = IsoLineType.LinesOnly;
            }
            else if (rdoClosedLinesAsPolygonsType.IsChecked.Value.Equals(true))
            {
                isoLineLayer.IsoLineType = IsoLineType.ClosedLinesAsPolygons;
            }
            else
            {
                isoLineLayer.IsoLineType = IsoLineType.LinesOnly;
            }

            //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, isoLineLevels.Count, ColorWheelDirection.CounterClockwise);

            //Setup a class break style based on the isoline levels and the colors
            ClassBreakStyle classBreakStyle = new ClassBreakStyle(isoLineLayer.DataValueColumnName);

            Collection <ThinkGeo.MapSuite.Styles.Style> firstStyles = new Collection <ThinkGeo.MapSuite.Styles.Style>();

            firstStyles.Add(new LineStyle(new GeoPen(colors[0], 3)));
            firstStyles.Add(new AreaStyle(new GeoPen(GeoColor.SimpleColors.LightBlue, 3), new GeoSolidBrush(new GeoColor(150, colors[0]))));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, firstStyles));
            for (int i = 0; i < colors.Count - 1; i++)
            {
                Collection <ThinkGeo.MapSuite.Styles.Style> styles = new Collection <ThinkGeo.MapSuite.Styles.Style>();
                styles.Add(new LineStyle(new GeoPen(colors[i + 1], 3)));
                styles.Add(new AreaStyle(new GeoPen(GeoColor.SimpleColors.LightBlue, 3), new GeoSolidBrush(new GeoColor(150, colors[i + 1]))));
                classBreakStyle.ClassBreaks.Add(new ClassBreak(isoLineLevels[i], styles));
            }
            isoLineLayer.CustomStyles.Add(classBreakStyle);

            //Create the text styles to label the lines
            TextStyle textStyle = TextStyles.CreateSimpleTextStyle(isoLineLayer.DataValueColumnName, "Arial", 8, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, 0);

            textStyle.HaloPen               = new GeoPen(GeoColor.StandardColors.White, 2);
            textStyle.OverlappingRule       = LabelOverlappingRule.NoOverlapping;
            textStyle.SplineType            = SplineType.StandardSplining;
            textStyle.DuplicateRule         = LabelDuplicateRule.UnlimitedDuplicateLabels;
            textStyle.TextLineSegmentRatio  = 9999999;
            textStyle.FittingLineInScreen   = true;
            textStyle.SuppressPartialLabels = true;
            isoLineLayer.CustomStyles.Add(textStyle);

            return(isoLineLayer);
        }
Exemple #21
0
        private DynamicIsoLineLayer GetDynamicIsoLineLayer()
        {
            Collection <double> isoLineLevels = GridIsoLineLayer.GetIsoLineLevels(wellDepthPointData, Convert.ToInt32(txtGridIsoLineLevelCount.Text));

            //Create the new dynamicIsoLineLayer using the well data and the number of isoline levels from
            //the screen
            DynamicIsoLineLayer dynamicIsoLineLayer;

            if (rdoLinesOnlyType.IsChecked.Value.Equals(true))
            {
                dynamicIsoLineLayer = new DynamicIsoLineLayer(wellDepthPointData, isoLineLevels, new InverseDistanceWeightedGridInterpolationModel(2, double.MaxValue), IsoLineType.LinesOnly);
            }
            else if (rdoClosedLinesAsPolygonsType.IsChecked.Value.Equals(true))
            {
                dynamicIsoLineLayer = new DynamicIsoLineLayer(wellDepthPointData, isoLineLevels, new InverseDistanceWeightedGridInterpolationModel(2, double.MaxValue), IsoLineType.ClosedLinesAsPolygons);
            }
            else
            {
                dynamicIsoLineLayer = new DynamicIsoLineLayer(wellDepthPointData, isoLineLevels, new InverseDistanceWeightedGridInterpolationModel(2, double.MaxValue), IsoLineType.LinesOnly);
            }
            dynamicIsoLineLayer.CellHeightInPixel = (int)(Map1.ActualHeight / int.Parse(txtDynamicIsoLineCellRowCount.Text));
            dynamicIsoLineLayer.CellWidthInPixel  = (int)(Map1.ActualWidth / int.Parse(txtDynamicIsoLineCellColumnCount.Text));

            //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, isoLineLevels.Count, ColorWheelDirection.Clockwise);

            //Setup a class break style based on the isoline levels and the colors
            ClassBreakStyle classBreakStyle = new ClassBreakStyle(dynamicIsoLineLayer.DataValueColumnName);

            Collection <ThinkGeo.MapSuite.Styles.Style> firstStyles = new Collection <ThinkGeo.MapSuite.Styles.Style>();

            firstStyles.Add(new LineStyle(new GeoPen(colors[0], 3)));
            firstStyles.Add(new AreaStyle(new GeoPen(GeoColor.SimpleColors.LightBlue, 3), new GeoSolidBrush(new GeoColor(150, colors[0]))));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, firstStyles));
            for (int i = 0; i < colors.Count - 1; i++)
            {
                Collection <ThinkGeo.MapSuite.Styles.Style> styles = new Collection <ThinkGeo.MapSuite.Styles.Style>();
                styles.Add(new LineStyle(new GeoPen(colors[i + 1], 3)));
                styles.Add(new AreaStyle(new GeoPen(GeoColor.SimpleColors.LightBlue, 3), new GeoSolidBrush(new GeoColor(150, colors[i + 1]))));
                classBreakStyle.ClassBreaks.Add(new ClassBreak(isoLineLevels[i], styles));
            }
            dynamicIsoLineLayer.CustomStyles.Add(classBreakStyle);

            //Create the text styles to label the lines
            TextStyle textStyle = TextStyles.CreateSimpleTextStyle(dynamicIsoLineLayer.DataValueColumnName, "Arial", 8, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, 0);

            textStyle.HaloPen               = new GeoPen(GeoColor.StandardColors.White, 2);
            textStyle.OverlappingRule       = LabelOverlappingRule.NoOverlapping;
            textStyle.SplineType            = SplineType.StandardSplining;
            textStyle.DuplicateRule         = LabelDuplicateRule.UnlimitedDuplicateLabels;
            textStyle.TextLineSegmentRatio  = 9999999;
            textStyle.FittingLineInScreen   = true;
            textStyle.SuppressPartialLabels = true;
            dynamicIsoLineLayer.CustomStyles.Add(textStyle);

            return(dynamicIsoLineLayer);
        }
        /// <summary>
        /// Updates the specified style to a specified overlay.
        /// </summary>
        private static void UpdateLabelingStyle(LayerOverlay overlay, Dictionary <string, string> styles)
        {
            string haloPen       = styles["haloPen"];
            string mask          = styles["mask"];
            string overlapping   = styles["overlapping"];
            string duplicateRule = styles["duplicate"];
            string gridSize      = styles["gridSize"];
            string drawingMargin = styles["drawingMargin"];

            if (overlay.Layers.Count > 0)
            {
                bool useHalopen       = false;
                bool useMask          = false;
                bool allowOverlapping = false;
                LabelDuplicateRule labelDuplicateRule      = LabelDuplicateRule.OneDuplicateLabelPerQuadrant;
                double             drawingMarginPercentage = 0;

                if (bool.TryParse(haloPen, out useHalopen) && bool.TryParse(mask, out useMask) &&
                    bool.TryParse(overlapping, out allowOverlapping) &&
                    Enum.TryParse <LabelDuplicateRule>(duplicateRule, out labelDuplicateRule) &&
                    double.TryParse(drawingMargin, out drawingMarginPercentage) &&
                    gridSizeConfigurations.ContainsKey(gridSize))
                {
                    int gridSizeValue = gridSizeConfigurations[gridSize];

                    foreach (string layerId in overlay.Layers.GetKeys())
                    {
                        ShapeFileFeatureLayer featureLayer = overlay.Layers[layerId] as ShapeFileFeatureLayer;
                        List <TextStyle>      textStyles   = new List <TextStyle>();
                        if (featureLayer.ZoomLevelSet.ZoomLevel10.CustomStyles.Count > 0)
                        {
                            ClassBreakStyle classBreakStyle = featureLayer.ZoomLevelSet.ZoomLevel10.CustomStyles[0] as ClassBreakStyle;
                            textStyles = classBreakStyle.ClassBreaks.Select(c => c.DefaultTextStyle).ToList();
                        }
                        else
                        {
                            textStyles.Add(featureLayer.ZoomLevelSet.ZoomLevel10.DefaultTextStyle);
                        }
                        foreach (var textStyle in textStyles)
                        {
                            int red   = textStyle.HaloPen.Color.RedComponent;
                            int green = textStyle.HaloPen.Color.GreenComponent;
                            int blue  = textStyle.HaloPen.Color.BlueComponent;
                            int alpha = useHalopen ? 255 : 0;

                            textStyle.HaloPen                    = new GeoPen(GeoColor.FromArgb(alpha, red, green, blue), textStyle.HaloPen.Width);
                            textStyle.Mask.IsActive              = useMask;
                            textStyle.OverlappingRule            = allowOverlapping ? LabelOverlappingRule.AllowOverlapping : LabelOverlappingRule.NoOverlapping;
                            textStyle.DuplicateRule              = labelDuplicateRule;
                            textStyle.GridSize                   = gridSizeValue;
                            featureLayer.DrawingMarginPercentage = drawingMarginPercentage;
                        }
                    }
                }
            }
        }
Exemple #23
0
        private void AddMapLayer()
        {
            // Create the MapPrinterLayer and set the position
            MapPrinterLayer mapPrinterLayer = new MapPrinterLayer();

            mapPrinterLayer.MapUnit        = GeographyUnit.Meter;
            mapPrinterLayer.MapExtent      = new RectangleShape(-20026376.39, 20048966.10, 20026376.39, -20048966.10);
            mapPrinterLayer.BackgroundMask = new AreaStyle(new GeoPen(GeoColors.Black, 1));
            mapPrinterLayer.Open();

            // Set the maps position slightly below the pages center and 8 inches wide and 7 inches tall
            RectangleShape pageBoundingbox = GetPageBoundingBox(PrintingUnit.Inch);

            mapPrinterLayer.SetPosition(8, 7, pageBoundingbox.GetCenterPoint().X, pageBoundingbox.GetCenterPoint().Y + 1, PrintingUnit.Inch);

            // Setup the intial extent and ensure they snap to the default ZoomLevel
            ZoomLevelSet zoomLevelSet = new ZoomLevelSet();

            mapPrinterLayer.MapExtent = MapUtil.ZoomToScale(zoomLevelSet.ZoomLevel03.Scale, new RectangleShape(-20026376.39, 20048966.10, 20026376.39, -20048966.10), mapPrinterLayer.MapUnit, (float)mapPrinterLayer.GetBoundingBox().Width, (float)mapPrinterLayer.GetBoundingBox().Height);

            // This ThinkGeo Cloud test key is exclusively for demonstration purposes and is limited to requesting base map
            // tiles only. Do not use it in your own applications, as it may be restricted or disabled without prior notice.
            // Please visit https://cloud.thinkgeo.com to create a free key for your own use.
            //ThinkGeoCloudRasterMapsLayer worldMapKitLayer = new ThinkGeoCloudRasterMapsLayer("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~");
            //worldMapKitLayer.TileCache = null;
            //mapPrinterLayer.Layers.Add(worldMapKitLayer);
            ShapeFileFeatureLayer backgroundLayer = new ShapeFileFeatureLayer(@"data/Countries02_3857.shp", FileAccess.Read);

            backgroundLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            backgroundLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyle.CreateSimpleAreaStyle(GeoColors.White, GeoColors.Black);
            mapPrinterLayer.Layers.Add(backgroundLayer);

            // Setup the Countries mapping layer
            ShapeFileFeatureLayer shapefileFeatureLayer = new ShapeFileFeatureLayer(@"data/Countries02_3857.shp", FileAccess.Read);

            shapefileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            //Create the class break style for countries less than 70 million
            ClassBreakStyle classBreakStyle = new ClassBreakStyle("POP_CNTRY");

            // Create the style and class break for countries with greater and 70 million
            AreaStyle hatchAreaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.FromArgb(100, GeoColors.Green)));

            classBreakStyle.ClassBreaks.Add(new ClassBreak(70000000, hatchAreaStyle));

            // Add the class break style to the layer
            shapefileFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);

            // Add the new country layer to the MapPrinterLayer
            mapPrinterLayer.Layers.Add(shapefileFeatureLayer);

            // Add the MapPrinterLayer to the PrinterInteractiveOverlay
            PrinterInteractiveOverlay printerInteractiveOverlay = (PrinterInteractiveOverlay)Map1.InteractiveOverlays["PrintPreviewOverlay"];

            printerInteractiveOverlay.PrinterLayers.Add("MapLayer", mapPrinterLayer);
        }
        /// <summary>
        /// Gets an overlay for showing streets.
        /// </summary>
        public static LayerOverlay GetOverlayWithLabelingLine(string overlayId, string accessId)
        {
            LayerOverlay labelingLinesOverlay = new LayerOverlay();

            ShapeFileFeatureLayer streetLayer = new ShapeFileFeatureLayer(string.Format(@"{0}\{1}", GetBaseDirectory(), "Street.shp"));

            labelingLinesOverlay.Layers.Add("street_Label", streetLayer);

            // Create a classBreakStyle for different type of roads
            ClassBreakStyle roadStyle = new ClassBreakStyle("Type");

            roadStyle.BreakValueInclusion = BreakValueInclusion.ExcludeValue;

            ClassBreak break1 = new ClassBreak();

            break1.Value                       = 0.9;
            break1.DefaultTextStyle            = new TextStyle("ROAD_NAME", new GeoFont("Arial", 12, DrawingFontStyles.Regular), new GeoSolidBrush(GeoColor.FromHtml("#666666")));
            break1.DefaultTextStyle.HaloPen    = new GeoPen(GeoColor.SimpleColors.White, 2);
            break1.DefaultTextStyle.SplineType = SplineType.ForceSplining;
            break1.DefaultTextStyle.Mask       = new AreaStyle();
            roadStyle.ClassBreaks.Add(break1);

            ClassBreak break2 = new ClassBreak();

            break2.Value                       = 3.8;
            break2.DefaultTextStyle            = new TextStyle("ROAD_NAME", new GeoFont("Arial", 8, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.FromHtml("#666666")));
            break2.DefaultTextStyle.HaloPen    = new GeoPen(GeoColor.SimpleColors.White, 1);
            break2.DefaultTextStyle.SplineType = SplineType.ForceSplining;
            break2.DefaultTextStyle.Mask       = new AreaStyle();
            roadStyle.ClassBreaks.Add(break2);

            ClassBreak break3 = new ClassBreak();

            break3.Value                       = 7;
            break3.DefaultTextStyle            = new TextStyle("ROAD_NAME", new GeoFont("Arial", 6, DrawingFontStyles.Regular), new GeoSolidBrush(GeoColor.FromHtml("#666666")));
            break3.DefaultTextStyle.Mask       = new AreaStyle();
            break3.DefaultTextStyle.SplineType = SplineType.ForceSplining;
            roadStyle.ClassBreaks.Add(break3);

            streetLayer.ZoomLevelSet.ZoomLevel10.CustomStyles.Add(roadStyle);
            streetLayer.ZoomLevelSet.ZoomLevel10.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            // Set DrawingMarginPercentage to a proper value to avoid some labels are cut-off
            streetLayer.DrawingMarginPercentage = 200;

            Dictionary <string, string> savedStyle = GetSavedLabelStyleByAccessId(overlayId, accessId);

            if (savedStyle != null)
            {
                UpdateLabelingLineStyle(labelingLinesOverlay, savedStyle);
            }

            return(labelingLinesOverlay);
        }
Exemple #25
0
        private DynamicIsoLineLayer GetDynamicIsoLineLayer(Dictionary <PointShape, double> csvPointData)
        {
            // We use this method to generate the values for the lines based on the data values and how many breaks we want.
            Collection <double> isoLineLevels = GridIsoLineLayer.GetIsoLineLevels(csvPointData, 25);

            //Create the new dynamicIsoLineLayer
            DynamicIsoLineLayer dynamicIsoLineLayer = new DynamicIsoLineLayer(csvPointData, isoLineLevels, new InverseDistanceWeightedGridInterpolationModel(), IsoLineType.LinesOnly);

            // Set the cell height and width dynamically based on the map view size
            //dynamicIsoLineLayer.CellHeightInPixel = (int)(mapView.ActualHeight / 80);
            //dynamicIsoLineLayer.CellWidthInPixel = (int)(mapView.ActualWidth / 80);

            //Create a series of colors from blue to red that we will use for the breaks based on the number of iso line levels we want.
            Collection <GeoColor> colors = GeoColor.GetColorsInQualityFamily(GeoColors.Blue, GeoColors.Red, isoLineLevels.Count, ColorWheelDirection.Clockwise);

            //Setup a class break style based on the isoline levels and the colors and add it to the iso line layer
            ClassBreakStyle classBreakStyle = new ClassBreakStyle(dynamicIsoLineLayer.DataValueColumnName);

            dynamicIsoLineLayer.CustomStyles.Add(classBreakStyle);

            // Create a collection of styles that we use we will use for the minimum value
            Collection <Core.Style> firstStyles = new Collection <ThinkGeo.Core.Style>();

            firstStyles.Add(new LineStyle(new GeoPen(colors[0], 3)));
            firstStyles.Add(new AreaStyle(new GeoPen(GeoColors.LightBlue, 3), new GeoSolidBrush(new GeoColor(150, colors[0]))));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, firstStyles));

            // Loop through all the colors we created as they will be class breaks
            for (int i = 0; i < colors.Count - 1; i++)
            {
                // Create the style collection for this break based on the colors we generated
                Collection <Core.Style> styles = new Collection <Core.Style>();
                styles.Add(new LineStyle(new GeoPen(colors[i + 1], 3)));
                styles.Add(new AreaStyle(new GeoPen(GeoColors.LightBlue, 3), new GeoSolidBrush(new GeoColor(150, colors[i + 1]))));

                // Add the class break with the styles
                classBreakStyle.ClassBreaks.Add(new ClassBreak(isoLineLevels[i], styles));
            }

            //Create the text styles to label the lines and add it to the iso line layer
            TextStyle textStyle = TextStyle.CreateSimpleTextStyle(dynamicIsoLineLayer.DataValueColumnName, "Arial", 10, DrawingFontStyles.Bold, GeoColors.Black, 0, 0);

            textStyle.HaloPen               = new GeoPen(GeoColors.White, 2);
            textStyle.OverlappingRule       = LabelOverlappingRule.NoOverlapping;
            textStyle.SplineType            = SplineType.StandardSplining;
            textStyle.DuplicateRule         = LabelDuplicateRule.UnlimitedDuplicateLabels;
            textStyle.TextLineSegmentRatio  = 9999999;
            textStyle.FittingLineInScreen   = true;
            textStyle.SuppressPartialLabels = true;
            dynamicIsoLineLayer.CustomStyles.Add(textStyle);

            return(dynamicIsoLineLayer);
        }
Exemple #26
0
        private static DynamicIsoLineLayer GetDynamicIsoLineLayer()
        {
            // Define the colors for different earthquake magnitude.
            Collection <GeoColor> colorsOfMagnitude = new Collection <GeoColor>()
            {
                GeoColor.FromHtml("#FFFFBE"),
                GeoColor.FromHtml("#FDFF9E"),
                GeoColor.FromHtml("#FDFF37"),
                GeoColor.FromHtml("#FDDA04"),
                GeoColor.FromHtml("#FFA701"),
                GeoColor.FromHtml("#FF6F02"),
                GeoColor.FromHtml("#EC0000"),
                GeoColor.FromHtml("#B90000"),
                GeoColor.FromHtml("#850100"),
                GeoColor.FromHtml("#620001"),
                GeoColor.FromHtml("#450005"),
                GeoColor.FromHtml("#2B0804")
            };

            // Get the file path name from its relative path.
            string shpFilePathName = GetFullPath("App_Data/usEarthquake.shp");

            // Create the layer for IsoLine.
            ShapeFileFeatureSource          featureSource      = new ShapeFileFeatureSource(shpFilePathName);
            Dictionary <PointShape, double> dataPoints         = GetDataPoints(featureSource);
            GridInterpolationModel          interpolationModel = new InverseDistanceWeightedGridInterpolationModel(3, double.MaxValue);
            DynamicIsoLineLayer             isoLineLayer       = new DynamicIsoLineLayer(dataPoints, GetClassBreakValues(dataPoints.Values, 12), interpolationModel, IsoLineType.ClosedLinesAsPolygons);

            // Create the style for different level of earthquake magnitude.
            ClassBreakStyle earthquakeMagnitudeBreakStyle = new ClassBreakStyle(isoLineLayer.DataValueColumnName);

            earthquakeMagnitudeBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, new AreaStyle(new GeoPen(GeoColor.FromHtml("#FE6B06"), 1), new GeoSolidBrush(new GeoColor(100, colorsOfMagnitude[0])))));
            for (int i = 0; i < isoLineLayer.IsoLineLevels.Count - 1; i++)
            {
                earthquakeMagnitudeBreakStyle.ClassBreaks.Add(new ClassBreak(isoLineLayer.IsoLineLevels[i + 1], new AreaStyle(new GeoPen(GeoColor.FromHtml("#FE6B06"), 1), new GeoSolidBrush(new GeoColor(100, colorsOfMagnitude[i + 1])))));
            }
            isoLineLayer.CustomStyles.Add(earthquakeMagnitudeBreakStyle);

            TextStyle textStyle = TextStyles.CreateSimpleTextStyle(isoLineLayer.DataValueColumnName, "Arial", 8, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, 0);

            textStyle.HaloPen               = new GeoPen(GeoColor.StandardColors.White, 2);
            textStyle.OverlappingRule       = LabelOverlappingRule.NoOverlapping;
            textStyle.SplineType            = SplineType.StandardSplining;
            textStyle.DuplicateRule         = LabelDuplicateRule.UnlimitedDuplicateLabels;
            textStyle.TextLineSegmentRatio  = 9999999;
            textStyle.FittingLineInScreen   = true;
            textStyle.SuppressPartialLabels = true;
            textStyle.NumericFormat         = "{0:0.00}";
            isoLineLayer.CustomStyles.Add(textStyle);

            return(isoLineLayer);
        }
 public ClassBreakStyleItem(ClassBreakStyle style)
     : base(style)
 {
     classBreakStyle = style;
     if (classBreakStyle != null)
     {
         foreach (var classBreak in classBreakStyle.ClassBreaks)
         {
             StyleLayerListItem classBreakItem = new ClassBreakSubItem(classBreak, classBreakStyle.ColumnName);
             Children.Add(classBreakItem);
         }
     }
 }
Exemple #28
0
        private static void SetDrawingLevelForStyle(Style style)
        {
            AreaStyle       areaStyle       = style as AreaStyle;
            LineStyle       lineStyle       = style as LineStyle;
            PointStyle      pointStyle      = style as PointStyle;
            CompositeStyle  compositeStyle  = style as CompositeStyle;
            FilterStyle     filterStyle     = style as FilterStyle;
            ValueStyle      valueStyle      = style as ValueStyle;
            ClassBreakStyle classBreakStyle = style as ClassBreakStyle;

            if (areaStyle != null)
            {
                areaStyle.SetDrawingLevel();
            }
            else if (lineStyle != null)
            {
                lineStyle.SetDrawingLevel();
            }
            else if (pointStyle != null)
            {
                pointStyle.SetDrawingLevel();
            }
            else if (filterStyle != null)
            {
                foreach (var item in filterStyle.Styles)
                {
                    SetDrawingLevelForStyle(item);
                }
            }
            else if (classBreakStyle != null)
            {
                foreach (var item in classBreakStyle.ClassBreaks.SelectMany(v => v.CustomStyles))
                {
                    SetDrawingLevelForStyle(item);
                }
            }
            else if (valueStyle != null)
            {
                foreach (var item in valueStyle.ValueItems.SelectMany(v => v.CustomStyles))
                {
                    SetDrawingLevelForStyle(item);
                }
            }
            else if (compositeStyle != null)
            {
                foreach (var subStyle in compositeStyle.Styles)
                {
                    SetDrawingLevelForStyle(subStyle);
                }
            }
        }
Exemple #29
0
        public AmapWalkingRoutePlanLayer(Uri serverUri, string key)
        {
            enableEmbeddedStyle = true;

            classBreakStyle            = new ClassBreakStyle();
            classBreakStyle.ColumnName = "jf";
            classBreakStyle.ClassBreaks.Add(new ClassBreak(0, new LineStyle(new GeoPen(GeoColor.SimpleColors.Green, 2.0f))));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(4, new LineStyle(new GeoPen(GeoColor.SimpleColors.Yellow, 2.0f))));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(8, new LineStyle(new GeoPen(GeoColor.SimpleColors.Red, 2.0f))));
            classBreakStyle.ClassBreaks.Add(new ClassBreak(10, new LineStyle(new GeoPen(GeoColor.SimpleColors.Black, 2.0f))));

            //http://restapi.amap.com/v3/direction/walking?key=您的key&origin=116.481028,39.989643&destination=116.434446,39.90816
            FeatureSource = new AmapWalkingRoutePlanSource(serverUri, key);
        }
Exemple #30
0
        private void Initialize()
        {
            Collection <GeoColor> levelAreaColors = new Collection <GeoColor>();

            levelAreaColors.Add(GeoColor.FromHtml("#FFFFBE"));
            levelAreaColors.Add(GeoColor.FromHtml("#FDFF9E"));
            levelAreaColors.Add(GeoColor.FromHtml("#FDFF37"));
            levelAreaColors.Add(GeoColor.FromHtml("#FDDA04"));
            levelAreaColors.Add(GeoColor.FromHtml("#FFA701"));
            levelAreaColors.Add(GeoColor.FromHtml("#FF6F02"));
            levelAreaColors.Add(GeoColor.FromHtml("#EC0000"));
            levelAreaColors.Add(GeoColor.FromHtml("#B90000"));
            levelAreaColors.Add(GeoColor.FromHtml("#850100"));
            levelAreaColors.Add(GeoColor.FromHtml("#620001"));
            levelAreaColors.Add(GeoColor.FromHtml("#450005"));
            levelAreaColors.Add(GeoColor.FromHtml("#2B0804"));

            FeatureSource.Open();

            Dictionary <PointShape, double> dataPoints         = GetDataPoints();
            GridInterpolationModel          interpolationModel = new InverseDistanceWeightedGridInterpolationModel(3, double.MaxValue);

            isoLineLayer = new DynamicIsoLineLayer(dataPoints, GetClassBreakValues(dataPoints.Values, 12), interpolationModel, IsoLineType.ClosedLinesAsPolygons);

            isoLineLayer.CellWidthInPixel  = 32;
            isoLineLayer.CellHeightInPixel = 32;
            levelClassBreakStyle           = new ClassBreakStyle(isoLineLayer.DataValueColumnName);
            levelClassBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, new AreaStyle(new GeoPen(GeoColor.FromHtml("#FE6B06"), 1), new GeoSolidBrush(new GeoColor(100, levelAreaColors[0])))));
            for (int i = 0; i < IsoLineLevels.Count - 1; i++)
            {
                if (!levelClassBreakStyle.ClassBreaks.Any(c => c.Value == IsoLineLevels[i + 1]))
                {
                    levelClassBreakStyle.ClassBreaks.Add(new ClassBreak(IsoLineLevels[i + 1], new AreaStyle(new GeoPen(GeoColor.FromHtml("#FE6B06"), 1), new GeoSolidBrush(new GeoColor(100, levelAreaColors[i + 1])))));
                }
            }
            isoLineLayer.CustomStyles.Add(levelClassBreakStyle);

            TextStyle textStyle = TextStyles.CreateSimpleTextStyle(isoLineLayer.DataValueColumnName, "Arial", 8, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, 0);

            textStyle.HaloPen               = new GeoPen(GeoColor.StandardColors.White, 2);
            textStyle.OverlappingRule       = LabelOverlappingRule.NoOverlapping;
            textStyle.SplineType            = SplineType.StandardSplining;
            textStyle.DuplicateRule         = LabelDuplicateRule.UnlimitedDuplicateLabels;
            textStyle.TextLineSegmentRatio  = 9999999;
            textStyle.FittingLineInScreen   = true;
            textStyle.SuppressPartialLabels = true;
            textStyle.NumericFormat         = "{0:0.00}";
            isoLineLayer.CustomStyles.Add(textStyle);
        }
Exemple #31
0
        private static ClassBreakStyle GetClassBreakStyle()
        {
            // Define the values which are used as the class breaks.
            double[] classBreakValues = new double[] { 0, 814180.0, 1328361.0, 2059179.0, 2967297.0, 4339367.0, 5303925.0, 6392017.0, 8791894.0 };
            // Create a color family for displying the features.
            Collection <GeoColor> familyColors = GeoColor.GetColorsInQualityFamily(GeoColor.FromArgb(255, 116, 160, 255), GeoColor.FromArgb(255, 220, 52, 56), 10, ColorWheelDirection.CounterClockwise);

            ClassBreakStyle classBreakStyle = new ClassBreakStyle("Population", BreakValueInclusion.IncludeValue);

            for (int i = 0; i < classBreakValues.Length; i++)
            {
                classBreakStyle.ClassBreaks.Add(new ClassBreak(classBreakValues[i], AreaStyles.CreateSimpleAreaStyle(new GeoColor(150, familyColors[i]), GeoColor.FromHtml("#f05133"), 1)));
            }
            return(classBreakStyle);
        }
        private void Initialize()
        {
            Collection<GeoColor> levelAreaColors = new Collection<GeoColor>();
            levelAreaColors.Add(GeoColor.FromHtml("#FFFFBE"));
            levelAreaColors.Add(GeoColor.FromHtml("#FDFF9E"));
            levelAreaColors.Add(GeoColor.FromHtml("#FDFF37"));
            levelAreaColors.Add(GeoColor.FromHtml("#FDDA04"));
            levelAreaColors.Add(GeoColor.FromHtml("#FFA701"));
            levelAreaColors.Add(GeoColor.FromHtml("#FF6F02"));
            levelAreaColors.Add(GeoColor.FromHtml("#EC0000"));
            levelAreaColors.Add(GeoColor.FromHtml("#B90000"));
            levelAreaColors.Add(GeoColor.FromHtml("#850100"));
            levelAreaColors.Add(GeoColor.FromHtml("#620001"));
            levelAreaColors.Add(GeoColor.FromHtml("#450005"));
            levelAreaColors.Add(GeoColor.FromHtml("#2B0804"));

            FeatureSource.Open();

            Dictionary<PointShape, double> dataPoints = GetDataPoints();
            GridInterpolationModel interpolationModel = new InverseDistanceWeightedGridInterpolationModel(3, double.MaxValue);
            isoLineLayer = new DynamicIsoLineLayer(dataPoints, IsoLineLayer.GetIsoLineLevels(dataPoints.Values, 12), interpolationModel, IsoLineType.ClosedLinesAsPolygons);

            IsoLineLayer.GetIsoLineLevels(dataPoints, 12);

            levelClassBreakStyle = new ClassBreakStyle(isoLineLayer.DataValueColumnName);
            levelClassBreakStyle.ClassBreaks.Add(new ClassBreak(double.MinValue, new AreaStyle(new GeoPen(GeoColor.FromHtml("#FE6B06"), 1), new GeoSolidBrush(new GeoColor(100, levelAreaColors[0])))));
            for (int i = 0; i < IsoLineLevels.Count - 1; i++)
            {
                levelClassBreakStyle.ClassBreaks.Add(new ClassBreak(IsoLineLevels[i + 1], new AreaStyle(new GeoPen(GeoColor.FromHtml("#FE6B06"), 1), new GeoSolidBrush(new GeoColor(100, levelAreaColors[i + 1])))));
            }
            isoLineLayer.CustomStyles.Add(levelClassBreakStyle);

            TextStyle textStyle = TextStyles.CreateSimpleTextStyle(isoLineLayer.DataValueColumnName, "Arial", 8, DrawingFontStyles.Bold, GeoColor.StandardColors.Black, 0, 0);
            textStyle.HaloPen = new GeoPen(GeoColor.StandardColors.White, 2);
            textStyle.OverlappingRule = LabelOverlappingRule.NoOverlapping;
            textStyle.SplineType = SplineType.StandardSplining;
            textStyle.DuplicateRule = LabelDuplicateRule.UnlimitedDuplicateLabels;
            textStyle.TextLineSegmentRatio = 9999999;
            textStyle.FittingLineInScreen = true;
            textStyle.SuppressPartialLabels = true;
            textStyle.NumericFormat = "{0:0.00}";
            isoLineLayer.CustomStyles.Add(textStyle);
        }
        protected override Collection<Style> GetStylesCore(FeatureSource featureSource)
        {
            // here we generated a class break style and a text style.
            Collection<GeoColor> familyColors = GeoColor.GetColorsInQualityFamily(Color, EndColor, classBreakCount, ColorWheelDirection);

            featureSource.Open();
            int featureCount = featureSource.GetCount();
            double[] values = new double[featureCount];
            for (int i = 0; i < featureCount; i++)
            {
                Feature feature = featureSource.GetFeatureById((i + 1).ToString(CultureInfo.InvariantCulture), SelectedColumns);
                double columnValue;
                if (double.TryParse(feature.ColumnValues[SelectedColumns[0]], out columnValue))
                {
                    values[i] = columnValue;
                }
            }
            featureSource.Close();

            ClassBreakStyle classBreakStyle = new ClassBreakStyle(SelectedColumns[0]) { BreakValueInclusion = BreakValueInclusion.IncludeValue };
            double[] classBreakValues = GetClusterClassBreaks(values, ClassBreakCount - 1);
            for (int i = 0; i < classBreakValues.Length; i++)
            {
                ClassBreak classBreak = new ClassBreak(classBreakValues[i], AreaStyles.CreateSimpleAreaStyle(new GeoColor(this.Opacity, familyColors[i]), GeoColor.FromHtml("#f05133"), 1));
                classBreakStyle.ClassBreaks.Add(classBreak);
            }

            return new Collection<Style>() { classBreakStyle, TextStyles.Country1("NAME") };
        }