Now Reading
Lane-accurate road maps with OpenStreetMap – writing a vector tileserver for osm2streets

Lane-accurate road maps with OpenStreetMap – writing a vector tileserver for osm2streets

2023-01-19 05:10:52

I’ve constructed safecyclingmap.com, an open-source proof of idea map that renders cycleways and streets right down to the person lanes, to help cyclists selecting secure routes and help advocacy for reallocating highway house to extra environment friendly modes (as supported by the TfNSW Future Transport Technique).

I’ve open sourced the backend infrastructure in order that others can incorporate the small print into their internet and cellphone maps (see osm2streets-vector-tileserver or learn under). This builds upon the unimaginable work of Dustin Carlino who leads the A/B Street traffic simulation project.

I wrote the preliminary vector tileserver from scratch in a single afternoon in Typescript, calling the JS bindings for the Rust osm2streets code compiled to wasm. It generates GeoJSON which is then returned by Koa as a protobuf. I’ve spent some extra hours bettering efficiency, however there’s a lot that could possibly be improved.

The TfNSW Future Transport Technique states “We’ll concentrate on getting extra out of our current investments, by reallocating highway house to extra environment friendly modes of transport like buses, strolling, biking and micromobility gadgets.”

This weblog submit explains how and why I constructed it.

Present detailed road maps

Most road maps simply use a line for every road:

Normally the color of this line denotes how giant or necessary the highway is. In case your metropolis doesn’t have a lot devoted bicycle infrastructure, selecting a secure highway is usually a problem.

In 2020 Google introduced that it could be implementing extra detailed road maps in chosen cities:

Quickly, you’ll be capable of see extremely detailed road info that reveals the correct form and width of a highway to scale. You can even see precisely the place sidewalks, crosswalks, and pedestrian islands are situated… We’ll begin rolling out detailed road maps in London, New York, and San Francisco within the coming months, with plans to develop to extra cities over time.

A more detailed, colorful map, Aug 18th 2020, Google.

Justin O’Beirne, a prolific author on the buyer maps aggressive panorama, wrote in April 2022 that Google has launched detailed road maps in 40 cities to date. No cities in Australia make up this listing.

Open supply competitors

OpenStreetMap (OSM) is a free, editable map of the entire world that’s being constructed by volunteers largely from scratch and launched with an open-content license. Due to the license it has grown shortly and now rivals (and sometimes exceeds) the element of business map suppliers. OSM information is utilized in Instagram, Wikipedia, Strava, Snapchat, Uber and plenty of others.

An undertaking utilizing this information has been quietly producing extremely detailed road maps. Dustin Carlino began constructing the A/B Street traffic simulation app since around 2019, and as a part of this launched the osm2streets undertaking. osm2streets takes OSM information and attracts detailed shapes of streets – although didn’t but help rendering into generic internet or cellphone “slippy” maps as detailed on this Github issue.

Brunswick, Melbourne rendered in A/B Road

I wrote an open supply vector tileserver osm2streets-vector-tileserver to allow “slippy” internet and cellphone maps to load the detailed automobile and bicycle lane info that osm2streets generates.

As a proof of idea, I’ve constructed safecyclingmap.com to devour the tiles produced by osm2streets-vector-tileserver. It’s a visualisation of this detailed road information to help cyclists with selecting secure routes in cities with little devoted biking infrastructure.

Technical particulars

Keep in mind: I initially wrote the tileserver in a single afternoon, and I haven’t put a lot effort into reliably internet hosting the infrastructure but, so this could possibly be improved.

The backend works by taking vector tile requests from a frontend (with a url like https://api.safecyclingmap.com/tile/18/241180/157318).

As soon as a request is obtained, the tile at zoom stage 15 that accommodates the requested tile as a subset is calculated.

The OSM XML is then fetched from an area Overpass Turbo occasion for that superset tile, and the osm2streets road community output for this tile is generated (utilizing the JS to wasm (Rust) bindings at https://www.npmjs.com/bundle/osm2streets-js).

See Also

Requested subset tiles are then generated utilizing the road community object that covers the superset tile.

The geojson layers are then generated and mixed, and returned to the consumer as a Protobuf.

When you’ve got any questions or are enthusiastic about contributing, come and be part of the Matrix room at #osm2streets-vector-tileserver:matrix.org or increase a PR at https://github.com/jakecoppinger/osm2streets-vector-tileserver.

Caching

I’ve used two least-recently-used caches to cache the osm2streets community output, in addition to the ultimate particular person vector tiles. Vector tiles requested that match inside the bounds of an in-progress zoom stage 15 Overpass Turbo obtain (and related community technology) busy-wait for the cache to develop into out there (with a timeout if there’s an error).

At present it really works in all of Australia, as downloading all map information for the complete world wants a bigger exhausting drive! I wanted 8GB of swap house to arrange the docker picture and not using a failure.

The frontend is at the moment hosted on Github pages (behind Cloudflare) as a result of haven’t but configured SSL config on AWS S3 for this area.

The backend at the moment runs on a Vultr VPS, utilizing Cloudflare Tunnel to ship requests to localhost:3000.

Additional work

Additional options that I feel can be helpful:

  • Making it work worldwide by passing requests exterior Australia to a public Overpass occasion from https://wiki.openstreetmap.org/wiki/Overpass_API#Public_Overpass_API_instances – with the brand new caching there shouldn’t an excessive amount of visitors
  • Contributing to osm2streets to go further attributes within the vector tiles returned, resembling:
    • Velocity of the road, to have the ability to color code streets
    • Degree of the road, to cover underground roads

Source Link

What's Your Reaction?
Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0
View Comments (0)

Leave a Reply

Your email address will not be published.

2022 Blinking Robots.
WordPress by Doejo

Scroll To Top