Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Assault on Copenhagen (SOTM Brussels)

The Assault on Copenhagen (SOTM Brussels)

A little story about a bug in some code from earlier this year and a war that happened in the 1600s

Julian Simioni

September 24, 2016

More Decks by Julian Simioni

Other Decks in Technology


  1. @juliansimioni
    500 Year Old Bugs in
    the Pelias Geocoder
    Julian Simioni
    So, we’re going to start with a bit of a Shakespearian list of characters and then I’ll tell a little story.

    View full-size slide

  2. @juliansimioni
    This is Denmark, it’s a nice little country not too far from here.

    View full-size slide

  3. @juliansimioni
    This is Sweeden, another nice country, not quite as small and not quite as near.

    View full-size slide

  4. @juliansimioni
    This is Copenhagen, it’s a very nice city and it’s the capital of Denmark.

    View full-size slide

  5. @juliansimioni
    This is the home page of the Pelias geocoder. It’s an open source geocoder built by us at Mapzen. I’ve been on the team for about 1.5 years

    View full-size slide

  6. @juliansimioni
    Even if you haven’t heard the term geocoder before, you probably know what it does. It’s basically the thing that lets you type in the name of a place and hopefully find it
    on a map. Here’s what it looks like when everything works great.

    View full-size slide

  7. @juliansimioni
    This is Mapillary, they’re here and they’re good people so definitely say hi. By the way their headquarters is in Sweden. Mapillary uses Pelias on their home page, so if
    you want to find a place and look at all the pictures, you’re already using Pelias.

    And that’s great, we’re happy that Mapillary is using it and everyone using it is happy, except for one day a few months ago where all of us at Mapzen in New York City
    woke up to this tweet:

    View full-size slide

  8. @juliansimioni
    So this is a screenshot of a search for Copenhagen on Mapillary’s home page. And remember from before that Copenhagen is the capital of _Denmark_, not Sweden.

    So that’s a little awkward. But many of you might know that Sweden and Denmark have been at war a few times. And you might also know that Copenhagen has been
    pretty pivotal in those wars and it’s changed hands a few times.

    So, this is pretty bad. And remember Mapillary is based in Sweden so it’s especially awkward.

    View full-size slide

  9. @juliansimioni
    So as part of the Pelias geocoded we import data on countries, cities, neighbourhoods, that sort of stuff. This is the geometry information we have for Hovedstaten,
    which is the district of Denmark that contains Copenhagen. Some of you might already see what’s happening here if you have done some work with spatial geometry.

    So Hovedstaten basically contains just the city of Copenhagen, except then there’s also this little island off to the right.

    So within our dataset use this geometry information to calculate parentage, which is basically what city belongs to what country, etc. And it turns out the way we initially
    did this was pretty basic, where we took the bounding box of the geometry, which you can see in this image, it’s the darkened square area. And then we would take
    whatever country was in the exact center of that box and just assume it’s the right one.

    So, what country is in the middle? Of course its Sweden and that’s what cause the problem. Anyways, we have facilities for fixing things where our basic algorithm
    doesn’t work, and we were able to manually fix the open data behind Pelias, and we also have some smarter code to do this in the future.

    But that’s not really the interesting part in my mind, it’s just some code that was wrong. What’s interesting is some of the history. Who has heard of King Charles Gustav X
    from Sweden? Yeah, so in the 1600s he decided that Copenhagen should really belong to Sweden instead of Denmark, so he went out and conquered it. Eventually of
    course he was repelled and the Danes got their capital city back. But the Danes also took back a bit of the southern tip of Sweden, and it turns out they negotiated for
    possession of that little island in exchange for giving back that territory.

    So, while it may have seemed in the 1600s that King Charles did not get Copenhagen like he wanted, at least according to Pelias, he got it for a few hours earlier this
    year, and he has the Danes who took the city back to thank for it.

    View full-size slide

  10. @juliansimioni

    View full-size slide