0

If i calculate the X and Y axis from latitude and longitude like so:

private static final int    EARTH_RADIUS    = 6371;
private static final double FOCAL_LENGTH    = 500;

                    latitude = latitude * Math.PI / 180;
                    longitude = longitude * Math.PI / 180;

                    double x = EARTH_RADIUS * Math.sin(latitude) * Math.cos(longitude);
                    double y = EARTH_RADIUS * Math.sin(latitude) * Math.sin(longitude);
                    double z = EARTH_RADIUS * Math.cos(latitude);

                    double projectedX = x * FOCAL_LENGTH / (FOCAL_LENGTH + z);
                    double projectedY = y * FOCAL_LENGTH / (FOCAL_LENGTH + z);

How would i ensure that the X and Y points are drawn within the screen? Ie., have the screen represent a 2d view of the world such that you will never be able to draw a point off of the screen?

Latitude and Longitude are values ranging from -90 to 90 and -180 to 180..

I do not want to use google services - no MapView or anything related to google maps...

Any help would be appreciated!

BigBug
  • 6,202
  • 23
  • 87
  • 138

1 Answers1

1

Get your device width and height and divide it with latitude and longitude ranges.

For instances, device width is 300px and longitude ranges from -180 to 180. It means 300 divide with 360.

edisonthk
  • 1,403
  • 16
  • 35