Iheritance from geometries

Topics: SharpMap v0.9 / v1.x
Aug 23, 2007 at 1:58 PM
Hi,

I got two questions!

First one:

In RenderGeometry I found that the check between what kind of primitive the geometries are of, is done byt cheking the full name of the object type agains the string corresponding to the object, as seen here below.
"
switch (feature.GetType().FullName)
{
case "SharpMap.Geometries.Polygon": ... DO RENDERING... break;
case .....
}

Wouln't it be better to use the "is" operator instead (see below), or am I missing something?

if(feature is SharpMap.Geometries.Polygon)
....DO RENDERING...


Second question:
What's the best way to go, in order to create my own primitves and have them rendered.
Such as making a geometry that has both graphics (symbol, img) as well as some text bound to it?



Coordinator
Aug 23, 2007 at 11:55 PM
Edited Aug 23, 2007 at 11:58 PM
Yes, this is a broken way to check the type. There had been someone else who had pointed this out a while ago, too. It's not this way in v2.0, but I don't have the time to fix the v1.0 code.

As for your second question, have you tried just creating your own geometry with the GeometryProvider? You can give it a list of Geometries and SharpMap will render it. Here is an example: Add a primitive geometry.