1

私は座標の「境界ボックス」を指定できる API を使用しており、そのボックス内でのみ結果を返すことができます。

  • ボックスの中心からの距離でソートされた、指定された境界ボックス内のジオキャッシュのリストを返します。
  • パラメータ南緯、西経、北緯、東経は境界ボックスの端を定義します。
  • 座標は 10 進法である必要があります。北緯と東経には正の数値を使用し、南緯と西経には負の数値を使用します。
  • ボックスは、経度 180° の線、または 90° または -90° の点を横切ることはできません。

これの計算は私には少し難しいですが、いくらか役立つ計算を見つけましたが、それが API に必要なものかどうかはわかりません。

MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(self.mapView.centerCoordinate, 2000.0, 2000.0);
CLLocationCoordinate2D northWestCorner, southEastCorner;
northWestCorner.latitude  = center.latitude  - (region.span.latitudeDelta  / 2.0);
northWestCorner.longitude = center.longitude + (region.span.longitudeDelta / 2.0);
southEastCorner.latitude  = center.latitude  + (region.span.latitudeDelta  / 2.0);
southEastCorner.longitude = center.longitude - (region.span.longitudeDelta / 2.0);

どうすればこれができるか知っている人はいますか?west longitude, north latitude, east longitudeここでの計算は、バウンディング ボックスのエッジを定義するを取得するのに役立ちませんか?

編集:

私が得ているエラー:

Invalid value for parameter: bbox=south,west,north,east

中心値を使用する:

center=37.552821,-122.377413

変換されたボックス (上記の計算後):

bbox=37.561831,-122.388730,37.543811,-122.366096

最終作業コード:

// Current distance
MKMapRect mRect = mapView.visibleMapRect;
MKMapPoint eastMapPoint = MKMapPointMake(MKMapRectGetMinX(mRect), MKMapRectGetMidY(mRect));
MKMapPoint westMapPoint = MKMapPointMake(MKMapRectGetMaxX(mRect), MKMapRectGetMidY(mRect));
CLLocationDistance distance = MKMetersBetweenMapPoints(eastMapPoint, westMapPoint);

// Region
MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(request.center, distance, distance);
CLLocationCoordinate2D northWestCorner, southEastCorner;
northWestCorner.latitude  = request.center.latitude  + (region.span.latitudeDelta  / 2.0);
northWestCorner.longitude = request.center.longitude - (region.span.longitudeDelta / 2.0);
southEastCorner.latitude  = request.center.latitude  - (region.span.latitudeDelta  / 2.0);
southEastCorner.longitude = request.center.longitude + (region.span.longitudeDelta / 2.0);
base = [base stringByAppendingFormat:@"bbox=%f,%f,%f,%f&", southEastCorner.latitude,northWestCorner.longitude,northWestCorner.latitude,southEastCorner.longitude];
4

1 に答える 1

2

半球が逆になっているようです。北と東は正です。したがって、中央緯度から開始して北の境界を見つけたい場合は、デルタの半分を減算するのではなく、加算します。

于 2013-05-06T02:00:52.430 に答える