search_by_location_rectangle
Search MLIT Data Platform for infrastructure data within a specified rectangular geographic area, optionally combining with keyword terms to filter results.
Instructions
矩形範囲と交差するデータを検索する。
使い方:
- 指定した矩形範囲(北西緯度経度と南東緯度経度)に含まれるデータを検索します。
- 検索語(term)を組み合わせて空間+キーワード検索も可能です。
例:
- 東京都内の橋梁を検索:
term="橋梁",
location_rectangle_top_left_lat=35.80,
location_rectangle_top_left_lon=139.55,
location_rectangle_bottom_right_lat=35.60,
location_rectangle_bottom_right_lon=139.85
- キーワードなしで矩形範囲のデータを取得:
term="",
location_rectangle_top_left_lat=35.7,
location_rectangle_top_left_lon=139.6,
location_rectangle_bottom_right_lat=35.6,
location_rectangle_bottom_right_lon=139.7
注意:
- `location_rectangle_top_left_lat/lon` と `location_rectangle_bottom_right_lat/lon` の4点は必須。
- 北西(top_left)は右下(bottom_right)よりも緯度が高く、経度が低くなるように指定。
- termが空の場合でも矩形条件のみで検索可能。
- phrase_match=Trueで完全一致検索。
- size は 1回あたり最大10,000件(API制限あり)。
- 座標は世界測地系(WGS84)を使用。Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| term | No | 検索キーワード。位置のみで検索する場合は省略可能 | |
| first | No | 検索結果の開始位置 | |
| size | No | 取得件数(最大500) | |
| phrase_match | No | フレーズマッチモード | |
| prefecture_code | No | 都道府県コード (例: '13'=東京都, '27'=大阪府)。normalize_codesツールで正規化できます。位置検索と組み合わせて結果を絞り込めます | |
| location_rectangle_top_left_lat | Yes | 矩形範囲の左上緯度 (例: 35.6895 for 東京) | |
| location_rectangle_top_left_lon | Yes | 矩形範囲の左上経度 (例: 139.6917 for 東京) | |
| location_rectangle_bottom_right_lat | Yes | 矩形範囲の右下緯度 | |
| location_rectangle_bottom_right_lon | Yes | 矩形範囲の右下経度 |
Implementation Reference
- src/server.py:1246-1267 (handler)The handler for the 'search_by_location_rectangle' tool in 'src/server.py'. It validates input using 'SearchByRect', then invokes 'client.search_by_rectangle'.
elif name == "search_by_location_rectangle": p = SearchByRect.model_validate({ "term": arguments.get("term"), "first": arguments.get("first", 0), "size": arguments.get("size", 50), "phrase_match": arguments.get("phrase_match", True), "prefecture_code": arguments.get("prefecture_code"), "rectangle": { "top_left_lat": arguments["location_rectangle_top_left_lat"], "top_left_lon": arguments["location_rectangle_top_left_lon"], "bottom_right_lat": arguments["location_rectangle_bottom_right_lat"], "bottom_right_lon": arguments["location_rectangle_bottom_right_lon"], } }) data = await client.search_by_rectangle( p.rectangle.top_left_lat, p.rectangle.top_left_lon, p.rectangle.bottom_right_lat, p.rectangle.bottom_right_lon, term=p.term or "", first=p.first, size=p.size, phrase_match=p.phrase_match, ) - src/client.py:685-690 (helper)The 'search_by_rectangle' method in 'src/client.py' which builds the location filter and executes the GraphQL search query.
async def search_by_rectangle( self, tl_lat: float, tl_lon: float, br_lat: float, br_lon: float, **kw ) -> Dict[str, Any]: loc = self.make_rectangle_filter(tl_lat, tl_lon, br_lat, br_lon) q = self.build_search(location_filter=loc, **kw) return await self.post_query(q) - src/server.py:112-190 (schema)The tool registration and schema definition for 'search_by_location_rectangle'.
name="search_by_location_rectangle", description="""矩形範囲と交差するデータを検索する。 使い方: - 指定した矩形範囲(北西緯度経度と南東緯度経度)に含まれるデータを検索します。 - 検索語(term)を組み合わせて空間+キーワード検索も可能です。 例: - 東京都内の橋梁を検索: term="橋梁", location_rectangle_top_left_lat=35.80, location_rectangle_top_left_lon=139.55, location_rectangle_bottom_right_lat=35.60, location_rectangle_bottom_right_lon=139.85 - キーワードなしで矩形範囲のデータを取得: term="", location_rectangle_top_left_lat=35.7, location_rectangle_top_left_lon=139.6, location_rectangle_bottom_right_lat=35.6, location_rectangle_bottom_right_lon=139.7 注意: - `location_rectangle_top_left_lat/lon` と `location_rectangle_bottom_right_lat/lon` の4点は必須。 - 北西(top_left)は右下(bottom_right)よりも緯度が高く、経度が低くなるように指定。 - termが空の場合でも矩形条件のみで検索可能。 - phrase_match=Trueで完全一致検索。 - size は 1回あたり最大10,000件(API制限あり)。 - 座標は世界測地系(WGS84)を使用。""", inputSchema={ "type": "object", "properties": { "term": { "type": "string", "description": "検索キーワード。位置のみで検索する場合は省略可能" }, "first": { "type": "integer", "default": 0, "description": "検索結果の開始位置" }, "size": { "type": "integer", "default": 50, "description": "取得件数(最大500)" }, "phrase_match": { "type": "boolean", "default": True, "description": "フレーズマッチモード" }, "prefecture_code": { "type": "string", "description": "都道府県コード (例: '13'=東京都, '27'=大阪府)。normalize_codesツールで正規化できます。位置検索と組み合わせて結果を絞り込めます" }, "location_rectangle_top_left_lat": { "type": "number", "description": "矩形範囲の左上緯度 (例: 35.6895 for 東京)" }, "location_rectangle_top_left_lon": { "type": "number", "description": "矩形範囲の左上経度 (例: 139.6917 for 東京)" }, "location_rectangle_bottom_right_lat": { "type": "number", "description": "矩形範囲の右下緯度" }, "location_rectangle_bottom_right_lon": { "type": "number", "description": "矩形範囲の右下経度" }, }, "required": [ "location_rectangle_top_left_lat", "location_rectangle_top_left_lon", "location_rectangle_bottom_right_lat", "location_rectangle_bottom_right_lon", ], },