マップに使用するカスタム画像を取得するアクティビティを作成し、左上と右下のgpsを知って、マップの上にgpsをプロットします。かなりうまくいきますが、精度を上げたいと思います。デバイスの場所をログに記録してGoogleマップに接続すると、カスタムマップで表現しているよりも実際に正確になるため、オフになっていることがわかります。
つまり、マップの左上と右下のgpsがあり、それらを対応するピクセル座標にマッピングしたので、ヘルメルト変換を使用してデバイスのgpsをピクセルに正確にプロットするにはどうすればよいですか。
編集:
私は現在、これを使用してデバイスのGPSを画面にプロットしています。
public double getCurrentPixelY(Location upperLeft, Location lowerRight, Location current) {
double hypotenuse = upperLeft.distanceTo(current);
double bearing = upperLeft.bearingTo(current);
double currentDistanceY = Math.cos(bearing * Math.PI / OneEightyDeg) * hypotenuse;
// "percentage to mark the position"
double totalHypotenuse = upperLeft.distanceTo(lowerRight);
double totalDistanceY = totalHypotenuse * Math.cos(upperLeft.bearingTo(lowerRight) * Math.PI / OneEightyDeg);
double currentPixelY = currentDistanceY / totalDistanceY * ImageSizeH;
return currentPixelY;
}
public double getCurrentPixelX(Location upperLeft, Location lowerRight, Location current) {
double hypotenuse = upperLeft.distanceTo(current);
double bearing = upperLeft.bearingTo(current);
double currentDistanceX = Math.sin(bearing * Math.PI / OneEightyDeg) * hypotenuse;
// "percentage to mark the position"
double totalHypotenuse = upperLeft.distanceTo(lowerRight);
double totalDistanceX = totalHypotenuse * Math.sin(upperLeft.bearingTo(lowerRight) * Math.PI / OneEightyDeg);
double currentPixelX = currentDistanceX / totalDistanceX * ImageSizeW;
return currentPixelX;
}
どこかで調整する必要があることはわかっていますが、ヘルメルト変換を見ると、既存のコードで実装を開始する場所がわかりません。
編集:
オンラインでさらにいくつかのものを見た後、私は大円の公式を使用することが役立つかもしれないことがわかります。ここに、Imが実装を検討しているものへのリンクがあります
http://introcs.cs.princeton.edu/java/12types/GreatCircle.java.html