My old way was similar to what you have done. I just worked backwards from a map size of 10 (131072).
This is the python code from the wrapper. It was assuming there would be no map size over 11
checkdimension = 131071
self.MAPSIZE = 10
while not self.MAPSIZESET:
self.MAPSIZESET = True
checkdimension = checkdimension/2
kwargs['Broadcast'].broadcast("echo #GetTerrainHeight(%s,0)#" % (checkdimension))
print 'Map Size =', self.MAPSIZE
And the max coordinates for the map are:
maxcoord = ((mapsize - 1) * 64 * 64)So you can scale fractional coordinates to absolute.