public void ConvertLayerProperties_MapDataWithMapThemeAndVaryingValueCriteria_SetsCorrectFilterExpression(ValueCriterionOperator criterionOperator,
                                                                                                                  string expressionFormat)
        {
            // Setup
            const string metadataAttributeName = "Meta";
            const string value = "test value";

            var valueCriterion = new ValueCriterion(criterionOperator,
                                                    value);
            var theme = new MapTheme <TestCategoryTheme>(metadataAttributeName, new[]
            {
                new TestCategoryTheme(valueCriterion)
            });

            var mapData = new TestFeatureBasedMapData("test data", theme)
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                    {
                        MetaData =
                        {
                            {
                                metadataAttributeName, new object()
                            }
                        }
                    }
                }
            };

            var featureScheme   = new PointScheme();
            var defaultCategory = new PointCategory();
            var category        = new PointCategory();
            var testConverter   = new TestFeatureBasedMapDataConverter
            {
                CreatedFeatureScheme         = featureScheme,
                CreatedDefaultCategory       = defaultCategory,
                CreatedCategoryThemeCategory = category
            };

            var mapLayer = new TestFeatureLayer();

            // Call
            testConverter.ConvertLayerProperties(mapData, mapLayer);

            // Assert
            Assert.IsNull(defaultCategory.FilterExpression);
            string expectedFilterExpression = string.Format(expressionFormat, value);

            Assert.AreEqual(expectedFilterExpression, category.FilterExpression);
        }
        public void ConvertLayerProperties_MapDataWithMapThemeAndExistingMetaData_SetsExpectedSymbology()
        {
            // Setup
            const string metadataAttributeName = "metaData";
            var          theme = new MapTheme <TestCategoryTheme>(metadataAttributeName, new[]
            {
                new TestCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion())
            });
            var mapData = new TestFeatureBasedMapData("test data", theme)
            {
                Features = new[]
                {
                    new MapFeature(Enumerable.Empty <MapGeometry>())
                    {
                        MetaData =
                        {
                            {
                                metadataAttributeName, new object()
                            }
                        }
                    }
                }
            };

            var scheme          = new PointScheme();
            var defaultCategory = new PointCategory();
            var categoryTheme   = new PointCategory();
            var testConverter   = new TestFeatureBasedMapDataConverter
            {
                CreatedFeatureScheme         = scheme,
                CreatedDefaultCategory       = defaultCategory,
                CreatedCategoryThemeCategory = categoryTheme
            };

            var mapLayer = new TestFeatureLayer();

            // Call
            testConverter.ConvertLayerProperties(mapData, mapLayer);

            // Assert
            IPointScheme symbology = mapLayer.Symbology;

            Assert.AreSame(scheme, symbology);
            CollectionAssert.AreEqual(new[]
            {
                defaultCategory,
                categoryTheme
            }, symbology.Categories);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Highlighting shapes with a mouse over is something that also needs to be undone when the
        /// mouse leaves. This test handles changing the colors back to normal when the mouse leaves a shape.
        /// </summary>
        /// <param name="e">The GeoMouseArgs parameter contains information about the mouse location and geographic coordinates.</param>
        /// <returns>Boolean, true if mapframe initialize (or visual change) is necessary.</returns>
        private bool ShapeRemoveHighlight(GeoMouseArgs e)
        {
            // If no shapes have ever been highlighted, this is meaningless.
            if (_oldCategory == null)
            {
                return(false);
            }

            Rectangle     mouseRect          = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);
            Extent        ext                = Map.PixelToProj(mouseRect);
            MapPointLayer mpl                = _layer as MapPointLayer;
            bool          requiresInvalidate = false;
            IPolygon      env                = ext.ToEnvelope().ToPolygon();

            if (mpl != null)
            {
                int           w  = 3;
                int           h  = 3;
                PointCategory pc = mpl.GetCategory(_activeFeature) as PointCategory;
                if (pc != null)
                {
                    if (pc.Symbolizer.ScaleMode != ScaleMode.Geographic)
                    {
                        w = (int)pc.Symbolizer.GetSize().Width;
                        h = (int)pc.Symbolizer.GetSize().Height;
                    }
                }

                Rectangle rect = new Rectangle(e.Location.X - (w / 2), e.Location.Y - (h / 2), w * 2, h * 2);
                if (!rect.Contains(Map.ProjToPixel(_activeFeature.Geometry.Coordinates[0])))
                {
                    mpl.SetCategory(_activeFeature, _oldCategory);
                    _activeFeature     = null;
                    requiresInvalidate = true;
                }
            }
            else
            {
                if (!_activeFeature.Geometry.Intersects(env))
                {
                    _layer.SetCategory(_activeFeature, _oldCategory);
                    _activeFeature     = null;
                    requiresInvalidate = true;
                }
            }

            return(requiresInvalidate);
        }
Exemplo n.º 4
0
        private void CategorizeCities(IMapPointLayer alayer)
        {
            PointScheme lScheme = new PointScheme();

            lScheme.Categories.Clear();
            PointCategory smallSize = new PointCategory(Color.Blue, DotSpatial.Symbology.PointShape.Rectangle, 4);

            smallSize.FilterExpression = "[Area] < 1e+08";
            smallSize.LegendText       = "Small Cities";
            lScheme.AddCategory(smallSize);

            PointCategory largeSize = new PointCategory(Color.Yellow, DotSpatial.Symbology.PointShape.Star, 16);

            largeSize.FilterExpression = "[Area] >= 1e+08";
            largeSize.LegendText       = "Large Cities";
            lScheme.AddCategory(largeSize);

            alayer.Symbology = lScheme;
        }
Exemplo n.º 5
0
        override protected void setSymbolizer()
        {
            int baseWidth = 48;

            PointScheme ftrScheme = new PointScheme();

            PointCategory catDef = new PointCategory(Properties.Resources.feature, baseWidth);

            catDef.LegendText = "No Info";
            catDef.SelectionSymbolizer.ScaleMode = ScaleMode.Geographic;
            catDef.SelectionSymbolizer.SetOutline(Color.Cyan, baseWidth / 4);
            catDef.Symbolizer.ScaleMode = ScaleMode.Geographic;
            ftrScheme.AddCategory(catDef);

            Image[] images =
            {
                Properties.Resources.feature,
                Properties.Resources.important,
                Properties.Resources.question,
                Properties.Resources.problem,
                Properties.Resources.ramp,
                Properties.Resources.sidewalk,
                Properties.Resources.feature,
                Properties.Resources.problem,
                Properties.Resources.pooling,
                Properties.Resources.crash
            };
            string[] iconNames = { "feature", "important", "question", "problem", "ramp", "sidewalk", "other", "road", "drainage", "accident" };

            for (int i = 0; i < images.Length; i++)
            {
                PointCategory cat = new PointCategory(images[i], baseWidth);
                cat.FilterExpression = "[TAMSICON] = '" + iconNames[i] + "'";
                cat.SelectionSymbolizer.ScaleMode = ScaleMode.Geographic;
                cat.SelectionSymbolizer.SetOutline(Color.Cyan, baseWidth / 4);
                cat.Symbolizer.ScaleMode = ScaleMode.Geographic;
                ftrScheme.AddCategory(cat);
            }

            ((MapPointLayer)Layer).Symbology = ftrScheme;
            ((MapPointLayer)Layer).ApplyScheme(ftrScheme);
        }
Exemplo n.º 6
0
        private Bitmap CreateDefaultSymbol(Color color, int symbolSize)
        {
            double   scaleSize    = 1;
            Size2D   size         = new Size2D(symbolSize, symbolSize);
            Bitmap   normalSymbol = new Bitmap((int)(size.Width * scaleSize) + 1, (int)(size.Height * scaleSize) + 1);
            Graphics bg           = Graphics.FromImage(normalSymbol);

            Random          rnd         = new Random();
            Color           randomColor = Color.FromArgb(rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255));
            PointSymbolizer sym         = new PointSymbolizer(randomColor, PointShape.Rectangle, 4);
            PointCategory   category    = new PointCategory(sym);

            bg.SmoothingMode = category.Symbolizer.Smoothing ? SmoothingMode.AntiAlias : SmoothingMode.None;
            Matrix trans = bg.Transform;

            trans.Translate(((float)(size.Width * scaleSize) / 2 - 1), (float)(size.Height * scaleSize) / 2 - 1);
            bg.Transform = trans;
            category.Symbolizer.Draw(bg, 1);
            return(normalSymbol);
        }
Exemplo n.º 7
0
        public ScenePoint(PointCategory pc, Point p)
        {
            this.position = new Point3D(p.X, p.Y, 0);
            this.Category = pc;
            listPoint.Add(this);
            if (pc == PointCategory.Road)
            {
                roadPoint.Add(this);
            }
            ellipse             = new Ellipse();
            ellipse.Fill        = brush;
            ellipse.MouseDown  += new System.Windows.Input.MouseButtonEventHandler(ellipse_MouseDown);
            ellipse.MouseMove  += new System.Windows.Input.MouseEventHandler(ellipse_MouseMove);
            ellipse.MouseUp    += new System.Windows.Input.MouseButtonEventHandler(ellipse_MouseUp);
            ellipse.MouseLeave += new System.Windows.Input.MouseEventHandler(ellipse_MouseLeave);

            ellipseh             = new Ellipse();
            ellipseh.Fill        = brush;
            ellipseh.MouseDown  += new MouseButtonEventHandler(ellipseh_MouseDown);
            ellipseh.MouseMove  += new MouseEventHandler(ellipseh_MouseMove);
            ellipseh.MouseUp    += new MouseButtonEventHandler(ellipseh_MouseUp);
            ellipseh.MouseLeave += new MouseEventHandler(ellipseh_MouseLeave);
        }
Exemplo n.º 8
0
        public ActionResult _RewardUsers(long?userId = null)
        {
            IEnumerable <long> userIds = Request.QueryString.Gets <long>("CheckBoxGroup", new List <long>());

            if (userId.HasValue)
            {
                //userIds.Union(new List<long> { userId.Value });
                List <long> tempList = userIds.ToList();
                tempList.Add(userId.Value);
                userIds = tempList.AsEnumerable();
            }
            ViewData["userIds"] = userIds;

            pageResourceManager.InsertTitlePart("奖惩用户");
            PointCategory experiencePoints = pointService.GetPointCategory(PointCategoryKeys.Instance().ExperiencePoints());
            PointCategory reputationPoints = pointService.GetPointCategory(PointCategoryKeys.Instance().ReputationPoints());
            PointCategory tradePoints      = pointService.GetPointCategory(PointCategoryKeys.Instance().TradePoints());

            ViewData["experiencePoints"] = experiencePoints;
            ViewData["reputationPoints"] = reputationPoints;
            ViewData["tradePoints"]      = tradePoints;
            return(View());
        }
Exemplo n.º 9
0
 public JsonResult AddCategory(string Name, string ProjectID, string Description, string Score, string Percentage, string Status)
 {
     PointCategory p = new PointCategory();
     p.Name = Name;
     p.ProjectOid = Int32.Parse(ProjectID);
     p.Description = Description;
     p.Score = double.Parse(Score);
     p.Status = Int32.Parse(Status);
     p.Percentage = float.Parse(Percentage) / 100;
     try
     {
         new PointCategoryDao().Insert(p);
     }
     catch (Exception e)
     {
         return Json(e.Message);
     }
     return Json("插入成功");
 }
Exemplo n.º 10
0
        /// <summary>
        /// Before a shape is selected, moving the mouse over a shape will highlight that shape by changing
        /// its appearance. This tests features to determine the first feature to qualify as the highlight.
        /// </summary>
        /// <param name="e">The GeoMouseArgs parameter contains information about the mouse location
        /// and geographic coordinates.</param>
        /// <returns>A value indicating whether the shape was successfully highlighted.</returns>
        private bool ShapeHighlight(GeoMouseArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e", "e is null.");
            }

            Rectangle mouseRect          = new Rectangle(_mousePosition.X - 3, _mousePosition.Y - 3, 6, 6);
            Extent    ext                = Map.PixelToProj(mouseRect);
            IPolygon  env                = ext.ToEnvelope().ToPolygon();
            bool      requiresInvalidate = false;

            foreach (IFeature feature in _featureSet.Features)
            {
                if (_featureSet.FeatureType == FeatureType.Point || _featureSet.FeatureType == FeatureType.MultiPoint)
                {
                    MapPointLayer mpl = _layer as MapPointLayer;
                    if (mpl != null)
                    {
                        int           w  = 3;
                        int           h  = 3;
                        PointCategory pc = mpl.GetCategory(feature) as PointCategory;
                        if (pc != null)
                        {
                            if (pc.Symbolizer.ScaleMode != ScaleMode.Geographic)
                            {
                                Size2D size = pc.Symbolizer.GetSize();
                                w = (int)size.Width;
                                h = (int)size.Height;
                            }
                        }
                        _imageRect = new Rectangle(e.Location.X - (w / 2), e.Location.Y - (h / 2), w, h);
                        if (_imageRect.Contains(Map.ProjToPixel(feature.Geometry.Coordinates[0])))
                        {
                            _activeFeature = feature;
                            _oldCategory   = mpl.GetCategory(feature);
                            if (_selectedCategory == null)
                            {
                                _selectedCategory = _oldCategory.Copy();
                                _selectedCategory.SetColor(Color.Red);
                                _selectedCategory.LegendItemVisible = false;
                            }
                            mpl.SetCategory(_activeFeature, _selectedCategory);
                        }
                    }
                    requiresInvalidate = true;
                }
                else
                {
                    if (feature.Geometry.Intersects(env))
                    {
                        _activeFeature = feature;
                        _oldCategory   = _layer.GetCategory(_activeFeature);

                        if (_featureSet.FeatureType == FeatureType.Polygon)
                        {
                            IPolygonCategory pc = _activeCategory as IPolygonCategory;
                            if (pc == null)
                            {
                                _activeCategory = new PolygonCategory(Color.FromArgb(55, 255, 0, 0), Color.Red, 1)
                                {
                                    LegendItemVisible = false
                                };
                            }
                        }
                        if (_featureSet.FeatureType == FeatureType.Line)
                        {
                            ILineCategory pc = _activeCategory as ILineCategory;
                            if (pc == null)
                            {
                                _activeCategory = new LineCategory(Color.Red, 3)
                                {
                                    LegendItemVisible = false
                                };
                            }
                        }
                        _layer.SetCategory(_activeFeature, _activeCategory);
                        requiresInvalidate = true;
                    }
                }
            }
            return(requiresInvalidate);
        }
Exemplo n.º 11
0
 void rbtnTree_Click(object sender, RoutedEventArgs e)
 {
     currentCate = PointCategory.Tree;
 }
Exemplo n.º 12
0
        /// <summary>
        /// Translates the given style as point style and adds it to the given point scheme.
        /// </summary>
        /// <param name="scheme">The scheme the style gets added to.</param>
        /// <param name="labelScheme">The scheme the label definitions gets added to.</param>
        /// <param name="style">The style that gets translated.</param>
        private static void TranslatePointStyle(PointScheme scheme, ILabelScheme labelScheme, string style)
        {
            if (string.IsNullOrWhiteSpace(style))
            {
                return;
            }

            var myStyle = style;
            int index   = myStyle.IndexOf("(", StringComparison.Ordinal);

            if (index < 1)
            {
                return;
            }

            var toolname = myStyle.Substring(0, index);

            myStyle = myStyle.Substring(index + 1);

            switch (toolname)
            {
            case "PEN":
            {
                var color = GetColor(ref myStyle, Parameters.Color);
                var width = GetWidth(ref myStyle);

                var cat = new PointCategory(color, Symbology.PointShape.Rectangle, width)
                {
                    FilterExpression = $"[style] = '{style}'",
                    LegendText       = style,
                    Symbolizer       =
                    {
                        ScaleMode = ScaleMode.Simple,
                        Smoothing = false
                    }
                };
                scheme.AddCategory(cat);
                break;
            }

            case "LABEL":
            {
                var fontSize    = GetFontSize(ref myStyle);
                var fontColor   = GetColor(ref myStyle, Parameters.Color);
                var boxColor    = GetColor(ref myStyle, Parameters.BoxColor);
                var haloColor   = GetColor(ref myStyle, Parameters.HaloColor);
                var shadowColor = GetColor(ref myStyle, Parameters.ShadowColor);
                var angle       = GetAngle(ref myStyle);
                var font        = GetFontName(ref myStyle);
                var orientation = GetOrientation(ref myStyle);

                // create a transparent point category because the point is only used to position the label
                var cat = new PointCategory(Color.Transparent, Symbology.PointShape.Rectangle, 1)
                {
                    FilterExpression = $"[style] = '{style}'",
                    LegendText       = style,
                    Symbolizer       =
                    {
                        ScaleMode = ScaleMode.Simple,
                        Smoothing = false
                    }
                };
                scheme.AddCategory(cat);

                // create the label category only if the text column exists, otherwise we don't know where to take the text from
                if (hasTextField)
                {
                    var lcat = new LabelCategory
                    {
                        Name             = style,
                        Expression       = "[Text]",
                        FilterExpression = $"[style] = '{style}'",
                        Symbolizer       =
                        {
                            ScaleMode   = ScaleMode.Simple,
                            Alignment   = StringAlignment.Center,
                            FontColor   = fontColor,
                            FontSize    = (float)fontSize,
                            Orientation = orientation
                        }
                    };

                    if (!string.IsNullOrWhiteSpace(font))
                    {
                        lcat.Symbolizer.FontFamily = font;
                    }

                    if (angle != 0)
                    {
                        lcat.Symbolizer.Angle    = angle;
                        lcat.Symbolizer.UseAngle = true;
                    }

                    if (haloColor != Color.Empty)
                    {
                        lcat.Symbolizer.HaloColor   = haloColor;
                        lcat.Symbolizer.HaloEnabled = true;
                    }

                    if (boxColor != Color.Empty)
                    {
                        lcat.Symbolizer.BackColor        = boxColor;
                        lcat.Symbolizer.BackColorEnabled = true;
                    }

                    if (shadowColor != Color.Empty)
                    {
                        lcat.Symbolizer.DropShadowColor   = shadowColor;
                        lcat.Symbolizer.DropShadowEnabled = true;
                    }

                    labelScheme.Categories.Add(lcat);
                }

                break;
            }

            default: throw new NotImplementedException($"The translation of the point tool {toolname} is not yet implemented.");
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Translates the style strings from the list to DotSpatial style categories and adds them to the given layer.
        /// </summary>
        /// <param name="layer">The layer the styles get added to.</param>
        /// <param name="styles">The style strings that should get translated.</param>
        public static void TranslateStyles(IMapFeatureLayer layer, IList <string> styles)
        {
            var featureType = layer.DataSet.FeatureType;

            switch (featureType)
            {
            case FeatureType.MultiPoint:
            case FeatureType.Point:
            {
                // create the scheme
                var scheme = new PointScheme();
                scheme.Categories.Clear();
                scheme.EditorSettings.ClassificationType = ClassificationType.UniqueValues;
                scheme.EditorSettings.FieldName          = "style";
                scheme.LegendText = "Point";

                // add the default category
                var cat = new PointCategory(Color.Black, Symbology.PointShape.Rectangle, 5)
                {
                    LegendText = "default",
                    Symbolizer =
                    {
                        ScaleMode = ScaleMode.Simple,
                        Smoothing = false
                    }
                };
                scheme.AddCategory(cat);

                var labelLayer = new MapLabelLayer();
                labelLayer.Symbology.Categories.Clear();

                bool needsLabels = styles.Any(_ => !string.IsNullOrWhiteSpace(_) && _.StartsWith("LABEL"));

                foreach (var style in styles)
                {
                    TranslatePointStyle(scheme, labelLayer.Symbology, style);
                }

                // assign the scheme
                layer.Symbology = scheme;

                // assign the label layer if needed
                if (needsLabels)
                {
                    layer.LabelLayer = labelLayer;
                    layer.ShowLabels = true;
                    layer.LabelLayer.CreateLabels();
                }

                layer.DataSet.UpdateExtent();
                layer.DataSet.InitializeVertices();
                layer.AssignFastDrawnStates();

                break;
            }

            case FeatureType.Line:
            {
                // create the scheme
                var scheme = new LineScheme();
                scheme.Categories.Clear();
                scheme.EditorSettings.ClassificationType = ClassificationType.UniqueValues;
                scheme.EditorSettings.FieldName          = "style";
                scheme.LegendText = "Line";

                // add the default category
                var cat = new LineCategory(Color.Black, 1)
                {
                    LegendText = "default",
                    Symbolizer =
                    {
                        ScaleMode = ScaleMode.Simple,
                        Smoothing = false
                    }
                };
                scheme.AddCategory(cat);

                // add the categories from the file
                foreach (var style in styles)
                {
                    TranslateLineStyle(scheme, style);
                }

                // assign the scheme
                layer.Symbology = scheme;

                layer.DataSet.UpdateExtent();
                layer.DataSet.InitializeVertices();
                layer.AssignFastDrawnStates();

                break;
            }

            case FeatureType.Polygon:
            {
                // create the scheme
                var scheme = new PolygonScheme();
                scheme.Categories.Clear();
                scheme.EditorSettings.ClassificationType = ClassificationType.UniqueValues;
                scheme.EditorSettings.FieldName          = "style";
                scheme.LegendText = "Polygon";

                // add the default category
                var cat = new PolygonCategory(Color.GhostWhite, Color.Black, 1)
                {
                    LegendText = "default",
                    Symbolizer =
                    {
                        ScaleMode = ScaleMode.Simple,
                        Smoothing = false
                    }
                };
                scheme.AddCategory(cat);

                // add the categories from the file
                foreach (var style in styles)
                {
                    TranslatePolygonStyle(scheme, style);
                }

                // assign the scheme
                layer.Symbology = scheme;

                layer.DataSet.UpdateExtent();
                layer.DataSet.InitializeVertices();
                layer.AssignFastDrawnStates();

                break;
            }

            default: throw new ArgumentOutOfRangeException(nameof(featureType), featureType, null);
            }
        }
Exemplo n.º 14
0
 void rbtnPeople_Click(object sender, RoutedEventArgs e)
 {
     currentCate = PointCategory.People;
 }
Exemplo n.º 15
0
 void rbtnRoad_Click(object sender, RoutedEventArgs e)
 {
     currentCate = PointCategory.Road;
 }
Exemplo n.º 16
0
 void rbtnHouse_Click(object sender, RoutedEventArgs e)
 {
     currentCate = PointCategory.House;
 }
        private void UpdateSymbology(IFeatureLayer mapLayer, string columnName)
        {
            var scheme = new PointScheme();

            scheme.ClearCategories();

            var settings = scheme.EditorSettings;

            settings.ClassificationType = ClassificationType.Custom;

            var colors = new[]
            {
                Color.Aqua, Color.Blue, Color.Brown, Color.Cyan, Color.Fuchsia, Color.LightSalmon,
                Color.Olive, Color.Wheat, Color.DodgerBlue
            };

            // Find min/max value in valueField
            var minValue = double.MaxValue;
            var maxValue = double.MinValue;

            foreach (DataRow row in mapLayer.DataSet.DataTable.Rows)
            {
                double value;
                try
                {
                    value = Convert.ToDouble(row[columnName]);
                }
                catch
                {
                    value = 0;
                }
                if (value < minValue)
                {
                    minValue = value;
                }
                if (value > maxValue)
                {
                    maxValue = value;
                }
            }
            const double EPSILON = 0.00001;

            if (Math.Abs(minValue - double.MaxValue) < EPSILON)
            {
                minValue = 0.0;
            }
            if (Math.Abs(maxValue - double.MinValue) < EPSILON)
            {
                maxValue = 0.0;
            }

            var fracLength = maxValue - minValue > 10? 0 : 1;

            // Set number of categories
            const int categoriesCount = 3;
            var       categorieStep   = (maxValue - minValue) / categoriesCount; // value step in filter

            const int imageStep = 5;
            var       imageSize = 10; // start image size

            var imageColor = colors[new Random().Next(0, colors.Length - 1)];

            for (int i = 0; i < categoriesCount; i++)
            {
                var min = minValue + categorieStep * i;
                var max = min + categorieStep;
                if (max >= maxValue)
                {
                    max = maxValue + 1;
                }

                min = Math.Round(min, fracLength);
                max = Math.Round(max, fracLength);

                // Fix possible round problems on interval borders
                if (i == 0 && min > minValue)
                {
                    min--;
                }
                if (i == categoriesCount - 1 && max < maxValue)
                {
                    max++;
                }

                imageSize += imageStep;
                var baseFilter = string.Format("[{0}] >= {1} and [{0}] < {2}", columnName,
                                               fracLength == 0 ? (int)min : min,
                                               fracLength == 0 ? (int)max : max);
                var legendText = string.Format("[{0}, {1})",
                                               fracLength == 0 ? (int)min : min,
                                               fracLength == 0 ? (int)max : max);
                var mySymbolizer = new PointSymbolizer(imageColor, PointShape.Ellipse, imageSize);
                var myCategory   = new PointCategory(mySymbolizer)
                {
                    FilterExpression = baseFilter.Replace(",", "."),
                    LegendText       = legendText,
                };
                scheme.AddCategory(myCategory);
            }

            mapLayer.Symbology = scheme;
        }
Exemplo n.º 18
0
        private static IPointScheme CreateSymbology(string servCode, IFeatureSet featureSet)
        {
            Debug.Assert(featureSet != null);

            var scheme = new PointScheme();

            scheme.ClearCategories();

            var settings = scheme.EditorSettings;

            settings.ClassificationType = ClassificationType.Custom;

            const string valueField = "ValueCount";
            // Find min/max value in valueField
            var minValue = int.MaxValue;
            var maxValue = int.MinValue;

            foreach (DataRow row in featureSet.DataTable.Rows)
            {
                int value;
                try
                {
                    value = Convert.ToInt32(row[valueField]);
                }
                catch
                {
                    value = 0;
                }
                if (value < minValue)
                {
                    minValue = value;
                }
                if (value > maxValue)
                {
                    maxValue = value;
                }
            }
            if (minValue == int.MaxValue)
            {
                minValue = 0;
            }
            if (maxValue == int.MinValue)
            {
                maxValue = 0;
            }

            // Calculate number of categories
            int categoriesCount;
            var length = maxValue - minValue;

            if (length < 50)
            {
                categoriesCount = 1;
            }
            else if (length < 100)
            {
                categoriesCount = 2;
            }
            else
            {
                categoriesCount = 3;
            }

            var       categorieStep = (maxValue - minValue) / categoriesCount + 1; // value step in filter
            const int imageStep     = 5;
            var       imageSize     = 5;

            var imageHelper = new WebServices.ServiceIconHelper(Settings.Instance.SelectedHISCentralURL); // we need it only to get image
            var image       = imageHelper.GetImageForService(servCode);

            const string seriesID = "SeriesID";
            var          needDownloadedCategories = featureSet.DataTable.Columns.Contains(seriesID);

            for (int i = 0; i < categoriesCount; i++)
            {
                var min = minValue - 1;
                var max = minValue + categorieStep;
                if (max > maxValue)
                {
                    max = maxValue;
                }
                minValue = max + 1;

                imageSize += imageStep;

                var baseFilter = string.Format("[{0}] > {1} and [{0}] <= {2}", valueField, min, max);

                var filterEx = needDownloadedCategories
                                   ? baseFilter + string.Format(" AND ([{0}] is null)", seriesID)
                                   : baseFilter;

                var legendText   = string.Format("({0}, {1}]", min, max);
                var mySymbolizer = new PointSymbolizer(image, imageSize);
                var myCategory   = new PointCategory(mySymbolizer)
                {
                    FilterExpression    = filterEx,
                    LegendText          = legendText,
                    SelectionSymbolizer = new PointSymbolizer(image, imageSize + 2)
                };
                myCategory.SelectionSymbolizer.SetFillColor(Color.Yellow);
                scheme.AddCategory(myCategory);

                // add category for downloaded
                if (needDownloadedCategories)
                {
                    mySymbolizer = new PointSymbolizer(image, imageSize);
                    mySymbolizer.SetOutline(Color.Green, 3);

                    filterEx   = string.Format("{0} AND not([{1}] is null)", baseFilter, seriesID);
                    legendText = myCategory.LegendText + " (downloaded)";
                    var categorieForDownload = new PointCategory(mySymbolizer)
                    {
                        FilterExpression    = filterEx,
                        LegendText          = legendText,
                        SelectionSymbolizer = new PointSymbolizer(image, imageSize + 2)
                    };
                    categorieForDownload.SelectionSymbolizer.SetFillColor(Color.Yellow);
                    scheme.AddCategory(categorieForDownload);
                }
            }

            return(scheme);
        }
Exemplo n.º 19
0
 void rbtnCar_Click(object sender, RoutedEventArgs e)
 {
     currentCate = PointCategory.Car;
 }