1
私の与えられた点から一定の距離ですべての経度と緯度を生成するJavaプログラムを作成しています。距離は正確に2000kmでなければなりません。与えられた緯度と経度から一定の距離から無作為なジオポイントを生成する
これは私のコード
public static void getLocation(double x0, double y0, int meters) {
Random random = new Random();
// Convert radius from meters to degrees
double radiusInDegrees = meters/111000f;
double u = random.nextDouble();
double v = random.nextDouble();
double w = radiusInDegrees * Math.sqrt(u);
double t = 2 * Math.PI * v;
double x = w * Math.cos(t);
double y = w * Math.sin(t);
// Adjust the x-coordinate for the shrinking of the east-west distances
// double new_x = x/Math.cos(Math.toRadians(y0));
double foundLongitude = x + x0;
double foundLatitude = y + y0;
System.out.println("Longitude: " + foundLongitude + " Latitude: " + foundLatitude);
}
どのように私はすべてのポイントが円を形成するように、GEOポイントから等距離を生成するのですか?
LETベアリング追加する必要が正しい、私たちは、あなたが円の全周に沿った点の座標を取得したい地理座標Xと点Yと半径Rを持っていると言いますか? –
yupppp ........... – user2399158
ランダムベアリングを選択し、距離と方程式を使用して目的地の緯度/経度を計算します。 [この回答](https://stackoverflow.com/questions/10119479/calculating-lat-and-long-from-bearing-and-distance)には1つの解決策があります。いくつかの詳細[ここ](https://www.movable-type.co.uk/scripts/latlong.html)。 – teppic