This project is read-only.

Cant' Find DotSpatial.Geometries.dll

Aug 2, 2012 at 7:57 PM

Hi 

I am trying to follow a simple tutorial "Sample code that demonstrates how to create a Multi Polygon Feature Set" but I can not find the "DotSpatial.Geometries.dll"!

Can you please let me know where can I get it? 

Thanks

Aug 3, 2012 at 12:58 AM

The code probably needed to be updated to DotSpatial.Topology

 

If so, feel free to come back and let us know!

Aug 3, 2012 at 1:16 AM
Edited Aug 3, 2012 at 1:18 AM

Thanks mudnug,

It seems you are right and the DotSpatial.Topology.dll works instead of DotSpatial.Geometries.dll BUT I am getting following error:

The type initializer for 'DotSpatial.Topology.Polygon' threw an exception. at following line:

 pg[i] = new Polygon(coord);

Can you please let me know why this is happening?

Thanks,

Aug 3, 2012 at 10:03 PM

I notice that the sample doesn't create a MultiPolygon anything. It is just creating a series of polygons. Is that what you needed?

I would expect using a MultiPolygon to look more like

            const int NumberOfPolygons = 100;
            Random rnd = new Random();
            var polygonList = new List<Polygon>();
            using (FeatureSet fs = new FeatureSet(FeatureType.Polygon))
            {
                for (int i = 0; i < NumberOfPolygons; i++)
                {
                    const int NumberOfCoordinates = 50;
                    Coordinate center = new Coordinate((rnd.Next(50) * 360) - 180, (rnd.Next(60) * 180) - 90);
                    Coordinate[] coord = new Coordinate[NumberOfCoordinates];
                    for (int ii = 0; ii < NumberOfCoordinates; ii++)
                    {
                        coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10);
                    }
                    var polygon = new Polygon(coord);
                    polygonList.Add(polygon);
                }
                fs.Features.Add(new MultiPolygon(polygonList.ToArray()));

                fs.SaveAs("C:\\test.shp", true);
            }

I did run the following code which creates a number of polygons several ties without problems

 const int NumberOfPolygons = 100;
            Random rnd = new Random();
            
            using (FeatureSet fs = new FeatureSet(FeatureType.Polygon))
            {
                for (int i = 0; i < NumberOfPolygons; i++)
                {
                    const int NumberOfCoordinates = 50;
                    Coordinate center = new Coordinate((rnd.Next(50) * 360) - 180, (rnd.Next(60) * 180) - 90);
                    Coordinate[] coord = new Coordinate[NumberOfCoordinates];
                    for (int ii = 0; ii < NumberOfCoordinates; ii++)
                    {
                        coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10);
                    }

                    var polygon = new Polygon(coord);
                    fs.Features.Add(polygon);
                }

                fs.SaveAs("C:\\test2.shp", true);
            }

Aug 9, 2012 at 7:20 AM

Hi Mudnug,

Sorry for late reply, I was out of town for field data capturing so I couldn't check your comment.Basically what I want is generating polygons based on some UTM point data (with easting , northing values).I still didn't have enough time to test your code but diffidently I am not tying to generate random polygons.

thanks again