Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Mapstraction to make a web-based mapping system. The documentation has some serious holes in it. I would like to use Mapstraction to draw polygons with holes in them. Serious holes.

Can anybody tell me how I can do this?

share|improve this question
up vote 3 down vote accepted

I can't find a polygon class and class mxn.Polyline seems only to be able to "mark a polyline as closed." This probably will not suffice for managing non-simply-connected polygons unless you can figure out how to handle disconnected polylines and try to close a set of them, hoping that the process will be done correctly.

A standard workaround for representing such polygons is to make "keyhole cuts" from the outside into each hole. For example, consider the annulus bordered by concentric circles of radii 1 and 2. Relative to their common origin you might make a cut from (2,0) to (1,0). The boundary of the resulting polygon begins at (2,0), goes straight to (1,0), follows the inner circle clockwise all the way around and back to (1,0), returns to (2,0), follows the outer circle counterclockwise all the way around and back to the starting position of (2,0). Throughout this traversal the polygon's interior lies to the left.

This picture from Webster's online dictionary roughly illustrates the idea. The inner circle in the picture is intended to be very small. The portions Gamma_1 and Gamma_3 are supposed to coincide but are drawn separately to help you trace the polyline.

Keyhole cut

You might pay a price for making such cuts depending on how the polygons are displayed. Ideally, overlapping portions of a boundary having opposite orientations (like Gamma_1 and Gamma_3) should cancel out and not be drawn at all, but it's unfair to expect a polygon rendering procedure to check for such overlaps. Thus, the cuts will likely be visible. A workaround for that is to draw such polygons with invisible boundaries and separately draw the polylines that form their proper (uncut) boundaries. Not a great solution, but you might find it serviceable in your application.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.