Example #1
0
        private static CategorialTheme GetCategorialTheme(theme theme)
        {
            var themeCategory = (themeCategory)theme.Item;
            var defaultStyle  = GetDefaultStyle(theme);

            var categorialTheme = new CategorialTheme(themeCategory.columnName, defaultStyle);

            foreach (themeItem catThemeItem in themeCategory.categoryThemeItems)
            {
                var categorialThemeItem = new CategorialThemeItem(catThemeItem.label, GetStyle(catThemeItem), null);
                categorialTheme.AddThemeItem(categorialThemeItem);
            }

            return(categorialTheme);
        }
Example #2
0
        public static CategorialTheme CreateCategorialTheme(string attribute, VectorStyle defaultStyle, ColorBlend blend, 
            int numberOfClasses, IList<IComparable> values, List<string> categories, int sizeMin, int sizeMax)
        {
            if (defaultStyle == null)
            {
                defaultStyle = new VectorStyle
                                   {
                                       GeometryType = typeof (IPolygon)
                                   };
            }

            var categorialTheme = new CategorialTheme(attribute, defaultStyle);

            for (int i = 0; i < numberOfClasses; i++)
            {
                string label = (categories != null)
                                   ? categories[i]
                                   : values[i].ToString();

                Color color = (numberOfClasses > 1)
                                  ? blend.GetColor((float) i/(numberOfClasses - 1))
                                  : ((SolidBrush) defaultStyle.Fill).Color;
                
                var vectorStyle = (VectorStyle) defaultStyle.Clone();

                var size = sizeMin + (sizeMax - sizeMin)*i/(float) numberOfClasses;

                if (defaultStyle.GeometryType == typeof(IPoint))
                {
                    vectorStyle.Fill = new SolidBrush(color);
                    vectorStyle.Line.Width = 16;
                    vectorStyle.Shape = defaultStyle.Shape;
                }
                else if ((defaultStyle.GeometryType == typeof(IPolygon)) || (defaultStyle.GeometryType == typeof(IMultiPolygon)))
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }
                else if ((defaultStyle.GeometryType == typeof(ILineString)) || (defaultStyle.GeometryType == typeof(IMultiLineString)))
                {
                    vectorStyle.Line = CreatePen(color, size, defaultStyle.Line);
                }
                else
                {
                    vectorStyle.Fill = new SolidBrush(color);
                }

                CategorialThemeItem categorialThemeItem = (values[i] != null)
                                                              ? new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol, values[i])
                                                              : new CategorialThemeItem(label, vectorStyle, vectorStyle.LegendSymbol);

                
                categorialTheme.AddThemeItem(categorialThemeItem);
            }

            return categorialTheme;
        }
Example #3
0
        private void AddQuadTreeEnvelopes(QTNode node, IMap map)
        {
            if (node.indexList != null)
            {
                //log.Debug(node.Bounds + ": " + string.Join(", ", node.indexList));

                var i = 0;
                foreach (var bound in node.boundsList)
                {
                    var id = node.indexList[i];

                    if (quadTreeEnvelopesLayer == null)
                    {
                        var featureCollection = new FeatureCollection {
                            Features = new List <Feature> {
                            }
                        };
                        quadTreeEnvelopesLayer = new VectorLayer
                        {
                            DataSource = featureCollection,
                            Style      = { Fill = Brushes.Transparent, Outline = { Width = 1, Color = Color.DarkGreen } },

                            Name       = Name + " quad tree, level: " + node.Level,
                            Selectable = false,
                            //UseQuadTree = true
                        };

                        var theme = new CategorialTheme("IsSelected", null);
                        theme.AddThemeItem(new CategorialThemeItem("true", new VectorStyle {
                            Fill = Brushes.Transparent, Outline = { Width = 3, Color = Color.FromArgb(200, 200, 100, 100) }
                        }, null));
                        theme.AddThemeItem(new CategorialThemeItem("false", new VectorStyle {
                            Fill = Brushes.Transparent, Outline = { Width = 3, Color = Color.FromArgb(50, 100, 200, 100) }
                        }, null));
                        quadTreeEnvelopesLayer.Theme = theme;

                        map.Layers.Insert(0, quadTreeEnvelopesLayer);
                        map.BringToFront(quadTreeEnvelopesLayer);
                    }

                    //if (!quadTreeEnvelopesLayer.DataSource.Features.Cast<IFeature>().Any(f => f.Attributes["ID"].Equals(id)))
                    {
                        var feature = new Feature {
                            Geometry = geometryFactory.ToGeometry(new Envelope(bound.X, bound.X + bound.Width, bound.Y, bound.Y + bound.Height))
                        };
                        feature.Attributes = new DictionaryFeatureAttributeCollection();
                        feature.Attributes["IsSelected"] = "false";
                        feature.Attributes["ID"]         = id;

                        quadTreeEnvelopesLayer.DataSource.Features.Add(feature);
                    }

                    i++;
                }
            }

            if (node.Children != null)
            {
                AddQuadTreeEnvelopes(node.Children[0], map);
                AddQuadTreeEnvelopes(node.Children[1], map);
                AddQuadTreeEnvelopes(node.Children[2], map);
                AddQuadTreeEnvelopes(node.Children[3], map);
            }
        }
Example #4
0
        private static CategorialTheme GetCategorialTheme(theme theme)
        {
            var themeCategory = (themeCategory)theme.Item;
            var defaultStyle = GetDefaultStyle(theme);
            
            var categorialTheme = new CategorialTheme(themeCategory.columnName, defaultStyle);

            foreach (themeItem catThemeItem in themeCategory.categoryThemeItems)
            {
                var categorialThemeItem = new CategorialThemeItem(catThemeItem.label, GetStyle(catThemeItem), null);
                categorialTheme.AddThemeItem(categorialThemeItem);
            }

            return categorialTheme;
        }