उपकरण सूची

Main Roads & Railways API

Access & limitsPublic, no key needed · Heavy▾

सभी के लिए खुला। आपकी प्रोफाइल से एक निःशुल्क API कुंजी सीमा बढ़ाती है: इसे भेजें X-API-Key शीर्ष लेख, या जैसा api_key= पते में।

5 मिनटघंटादिन
एक key के बिना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.

एक मुफ़्त key बनाने के लिए अपने profile page में log in करें।

हर उत्तर ले जाता है X-RateLimit-Remaining और X-RateLimit-Reset. सीमा से अधिक, उत्तर त्रुटि है 429 के साथ retry_after सेकंड में। अस्वीकृत अनुरोध गिनती नहीं करते हैं।

GET कोई कुंजी की आवश्यकता नहीं JSON or binary file 30 किमी वर्ग तक 3-bit classes प्रति पता 60 अनुरोध प्रति घंटा

जहां मुख्य सड़कें और रेलवे एक बिंदु के चारों ओर एक वर्ग पर हैं, और प्रत्येक क्या है: लगभग 10 मीटर की हर कोशिका सात वर्गों में से एक के रूप में वापस आती है, मोटरवे से विरासत रेलवे तक, समान डेटा मुख्य सड़कें और रेलवे मानचित्र खींचता है। यह के बगल में एक लैंडिंग खतरे की परत के रूप में अभिप्रेत है इनलैंड वाटर API, इसलिए एक landing tool एक motorway से quiet road से व्यापक margin रख सकता है: इसे web page या script के लिए JSON के रूप में, या एक छोटी binary file के रूप में जो flight computer या ground station ले जा सकता है, इसके लिए पूछें।

GEThttps://www.altimetercloud.com/api/roads/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.
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भारी रेलवेrail
6मध्यम रेलवेलाइट रेल, ट्राम, सबवे, मोनोरेल
7Light 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 × 1867.4 KB
3 km324 × 55666 KB
5 किमी540 × 926183 KB
10 km1,078 × 1,850731 KB
20 km2,156 × 3,7002.9 MB
30 km3,234 × 5,5506.4 MB

सड़कें और रेलवे जमीन का एक छोटा हिस्सा कवर करते हैं, इसलिए संपीड़न इन्हें उनके कच्चे आकार के एक छोटे अंश तक ले जाता है।

बाइनरी फाइल

जल और वृक्ष छतरी फ़ाइलों के समान 32 बाइट हेडर, संस्करण 2 के साथ और तीन बिट्स एक सेल।

Byteटाइपमान
0char[4]ACRD
4uint8Version, 2
5uint8Bits per cell, 3
6uint16डिग्री प्रति सेल, 12000
8int32उत्तरी किनारा कक्षों में: इसका अक्षांश × 12000
12int32पश्चिम की सीमा सेल में: इसकी देशांतर × 12000
16uint32पंक्तियां
20uint32कॉलम
24uint32Bytes per row
28uint320, आरक्षित

एक स्थिति अपने सेल से बिल्कुल मैप करती है: 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

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 को 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”. इस पृष्ठ पर सूचीबद्ध डेटा के अपने स्रोतों के लिए कोई भी क्रेडिट लागू होता है।