Welcome to MapForums!

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

## Shape Bug in MP 2006

This is a discussion on Shape Bug in MP 2006 within the MapPoint Desktop Discussion forums, part of the Map Forums category; I think I've found a bug in MapPoint 2006 when reading freeform/polyline shapes. These shapes are marked as 'closed' (ie. ...

1. ## Shape Bug in MP 2006

I think I've found a bug in MapPoint 2006 when reading freeform/polyline shapes. These shapes are marked as 'closed' (ie. a polygon rather than a polyline) when the first location is repeated at the end. That works well when creating a new shape, but I've found that the repeated location is not returned when you query the vertices of a shape.

Unless I'm having an end-of-day brain melt, I can't see a way of detecting if a shape is closed or not. (which is what I'm trying to do at the moment)

Here's some sample C# code to demonstrate what I mean. It creates a closed quadrilateral. This requires 5 vertices because the first location (loc1) is repeated at the end. It displays correctly. The vertices (locations) are queried through the Shape.Vertices property. This returns an array of Location objects. Only four locations are returned. I've checked the coordinates - each is represented once only. No duplication.

Code:
// Test locations
MapPoint.Location loc1 = myMap.GetLocation(30.0, -90.0, 100);
MapPoint.Location loc2 = myMap.GetLocation(35.0, -90.0,100);
MapPoint.Location loc3 = myMap.GetLocation(35.0, -95.0,100);
MapPoint.Location loc4 = myMap.GetLocation(30.0, -95.0,100);

MapPoint.Shape shp = myMap.Shapes.AddPolyline(new MapPoint.Location[] { loc1, loc2, loc3, loc4, loc1 });

// Query the shape
object[] vertices = shp.Vertices as object[];

MessageBox.Show("No. of vertices=" + Convert.ToString(vertices.Length));

Richard

2. ## Re: Shape Bug in MP 2006

I was investigating this some about six months ago... I couldn't find a way to tell whether it was closed or not.

For our purposes at the time, ultimately it did not matter as we always wanted it to be closed, so we could always read off the coordinates and when re-rendering the polygon we would always close it.

But it was still a little disturbing not to be able to detect whether an existing polygon is closed or not.

Eric

3. ## Re: Shape Bug in MP 2006

One of those aarghs!

So far, it is implicitly assumed in MPSuperShape that a selected shape is closed. However a new export option can export lines as well as closed shapes. I'm going to have to assume they're closed, for now.

Richard

4. ## Re: Shape Bug in MP 2006

It seems like there's got to be something we're overlooking..

How about the Fill Property? It is read only. Is it always set if the polygon is closed and not if it's not closed?

"Returns a FillFormat object that contains the fill color and visibility properties for the specified shape. Read-only."

Or how about the Type Property? Does it change from geoLine to geoFreeform depending on whether or not it's closed?

"Returns the data type for the specified Shape object. Read-only GeoShapeType."

5. ## Re: Shape Bug in MP 2006

No Type doesn't do it - my code (or at the very least diagnostics) would have picked that up.
My test data had lines and freeforms. Some of the freeforms were closed, some were not.
Note that the lines only have a start & end - they are not polylines.

The Fill object must be there for open freeforms, otherwise my code would throw an exception!
A transparent fill doesn't make difference. After all a transparent fill is still valid for a closed shape.

Richard