2

I'm implementing a custom maps (image with size map_width and map_height) on an iPhone app and i try to show the current user position on this map (current_long and current_lat)

I have 2 references points with a known GPS coordinates (ref1_long, ref1_lat, ref2_long and ref2_lat) and known X, Y positions in pixels (ref1_x, ref1_y, ref2_x and ref2_y)

My question is: how to calculate the current_x and current_y according to these informations ?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Safouane Azzabi
  • 299
  • 1
  • 3
  • 7

2 Answers2

0

You need to know the projection of the map. There are hundreds of different map projection and many of them can have the important constants that can have any meaning.

So, at first, you need to know, what map do you use?

After that, find the formulas for this projection and use them. For example, for UTM projection the formulas are here. But for another projection the formulas and the whole system will be absolutely different.

The next step, you'll have to imagine yourself how the abstract map will be shown on your screen.

For me, a pro in geomatic and programming, the whole task would take minimally 2 days for some exactly known and not rare map system. There always are serious problems in debugging, to set the point exactly. And there are always problems with formulas - you'll find several variants and will need to find the correct ones.

But if the map is already actively used by programmers, you could find not formulas, but pieces of code. Good luck!

Gangnus
  • 24,044
  • 16
  • 90
  • 149
  • :2 days? You can buy it for 5$? – Micromega Feb 17 '14 at 08:47
  • @Phpdna Maybe. We are not talking about buying, but about how to do it. I did it several times and I remember these problems with maps that are not really up to the standard written on them. – Gangnus Feb 17 '14 at 08:54
0

Most likely the map uses a mercantor projection. The problem is that the earth is a sphere but you have only 2 dimensions on a map. You need the co-ordinate of the 4 corners of the map and the map dimensions. The y-map value doesn't change but for the x-map value you need the mercantor projection. Then it become a linear transformation and either the width or the height of the map can be slightly different from the input:Convert lat/lon to pixel coordinate?.

Community
  • 1
  • 1
Micromega
  • 12,486
  • 7
  • 35
  • 72