There is another way to get closer with Google Earth Api. I know this is javascript, but I thought it was a new way to solve the problem.
In any case, I have put together a complete working solution - note that it works for rivers too: http://www.msa.mmu.ac.uk/~fraser/ge/coord/
The main idea I used was to implement the hiTest method of a GEView object in Google Earth Api .
Take a look at the following Hitest example from Google. http://earth-api-samples.googlecode.com/svn/trunk/examples/hittest.html
The hitTest method is supplied with a random point on the screen (pixel coordinates), for which it returns a GEHitTestResult object that contains information about the geographical location corresponding to the point. If you use the GEPlugin.HIT_TEST_TERRAIN mode using the method, you can limit the results to only landing (terrain) while we look at the results at points with a height> 1 m
This is the function I use to implement hitTest:
var hitTestTerrain = function() { var x = getRandomInt(0, 200);
Obviously, you also want to have random results from anywhere on the globe (and not just random points visible from one point of view). To do this, I move the land view after each successful hitTestTerrain call. This is achieved with a small helper function.
var flyTo = function(lat, lng, rng) { lookAt.setLatitude(lat); lookAt.setLongitude(lng); lookAt.setRange(rng); ge.getView().setAbstractView(lookAt); };
Finally, this is a stripped-down version of the main block of code that calls these two methods.
var getRandomLandCoordinates = function() { var test = hitTestTerrain(); if (test.success) { coords[coords.length] = { lat: test.result.getLatitude(), lng: test.result.getLongitude() }; } if (coords.length <= number) { getRandomLandCoordinates(); } else { displayResults(); } };
So, the earth moves randomly to postulate
Other functions have only helpers for generating random x, y and random numbers lat, lng for outputting results, as well as for switching controls, etc.
I tested the code a bit, and the results were not 100% perfect, improving the altitude to a level higher, for example 50 m, but obviously it reduces the area of possible selected coordinates.
Obviously, you could adapt the idea to suit your needs. Perhaps run the code several times to populate the database or something else.