2

Hello I'm a newbie in maps and not so good (as I wish to be...) in math and geometrics stuffs.

So: I have a 2d google map.

I have to put a 2d projection of this map (not exactly this one but a handpainted one, so I will not violate any copyright) in an app (that must work offline, so I cannot use external API but only math resources on the smartphone): enter image description here

I need to put a locator (on this projection) in real time, calculating it from GPS position of the user.

So, e.g. if the user is here (45.064768 N, 7.695454 E), I will put the locator here: enter image description here

In other words, I need to know how can I calculate X and Y distance from the upper left corner of the projection (I know the GPS position of all four corners of the projection).

I understand that is a strange question, that I 've asked before on SO (but I was downvoted and informed about this site). I also seem to understand that this math calculation has something to do with a rotated perspective grid: enter image description here

FYI, I will manage this "GPS coords to XY" manipulation using javascript.

Pls I don't need the final "copy and paste" solution but only an idea on how to proceed, explained in words as simple as possible.

UPDATE:

After some brainstorming I understand that I could start from a trapezoidal shape laying on a 2d map (from top): enter image description here

Then, if I will observe this shape from behind, this isosceles trapezoidal view will become a perspective view (what I want to show in my app) but with a rectangular shape, due the inclination (no more from the top but e.g. from 45° degrees): enter image description here

Considering a given point on the "flat" map, I can get distance and angle from the four vertex of the isosceles trapezoid.

Then, I must "transpose" these distance and their angles on the resulting rectangle. I think it can be quite easy to do so, although I believe there'll some errors doing in this way (due to a lot of missing other parameters):

enter image description here

9
  • 1
    I believe you are looking for the en.m.wikipedia.org/wiki/Oblique_projection. There are implementations of thia on OpenCV, or you could create a Postgis function to do it. – John Powell Jan 21 '20 at 18:11
  • 1
    Actually, I think you need the axonometric projection, as it appears to be rotated as well as tilted. This kind of map, as you have shown, ia generally called 2.5D. – John Powell Jan 21 '20 at 18:15
  • I feel that I must find something less tricky. The top view is a way ugly for my app, but this projection is too hard to handle. – RikiRiocma Jan 21 '20 at 19:07
  • 1
    In my opinion, the easiest thing would be to find out the coefficients of a matrix of projective transformation between one plane and another. Which I think would be possible by having 4 known coordinate points in both systems. When you put the coordinates, I deleted my comment requesting them because it (my comment) was no longer necessary, but now I don't know if you deleted the coordinates because they were not correct or because you thought they would no longer be necessary. – Gabriel De Luca Jan 23 '20 at 1:17
  • 1
    The transformation is clearly not-affine: parallel lines cease to be parallel when mapped. However, an affine transformation differs from a projective one in the coefficients of the last row of the transformation matrix (en.wikipedia.org/wiki/Affine_transformation#Augmented_matrix). If we project the geographic coordinates of the corners to a plane (probably custom Transverse Mercator) we could try to find the matrix of a 2D to 2D projective transformation to the image plane. – Gabriel De Luca Jan 23 '20 at 1:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.