GeoPoint クラス

GeoPoint クラスは、緯度と経度の座標で指定される地球上の地点を表します。

注意: **このソリューションはおすすめしません。** この API を使用するアプリは Python 2 ランタイム以外では実行できません。Python 3 ランタイムを移行する前に、[推奨ソリューション](/appengine/docs/standard/python/migrate-to-python3/migrating-services#migration_paths_for_bundled_services)にアップグレードする必要があります。

GeoPoint は、google.appengine.api.search モジュールで定義されます。

概要

GeoPoint クラスを使用すると、地図上の場所を検索できるようになります。まず、GeoPoint クラスをインスタンス化してから、そのオブジェクトを特定のドキュメント フィールドに渡します。

from google.appengine.api import search
...
# Construct the GeoPoint class
geopoint = search.GeoPoint(latitude, longitude)

fields = [search.TextField(name='name', value=store_name),
          search.TextField(name='address', value=store_address),
          # Construct a GeoField passing geopoint as the value of that field
          search.GeoField(name='store_location', value=geopoint)
         ]

場所に基づいて検索を行う方法の詳細については、Queries on geopoint fields をご覧ください。

コンストラクタ

GeoPoint クラスのコンストラクタは、次のように定義されます。

GeoPoint(latitude, longitude)

緯度と経度の座標で表される地球上の地点。

引数

latitude

赤道面と GeoPoint を通る線との間の角度。-90~90 度。

longitude

基準子午線と GeoPoint を通る別の子午線との間の角度(東側または西側)。-180~180 度。

例外

TypeError

いずれかのパラメータが無効なタイプであるか、不明な属性が渡されました。

ValueError

パラメータのいずれか 1 つに対して無効な値が渡されました。

プロパティ

GeoPoint クラスのインスタンスには次のプロパティがあります。

latitude

赤道からの角距離(度数)。赤道の南に位置する地点は負の値になり、北に位置する地点は正の値になります。

longitude

グリニッジ子午線からの角距離(度数)。グリニッジ子午線の西に位置する地点は正の値になり、東に位置する地点は負の値になります。