Category Archives: English

Falsehoods programmers believe about maps

Ok, I’m probably not the first one to write a post about falsehoods programmers believe about maps, but I still remember reading “Falsehoods programmers believe about names” and “Falsehoods programmers believe about time“, and thinking “there should be a post like that about maps”. So, go ahead, read those two posts to get to know the style of a post like this and then read on here.

  1. All coordinates are in “Latitude/Longitude” (Why is this false?)
  2. If you know the “Latitude/Longitude” you can be certain of exactly where you are
  3. “Spatial is special”
  4. The earth is round (Why is this false?)
  5. The earth is ellipsoidal (Why is this false?)
  6. The GPS-satellites know where I am
  7. There is a single, right, map projection
  8. Scale numbers works on a screen (Why is this false?)
  9. There are no good alternatives to Google Maps
  10. Web Mercator works for all purposes
  11. The shortest path between two points is a straight line
  12. All programmers agree on the ordering of latitude and longitude pairs
  13. Given a paper map I can always digitize and georeference it
  14. My background map will be better if I cache it, always!
  15. GIS software is always expensive
  16. The whole world is mapped, thouroughly
  17. Looking up a street address and get it’s position is easy
  18. Offline maps is as easy as Goole Maps

That’s what I’ve come up with this far, I might fill in something here when I think about it. Comments? Additions? Any errors? Want citations? Well, the comment section is open, so go ahead!

Lightweight coordinate transformations in JavaScript

We (as in: people that work with geospatial JavaScript) have all been there: We have coordinates as “latlons” (i.e. Geographic coordinates in WGS84), but we need to transform them to some other coordinate system (as a Norwegian: replace “some other” with UTM Zone 33N). Ok, that shouldn’t be that difficult, just include proj4.js. It’s a mere 73.275 kb, and handles almost all coordinate transformations (given that you know their definitions).

But, sometime you just care about one single transformation (say: EPSG:4326 to EPSG:32633), and you are really concerned about file size (maybe you are targeting a mobile site), because size does matter and you feel that proj4.js weighs in a bit too heavy. Well, that was what Bjørn Sandvik thought yesterday:

Then I got around to thinkning: how hard can this be? After a bit of thinking I realized that, yes, this is actually rather complicated in terms of maths. But, after a bit more thinking, I remembered this project from a couple of years ago (blog post in Norwegian). Basically, my old department at NTNU had some fortran code from around 1990 written by professor Jon Holsen in Fortran.

A couple of years ago I ported that code to JavaScript (on GitHub), but did not think much more about it (although I heard reports that the department has used it some).

After looking at old notes and books on coordinate transformations it dawned on me that Holsen.js has a “bl_to_xy”-function, which transforms Geographic to planar coordinates. I then ripped out the relevant code, removed things that wasn’t needed for my simple WGS84 to UTM33 conversion, looked up the right params for UTM33N and made a gist in the middle of the night.

I did some testing against proj4js, and Bjørn did some more (reporting: “similar down to the centimetre”), and after figuring out that the original code used X for North and Y for East it seems to do the work. Result: a js file of about 100 lines, and that is rather readable lines as well. Running this code through a minifier (uglify.js) results in a 8 kb file (that is, about 10% of proj4js).

The code is tailored to transforming to one specific UTM Zone, but it should be easy to modify to work for other zones as well. Another idea is to make a similar script for transforming the other way, from UTM33 to Geographic coordinates. Holsen.js has support for this, so it shouldn’t be that difficult.

In closing: I think that small, simple scripts like this (which is small in size and does _one_ thing) is much more needed in JavaScript than in other languages. Download size matters for web apps, and the idea of one, monolithic library to solve all conceivable tasks does not work for JavaScript the way it does for Java and similar languages. Also: beeing able to provide a fellow geo-geek with working code in the course of a couple of hours is always cool! In addition: nice to see that work I did mostly for fun two years ago can be of use to someone.

FOSS4G 2013 – The Good, The Bad and the Ugly

Woha! Getting back to work after three days at FOSS4G in Nottingham kinda makes me feel the void. The last four days have really been an expirience. This years FOSS4G was the first that provided me with an employer willing to send me there and a non-jetlag-inducing travel distance.

Although the title has an overweight of negative words this does not reflect my impression of the conference (I’m just a sucker for a catchy title). The plans for this piece is to provide a summary of my experience, some reflections and an insight in what I’ve learnt during the course of the days in “Mappingham”.

So, without further ado, let’s get down to the details. The trip started on Wednesday evening at Værnes Airport, where I managed to get to my gate without checking in to my flight. A kind, but annoyed person at the check-in counter agreed to let me board the plane, but I was a bit nervous for a while. The plane took us to London (don’t ask, I assumed London – Nottingham was a short ride by train). After an aborted landing and a round-trip and then an actual landing my colleague and I had a sprint through Gatwick airport, a long wait in the immigration queue and managed, with a margin of 10 minutes, to catch the train to London. In St. Pancras we had a 20 minute wait before the Midlands Express departed for Nottingham. The train ride was okay, a bit cramped, but I managed to write some code and we had a beer, kinda like a normal evening, apart from the lack of space. After arriving in Nottingham we got a taxi and arrived in our accommodation in Cavendish hall 23.55, five minutes before the man registering us planned to leave for the night. After a while he even managed to find my name on his list (note to self: someone may alphabetically sort me by my middle name..). Cavendish hall was rather spartan, but it had a bed, a power socket and WiFi (in addition to really thin walls..). I couldn’t let go of the code from the train, and spent a few more hours coding (not on an open source project I’m afraid :\).

The long trip and nightly coding session meant that I missed the heart-attack-inducing English breakfast and headed straight to the conference venue at 09.00 (which is actually 10.00 by Norwegian time, so I was rather awake). After getting our tags, programs, bracelets and t-shirts we got highjacked by the guys at the Mango Maps stand who gave us an demo of their software, Mango Maps. Impressive stuff, and while I may have seemed more interested in the technology behind it than the applications of it I can think of some places where it might be useful.

After a coffee or two we headed into the auditorium for the opening plenary. What can I say? went a bit over time, it mentioned drinking a lot, but apart from that I really think it showed how hard the conference committee has worked setting this up. And Daft Maps. What. A. Shock. That tune is still stuck in my head! The opening keynote from Chris Tucker introduced (to me at least) the mapstory.org website and foundation. Great talk, and a mindset and approach that I really think has potential. Being reminded that there are a lot of users and data-owners that have no clue what a shapefile is was a bit scary though.

Another key-takeaway from the opening plenary was that it was a 5-10 minute walk to the arena for three of the sessions, the Clive Granger Building (CGB). As the first talk I wanted to see was scheduled to start at 12.00 in CGB, and the plenary went on till about 12.00, I sprinted out in the rain and found the distance to be closer to 10 than 5 minutes. The talk was held back for about 15 minutes, as I wasn’t the only one late. The talk, with the title “pgRouting for dummies”, gave an introduction and overview of a project I’ve heard about and thought about using a few times, but never came around to actually use. A nice introduction, although maybe a bit technical for the complete dummy, and a bit to shallow for the non-dummy I consider myself to be. On my way back from the talk I got lost (yes, I see the irony there), so the next talk I attended was Arnulf Christls talk on open data. Without revealing too much in advance, I think open data was a big topic at FOSS4G this year, and I would be suprised if it’s not even larger next year. Arnulf is a good presenter, and delivered a great talk. I even learned some new things about the OdBl license that OpenStreetMap uses, prompting me to encourage the attendees from Norkart to publish a recipe on how they manipulate the OSM-data used in their products. The power of Twitter! 🙂

After lunch i went to the banqueting suite for several talks. The main theme was mobile development, and the first talk by Pascal Coulon was a bit confusing. I think i heard that they where running a stack of Geoserver and PostGIS on a tablet, but I can’t really believe that. The next talk was actually two, Pierre Giraud and Bart van den Eijnden presented their experiences creating mobile map apps with OpenLayers and Phonegap. The main takeaway is that mobile is a bit more complicated than desktop, and my suspicions about Seneca Touch was re-inforced. Leaving a bit early (before the QA that is) I sprinted back to the CGB (in sunshine this time), and managed to get a seat in the small auditorium where Frank Warmerdam (of GDAL/OGR fame) presented the satus of said projects in cooperation with Even Rouault, the man who has “kept the project alive for the last years” (fun fact: Warmerdam met Rouault for the first time in person during FOSS4G 2013). With this/these project(s) being the backbone of open source GIS that they are, an overview of the project(s) from these guys was really worth spending 30 minutes on the floor of a crowded auditorium for.

The afternoon wrap-up for Thursday consisted of a walk-though of the OSGeoLive DVD Linux distro that we’ve got, and a keynote talk from Ben Hennig, known for the worldmapper.com project. With Ben being more a cartographer than a developer he really gave a bit of perspective, and could assure us that cartography is not dead (it just need to expand a bit maybe). It should be mentioned that I spent a lot of time googling his slide titles and tweeting them, as he launched the #mappinghamsongcontest hash tag at the start of his talk!

The closing plenary did not feature the keynote on d3.js by Jason Davies, which was a bit of a downer, as I really had looked forward to this one.

The keynote finished, Claire Gilmour entered the stage and asked us to “go away” and come back at 19.00 “dressed in out best” for the Gala event. I went back to my room, and the moment I sat down on my bed to relax for a minute I got an SMS from @alexanno, asking if I wanted to grab some beers in the hotel lobby. That’s an offer I can’t refuse, so after a quick change of clothes I was there, drinking beer and talking to an ESRI guy about beer and CAMRA. The gala event started approximately two pints of Marstons Pedigree later, and after some queuing I got a beer and a plate of Welsh lamb. The lack of tables made for a nice scene with four Norwegians trying to use the conference chairs both as chair and table. When we finished our meal the doors had opened to the GeoCamp, and we managed to get some seats at a table there, waiting for “The festival of the spoken nerd”. A great, geeky stand-up-show, featuring Mandelbrot-coastlines, and “our favorite shape” (no, not the Shapefile!). Great, geeky humor, which proves that FOSS4G is a conference that suits me well. I felt really at home. After the show we hung around for a bit, met some known and twitter-known Norwegians and spent the rest of the evening drinking beers (or, barley-flavored water, as all they had left in the bar was Stella and Becks) and talked about geospatial topics. The night ended where it started, in the hotel lobby, when the barkeeper announced the last round I was smart enough to go to bed (if only this was normal procedure!).

Nevertheless, the next morning I sacrificed breakfast for sleep yet again, but at 09.00 I was present and ready for one of the Python-talks of the conference. Edward Campbell from MetOffice (Britain’s Meteorological organization) presented Cartopy and Iris, with an emphasis on Cartopy. Really nice library that I’ll sure check out. I was also really impressed by the use of iPython to show off the code, running live in the browser! Next up was Geoserver on Steroids, which focused a lot on raster optimizing for Geoserver. Nice talk, but not exactly my day-to-day interest.

The next slot was a plenary, where Kate Chapman and Edward Anderson delivered good keynotes. Chapman presented the Humanitarian OpenStreetMap Team (HOT), what, how and why they do the things they do. Seeing the technology and data we daily use being utilized far from the comfort of the office really gives you a sense of perspective! Anderson, from the World Bank, continued the humanitarian theme, giving an overview of their efforts to use geospatial data and (open source) tools in their work.

After the plenary I did some serious session-switching, first the State Of Geoserver talk, which concluded with the live-release of Geoserver 2.4, then a talk/demo of CartoDB, which really impressed me. I mean, I’ve heard about before, but why I haven’t used it is a mystery to me. Great looking, feature rich and (from what it seems) fast and stable. This is the future. Then I watched Cédric Moullet present the process being developing the new map website for the Swiss mapping agency, with emphasis on user involvement in the development process. This is something that I find really important, and it’s nice to see GIS-developers acknowledge this fact!

A bit wiser after the sprints to CGB the last day I decided to head there early the the “PostGIS Feature Frenzy” talk by Paul Ramsey. This turned out to be a smart move, as the small auditorium quickly overflowed. Paul delivered an enthusiastic talk on a topic that might be considered dry, and I was really glad to know the reason for introducing the Geography type (“the newbies who kept nagging me, and the huge guys that owns satellites”). In the mood for more PostGIS knowledge I did not move (like most others) but waited for the PostMap talk. Jan Jezeck presented a web interface to PostGIS that allows the rendering of actual geographies. While I might disagree a bit on the technology used and the complexity, I really like the idea, so maybe I should put my money (or, my time) where my mouth is and make this web interface the way I envision it.. The last PostGIS talk of the day was about indices, which is really important. A good description of how, what and why when it comes to indexing. Mostly things I knew, but worth being reminded of!

The closing plenary started of with MetOffice presenting themselves and the winner of the hackaton. These guys really see the value in sponsoring an event such as FOSS4G, which is great! After this the winner of the Sol Katz award was presented to Arnulf Christl. This award is given to people who’s done an extra effort for OSGeo, and according to the committee, Arnuf getting this award was long overdue.

The first keynote was by Emer Coleman, who gave us a keynote on Open Data. The second was by Tim Sutton from the (now officially named) QGIS project. He stepped in for Nathan Woodrow, who couldn’t make it. Nevertheless, Tim told us about the QGIS history, the philosphy and the hurdles, as well as a showcase of the new 2.0 release (actually released during FOSS4G!). He also stressed the need for funds to keep the project going, and the work of all the contrbutores

Friday night was without an official programme, but on Thursday night I had used the power of Twitter to gather all the Norwegians present to “go into town for some beers”. In the end about 25 people turned up, and we figured we where hungry. No reservations where made, but we did manage to find an Italian restaurant and we all got something to eat. I was really eager to get to the Brewdog bar, so before dessert I joined a group that left with the same goal. Turned out the Brewdog bar was full, so we found some other joint, where a local punk band played. Some beers and music later we re-united with the remains of the Norwegians and had no trouble getting in to the Brewdog bar. What can I say? Tactical Nuclear Penguin and Black Tokyo* Horizon really made my night, and we stayed there until they turned on the lights and started cleaning tables (which isn’t that late in Britain, thank Xenu!).

Saturday morning I actually had eggs, bacon and sausages for breakfast, and headed straight for the CGB. The first talk of the day was by Frank Warmerdam, again on one of the pillar libraries of FOSS4G, Proj.4. Great, informative talk on topics that more than a few has had their share of struggles with (I know I’ve had). The next talk was on Lucene Spatial, which left me more confused than enlightened (and there was little room for questions due to technical issues). Then the OpenLayers 3 showcase brought me back to more familiar territory. A good talk that, for me at least, inspired to try out this “new library” and explore it. While the CGB featured two more OpenLayers 3-talks, I really wanted to catch the Leaflet talk, so i used the 30-minute break to walk back to the main conference center. This proved worth it, Vlad gave one of the best talks of FOSS4G13, focusing not on technology but on the history and philosophy behind Leaflet. I’m really impressed with this project! Key takeaways are the focus on removing instead of adding features and striving to keep your code base simple so that possible contributors are not scared away.

Next up was a talk by Christopher Helm, an Esri (or E-dollar-ri as they where referred to as) guy. Proving my assumptions wrong, Helm turned out to be a genuine geek, an energetic speaker and really the javascript-grunt-node-geek that FOSS4G features a bit few of. The talk itself was maybe a bit hard to get the main idea behind, but in essence: “Git is cool, why not use it for geospatial data as well”. With examples. Next up was GeoGit, which “relates to Git the same way carpet relates to car”. GeoGit is, after what I understand, a way to handle updates and revisioning of geospatial data. Topics covered included why not just use git, the proposed solution and status of the project (which is: working, but “trivial” matters such as speed and indexing are missing). Overall a great project, and really a good answer to a question I posted on gis.stackexchange.com a while ago.

To squeeze the most out of the conference, I chose to minimize lunch-time and maximize talk-time. Having already seen the PostGIS feature frenzy (which was re-run) I watched a talk from the Danish Geodata Agency. The topic was their migration to an open source database system (PostGIS). Rather similar to talks I’ve heard from the Norwegian Mapping Agency, which have done the same ting. Cost and licensing of proprietary db-systems for web-scale was the main drivers, and the result was absolutely delivering. A shame they still rely on their proprietary db for actual in-house use, but I guess it’s difficult to bring change by revolution. A step at a time is probably a better way (evolution FTW).

The last talk before the closing plenary was Helm again, this time on Javascript and GIS. I couldn’t agree more on his thoughts, js is the shit and we need more of it in GIS. I really wish there was an European version of the geospatial JS-conference in the US. Apart from this: lots of js-gis-libraries showcased, and I really agree that JSTS is a bit to much of a Java-port.

Sadly, all good things come to an end, and the closing plenary marked the beginning of the end. The bencmarking sessions where a bit watered down; the WPS-benchmark was more of an overview and the WMS “shootout” was canceled due to organizing issues. Though, Arnulf Christl appealed for a new WMS shootout next year, hopefully someone will make that happen.

The two closing keynotes where delivered by Ian James from the Ordnance Survey and Paul Ramsey (who doesn’t need further introduction I guess..). James told us the story of the Ordnance Survey path towards open source (well-thought out and planned was not how it happened), and why they use open source. I feel that there really is a theme that governmental organizations use open source software, and in many countries there are guidelines which indeed mandate the use of open source.

Then Paul Ramsey delivered a keynote which many has described as “the best I’ve heard in ages”, and I agree with them. The topic was “Being an open source citizen”, and trying to recap it here won’t do it justice. Some keywords are: “digital barn building” and how egoism really is the drive behind open source. Just a great talk of the kind that makes you think.

The final words and thank yous by Steven Feldman, and included a lot of applause and almost everyone in the audience ending up on the stage (it felt that way at least), and a cozy recap-by-the-fireplace scene with the main organizers. At the end Portland, Oregon was presented as the venue for next years FOSS4G, and I really want to go! (beer-geek-heaven combined with mapping/code-geek-conference, what could be better??)

That concluded the actual conference, and a colleague of mine and I headed into Nottingham, in search of some beers to bring back home and some food. I managed to offend a wine shop employee (“do you have any quality beers?”) and we had a great burger at “Gourmet Burger” before we got on the bus back to campus and the GeoCamp for what turned out to be a large-scale, kinda messy and confusing beer tasting involving Brewdog beers and ~150 thirsty geo-geeks. After beer, pizza, bow and arrow shooting and a lot of ping-pong balls an improv-comedy group knows as “The red herrings” entered the stage, and put on quite a show. I laughed hard for about an hour, splendid! The highlights? The “I like my maps like i like my women..”. “Spread on the kitchen table” was a great contribution from the audience! Rather tired I went to bed at around 23.00, and though my window I could hear the tunes of “up all night to get mapping” from the GeoCamp. Someone had a lot more energy left than me 🙂 The entire Sunday was spent going back to Trondheim, talking about the experience and coding a bit.

So. What was FOSS4G13 like? The short version: GREAT! I really felt at home there, the people, the talks, the buzz was all things I know and can relate to. Spot on with the conference there. The actual talks of course varied in quality, some technical issues, some introverts having a bit of stage-fright and some language-issues, but these are minor issues. Three main things really annoyed me, that was the 10 minute walk to the CGB, which made session switching difficult. The other was the fact that several of the most popular talks where placed in such small rooms (Paul Ramsey, Frank Warmerdam and the OpenLayers team in the smallest rooms, come on, you knew these would be popular). Lastly, a lot of talks (and especially the plenaries) went over time. Oh, and eating from a plate with knife and fork without a table to sit down at is difficult..

Apart from that? Great. Just great! Next year, if I get the chance to go, I’d definitely would like to get in on more of the action, code sprints, hackatons, workshops, the whole works really! On such a large event you just can’t participate in everything, but I really would like to be able to engage some more.

OpenLayers and Leaflet

The world of open source software sometimes seems as competative as the proprietary world. So also in the field of web mapping clients. For many years (since 2006) OpenLayers was the only player in town (that is, if you wanted a mature, stable, customizable and open source javascript mapping library that is).

Then came the new kid on the block, Leaflet, (in 2011). Where OpenLayers supported IE6, has support for almost all projections and tiling schemes you could think of, Leaflet was the “Javascript hipster”, with a streamlined API, modern JavaScript, small footprint and gained a large following in short time. All the while Leaflet rose to fame, OpenLayers started its fundraising campaign to support the development of the promised version 3, a complete rewrite with more modern Javascript, a smaller footpront and lots of improvement.

Some may think that OpenLayers has lost it’s throne, but when I checked the list of submitted talks to FOSS4G 2013 I was a bit supprised: 5 talks mentioned Leaflet, while a tenfold as many mentioned OpenLayers. I guess OpenLayers is going nowhere, and still has a strong standing!

But then, after mentioning this on Twitter and getting some feedback, I started to think a bit. And what I thought of was this: Is it really “fair” to compare Leaflet and OpenLayers? My point of view is a bit split, I kinda grew in to the world of geo-web-development with OpenLayers back in 2009, learning Javascript and OpenLayers simulataneously. This has colored my view quite a bit, but then again, after becoming more and more of a Javascript Hipster myself, I find myself drawn to the clean, sleek code of Leaflet. But, from my time in the industry I know there are huge differences between startups and “web companies” and the large players in the geospatial field. Many of those big players have “gone opensource”, and based their web mapping presence on OpenLayers (and derivatives thereof). These players (like the Norwegian Mapping agency, as a norwegian I like to use examples I know) are “slow movers”, and I don’t see them switching over to Leaflet anytime soon. And why should they? Requirements like support for old browsers and OGC-standards are esential for the needs of such players.

And again, I do think that OpenLayers will manage to release it’s version 3, and I have high hopes for the code of that version. Maybe I can be a Javascript hipster with OpenLayers? Which reminds me, I gotta get around to contribute a bit to the project!

My point? Well, not quite sure, but I hope and think that the “rivalry” between the libraries and (maybe even more so), the supporters of the libraries, are kept at a sivilized level, where one debates the technology and performance of the products. And, I also feel that these libraries fills two, rather overlapping, but also different needs and “markets”. And I kinda wanted to blog a bit in english 🙂

Thoughts? Comments? Opinions?