Main Roads & Railways 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 그리고 X-RateLimit-Reset제한을 초과하면 오류 응답 429 포함 retry_after 초 단위입니다. 거부된 요청은 계산되지 않습니다.

GET 키가 필요 없음 JSON 또는 바이너리 파일 최대 30 km² 3비트 클래스 시간당 주소당 60개 요청

주변 지역의 주요 도로와 철도의 위치 및 각각의 형태: 약 10미터 크기의 각 셀은 고속도로부터 유산 철도까지 7가지 등급 중 하나로 반환되며, 이는 다음과 같은 데이터입니다 주요 도로 및 철도 지도 드로우. 이는 내륙 수역 API, 따라서 착륙 도구는 고속도로에서 조용한 도로보다 더 넓은 여백을 유지할 수 있습니다: 웹 페이지 또는 스크립트용 JSON으로 요청하거나, 비행 컴퓨터 또는 지상국이 보관할 수 있는 작은 바이너리 파일로 요청하세요.

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

매개변수

파라미터의미
lat, lon정사각형의 중앙, 십진도 (lng 도 허용됨)
size_km제곱형의 한 변의 거리(km), 0 이상 30 이하. 생략하면 1. 10 km를 초과하는 사각형은 다음과 같이 표시됩니다 format=bin 만 해당.
format선택 사항. json (기본값, 최대 10km의 사각형) 또는 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)
5Heavy railway레일
6중간 철도경전철, 트램, 지하철, 모노레일
7경량 및 유산 철도협궤, 소형 철도, 케이블카, 랙 철도

도로나 철도가 셀을 통과하는 모든 셀은 그 클래스를 취하므로, 각각은 그것이 작동하는 방식에 관계없이 셀의 연속된 선으로 돌아옵니다. 두 개가 셀을 공유하는 경우, 더 나쁜 위험이 유지되며, 이 순서대로, 최악이 먼저입니다: 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

도로와 철도는 지면의 매우 작은 부분을 차지하므로 압축하면 원본 크기의 작은 부분으로 줄어듭니다.

binary file

수역 및 수목 캐노피 파일과 동일한 32바이트 헤더, 버전 2 및 셀당 3비트.

바이트유형값
0char[4]ACRD
4uint8버전, 2
5uint8Cell당 비트, 3
6uint16도당 셀 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

셀 읽기

장치에서

헤더는 water 파일의 구조와 동일합니다 (참조: 내륙 수역 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”. 이 페이지에 나열된 데이터의 출처가 요청하는 모든 출처 표시가 적용됩니다.