I have images of malls that I need to use as maps for an app I am making. I have the GPS lat/long of the bottom corners of the map and I figured out the distance from the bottom GPS coordinates to what would be the top of the map image. How ever these are not straight up and down linear maps meaning I can't just plot my lat and long all nice and neat.
I've tried using various formulas and I'm so close but I can't plot the top lat and long of the top left and right of the map. So far this is what I have:
double distanceFromLeftToRightGPS = bottomLeft.distanceTo(bottomRight);
double bearingleftToRight= bottomLeft.bearingTo(bottomRight);
double distmapFromLeftToRightImg = map.getWidth();
double distmapFromTopToBottomImg = map.getHeight();
double percentageValueOfTopToBottomImg = (distmapFromTopToBottomImg * 100)
/ distmapFromLeftToRightImg;
double distanceFromTopToBottomGPS = (percentageValueOfTopToBottomImg * 0.01)
* distanceFromLeftToRightGPS;
double bearingToTopFromBottom = -90;
double lat1 = Math.toRadians(bottomLeft.getLatitude());
double lon1 = Math.toRadians(bottomLeft.getLongitude());
double dist = (distanceFromTopToBottomGPS/1000f)/6371.0f;
double lat2 = Math.asin(Math.sin(lat1) * Math.cos(dist)
+ Math.cos(lat1) * Math.sin(dist) * Math.cos(bearingToTopFromBottom));
double a = Math.atan2(Math.sin(bearingToTopFromBottom) * Math.sin(dist)
* Math.cos(lat1), Math.cos(dist) - Math.sin(lat1) * Math.sin(lat2));
System.out.println("a = " + a);
double lon2 = lon1 + a;
lon2 = (lon2 + 3 * Math.PI) % (2 * Math.PI) - Math.PI;
System.out.println("Latitude = " + Math.toDegrees(lat2) + "\nLongitude = "
+ Math.toDegrees(lon2));
This gets me oh so close but the end location is off from where it really should be. I'm also not sure what bearing I should be using to look to what would be up from the bottom of the map. If anyone else has some info on how to get this to work that would be awesome.