I'm using the nettopologysuite (a port of the JTS Topology Suite). I'm using the SRTtree implementation to store a list of timezones and a corresponding coordinates (based on this suggestion ). I took the list of cities from geonames, pulled out the timezone of the city and the coordinates and I'm storing them in the STRtree. the problem I'm having is that this implementation doesn't provide a "Nearest" function. In order to do a query I have to provide a starting point and a circumference. Currently I'm incrementing the circumference by .1 in a loop until I find some results and then i take the first one. Is there a better way of doing this?
Here's what I'm doing:
public static SRTtree Cities { get; set; }
public static string GetTimezone(double lat, double lng)
{
var envelope = new Envelope(new Coordinate(lat, lng));
IList results;
do
{
envelope.ExpandBy(.1);
results = Cities.Query(envelope);
} while (results.Count == 0);
return results[0] as string;
}