2

Im creating Android application where I need to draw polyline on bitmap. I got bunch off coordinates like

    X:         Y:
    57.567177, 25.383375
    57.567391, 25.384218
    57.568717, 25.382321
    57.568159, 25.382033

Then I need want to convert them to pixel coordinates. What I have done so far is converted length between two points in px with this code

public double KoordToMeters(double lat1, double lon1, double lat2, double lon2){  // generally used geo measurement function
    double R = 6378.137; // Radius of earth in KM
    double dLat = lat2 * Math.PI / 180 - lat1 * Math.PI / 180;
    double dLon = lon2 * Math.PI / 180 - lon1 * Math.PI / 180;
    double a = Math.sin(dLat/2) * Math.sin(dLat/2) +
            Math.cos(lat1 * Math.PI / 180) * Math.cos(lat2 * Math.PI / 180) *
                    Math.sin(dLon/2) * Math.sin(dLon/2);
    double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
    double d = R * c;
    return d * 1000; // meters
}
public double MeterstoPx(double Meters, int scale){ //Scale 10000
    double Px;
    Meters = Meters / scale;

    Px = Meters / 0.0002645833; //Got this number as 1m=0.0002645833px

    return Px;
}

I am not sure if this is necessary to get pixel coordinates. I am using scale 10000 thats why I am doing Meters = Meters / scale;

Dandalis
  • 130
  • 9

0 Answers0