Archive | openstreetmap

Connecting WordPress to OpenStreetMap with Auth0

If you log in to this blog you can now do so using your OSM account. If I say so myself, that’s pretty awesome. Here’s how I did it:

First we need to install the Auth0 WordPress Plugin which you can find by opening up WP, going to plugins and searching for “Auth0.”

Auth0 is just fantastically awesome. It’s a service which allows you to login to anything using anything. For example, you have a rails project and want to log in using facebook. Or you have a Node project and you want to log in using Active Directory. Or in our case, WordPress and log in using OSM. Auth0 is very extensible and developer friendly. For example, there are arbitrary JS events that fire through the login process. You can have twilio send you an SMS when someone logs in as an example.

Another way I like to think about it is like this: It used to be that you’d write a PHP app with JS front end and SQL backend. What Ruby on Rails did is meld together SQL and Ruby so now you only need to learn two things (Ruby and JS). You didn’t have to write SQL as well. Now things like meteor are removing even that so you just write JS everywhere. In a similar way – the first thing you do when you make an app is usually go build your login system. No more! Just use Auth0 and avoid all that pain. Auth0 is going to be more secure than anything you do, and immediately extensible.

Once you’ve installed your WP plugin, head over to the connection API Explorer.  Most things in your Auth0 dashboard are trivial you just turn them on and off like this:Capture

But OSMs authentication API isn’t this easy for a number of reasons. First, it uses OAuth 1.0(a) and Auth0 support version 2 out of the box as a thing on the dashboard. Second, OSM still uses XML where the rest of the world has moved on to JSON.

But it still works! We just need to use the Auth0 connection API to create a connection.

Next you need to log in to OSM. Click on your user at the top right, click settings, click OAuth settings, and create a OAuth Client. More docs are here. Once you have a OAuth app set up on OSM, you will get your client id and secret you can use with the code below.

On the Auth0 dashboard, create an application (applications -> create) and note down the client ID and secret.

On the API page, create a token with connections:create with the token generator at the top left – this lets you create new connections straight from the browser:

Capture2You also want to create a token with all the permissions around the following: clients (create and update), connections (create, read and update), rules (create and delete) and users (create, read and update). Note down this token, as the Auth0 WP plugin will need it.

Next we need to paste some code in to the box marked “body”:

{
  "name": "OpenStreetMap",
  "strategy": "oauth1",
  "options": {
    "client_id": "YOUR OSM CLIENT ID HERE",
    "client_secret": "YOUR OSM SECRET HERE",
    "requestTokenURL": "https://www.openstreetmap.org/oauth/request_token",
    "accessTokenURL": "https://www.openstreetmap.org/oauth/access_token",
    "userAuthorizationURL": "https://www.openstreetmap.org/oauth/authorize",
    "scripts": {
      "fetchUserProfile": "function (token, tokenSecret, ctx, cb) {var parseString = require('xml2js').parseString;var OAuth = new require('oauth').OAuth;var oauth = new OAuth(ctx.requestTokenURL,ctx.accessTokenURL,ctx.client_id,ctx.client_secret,'1.0',null,'HMAC-SHA1');oauth.get('http://api.openstreetmap.org/api/0.6/user/details',token,tokenSecret,function(e, b, r) {if (e) return cb(e);if (r.statusCode !== 200) return cb(new Error('StatusCode: ' + r.statusCode));parseString(b, function (err, result) {if (err) return cb(err);var profile = {user_id: result.osm.user[0]['$']['id'],given_name: result.osm.user[0]['$']['display_name'],picture: result.osm.user[0].img[0]['$'].href};cb(null, profile);});});}"
    }
   },
"enabled_clients": [
    "AUTH0 APPLICATION CLIENT ID HERE"
  ]
}

Remember to enter your ID and secret. Now click the “Try” button and you should get a “201” response that the connection was created.

So now we need to hook this up to the Auth0 login box (called the “lock”). Back on your wordpress site, go to the Auth0 plugin, settings, basic. Here enter your client ID and secret from when you made the application in the Auth0 dashboard. Also add the API token you created with all those permissions and click save. Next go to the advanced settings and enter the following in the CSS box:

#a0-lock.a0-theme-default .a0-zocial.a0-osm {
    color: #fff;
    width: 40px;
    height: 40px;
    background: #ffffff url('http://www.openstreetmap.org/favicon.ico') center center no-repeat no-repeat;
    background-size: 21px;
    border: 1px solid #5C666F;
}

And then this in the JS box:

lock.once('signin ready', function() {
    var link = jQuery('<div title="Login with Open Streen Maps" class="a0-zocial a0-icon a0-osm " dir="ltr"><span>Login with Open Streen Maps</span></div>');
    link.on('click', function () {
        lock.getClient().login({
            connection: 'OpenStreetMap' });
    });

    var iconList = jQuery('.a0-iconlist');
    iconList.append(link);
});

We need to do this to add the button on the login box for OSM. Lastly, go back to your Auth0 dashboard and the app you created. You’ll need to add a line in “Allowed Callback URLs ” which will be unique for your site, but for my blog it’s this: http://stevecoast.com/index.php?auth0=1

That should be it, now users can log in using OSM:

Capture3Notice that I’ve turned on facebook, GitHub and so on… and a the end there’s the OSM logo. Click it and you can login with OSM!

Of course, now you’ve done this it means you can connect an iOS application, your webapp or anything else to OSM in the same way. Magic.

0

New Year, New Roles

It’s been a wild two-and-a-half years at Telenav helping bring OpenStreetMap to the consumer. We shipped consumer turn-by-turn navigation in the US with Scout which was for me a big first – a turning point of showing OSMs true potential.

As the OSM project at Telenav has grown the need for the visionary founder has shifted and I’m stepping back from full-time work at Telenav. I’ll be still helping part-time and helping with new projects going forward. 2016 is going to be a fun year with a great team at Telenav (including all the bright folks we brought in from Skobbler) and I know they’ll continue to push out more OSM goodness.

New Kickstarter: Every Road

Untitled.001

I have a new kickstarter live now: Every Road! Every Road is a unique poster print of every road leading away from your house (or any other point). Above you see the bay area, driving away from the Ferry Building at the NE of San Francisco. Here’s the same thing driving away from a point in the Sunset:

Untitled.006

The roads get thinner as you go and lead to a tree-like structure. Each print is totally unique to you. Here’s driving away from Buckingham Palace in London:

Untitled.002

Here’s walking everywhere from Wall Street in Manhattan. Notice most route on Manhattan end up walking North and branch out across each side:

Untitled.003

Here’s the same thing, but driving:

Untitled.004

Notice how it leads to a totally different map because driving leads to quicker routes along the edge of Manhattan and then driving inward to each point. As opposed to walking, where your maximum speed doesn’t change depending on what road you’re walking on.

The data of course comes from OpenStreetMap, more details are at the Every Road kickstarter!

The Book of OSM, now available!

bookThe Book of OSM is now shipping on Amazon Kindle and in paperback (uk, de)!

This book contains 15 interviews conducted by OSM founder Steve Coast with the people who were there as the project began and grew. Starting in 2004, the interviews trace how a rag tag collection of volunteers was able to produce a map which compares in quality to maps produced by multi-billion dollar corporations. Learn how such an ambitious project got started and then succeeded at mapping the world, for free!

The book was the result of a kickstarter that raised just under $10k.

The Book of OSM – nearly available

My kickstarter project for the book of OSM is nearly done. Kickstarter backers already have the PDF of the book: The contents are final and the cover has some bugs being fixed:

BookOfOSMBug

Notice the white lines on the back cover. Once that is done, it’ll be available on Amazon.com and Kindle. If you want to stay up to date, there is a mailing list on the website for the book.

Tesla Maps and the exploding future of map data

Out of a job!

Out of a job!

Tesla are making maps, and why not? It used to cost billions of dollars to go collect the data, now the customers do it for free. The sensor packages in phones, let alone in the car, have put the power of geography in everyone’s hands.

We used to do this with volunteers in OpenStreetMap but now even that will be superseded. Armed with cameras, GPS, radar and sonar, a car can just capture all the data and (pretty much) make a map automatically, for free. It’s happening for two reasons:

  1. The costs are now so low. The old model of paying people to drive around expensive vehicles to capture data is too expensive and takes too long. Even if you did drive every road, every year, it still isn’t good enough for autonomous driving.
  2. The incentives are so high. If you were Tesla would you want a dependency in Google for maps? Really, would you want a dependency on anyone now that the cost is zero?

I was talking to someone recently who’s 18 or so. They literally thought “encyclopedia” meant “wikipedia”. Digging in their memory they remembered that there used to be sets of books (Britannica) too, but not anything else. That’s how maps are going to go, in a sense.

When proprietary map companies drive around expensive cars to collect data they had to pay for the car, the equipment and the people. Tesla has their customers to pay for all of that. They’ll have a fixed cost in building software to capture the data and then amortize that very quickly so the effective cost for them to build one of the best maps of the world is going to be… zero dollars.

StreetView cars are going to go away, it will just be every car taking photos all the time.

Implications

The number of maps is going to explode. It used to be that pretty much just two companies held map data for the US and EU; NavTeq and TeleAtlas. Now there are five: Google, Waze, OSM, TomTom and Nokia. Correction, now there are six with Tesla. We can argue over their relative qualities, OSM lacks geocoding, Tesla probably does too and so on. But it’s coming.

And those are just the public ones. There are a bunch of logistics companies and governments who have their own maps.

The list of people who might want their own map, and be in a position to build it, is large. Every car company, every decent-sized tech company, every location company (Garmin to Strava). The arms race is now on.

As the number of maps goes up, the value per-map is going down. That means that you should probably short anyone reliant on proprietary map revenue for their future. OpenStreetMap is pretty comfortable because the dollar cost of OSM is already zero so there aren’t any adjustments to be made, except perhaps that the incentives to help complete a free map of the world are going away, if everyone has maps and the value is dropping so precipitiously.

You could argue that price of maps won’t change since Google, Waze and Tesla will keep their maps to themselves. And yes, maybe. But it’s more likely not since they are removing themselves (and their dollars) from the customer pool. One of the new maps will be made available at some point too, they won’t all be locked up.

So the value that used to be in the map data will move up the stack, right?

Actually I’m not so sure. Charlie Munger has this nice story about textiles where some factory making fabric bought some machine that made them 20% cheaper, or whatever. They were proud of this. But of course, every other factory does the same thing and the value doesn’t go to the factories but to the consumer. The consumer wins not the factory.

The primary way map service companies got their valuations was waving around the Nokia acquisition as a bellwether for value. But Nokia actually owned something – map data. If you’re providing services then you need something else, like large long-term customer deals to provide map services to anchor you.

The cost for anyone to start doing basic map service work is… zero. So we should expect a bunch of competition in that sector. And of course, thanks to Google making maps free to the consumer, everyone thinks maps are free so the actual dollars you get from developers or whatever are pretty thin.

So at the top end, your customers are going to go make their own maps and at the bottom end, Google, Apple and so on are making maps free. It’s a tough spot, but luckily there’s probably a decade in there to figure it out.

Further Out, 10-30 years

The interesting implication is that creating a map will cost zero for Tesla, doesn’t mean it’s zero for everyone. It’s very beneficial to have a convenient fleet of sensors out on the roads. But that too is changing. Everyone and their brother is building self-driving cars.

But will there be a market for them?

It’s deeply interesting. A lot of the models seem to be predicated upon everyone buying two self-driving cars like today every household buys two cars. That just seems really unlikely. It looks more likely that instead of two cars I buy one self-driving car and rearrange life a tiny bit, since when I’m done with it, it can drive home and help someone else.

So the market could easily drop 50%. But wait, there’s more!

Why would I have one at all? Pizza Hut will have them. They’ll send a car to pick me up and run an errand so long as I stop in for pizza. Or if I want to visit a friend, they can just send their car to pick me up. Or, one of the ride-sharing services. So, really, would I buy a self-driving car at all? So if it’s mostly fleets buying the things, you can kiss goodbye to the network of dealers. And since most of these things will be electric, the current network of maintenance shops is going to go away.

At minimum the landscape around driving is going to change dramatically. It’s hard to see drive-thrus working out like they do today, or taxi companies… or mapping companies.

Because in a world of self-driving cars, why do we need traffic lights? Why would we need stop signs or lane markings? How much paint do we use every year to mark lines on roads? Will we need roads? No – we won’t need roads covered in asphalt, we only need the parts the wheels go on covered and can leave a gap in the middle of weaker, or no, material. So the cost of building or maintaining a freeway is going to drop off a cliff too.

And in that world, maps themselves are going to be completely different. Why would you need street signs? In fact, why name anything at all? The name of the highway you’re on is completely meaningless since you don’t use that information, the car does.

Fun times.

License Ascent

Copyright when first envisaged granted a limited-term monopoly on a work which then later fell in to the public domain, or PD. This would give the author some amount of time to make money and pay the mortgage, balanced with allowing people later on to take the work and build upon it. So you write a book, you can sell it but nobody else can, and then some number of years later everybody can do as they please with your book.

This is no longer the case. Copyright is effectively infinite. This means that while we can take old works and build upon them (Pinocchio) we cannot do the same with even pretty old works (Mickey Mouse). Edge cases exist of course, for example you can in many places use old works for parody.

Some people wish to make their work available under less restrictive terms than owning it forever. For them, there are a set of licenses which they can use to release their works.

  • They can claim attribution. Broadly, this means you can use my work but you have to say where it came from.
  • They can claim share-alike. Broadly, this means you can use my work, but any derivative works need to also be sharable. So you can’t take my book and then rewrite portions and claim it for yourself.
  • They can claim commercial rights. Essentially this means you can use my work for anything but profit.
  • You can use some combination of the above.

Thus instead of claiming copyright forever for your new book, photograph or software, you could instead for example say “use it however you wish but all changes must be shared-alike and you can’t use it commercially”. This allows individuals and companies to put works out there and allow them to spread more easily than if they retained all the copyrights.

Two basic methods of making money have emerged while using these open licenses:

  1. The intellectual piece is free, but any physical product costs money. For example, 3D Robotics software for drones is freely downloadable and you can change it. But if you want a physical, flying drone then that costs money. Very similar is this: the basic software is free but some critical piece required for some use case requires payment.
  2. The work is available publicly under a difficult open license, but privately under some commercial agreement. This is known as dual licensing. The downside is that to encourage commercial usage, the open license tends to be as painful as possible. This way, a student at home is unaffected but a company might find a license difficult. Perhaps it requires a legal review, or places burdens on the company like open sourcing everything they do. To avoid this pain, they pay for the commercial license.

The trouble here is we still don’t have things leaking in to the public domain over time. It’s seen that once a work is licensed under some license that it’s stuck there until the end of man.Capture

What if we changed that?

I propose we engage in some kind of license ascent over time. Perhaps descent would be better. Under this scheme, some work starts out under a restrictive and painful license and over time makes it’s way in to the public domain. For example:

  1. I write a book. For the first year, it is available under a attribution, share-alike non-commercial license.
  2. After the first year, it is available attribution, non-commercial.
  3. After the second year, it is available under attribution.
  4. After the third year, it is available public-domain.

We are reintroducing the concept of the work leaking in to the public domain gradually. So when I first create some piece of work I own it outright and then over time it becomes less and less burdened.

For static works like a book, the timelines may be longer. Say, two or five years per step. For works which changed all the time, like datasets about the world, perhaps each step lasts a year. Why would we want to do this? Two reasons: Because otherwise it’s really hard to make money from open source, and otherwise open projects don’t benefit the public domain.

There are classes of works which require “giving back” like OpenStreetMap in order to attract people to contribute. That is, why would you contribute to OSM if you couldn’t access the data? OSM has now existed for 11 years and the state of mapping in the public domain is still essentially the same as it was 11 years ago. But what if OSM data dropped in to a more liberal license, or the public domain, over time? Perhaps we could have a PD version of OSM but it was 5 years old. It wouldn’t compete with OSM itself, but it would enrich what people could build on without restrictions.

Put another way, do we want OSM to be perfect in another 10 years and the public domain still be essentially unusable? Wouldn’t it be nice to improve both OSM and (for free!) the public domain maps available?

Now imagine you have some new project which requires crowdsourcing to succeed. Dual licensing has the downside that picking the open license has many difficulties. You want to pick something that encourages people to contribute yet allows you to retain space to sell things, and this isn’t easy. If instead you practiced license ascent then everybody gets the data at some point in the future. Perhaps if you are a PD person you wait 3 years, and a share-alike person you have to wait two years. But either way, it’s better than never getting the data under a license that you would consider useful.

And, it does this whilst allowing the project or company to make money off the freshest data. It also creates an incentive to make the data fresher, all the time, because otherwise the old data will be good enough for people.

Now you could argue that any project should be open from the start, but open projects tend to have significant downsides. Open projects are terrible at user interaction and experience. They’re terrible at design. They tend to be incoherent. But they are great at innovation and collecting data. At the other end, private companies which collect data tend to be great at design and so on, but terrible at innovation and collecting data because they don’t have volunteers. I posit that license ascent is a way to achieve both and that it’s better than just picking a license or selling widgets on the side.

 

A Modern Mapping Party

Last month I ran a mapping party in Castle Rock, Colorado at the new Philip S. Miller Park:

Philip S Miller Park

Philip S Miller Park

The park was challenging for a few reasons:

  • Nothing on the map before we did the party
  • No up-to-date aerial imagery
  • Lots of footpaths in winter mud conditions

Luckily we had a bunch of enthusiastic people at the event. The footpaths were easily captured using GPS units but the new buildings, football field and other macroscopic features were harder to do.

videoscreenshot

Drones to the rescue!

Luckily I own a Phantom Vision 2+ drone which looks like this:

th

So I sent it up to 500 feet or so and took some pictures with the HD camera which looked like this:

DCIM101MEDIA

The image shows part of the car park, internal access roads and the new sports building (red) and swimming pool (beige). Having some pictures is great, but what we needed to do was patch the images together to be able to map on top of them. You take these warped images from some height, location, yaw, pitch and roll and stitch them in to something flat and usable .

Enter MapWarper. This web-based tool will help you spit out that map:

imagerymiller

You’re looking at multiple images stitched together, click it for a bigger interactive version. MapWarper is a little clunky in the work flow as it stands today. Each image is stitched to OSM as a ground truth and then you use multiple of those in to a layer. The problem here is when you have no ground reference to stitch to, which is the issue we had. It would be super useful to be able to stitch images to each other, and to the ground rather than having multiple images in free space. Still, the thing basically works but is best used (and apparently intended for) single high altitude images, or old maps. Not multiple images like I did.

One solution would be to send the drone higher and cross fingers it doesn’t decide to fly away or something, and take a single image that way. The downside is lower resolution of the imagery. Upside it (hopefully) less distortion from the fairly wide angle lens the Phantom Vision 2+ has.

You can go from MapWarper to editing using iD on the OSM website pretty trivially, and anyone can now use the imagery to help improve the map. So one person can go through all the imagery pain, but then everyone else can use the imagery as if it was just any other layer. Big savings there.

So what’s important here? I think it’s a new tool in the belt for use at mapping parties (and a new set of toys to play with). You’re no longer (and haven’t been for a while) restricted to existing imagery and GPS units. For a fairly modest cost you can collect your own live imagery and make maps better, all by yourself.

Powered by WordPress. Designed by Woo Themes