mapping long/lat coords to jitter/OpenGL window

youcloudsofdoom's icon

Hi all, I'm having trouble accurately mapping long/lat coords into a jit window.

I took a screengrab from google maps, worked out what the boundary long/lat coords were, and then imported the image as a jit.gl.texture. I'm using two [scale] objects to convert the long and lat coords to x and y positions in the window, but when I try to draw things to certain long/lat coords, they are off in the image. Am I missing a piece of logic here? Does the image/window need to be a pixel size equal to the number of geographic degrees or something?

Thanks!

Rob Ramirez's icon

hard to say without seeing a patch.

youcloudsofdoom's icon

Sorry, you're completely right - patch attached with some notes/links

mapdemo.maxpat
Max Patch
MK.jpg
jpg
youcloudsofdoom's icon

Details inside the patch show what the long/lat coords of the image are, as well as a link to where you can quickly compare positions of a dot on the map to where it should be on the planet!

Rob Ramirez's icon

you should set @ortho 2 on jit.gl.render and use @transform_reset on your gridshape for these kinds of calculations.

Max Patch
Copy patch and select New From Clipboard in Max.

youcloudsofdoom's icon

That's incredibly helpful, thank you Rob! The issue seems to remain though, with quite a noticeable difference between points as they occur on the google map and how they appear on the rendered map. Any other thoughts as to why that is? Coordinates seem to be in line on the y axis, though always further left on the x axis then they should be...

youcloudsofdoom's icon

Update on this - problem was solved by altering the image to be perfectly square - map coords now line up very nicely!