Quantcast
Channel: DotSpatial
Viewing all 3973 articles
Browse latest View live

New Post: Some advice on adding open streetmap to my project

$
0
0
No, it does not.
There are classes that can parse WMS Server results.
WebMap plugins WMS capabilities are based on these.

New Comment on "Developer Getting Started"

$
0
0
I code in VB.NET and having a hard time following the C# code. Does this Getting Started Guide have a finished .NET solution so that I can convert to .NET? Thanks.

New Post: Getting Started Guide in VB.NET

$
0
0
I code in VB.NET and am having a hard time following the C# code. Does the Getting Started Guide have a finished .NET solution so that I can convert to VB.NET? NOt the tutorials but the Getting Started Guide.

New Comment on "Developer Getting Started"

$
0
0
I code in VB.NET and having a hard time following the C# code. Does this Getting Started Guide have a finished C# solution so that I can convert to VB.NET? Thanks.

New Post: How to use AddShapeFunction and MoveVertexFunction in Plugins?

$
0
0
Hi everybody,

Please show me how to use AddShapeFunction and MoveVertexFunction in Plugins!

Kind Regards
Lanmta

New Post: Adding Labels to a MapPointLayer stops selection being possible

$
0
0
Hi,

I have a super simple prototype app illustrating my problem which you can download from here:

https://dl.dropboxusercontent.com/u/2497368/PlanningPrototype.zip

I have an app that allows me to switch between SelectionMode and my own "Add Points Mode" using the S and P keys:
        private void MapContainer_OnKeyUp(object sender, KeyEventArgs e)
        {
            _ignoreClick = true;
            if (e.Key == Key.P)
            {
                _ignoreClick = false;
                _map.FunctionMode = FunctionMode.None;
                _map.Cursor = Cursors.Cross;
            }
            if (e.Key == Key.S)
            {
                _map.FunctionMode = FunctionMode.Select;
            }
        }
I'm setting up a MapPointLayer like so:
            _featureSet = new FeatureSet(FeatureType.Point);
            DataColumn column = new DataColumn("PointID");
            _featureSet.DataTable.Columns.Add(column);

            _pointLayer = (MapPointLayer)_map.Layers.Add(_featureSet);
            _pointLayer.Symbolizer = new PointSymbolizer(System.Drawing.Color.Red, DotSpatial.Symbology.PointShape.Star, 30);
            _pointLayer.SelectionSymbolizer = new PointSymbolizer(System.Drawing.Color.Yellow, DotSpatial.Symbology.PointShape.Star, 30);
Then I'm subscribing to the GeoMouseMove event and Click event of the Map:
        private void MapOnMouseMove(object sender, GeoMouseArgs geoMouseArgs)
        {
            // Storing this as it doesn't seem to be available in the Click event
            _geoMouseArgs = geoMouseArgs;  
        }

        void MapOnClick(object sender, EventArgs e)
        {
            if (_ignoreClick) return;

            Coordinate coord = _map.PixelToProj(_geoMouseArgs.Location);
            Point point = new Point(coord);
            IFeature feature = _featureSet.AddFeature(point);
            feature.DataRow["PointID"] = _pointId++;

            _map.ResetBuffer();
        }
This all works fine, although the selection tool doesn't work quite as expected. If I add 3 points to the map and then use the selection tool to select one of them; when I select another one, the first one doesn't unselect. Strange, but I can get around it with a call to _pointLayer.UnSelectAll() in the Click handler.

Next I try to add labels by adding this after I setup the MapPointLayer:
            _labelLayer = new MapLabelLayer(_pointLayer);
            _labelLayer.FeatureLayer = (IMapFeatureLayer)_pointLayer;
            _labelLayer.FeatureSet = _featureSet;
            _labelLayer.Symbology.Categories[0].Expression = "[PointID]";
            _labelLayer.Symbolizer.FontSize = 8F;
            _labelLayer.Symbolizer.BorderVisible = false;
            _labelLayer.Symbolizer.DropShadowEnabled = false;
            _labelLayer.Symbolizer.OffsetX = 20;
            _pointLayer.LabelLayer = _labelLayer;
            _pointLayer.ShowLabels = true;
This does one of two things, it stops the points from being selectable at all, and it only adds a label to the first point, none of the remaining points receive a label. I seem to be able to fix the remaining labels by adding this to the end of the Click handler:
            _featureSet.ShapeIndices = null;
            _featureSet.UpdateExtent();
            _pointLayer.AssignFastDrawnStates();
            _labelLayer.CreateLabels();
However I still can't select my points!

Any ideas?

Thanks,
Anthony

New Post: Adding Labels to a MapPointLayer stops selection being possible

$
0
0
I've just realised that the points ARE being selected, but for some reason adding the label layer stops the SelectionSymbolizer from being displayed. If I check the Selection.Count for the layer, then the points are selected, but the symbol never changes.

New Post: How do I create static labels around map1 for grid features?

$
0
0
I have the code below that generates a gridline X and gridline Y features and adds them to the map and then adds the field 'x' and field 'y' for labeling.

I am able to label these two grid features but its placed on the line.
I would want the labels to be static around the map1 like having tick marks with labels so that when I zoomin or zoomOut, the grid labels would still be at that same place.

Please, I would be very happy if anyone can help me with this.

The codes are below:

Feature f = new Feature();
        FeatureSet fs = new FeatureSet(f.FeatureType);

        Feature fz = new Feature();
        FeatureSet fsz = new FeatureSet(f.FeatureType);


        double minX, minY, maxX, maxY;
        minX = 400000.000;

        double stepX, stepY;
        stepX = 2000;
        stepY = 2000;
        minY = 0.00;
        maxY = 4000000;
        //maxY = map1.ClientSize.Height - 70;
        maxX = 4000000;
        //maxX = map1.ClientSize.Width - 10;

        List<DotSpatial.Topology.LineString> lines = new List<DotSpatial.Topology.LineString>();

        fs.DataTable.Columns.Add("y");


        //create the lines running from top to bottom
        for (double currX = minX; currX < maxX + stepX; currX += stepX)
        {
            DotSpatial.Topology.Point point1, point2;
            point1 = new DotSpatial.Topology.Point(currX, minY);
            point2 = new DotSpatial.Topology.Point(currX, maxY);
            LineString line = new LineString(new List<DotSpatial.Topology.Point>(new DotSpatial.Topology.Point[] { point1, point2 }));
            lines.Add(line);

            //dr["id"] = shapeIndex;

            f = new Feature(line);
            fs.Features.Add(f);





        }

        double currX_value = minX;
        foreach (DataRow dr in fs.DataTable.Rows)
        {
            dr["y"] = currX_value += stepX;


        }
        //map1.Layers.Add(fs);
        MapLineLayer lineLayery = (MapLineLayer)map1.Layers.Add(fs);   //add the featureSet as map layer
        lineLayery.LegendText = "GridlineY";
        lineLayery.Symbolizer = new LineSymbolizer(Color.Red, 1);

        IMapLabelLayer labelLayer = new MapLabelLayer(); ILabelCategory category = labelLayer.Symbology.Categories[0]; category.Expression = "[x]";
        category.Symbolizer.Orientation = ContentAlignment.MiddleCenter; lineLayery.ShowLabels = true;
        lineLayery.LabelLayer = labelLayer;


        fsz.DataTable.Columns.Add("x");
        //create the lines running from left to right
        for (double currY = minY; currY < maxY + stepY; currY += stepY)
        {
            DotSpatial.Topology.Point point1, point2;
            point1 = new DotSpatial.Topology.Point(minX, currY);
            point2 = new DotSpatial.Topology.Point(maxX, currY);
            LineString line = new LineString(new List<DotSpatial.Topology.Point>(new DotSpatial.Topology.Point[] { point1, point2 }));
            lines.Add(line);



            fz = new Feature(line);
            fsz.Features.Add(fz);


        }

        double currY_value = minY;
        foreach (DataRow dr in fsz.DataTable.Rows)
        {
            dr["x"] = currY_value += stepY;


        }
        ProjectionInfo dest = default(ProjectionInfo);
        //add the line to the feature set
        MapLineLayer lineLayer = (MapLineLayer)map1.Layers.Add(fsz);   //add the featureSet as map layer
        lineLayer.LegendText = "GridlineX";
        lineLayer.Symbolizer = new LineSymbolizer(Color.Blue, 1);
        //dest = KnownCoordinateSystems.Projected.NationalGrids.AccraGhanaGrid;
        //fsz.Projection = dest;
        //fs.Projection = dest;
        IMapLabelLayer labelLayer1 = new MapLabelLayer(); ILabelCategory category1 = labelLayer.Symbology.Categories[0]; category.Expression = "[y]";
        category.Symbolizer.Orientation = ContentAlignment.MiddleCenter; lineLayer.ShowLabels = true;
        lineLayer.LabelLayer = labelLayer1;

New Post: Getting Started Guide in VB.NET

$
0
0
As far as I know there is not Vb.Net version of the Getting Started Guide. But there are some good websites for converting code from c# to vb.net. I think those should help you to understand the Getting Started Guide.

New Post: Getting Started Guide in VB.NET

New Post: Split a polyline at a certain point

$
0
0
Need suggestions as to how to split a polyline at a point

Created Unassigned: Having Problem With Creating Polygone Shapefile(Closed Polygone) [63624]

$
0
0
hello, i have a question,when i worked with dotspatial reference in c# i founded that when you create a polygone shapefile and save it you see that the last line dose not save and we have not a complete polygone layer,please answer,i attached the created polygone shapefile and used codes and filles and methods,Please check my polygone shapefile in attached file and answer why we can not create the closed and complete polygone with dotspatial topology refrences,thanks,

Reviewed: DotSpatial 1.8 (Apr 10, 2016)

$
0
0
Rated 5 Stars (out of 5) - Excellent for GIS And Geomatics

Commented Unassigned: Having Problem With Creating Polygone Shapefile(Closed Polygone) [63624]

$
0
0
hello, i have a question,when i worked with dotspatial reference in c# i founded that when you create a polygone shapefile and save it you see that the last line dose not save and we have not a complete polygone layer,please answer,i attached the created polygone shapefile and used codes and filles and methods,Please check my polygone shapefile in attached file and answer why we can not create the closed and complete polygone with dotspatial topology refrences,thanks,
Comments: Polygons have to be closed by definition. That means the first and last point of a polygon have to be the same. Add ``` IFeature existingFeature = polygonF.Features[polygonF.Features.Count - 1]; existingFeature.Coordinates.Add(coord); ``` to the else part (mouse right click) of the polygon case of your map1_MouseDown function. This closes your polygon by adding the first point again as last point. It is not a good idea to add an polygon with only one coordinate to a polygon layer and hope the user adds at least 2 more coordinates afterwards. This causes defective polygons if your user stops editing before he has added 3 coordinates. It would be better to keep a temporary list of the coordinates and only add the polygon to the polygon layer if it has at least 3 differend coordinates and its IsSimple function returns true. Otherwise you have to make sure that your polygon becomes simple before you add it to a polygon layer. You can have a look at the source code of the shape editors [AddShapeFunction.cs](https://dotspatial.codeplex.com/SourceControl/latest#Trunk/DotSpatial.Plugins.ShapeEditor/AddShapeFunction.cs) if you want to know how creating polygons with a temporary list can be done.

New Post: Getting Started Guide in VB.NET

$
0
0
Thank you. I guess what I am saying is I know about the tools to convert C# to VB. However the guide itself has some things that I have never seen like the app manager loader. after some trial and error I think I got it.

Thanks,
~AGP

Created Unassigned: zoom in throws a StackOverflowException [63625]

$
0
0
When zooming in to an extent of less then 1e-7 in OnViewExtentsChanged of DotSpatial.Controls.Map, the ViewExtender will be caught in a infinite loop and will eventually throw a StockOverflowException.

This was achieved by scrolling in a couple of times on a shape.
Attached are the ViewExtents' values during the infinite loop.

Please have a look at this.
Cheers

New Post: NorthPoleStereographic projection

$
0
0
I am running the Tutorial5 dealing with setting the map to display different projections. Excellent work!!! I was hopinig for something like this. Now I have setup a map as follows:
            Map6.Projection = KnownCoordinateSystems.Projected.Polar.NorthPoleStereographic
            Map6.Projection.CentralMeridian = -180
            Map6.Projection.FalseEasting = 0
            Map6.Projection.FalseNorthing = 0
            Map6.Projection.ScaleFactor = 1
            Map6.Projection.LatitudeOfOrigin = 90
Then I load up a world country shapefile and a lat/lon shapefile. All the other maps show the full extents except the NorthPoleStereographic. Not sure what I am doing wrong.

~AGP

Commented Unassigned: zoom in throws a StackOverflowException [63625]

$
0
0
When zooming in to an extent of less then 1e-7 in OnViewExtentsChanged of DotSpatial.Controls.Map, the ViewExtender will be caught in a infinite loop and will eventually throw a StockOverflowException.

This was achieved by scrolling in a couple of times on a shape.
Attached are the ViewExtents' values during the infinite loop.

Please have a look at this.
Cheers
Comments: What DotSpatial version do you use? I'm running the latest changeset. You said you scrolled in on a shape when your error showed up. So I went and scrolled in on my map til I had an extent smaller than 1e-7 and then scrolled in another 1000 times by keeping the + key pressed. This runs the code shown in your screenshot without causing an error. If you're not running the latest changeset please download that and try whether you get your error again. If you're running the lastest changeset please tell me how to recreate your error.

New Post: NorthPoleStereographic projection

$
0
0
I think I got the hang of it. What I was not understanding was the Extents. So I created some coordinates in geographic format and then used Reproject.ReprojectPoints to project those coords to a new projection. Once I had the reprojected coordinates I created an Extent and set that to the map. So in pseudo code something like
Map6.ViewExtents = GenerateExtents(Map6.Projection)

    Private Function GenerateExtents(ByVal endProj As ProjectionInfo) As Extent
        'create the geographic coordinates of the bounding rectangle

        'now we reproject the coordinates to the target projection
       Reproject.ReprojectPoints(xy, z, KnownCoordinateSystems.Geographic.World.WGS1984, endProj, 0, 2)

        'create new extents and return as an object
        Dim exts As Extent = New Extent(coords1.X, coords1.Y, coords2.X, coords2.Y)
        Return exts
    End Function

Commented Unassigned: zoom in throws a StackOverflowException [63625]

$
0
0
When zooming in to an extent of less then 1e-7 in OnViewExtentsChanged of DotSpatial.Controls.Map, the ViewExtender will be caught in a infinite loop and will eventually throw a StockOverflowException.

This was achieved by scrolling in a couple of times on a shape.
Attached are the ViewExtents' values during the infinite loop.

Please have a look at this.
Cheers
Comments: Hi and thanks for your quick reply. I used the latest source code available on your website (also reproducible when using the compiled download). Attached is the callstack. Also, when limiting the zoom from __1e-7__ to __1e-4__ in __DotSpatial.Controls.Map.OnViewExtentsChanged__, there is no StackOverflowException.
Viewing all 3973 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>