1

Well, I have an image of a floor. What I need to do is get the user’s current location and display it on the floor image. I know that I need to convert the lat and lon to pixels and point it on the custom map.

I followed this Convert GPS coordinates to coordinate plane. But I couldn’t get it properly. Not even close. May be its because, the area of the building is small (Wonder whether it could be developed for small area). And I looked up on some other question. Its merely hard-coding. I don’t want to do it.

So It would be helpful if somebody provide me any logical ideas or code samples or tutorials. Anything would be fine. Thanks in advance!! :-)

lat = 12.875538;
longitudeVal = 80.227112;

delta_lat = 0.0001;      // Adjust Y
delta_long = 0.0001;    // Adjust X 

/* length */ delta_x = 130; // 130 
/* width */ delta_y = 70;  // 70

vertical_scale = delta_y/delta_lat;
horizontal_scale = delta_x/(cos(lat)*delta_long);

/* lati */ x = (6378.1 * (1+sin(lat))/cos(lat));
/* long */ y = (6378.1 * longitudeVal); 

x = x / horizontal_scale;
y = y / vertical_scale;

/*    y = ((-1 * lat) + 90) * (delta_x / 180);
x = (longitudeVal + 180) * (delta_y / 360);*/

NSLog(@"lat %f long %f x %d y %d",lat,longitudeVal,x,y); 
Community
  • 1
  • 1
Nina
  • 1,579
  • 2
  • 21
  • 51
  • Here's some advice: if you don't want to do your own hard coding hire someone to do it for you. SO isn't a very good place to ask people to do your work for you, you'll get much better answers if you show your own work and ask for help improving it. – High Performance Mark Aug 16 '12 at 06:34
  • Here you go!! Now temme the changes to be made. I did what told in that answer :| That’s why I didn’t post my code. – Nina Aug 16 '12 at 06:59
  • i am trying the same thing ,showing current location on image.can you provide some more help on it? any reference link or code will be a great help – wasim Dec 18 '12 at 08:28
  • @wasim Sorry. I didn’t continue that after few trials. You should manually find the coordinates. Need more math to make it work. – Nina Dec 18 '12 at 09:43

1 Answers1

0

It looks to me as if you are making a very common error. Your latitude and longitude are measured in degrees, but sin and the other trigonometric functions take arguments measured in radians.

You may be making other mistakes too, but just telling us that the code is wrong without telling us how it is wrong doesn't offer us much of a clue.

High Performance Mark
  • 77,191
  • 7
  • 105
  • 161
  • And I am just in my learning phase, i do make errors. Wrong in the sense, it doesn’t indicate to proper point on map. Sometimes not even pointing. Will convert it to radians and try it. if the problem persists, i’ll post what it is. – Nina Aug 16 '12 at 07:13