Main Roads & Railways API
Access & limitsPublic, no key needed · Heavy▾
सभी के लिए खुला। आपकी प्रोफाइल से एक निःशुल्क API कुंजी सीमा बढ़ाती है: इसे भेजें X-API-Key शीर्ष लेख, या जैसा api_key= पते में।
| 5 मिनट | घंटा | दिन | |
|---|---|---|---|
| एक key के बिना | 20 | 120 | 500 |
| एक कुंजी के साथ | 60 | 400 | 2,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.
एक मुफ़्त key बनाने के लिए अपने profile page में log in करें।
हर उत्तर ले जाता है X-RateLimit-Remaining और X-RateLimit-Reset. सीमा से अधिक, उत्तर त्रुटि है 429 के साथ retry_after सेकंड में। अस्वीकृत अनुरोध गिनती नहीं करते हैं।
जहां मुख्य सड़कें और रेलवे एक बिंदु के चारों ओर एक वर्ग पर हैं, और प्रत्येक क्या है: लगभग 10 मीटर की हर कोशिका सात वर्गों में से एक के रूप में वापस आती है, मोटरवे से विरासत रेलवे तक, समान डेटा मुख्य सड़कें और रेलवे मानचित्र खींचता है। यह के बगल में एक लैंडिंग खतरे की परत के रूप में अभिप्रेत है इनलैंड वाटर API, इसलिए एक landing tool एक motorway से quiet road से व्यापक margin रख सकता है: इसे web page या script के लिए JSON के रूप में, या एक छोटी binary file के रूप में जो flight computer या ground station ले जा सकता है, इसके लिए पूछें।
lat lon size_kmपैरामीटर
| पैरामीटर | अर्थ |
|---|---|
lat, lon | वर्ग के बीच में, दशमलव डिग्री (lng also accepted) |
size_km | किमी में वर्ग की भुजा, 0 से अधिक और 30 तक। छोड़ा गया, 1। 10 किमी से अधिक वर्ग के रूप में आते हैं format=bin केवल। |
format | वैकल्पिक। json (the default, for squares up to 10 km) या bin: एक 32 बाइट हेडर और कक्ष, एक फ़ाइल के रूप में, किसी भी आकार के लिए। |
compress | वैकल्पिक। none (डिफ़ॉल्ट), zlib या lzma, जैसे पर इनलैंड वाटर API. |
classes | वैकल्पिक। रखने के लिए कक्षाएं, जैसे सूची के रूप में 1,2,5; every other class comes back as 0. Left out, all seven. |
download | Optional. 1 makes a browser save a format=bin answer as a file, named for the square. |
The classes
| Class | What | OpenStreetMap types |
|---|---|---|
| 0 | Nothing | |
| 1 | Motorway and trunk road | motorway, trunk, and their slip roads |
| 2 | A road | primary and its slip roads |
| 3 | B road | secondary and its slip roads |
| 4 | Tertiary and minor road | tertiary and its slip roads; unclassified (the public minor roads and lanes between villages and farms) |
| 5 | भारी रेलवे | rail |
| 6 | मध्यम रेलवे | लाइट रेल, ट्राम, सबवे, मोनोरेल |
| 7 | Light and heritage railway | संकीर्ण गेज, लघु रेलवे, फनिकुलर, रैक रेलवे |
कोई भी सेल जो सड़क या रेलवे को पार करता है, उसका वर्ग लेता है, इसलिए प्रत्येक सेल की एक अटूट पंक्ति के रूप में वापस आता है, चाहे वह कैसे भी चले। जहां दोनों एक सेल साझा करते हैं, वहां बदतर खतरा रखा जाता है, इस क्रम में, सबसे खराब पहले: 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, पंक्तियाँ दक्षिण की ओर चल रही हैं और स्तंभ पूर्व की ओर। प्रत्येक सेल है तीन bits, इसका class, पंक्ति के साथ सेल को अंत से अंत तक रखा गया, पहली बाइट के सबसे ऊंचे बिट्स में पहली सेल के साथ, इसलिए आठ सेल बिल्कुल तीन बाइट भरते हैं. प्रत्येक पंक्ति को बाइट की पूरी संख्या तक पैड किया जाता है, इसलिए पंक्ति j बाइट पर शुरू होता है j * row_bytes.
Ground not yet in the database is 0 as well; the JSON answer's coverage_pct बताता है कि डेटाबेस वर्ग का कितना हिस्सा रखता है, road_pct इसका कितना हिस्सा कोई सड़क या रेलवे है, और class_pct प्रत्येक class कितना रखा जाता है।
आकार
यूके अक्षांशों पर (54°N), संपीड़न से पहले:
| वर्ग | Cells | फ़ाइल |
|---|---|---|
| 1 किमी | 108 × 186 | 7.4 KB |
| 3 km | 324 × 556 | 66 KB |
| 5 किमी | 540 × 926 | 183 KB |
| 10 km | 1,078 × 1,850 | 731 KB |
| 20 km | 2,156 × 3,700 | 2.9 MB |
| 30 km | 3,234 × 5,550 | 6.4 MB |
सड़कें और रेलवे जमीन का एक छोटा हिस्सा कवर करते हैं, इसलिए संपीड़न इन्हें उनके कच्चे आकार के एक छोटे अंश तक ले जाता है।
बाइनरी फाइल
जल और वृक्ष छतरी फ़ाइलों के समान 32 बाइट हेडर, संस्करण 2 के साथ और तीन बिट्स एक सेल।
| Byte | टाइप | मान |
|---|---|---|
| 0 | char[4] | ACRD |
| 4 | uint8 | Version, 2 |
| 5 | uint8 | Bits per cell, 3 |
| 6 | uint16 | डिग्री प्रति सेल, 12000 |
| 8 | int32 | उत्तरी किनारा कक्षों में: इसका अक्षांश × 12000 |
| 12 | int32 | पश्चिम की सीमा सेल में: इसकी देशांतर × 12000 |
| 16 | uint32 | पंक्तियां |
| 20 | uint32 | कॉलम |
| 24 | uint32 | Bytes per row |
| 28 | uint32 | 0, आरक्षित |
एक स्थिति अपने सेल से बिल्कुल मैप करती है: row north_edge - 1 - floor(lat * 12000), column 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 bytes है जो इसके सीधे बाद आता है। एक cell के तीन bits दो bytes को straddle कर सकते हैं, इसलिए उन्हें row के साथ एक bit position के रूप में पढ़ें:
// 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
| Code | Meaning |
|---|---|
412 | A 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 |
413 | The 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 को credit देना
उपयोग करने के लिए मुफ्त। यदि आप 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”. इस पृष्ठ पर सूचीबद्ध डेटा के अपने स्रोतों के लिए कोई भी क्रेडिट लागू होता है।



















