A point is basically a bay turned inside out. Where a bay goes inward and is filled with water, the point goes outward and is filled with land. So the code for detecting and labeling bays can be very easily adapted for points. The only significant difference is that I wanted bays to be blobby, while I want points to be ... well, pointy. So I have to use slightly different metrics to find pointy shapes rather than blobby shapes. The metric I'll use is basically the ratio of the length of the point to the width of the point -- the higher that number, the more pointy the candidate.
As an initial cut, I set up the code to detect points without worrying how pointy they are:
Here the detected point coastline is outlined in green with a red dot at one end, a purple dot at the other end and a green dot in the "visual center" of the point. Three "points" have been detected: The north and south ends of Zercher Island, and the land sticking out above the city of Peignear. These are all technically points -- sticking out and full of land, so the basic functionality seems to be working. The northern point on Zercher Island is too big, I think, and none of these may be "pointy" enough. I can address these problems by adjusting the cutoffs for length and pointiness.
This demonstrates another problem:
I want to allow points on islands. For example, the bottom half of Zercher Island above might be a reasonable feature to label as a point. But it doesn't make any sense to identify half of an island as a point. To address this, I'll require that a point not take up more than (say) 1/4 of its coastline, and adjust that as necessary.
Here's an example of a point identified by the tweaked algorithm:
This point has a ratio of length to width of about 3. The width is measured between the red and purple dots. This might be a problem for points like this one that are significantly wider elsewhere on the point. But this at least is acceptable for now.
Now I need to put a label on the point. There aren't a lot of examples of labeled points on my reference maps. Real maps tend to label across the point (as in the Google Map above) or hanging off the end of the point as in this map of Long Island:
It's probably easiest to implement a label across the point, so I'll do that first. This can be done by creating an area label for the point area and anchoring the label strongly to the visual center of the area. That gives me something like this:
Hanging the label off the end of the point requires a little ingenuity. The trick is to treat the label as a point label for a spot right on the end of the point -- which I'll assume is the midpoint of the path around the point. Because the label placement tries to avoid crossing the coasts, it will usually end up in the water:
And the multi-line version:
And that's about all that was required to add points.
Although there's more to do with labeling (mountain ranges!) I've gotten a little tired of labeling at this point, so in the next series of posts I'm going to move on to a different topic for a while.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.