How Draw Geometry Collection

Jan 3, 2011 at 4:24 PM


As I can draw a collection of geometries with DotSpatial.

I want to draw with Dotspatial a figure with a circle and a line that represents a circuit breaker in an electrical network (geografic mode)

I try  with the following code but DotSpatial dont draws nothing.


                LineString line1=new LineString(points);
                LineString line2 = new LineString(points);            
                IBasicGeometry p = new Feature(new Coordinate(lastx, lasty));
                List<IBasicGeometry> group=new List<IBasicGeometry>();

                GeometryCollection gcol = new GeometryCollection(group,line1.Factory);
                Feature f = new Feature(gcol);





Thanks for any help,


Jan 3, 2011 at 4:55 PM

Try feature.InitializeVertices() after you have added your feature f.  You might want to try _Map.Layers.Add(feature) instead of f.  You should be adding the whole feature set there instead of just one feature I think.  It also looks like line1 and line2 use the same points, though that shouldn't cause a problem.  Also make sure that you are zoomed to the extent of your feature.  In other words, depending on the coordinates added, the view may or may not be focused on your new shapes.  You can control this by setting the  _Map.ViewExtents.



Jan 4, 2011 at 12:40 PM

Hi, Ted tanks for your anwers,

Looking in debug mode, when i add the new GeometricCollection Layer this is not created for the FeatureType, which in this case is FeatureType.Unspecified.

In the method MapLayerCollection. Add(IFeatureSet featureSet) is verified the FeatureType and for Type Unspecified the layer is not created. this is deliberate or is pending issues. 

I want draw por the each elements in the Electrical  Network appropriate symbols for examples; Transformers =Rectangle + line, Circuit Breaker = line + Rectangle, Bridge=line + circle. I want for each one, one feateure and one datarow for electrical propierties.

I work for a electric utility in Colombia and we are exploring using DotSpatial to show  results of electric network planning, gladly  to share the work when ready





Jan 4, 2011 at 3:09 PM

You can specify the feature type in the constructor of the FeatureSet.  FeatureSet fs = new FeatureSet(FeatureType.Line);

Theoretically this is also specified by the first feature that you add to the set if the feature type is unspecified, but there may be something wierd about how you are creating your features so that their feature type is also not specified or whatever.  Anyway, once you specify this it should work fine.