主要道路・鉄道API

アクセス & 制限Public, no key needed · Heavy▾

誰でも利用可能です。プロファイルからの無料APIキーは制限を引き上げます: X-API-Key ヘッダー、またはとして api_key= アドレスで。

5分時間日
キーなし20120500
キーを使用して604002,000

Each 100 square km of area counts as one request, so a 10 km square is 1 and a 30 km square is 9.

プロフィールページで無料キーを作成するにはログインしてください。

すべての回答には X-RateLimit-Remaining and X-RateLimit-Reset制限を超えると、エラーになります 429 〜と retry_after 秒単位。拒否されたリクエストはカウントされません。

GET キーは不要 JSON またはバイナリ ファイル 最大30km四方 3 ビットクラス 1時間あたりアドレスあたり60リクエスト

主要な道路と鉄道がポイント周辺の正方形にある場所、および各道路がどの道路であるかについては、約10メートルの各セルが7つのクラスのいずれかとして戻ってきます。道路からヘリテージ鉄道までで、 主要道路と鉄道地図 描画します。着陸ハザードレイヤーの隣に配置されることを意図しています。 内陸水路API, ランディングツールが高速道路より静かな道から広い余裕を保つことができるように:ウェブページやスクリプト用にJSONとして、またはフライトコンピュータまたはグラウンドステーションが携帯できる小さなバイナリファイルとして要求してください。

GEThttps://www.altimetercloud.com/api/roads/lat lon size_km

パラメータ

パラメータ意味
lat, lon矩形の中央、10進度数 (lng 受け入れられます)
size_km正方形の 1 辺の長さ(km 単位)。0 より大きく 30 まで。省略した場合は 1。10 km を超える正方形は format=bin のみ。
formatオプション。 json (10 kmまでの正方形の場合のデフォルト)または bin: 32 バイトのヘッダーとセルを、任意のサイズのファイルとして。
compressオプション。 none (デフォルト), zlib または lzma, と同様に 内陸水路API.
classesオプション。保持するクラスのリスト(例: 1,2,5; every other class comes back as 0. Left out, all seven.
downloadOptional. 1 makes a browser save a format=bin answer as a file, named for the square.

The classes

ClassWhatOpenStreetMap types
0Nothing
1Motorway and trunk roadmotorway, trunk, and their slip roads
2A roadprimary and its slip roads
3B roadsecondary and its slip roads
4Tertiary and minor roadtertiary and its slip roads; unclassified (the public minor roads and lanes between villages and farms)
5重い鉄道レール
6Medium railwayライトレール、路面電車、地下鉄、モノレール
7Light and heritage railway狭軌、ミニチュア鉄道、ケーブルカー、ラック鉄道

道路または鉄道が通過するセルは、その等級を取得するため、移動方法に関わらず、セルの途切れない行が戻されます。2つが同じセルを共有する場合、より悪いハザードが保持され、この順序で最初に最悪です: 1 motorway and trunk, 5 heavy railway, 2 A road, 6 medium railway, 3 B road, 7 light and heritage railway, 4 tertiary road. Anything in a tunnel is left out, and so are disused railways; the minor roads and lanes between villages and farms (OpenStreetMap's unclassified roads) count with tertiary as class 4, while town side streets, driveways, car parks and farm tracks are never included. Heavy railway is every standard gauge line, so standard gauge heritage lines count as heavy.

The cells

The grid is the Inland Water API's: cells of 1/12000 of a degree each way (about 9.3 m north to south), row 0 the north edge and column 0 the west edge, 南へ走る行と東へ走る列。各セルは 3ビット、そのクラス, 最初のバイトの最上位ビットにある最初のセルを含む行に沿って、端から端まで配置されたセル、 8 つのセルが正確に 3 バイトを占める. 各行は整数バイト数にパディングされます j バイト位置から開始 j * row_bytes.

Ground not yet in the database is 0 as well; the JSON answer's coverage_pct 正方形のどの程度がデータベースに保存されているかを示します, road_pct これがいくつかの道路または鉄道であるか、 class_pct 各クラスがどのくらい保持されるか。

サイズ

英国緯度 (54°N) では、圧縮前に:

正方形セルファイル
1 km108 × 1867.4 KB
3 km324 × 55666 KB
5 km540×926183 KB
10 km1,078 × 1,850731 KB
20 km2,156 × 3,7002.9 MB
30 km3,234 × 5,5506.4 MB

道路と鉄道は土地のごく一部しか占めていないため、圧縮によってそのサイズが大幅に削減されます。

バイナリファイル

水とツリーキャノピーファイルと同じ32バイトヘッダー(バージョン2およびセルあたり3ビット)。

バイトタイプ値
0char[4]ACRD
4uint8バージョン、2
5uint8ビット/セル、3
6uint161度あたりのセル数、12000
8int32北端(セル単位):その緯度 × 12000
12int32西端(セル): 経度 × 12000
16uint32行
20uint32列
24uint32行ごとのバイト数
28uint320、予約済み

位置はそのセルに正確にマッピングされます: 行 north_edge - 1 - floor(lat * 12000), 列 floor(lon * 12000) - west_edge.

例

https://www.altimetercloud.com/api/roads/?lat=54.35&lon=-2.95&size_km=3
https://www.altimetercloud.com/api/roads/?lat=54.35&lon=-2.95&size_km=5&classes=1,2,5&format=bin&compress=zlib
https://www.altimetercloud.com/api/roads/?lat=54.35&lon=-2.95&size_km=10&format=bin&compress=lzma&download=1

セルの読み取り

デバイス上で

ヘッダーはウォーターファイルと同じ構造です(参照: 内陸水路API); cells は直後のバイトです。セルの3つのビットは2つのバイトにまたがる可能性があるため、行に沿ったビット位置として読んでください:

// C: the class at a position, 0 to 7, or -1 outside the square
int roadClassAt(const GridHeader *h, const uint8_t *cells, double lat, double lon) {
  int32_t j = h->north_edge - 1 - (int32_t)floor(lat * h->cells_per_deg);
  int32_t i = (int32_t)floor(lon * h->cells_per_deg) - h->west_edge;
  if (j < 0 || i < 0 || j >= (int32_t)h->rows || i >= (int32_t)h->cols) return -1;
  const uint8_t *row = cells + (uint32_t)j * h->row_bytes;
  uint32_t bit = (uint32_t)i * 3;                    // first bit of the cell along the row
  uint32_t two = ((uint32_t)row[bit >> 3] << 8)
               | ((bit >> 3) + 1 < h->row_bytes ? row[(bit >> 3) + 1] : 0);
  return (two >> (13 - (bit & 7))) & 7;             // the 3 bits, wherever they start
}

コンピューター上

# Python
import requests, struct, zlib, numpy as np
r = requests.get('https://www.altimetercloud.com/api/roads/',
                 params={'lat': 54.35, 'lon': -2.95, 'size_km': 3, 'format': 'bin', 'compress': 'zlib'})
f = zlib.decompress(r.content)            # or lzma.decompress(r.content, format=lzma.FORMAT_ALONE)
magic, ver, bits, cpd, north, west, rows, cols, rb, _ = struct.unpack('<4sBBHiiIIII', f[:32])
b = np.unpackbits(np.frombuffer(f[32:], np.uint8).reshape(rows, rb), axis=1)[:, :cols * 3]
classes = (b[:, 0::3] << 2) | (b[:, 1::3] << 1) | b[:, 2::3]   # rows x cols, 0 to 7

JSONの答え

{
  "success": true,
  "lat", "lon", "size_km", "bits",           bits is 3
  "rows", "cols", "cells", "row_bytes",      the grid, as above
  "cells_per_degree", "north_edge_cell", "west_edge_cell",
  "north", "south", "west", "east",          the square's edges, degrees
  "cell_deg", "cell_m_north_south", "cell_m_east_west",
  "road_pct",                                cells with any road or railway kept
  "class_pct": { "1": ..., "5": ... },       each class kept
  "classes": { "1": "motorway and trunk", ... },
  "kept": [1, 2, 3, 4, 5, 6, 7],             the classes asked for
  "coverage_pct",                            cells the database holds
  "meaning", "order", "compress", "bytes",
  "data_b64",                                the rows, row 0 first, compressed if asked
  "file_name", "seconds",
  "credits": { "roads", "source", "licence", "full" }
}

Errors

CodeMeaning
412A parameter is missing or not valid, the square is more than 30 km, JSON was asked for over 10 km, or classes= is not a list of 1 to 7
413The square has too many cells, which only happens very close to the poles
429アドレスからのリクエストが多すぎるか、まだ処理中です
501要求された圧縮は今のところ利用できません

試してみる

ザ Main Roads and Railways Map has a download panel: move the map so the cross sits on your launch site, choose the size and compression, and it saves the file from this API.

Road and railway data credits

Contains OpenStreetMap data © OpenStreetMap contributors, available under the Open Database Licence (ODbL), through the regional extracts published by Geofabrik. The main roads and railways are reduced here to a class a cell, which changes them: this is not the original data.

Licence of this data. Because it contains OpenStreetMap data, the data this API gives out is made available under the Open Database License (ODbL) 1.0. You may use it freely, commercially too, as long as you credit it as above and share any database you make from it under the same licence.

AltimeterCloud に謝辞を表す

無料で使用できます。使用する場合 this API, or anything made from the answers, in a commercial product or service, credit AltimeterCloud with a link to www.altimetercloud.com 使用時点:データが表示されている画面、ページ、または印刷物上など “Data from AltimeterCloud.com”. このページにリストされている、データ自体のソースが要求するいかなるクレジットも同様に適用されます。