20,741
edits
Line 46: | Line 46: | ||
# this would need to be changed when using a different image | # this would need to be changed when using a different image | ||
var | var map_width = 310; | ||
var | var map_height = 155; | ||
var x_offset = (width- | var x_offset = (width-map_width)/2; | ||
var y_offset = (height- | var y_offset = (height-map_height)/2; | ||
# assuming Mercator projection for now (untested pseudo code) | |||
var position2Pixels = func(lat, lon) { | |||
var xpos = (lon+180)*(map_width/360); | |||
var latRad = lat*math.PI/180; | |||
var mercN = math.log(math.tan((math.PI/4)+(latRad/2))); | |||
var ypos= (map_height/2)-(map_width*mercN/(2*math.PI)); | |||
return [xpos+x_offset, ypos+y_offset]; | |||
} | |||
# create an image child for the texture | # create an image child for the texture |