I have the seemingly tricky challenge of trying to work out a path, by sea, from one sea port to another sea port. The eventual aim is to plot this on a Google (or Bing) Map as a polyline.
The path needs to:
- Be plausible, as a ship can't go over land (obviously)
- Not run too close to the coast line. Ships can't go that far near to shore
- Not be too complex. It's going to be plotted on Google Maps so a 2000 point polyline wont do.
- Be the shortest, but not at the expense of the above three points
So, my first idea was obtain data on coast lines around the world. Such a thing is available here. Unfortunately it's incomplete however. OpenStreetMap shows this data and shorelines for things like Caribbean islands are missing.
I also thought about Geocoding (not reliable enough plus I would burn through thousands of requests trying to plot a route)
My next idea was to somehow use Google Maps and test if a point is blue or not. GMaps.NET, a great .NET Mapping component, allowed me to achieve this by creating a bitmap of what it renders and testing the color of a pixel.
First problem is that the accuracy of this hit testing is only as good as the resolution image of the image I test against. For ports close to each other, this is fine for ports further away, the accuracy suffers.
Second problem, assuming I use some kind of 'blue pixel testing' method, is what algorithm is right for finding a route. The A* algorithm looks promising, but I'm not sure how to push the path 'out' from the being to near to the coast. Nor how to reduce complexity of the polyline.
So ... any input: ideas, thoughts, links, sample code, etc would be welcome. Thanks.
(I should add that this is for a travel site. Accuracy isn't too important, I'm not directing shipping or anything)