public RuleSymbolizerPreview()
        {
            InitializeComponent();
            mapPreview.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
            featureSetPoint.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
            featureSetLine.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
            featureSetPolygon.Projection = DotSpatial.Projections.KnownCoordinateSystems.Geographic.World.WGS1984;
            DotSpatial.Topology.LineString ls = new DotSpatial.Topology.LineString(new Coordinate[] { new Coordinate(-45D, 0D), new Coordinate(45D, 0D) });
            featureSetLine.AddFeature(ls);
            DotSpatial.Topology.Polygon polygon = new DotSpatial.Topology.Polygon(new LinearRing(new Coordinate[] {
                new Coordinate(90, -25), new Coordinate(135, -25), new Coordinate(135,25),new Coordinate(90, 25),new Coordinate(90, -25)
            }));
            featureSetPolygon.AddFeature(polygon);

            DotSpatial.Topology.Point point = new DotSpatial.Topology.Point(new Coordinate(-90D, 0D));
            featureSetPoint.AddFeature(point);

            layerPoint = new MapPointLayer(featureSetPoint);
            layerLine = new MapLineLayer(featureSetLine);
            layerPolygon = new MapPolygonLayer(featureSetPolygon);
               // layerPoint.Symbolizer = new DotSpatial.Symbology.PointSymbolizer(System.Drawing.Color.DarkBlue, DotSpatial.Symbology.PointShape.Triangle, 20);

            mapPreview.Layers.Add(layerLine);
            mapPreview.Layers.Add(layerPolygon);
            mapPreview.Layers.Add(layerPoint);
            this.SizeChanged += RuleSymbolizerPreview_SizeChanged;
            mapPreview.ViewExtents = new Extent(-180, -180, 180, 180);
            mapPreview.ViewExtents.SetCenter(new Coordinate(0, 0));
        }
 public static IMapFeatureLayer Insert(this IMapLayerCollection collection, int index, IFeatureSet featureSet)
 {
     if (featureSet != null)
     {
         featureSet.ProgressHandler = collection.ProgressHandler;
         if ((featureSet.FeatureType == FeatureType.Point) || (featureSet.FeatureType == FeatureType.MultiPoint))
         {
             IMapPointLayer item = new MapPointLayer(featureSet);
             collection.Insert(index, item);
             item.ProgressHandler = collection.ProgressHandler;
             return item;
         }
         if (featureSet.FeatureType == FeatureType.Line)
         {
             IMapLineLayer layer2 = new MapLineLayer(featureSet);
             collection.Insert(index, layer2);
             layer2.ProgressHandler = collection.ProgressHandler;
             return layer2;
         }
         if (featureSet.FeatureType == FeatureType.Polygon)
         {
             IMapPolygonLayer layer3 = new MapPolygonLayer(featureSet);
             collection.Insert(index, layer3);
             layer3.ProgressHandler = collection.ProgressHandler;
             return layer3;
         }
     }
     return null;
 }
        /// <summary>
        /// This overload automatically constructs a new MapLayer from the specified
        /// feature layer with the default drawing characteristics and returns a valid
        /// IMapLayer which can be further cast into a PointLayer, MapLineLayer or
        /// a PolygonLayer, depending on the data that is passed in.
        /// </summary>
        /// <param name="featureSet">Any valid IFeatureSet that does not yet have drawing characteristics</param>
        /// <returns>A newly created valid implementation of FeatureLayer which at least gives a few more common
        /// drawing related methods and can also be cast into the appropriate Point, Line or Polygon layer.</returns>
        public virtual IMapFeatureLayer Add(IFeatureSet featureSet)
        {
            if (featureSet == null)
            {
                return(null);
            }

            featureSet.ProgressHandler = ProgressHandler;
            IMapFeatureLayer res = null;

            if (featureSet.FeatureType == FeatureType.Point || featureSet.FeatureType == FeatureType.MultiPoint)
            {
                res = new MapPointLayer(featureSet);
            }
            else if (featureSet.FeatureType == FeatureType.Line)
            {
                res = new MapLineLayer(featureSet);
            }
            else if (featureSet.FeatureType == FeatureType.Polygon)
            {
                res = new MapPolygonLayer(featureSet);
            }

            if (res != null)
            {
                base.Add(res);
                res.ProgressHandler = ProgressHandler;
            }

            return(res);
        }
 /// <summary>
 /// This overload automatically constructs a new MapLayer from the specified
 /// feature layer with the default drawing characteristics and returns a valid
 /// IMapLayer which can be further cast into a PointLayer, MapLineLayer or
 /// a PolygonLayer, depending on the data that is passed in.
 /// </summary>
 /// <param name="featureSet">Any valid IFeatureSet that does not yet have drawing characteristics</param>
 /// <returns>A newly created valid implementation of FeatureLayer which at least gives a few more common
 /// drawing related methods and can also be cast into the appropriate Point, Line or Polygon layer.</returns>
 public virtual IMapFeatureLayer Add(IFeatureSet featureSet)
 {
     if (featureSet == null)
     {
         return(null);
     }
     featureSet.ProgressHandler = ProgressHandler;
     if (featureSet.FeatureType == FeatureType.Point || featureSet.FeatureType == FeatureType.MultiPoint)
     {
         IMapPointLayer pl = new MapPointLayer(featureSet);
         base.Add(pl);
         pl.ProgressHandler = ProgressHandler;
         return(pl);
     }
     if (featureSet.FeatureType == FeatureType.Line)
     {
         IMapLineLayer ll = new MapLineLayer(featureSet);
         base.Add(ll);
         ll.ProgressHandler = ProgressHandler;
         return(ll);
     }
     if (featureSet.FeatureType == FeatureType.Polygon)
     {
         IMapPolygonLayer pl = new MapPolygonLayer(featureSet);
         base.Add(pl);
         pl.ProgressHandler = ProgressHandler;
         return(pl);
     }
     return(null);
     //throw new NotImplementedException("Right now only point types are supported.");
 }
        private static Layer GetPolygonLayer(dynamic layer)
        {
            MapPolygonLayer polyLayer = new MapPolygonLayer(FeatureSet.OpenFile(layer["Path"]));
            LegacyDeserializer.DeserializeLayer(layer, polyLayer);

            return polyLayer;
        }
Esempio n. 6
0
        /// <summary>
        /// This is the strong typed version of the same process that is specific to geo point layers.
        /// </summary>
        /// <param name="result">The new GeoPointLayer to be created.</param>
        /// <returns>Boolean, true if there were any values in the selection.</returns>
        public virtual bool CreateLayerFromSelectedFeatures(out MapPolygonLayer result)
        {
            result = null;
            if (Selection == null || Selection.Count == 0)
            {
                return(false);
            }
            FeatureSet fs = Selection.ToFeatureSet();

            result = new MapPolygonLayer(fs);

            return(true);
        }
Esempio n. 7
0
        /// <summary>
        /// Deserializes the layer.
        /// </summary>
        /// <param name="layer">The layer.</param>
        /// <param name="polyLayer">The poly layer.</param>
        internal static void DeserializeLayer(dynamic layer, MapPolygonLayer polyLayer)
        {
            if (UseAlternateParser(layer))
            {
                DeserializeLayerAlternateVersion(layer.ShapefileProperties, polyLayer);
                return;
            }
            var polySymbolizer = new PolygonSymbolizer();
            var outlineColor = LegacyDeserializer.GetColor(layer.ShapeFileProperties["OutLineColor"]);
            var outlineWidth = Convert.ToDouble(layer.ShapeFileProperties["LineOrPointSize"]);
            polySymbolizer.SetOutline(outlineColor, outlineWidth);
            if (Convert.ToBoolean(layer.ShapeFileProperties["DrawFill"]))
            {
                Color color = LegacyDeserializer.GetColor(layer.ShapeFileProperties["Color"]);
                float transparency = Convert.ToSingle(layer.ShapeFileProperties["TransparencyPercent"]);
                color = color.ToTransparent(transparency);
                polySymbolizer.SetFillColor(color);
            }
            else
            {
                polySymbolizer.SetFillColor(Color.Transparent);
            }

            polyLayer.Symbolizer = polySymbolizer;
            try
            {
                int fieldIndex = Convert.ToInt32(layer.ShapeFileProperties.Legend["FieldIndex"]);

                // we have to clear the categories or the collection ends up with a default item
                polyLayer.Symbology.Categories.Clear();

                foreach (var colorBreak in layer.ShapeFileProperties.Legend.ColorBreaks.Elements())
                {
                    PolygonCategory category;

                    string startValue = colorBreak["StartValue"];
                    string endValue = colorBreak["EndValue"];

                    if (startValue == endValue)
                    {
                        category = new PolygonCategory(LegacyDeserializer.GetColor(colorBreak["StartColor"]), LegacyDeserializer.GetColor(colorBreak["StartColor"]), 0);
                        category.FilterExpression = String.Format("[{0}] = '{1}'", polyLayer.DataSet.DataTable.Columns[fieldIndex].ColumnName, startValue);
                        category.LegendText = startValue;
                    }
                    else
                    {
                        category = new PolygonCategory(LegacyDeserializer.GetColor(colorBreak["StartColor"]), LegacyDeserializer.GetColor(colorBreak["EndColor"]), 0, GradientType.Linear, outlineColor, outlineWidth);
                        category.FilterExpression = String.Format("'{2}' >= [{0}] >= '{1}'", polyLayer.DataSet.DataTable.Columns[fieldIndex].ColumnName, startValue, endValue);
                        category.LegendText = String.Format("{0} - {1}", startValue, endValue);
                    }
                    category.LegendText = startValue;
                    category.LegendItemVisible = Convert.ToBoolean(colorBreak["Visible"]);
                    polyLayer.Symbology.AddCategory(category);
                }

                // it took too a lot of work to figure out that we would need to do this...
                polyLayer.ApplyScheme(polyLayer.Symbology);
            }
            catch (RuntimeBinderException)
            {
                // ignore and continue.
                // this means the legend is not available.
            }
        }
Esempio n. 8
0
        private static void DeserializeLayerAlternateVersion(dynamic shapefileProperties, MapPolygonLayer polyLayer)
        {
            var polySymbolizer = new PolygonSymbolizer();
            var outlineColor = LegacyDeserializer.GetColor(shapefileProperties.DefaultDrawingOptions["LineColor"]);
            var outlineWidth = Convert.ToDouble(shapefileProperties.DefaultDrawingOptions["LineWidth"]);
            polySymbolizer.SetOutline(outlineColor, outlineWidth);
            if (Convert.ToBoolean(shapefileProperties.DefaultDrawingOptions["FillVisible"]))
            {
                Color color = LegacyDeserializer.GetColor(shapefileProperties.DefaultDrawingOptions["FillBgColor"]);
                float transparency = Convert.ToInt32(shapefileProperties.DefaultDrawingOptions["FillTransparency"]) / 255f;
                color = color.ToTransparent(transparency);
                polySymbolizer.SetFillColor(color);
            }
            else
            {
                polySymbolizer.SetFillColor(Color.Transparent);
            }

            polyLayer.Symbolizer = polySymbolizer;
        }
Esempio n. 9
0
        public void SetLayer(IFeatureSet value)
        {
            IMapLayer mapR = null;
            foreach (IMapLayer ra in map1.GetPolygonLayers())
            {
                if (ra.LegendText != "point" && ra.LegendText != "line" && ra.LegendText != "polygon" && ra.LegendText != "cross")
                mapR = ra;
            }
            if (mapR != null)
                map1.Layers.Remove(mapR);


            this._polygon = value;

            IMapPolygonLayer mp = new MapPolygonLayer(value);
            mp.Symbolizer = new PolygonSymbolizer();
            mp.Symbolizer.SetOutline(Color.Green, 1.0);
            mp.Symbolizer.SetFillColor(Color.Transparent);
            map1.Layers.Add(mp);

        }
Esempio n. 10
0
        private void AddLayers(string type)
        {
            if (type == "cross" || type == "all")
            {
                idcross = new FeatureSet(FeatureType.Line);
                idcross.Projection = proj;
                idcross.Name = "cross";
                IMapLineLayer ml = new MapLineLayer(idcross);
                ml.Symbolizer = new LineSymbolizer();
                ml.Symbolizer.SetFillColor(Color.Red);

                map1.Layers.Add(ml);
            }


            if (type == "point" || type == "all")
            {
                pointSelect = new FeatureSet(FeatureType.Point);
                pointSelect.Projection = proj;
                pointSelect.Name = "point";
                IMapPointLayer mp = new MapPointLayer(pointSelect);
                mp.Symbolizer = new PointSymbolizer();
                mp.Symbolizer.SetSize(new Size2D(5, 5));
                mp.Symbolizer.SetOutline(Color.Blue, 1.0);
                mp.Symbolizer.SetFillColor(Color.Blue);
                map1.Layers.Add(mp);
            }
             if (type == "line" || type == "all")
            {
                cross = new FeatureSet(FeatureType.Line);
                cross.Projection = proj;
                cross.Name = "line";
             IMapLineLayer ml = new MapLineLayer(cross);
             ml.Symbolizer = new LineSymbolizer();
             ml.Symbolizer.SetOutline(Color.Magenta, 1.0);
             map1.Layers.Add(ml);
             }

             if (type == "polygon" || type == "all")
             {
                 poly = new FeatureSet(FeatureType.Polygon);
                 poly.Projection = proj;
                 poly.Name = "polygon";
                 IMapPolygonLayer my = new MapPolygonLayer(poly);
                 my.Symbolizer = new PolygonSymbolizer();
                 my.Symbolizer.SetOutline(Color.Maroon, 1.0);
                 my.Symbolizer.SetFillColor(Color.Transparent);
                 map1.Layers.Add(my);
             }

            
           
            
            
        
        }
Esempio n. 11
0
        /// <summary>
        /// This is the strong typed version of the same process that is specific to geo point layers.
        /// </summary>
        /// <param name="result">The new GeoPointLayer to be created</param>
        /// <returns>Boolean, true if there were any values in the selection</returns>
        public virtual bool CreateLayerFromSelectedFeatures(out MapPolygonLayer result)
        {
            result = null;
            if (Selection == null || Selection.Count == 0) return false;
            FeatureSet fs = Selection.ToFeatureSet();
            result = new MapPolygonLayer(fs);

            return true;
        }
Esempio n. 12
0
 /// <summary>
 /// This overload automatically constructs a new MapLayer from the specified
 /// feature layer with the default drawing characteristics and returns a valid
 /// IMapLayer which can be further cast into a PointLayer, MapLineLayer or
 /// a PolygonLayer, depending on the data that is passed in.
 /// </summary>
 /// <param name="featureSet">Any valid IFeatureSet that does not yet have drawing characteristics</param>
 /// <returns>A newly created valid implementation of FeatureLayer which at least gives a few more common
 /// drawing related methods and can also be cast into the appropriate Point, Line or Polygon layer.</returns>
 public virtual IMapFeatureLayer Add(IFeatureSet featureSet)
 {
     if (featureSet == null) return null;
     featureSet.ProgressHandler = ProgressHandler;
     if (featureSet.FeatureType == FeatureType.Point || featureSet.FeatureType == FeatureType.MultiPoint)
     {
         IMapPointLayer pl = new MapPointLayer(featureSet);
         base.Add(pl);
         pl.ProgressHandler = ProgressHandler;
         return pl;
     }
     if (featureSet.FeatureType == FeatureType.Line)
     {
         IMapLineLayer ll = new MapLineLayer(featureSet);
         base.Add(ll);
         ll.ProgressHandler = ProgressHandler;
         return ll;
     }
     if (featureSet.FeatureType == FeatureType.Polygon)
     {
         IMapPolygonLayer pl = new MapPolygonLayer(featureSet);
         base.Add(pl);
         pl.ProgressHandler = ProgressHandler;
         return pl;
     }
     return null;
     //throw new NotImplementedException("Right now only point types are supported.");
 }
Esempio n. 13
0
        /// <summary>
        /// Creates a new raster with the specified cell size.  If the cell size
        /// is zero, this will default to the shorter of the width or height
        /// divided by 256.  If the cell size produces a raster that is greater
        /// than 8, 000 pixels in either dimension, it will be re-sized to
        /// create an 8, 000 length or width raster.
        /// </summary>
        /// <param name="fs">The featureset to convert to a raster.</param>
        /// <param name="extent">Force the raster to this specified extent.</param>
        /// <param name="cellSize">The double extent of the cell.</param>
        /// <param name="fieldName">The integer field index of the file.</param>
        /// <param name="outputFileName">The fileName of the raster to create.</param>
        /// <param name="driverCode">The optional GDAL driver code to use if using GDAL
        /// for a format that is not discernable from the file extension.  An empty string
        ///  is usually perfectly acceptable here.</param>
        /// <param name="options">For GDAL rasters, they can be created with optional parameters
        ///  passed in as a string array.  In most cases an empty string is perfectly acceptable.</param>
        /// <param name="progressHandler">An interface for handling the progress messages.</param>
        /// <returns>Generates a raster from the vectors.</returns>
        public static IRaster ToRaster(IFeatureSet fs, Extent extent, double cellSize, string fieldName,
                                       string outputFileName,
                                       string driverCode, string[] options, IProgressHandler progressHandler)
        {
            Extent env = extent;
            if (cellSize == 0)
            {
                if (env.Width < env.Height)
                {
                    cellSize = env.Width / 256;
                }
                else
                {
                    cellSize = env.Height / 256;
                }
            }
            int w = (int)Math.Ceiling(env.Width / cellSize);
            if (w > 8000)
            {
                w = 8000;
                cellSize = env.Width / 8000;
            }
            int h = (int)Math.Ceiling(env.Height / cellSize);
            if (h > 8000)
            {
                h = 8000;
            }
            Bitmap bmp = new Bitmap(w, h);
            Graphics g = Graphics.FromImage(bmp);
            g.Clear(Color.Transparent);
            g.SmoothingMode = SmoothingMode.None;
            g.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
            g.InterpolationMode = InterpolationMode.NearestNeighbor;
            Hashtable colorTable;
            MapArgs args = new MapArgs(new Rectangle(0, 0, w, h), env, g);

            switch (fs.FeatureType)
            {
                case FeatureType.Polygon:
                    {
                        MapPolygonLayer mpl = new MapPolygonLayer(fs);
                        PolygonScheme ps = new PolygonScheme();
                        colorTable = ps.GenerateUniqueColors(fs, fieldName);
                        mpl.Symbology = ps;
                        mpl.DrawRegions(args, new List<Extent> { env });
                    }
                    break;
                case FeatureType.Line:
                    {
                        MapLineLayer mpl = new MapLineLayer(fs);
                        LineScheme ps = new LineScheme();
                        colorTable = ps.GenerateUniqueColors(fs, fieldName);
                        mpl.Symbology = ps;
                        mpl.DrawRegions(args, new List<Extent> { env });
                    }
                    break;
                default:
                    {
                        MapPointLayer mpl = new MapPointLayer(fs);
                        PointScheme ps = new PointScheme();
                        colorTable = ps.GenerateUniqueColors(fs, fieldName);
                        mpl.Symbology = ps;
                        mpl.DrawRegions(args, new List<Extent> { env });
                    }
                    break;
            }
            Type tp = fieldName == "FID" ? typeof(int) : fs.DataTable.Columns[fieldName].DataType;
            // We will try to convert to double if it is a string
            if (tp == typeof(string))
            {
                tp = typeof(double);
            }
            InRamImageData image = new InRamImageData(bmp, env);
            ProgressMeter pm = new ProgressMeter(progressHandler, "Converting To Raster Cells", h);

            IRaster output;
            output = Raster.Create(outputFileName, driverCode, w, h, 1, tp, options);
            output.Bounds = new RasterBounds(h, w, env);

            double noDataValue = output.NoDataValue;

            if (fieldName != "FID")
            {
                // We can't use this method to calculate Max on a non-existent FID field.
                double dtMax = Convert.ToDouble(fs.DataTable.Compute("Max(" + fieldName + ")", ""));
                double dtMin = Convert.ToDouble(fs.DataTable.Compute("Min(" + fieldName + ")", ""));

                if (dtMin <= noDataValue && dtMax >= noDataValue)
                {
                    if (dtMax != GetFieldValue(tp, "MaxValue"))
                    {
                        output.NoDataValue = noDataValue;
                    }
                    else if (dtMin != GetFieldValue(tp, "MinValue"))
                    {
                        output.NoDataValue = noDataValue;
                    }
                }
            }

            List<RcIndex> locations = new List<RcIndex>();
            List<string> failureList = new List<string>();
            for (int row = 0; row < h; row++)
            {
                for (int col = 0; col < w; col++)
                {
                    Color c = image.GetColor(row, col);
                    if (c.A == 0)
                    {
                        output.Value[row, col] = output.NoDataValue;
                    }
                    else
                    {
                        if (colorTable.ContainsKey(c) == false)
                        {
                            if (c.A < 125)
                            {
                                output.Value[row, col] = output.NoDataValue;
                                continue;
                            }

                            // Use a color matching distance to pick the closest member
                            object val = GetCellValue(w, h, row, col, image, c, colorTable, locations);

                            output.Value[row, col] = GetDouble(val, failureList);
                        }
                        else
                        {
                            output.Value[row, col] = GetDouble(colorTable[c], failureList);
                        }
                    }
                }
                pm.CurrentValue = row;
            }
            const int maxIterations = 5;
            int iteration = 0;
            while (locations.Count > 0)
            {
                List<RcIndex> newLocations = new List<RcIndex>();
                foreach (RcIndex location in locations)
                {
                    object val = GetCellValue(w, h, location.Row, location.Column, image,
                                              image.GetColor(location.Row, location.Column), colorTable, newLocations);
                    output.Value[location.Row, location.Column] = GetDouble(val, failureList);
                }
                locations = newLocations;
                iteration++;
                if (iteration > maxIterations)
                {
                    break;
                }
            }

            pm.Reset();
            return output;
        }
        public void Deserialize(dynamic xmlRoot)
        {
            var mapwin4Section = xmlRoot.MapWindow4;
            var mapwingisSection = xmlRoot.MapWinGIS;

            _map.MapFrame.ProjectionString = mapwin4Section["ProjectProjection"];

            if (!Convert.ToBoolean(mapwin4Section["ViewBackColor_UseDefault"]))
            {
                var mapControl = _map as Control;
                if (mapControl != null)
                    mapControl.BackColor = LegacyDeserializer.GetColor(mapwin4Section["ViewBackColor"]);

                _map.Invalidate();
            }

            // Deserialize layers
            var layersDescs = mapwingisSection.Layers.Elements();
            var allLayers = new Dictionary<int, List<ILayer>>(); // key: Group Name. Value: layers
            foreach (var layer in mapwin4Section.Layers.Elements())
            {
                var name = (string)layer["Name"];
                var groupInd = Convert.ToInt32(layer["GroupIndex"]);
                if (!allLayers.ContainsKey(groupInd)) allLayers[groupInd] = new List<ILayer>();
                var listLayers = allLayers[groupInd];
                
                IMapLayer layerToAdd = null;
                foreach (var layersDesc in layersDescs)
                {
                    if (layersDesc["LayerName"] == name)
                    {
                        var lt = (string) layersDesc["LayerType"]; 
                        switch (lt)
                        {
                            case "Image":
                                layerToAdd = new MapImageLayer(ImageData.Open(layersDesc["Filename"]));
                                break;
                            case "Shapefile":
                                var fs = FeatureSet.OpenFile(layersDesc["Filename"]);
                                if (fs is PointShapefile)
                                {
                                    layerToAdd = new MapPointLayer(fs);
                                }
                                else if (fs is PolygonShapefile)
                                {
                                    layerToAdd = new MapPolygonLayer(fs);
                                }
                                else if (fs is LineShapefile)
                                {
                                    layerToAdd = new MapLineLayer(fs);
                                }
                                else
                                {
                                    Trace.WriteLine("Unsupported FeatureSet Type: " + fs.GetType());
                                }
                                break;
                            default:
                                Trace.WriteLine("Unsupported LayerType: " + lt);
                                break;
                        }
                        break;
                    }
                }

                if (layerToAdd != null)
                {
                    layerToAdd.IsExpanded = Convert.ToBoolean(layer["Expanded"]);
                    listLayers.Add(layerToAdd);
                }
            }

            // Deserialize groups
            foreach (var group in mapwin4Section.Groups.Elements())
            {
                var gInd = Convert.ToInt32(group["Position"]);
                var g = new MapGroup
                {
                    LegendText = group["Name"],
                    IsExpanded = Convert.ToBoolean(group["Expanded"])
                };
                List<ILayer> gl;
                if (allLayers.TryGetValue(gInd, out gl))
                {
                    foreach (var layer in gl)
                    {
                       g.Add(layer);
                    }
                }
                _map.MapFrame.Layers.Add(g);
            }
        }
Esempio n. 15
0
        /// <summary>
        /// This overload automatically constructs a new MapLayer from the specified
        /// feature layer with the default drawing characteristics and returns a valid
        /// IMapLayer which can be further cast into a PointLayer, MapLineLayer or
        /// a PolygonLayer, depending on the data that is passed in.
        /// </summary>
        /// <param name="featureSet">Any valid IFeatureSet that does not yet have drawing characteristics</param>
        /// <returns>A newly created valid implementation of FeatureLayer which at least gives a few more common
        /// drawing related methods and can also be cast into the appropriate Point, Line or Polygon layer.</returns>
        public virtual IMapFeatureLayer Add(IFeatureSet featureSet)
        {
            if (featureSet == null) return null;

            featureSet.ProgressHandler = ProgressHandler;
            IMapFeatureLayer res = null;
            if (featureSet.FeatureType == FeatureType.Point || featureSet.FeatureType == FeatureType.MultiPoint)
            {
                res = new MapPointLayer(featureSet);
            }
            else if (featureSet.FeatureType == FeatureType.Line)
            {
                res = new MapLineLayer(featureSet);
            }
            else if (featureSet.FeatureType == FeatureType.Polygon)
            {
                res = new MapPolygonLayer(featureSet);
            }
            if (res != null)
            {
                base.Add(res);
                res.ProgressHandler = ProgressHandler;
            }

            return res;
        }
Esempio n. 16
0
 public bool GridLayerIsInMap()
 {
     foreach (IMapLayer lay in _mainMap.GetAllLayers())
     {
         if (lay.LegendText == "Grid")
         {
             _GridLayer = (MapPolygonLayer)lay;
             return true;
         }
     }
     return false;
 }
Esempio n. 17
0
        public void AddLayer()
        {
            if (GridLayerIsInMap())
            {
                _GridLayer.DataSet.Features.Clear();
            }
            else
            {
                rectangleFs = new FeatureSet(FeatureType.Polygon);
                rectangleFs.DataTable.Columns.Add("polygonID");
                rectangleFs.DataTable.Columns.Add("row");
                rectangleFs.DataTable.Columns.Add("col");
                rectangleFs.DataTable.Columns.Add(new System.Data.DataColumn("Value", typeof(double)));
                rectangleFs.DataTable.Columns.Add(new System.Data.DataColumn("Number", typeof(int)));
                rectangleFs.DataTable.Columns.Add("R");
                rectangleFs.DataTable.Columns.Add("G");
                rectangleFs.DataTable.Columns.Add("B");
                rectangleFs.Projection = _mainMap.Projection;

                _GridLayer = new MapPolygonLayer(rectangleFs);
                _GridLayer.LegendText = "Grid";

                //_rectangleLayer.LegendItemVisible = false;
                Color redColor = Color.Red.ToTransparent(0.8f);
                _GridLayer.Symbolizer = new PolygonSymbolizer();
                // 
                _GridLayer.Symbolizer.SetOutline(Color.Red, 1.0);
                _GridLayer.Symbolizer.SetFillColor(Color.Transparent);
                _GridLayer.SelectionSymbolizer = _GridLayer.Symbolizer;
                _GridLayer.Symbolizer.SetOutline(Color.Red, 1.0);
                // Extent ext = this.GetExtent(0.15);
                _mainMap.Layers.Add(_GridLayer);
                // _mainMap.ViewExtents = ext;

            }

            if (!GridLayerIsInMap())
            {
                //    Extent ext = this.GetExtent(0.15);
                _mainMap.Layers.Add(_GridLayer);
                //   _mainMap.ViewExtents = ext;
            }
        }