So why does the International Date Line (IDL) cause so many headaches? It seems like a really simple problem, but it ends up touching a bunch of mapping concepts, none of which are easily dealt with. I ran across this when working on the Sourcemap project, when we wanted to relatively realistic travel paths. When I say “relatively”, I mean, don’t travel from Japan to California via France (and not via Kayak, either).
For Sourcemap, we started visualizing larger and larger networks, and began noticing that nothing from China was ever connected to anything in North America vai the Pacific Ocean. When you want to visualize a globally connected network, it helps if the network knows that the map is a globe, and creates connections in the direction that minimizes the distance between points. Using the built in cartography of OpenLayers, we get the following map:
Where the network is always constrained within the rectangle of -180, -90, 180, 90 (xmin, ymin, xmax, ymax). I approached this a couple of ways, and the one that turned out to be the easiest exploits a lesser-known ‘feature’ of OpenLayers, whereby a Longitude that exceeds the coordinate system (e.g. -200) is indeed rendered on the opposite side of the IDL (e.g. +160).
This is excellent! Now I know that OpenLayers can render multiple instances of a feature in a single map. Instead of adding single vector features, I added multipart features{multipoint and multiline), with each individual feature in that multipart offset by 360 degrees from the next.
Interestingly enough, OpenLayers also does some flipping of your features when you cross the IDL. When you grab the map and pan across the IDL, your features will flip into the coordinate system that contains the center point of the map. For this reason, I created 3 versions of everything, and placed them at (x – 360), (x), and (x + 360). This allows for continuous coverage on the map, even when the features are flipped over the IDL.
The result:

Now the maps reflect more accurately the trip of objects around the world! Each line is the shortest path between points, and are allowed to cross the IDL if necessary. For the purposes of Sourcemap, it was important to be able to show these trips, since we are discussing ways of modeling the transportation networks of goods around the world.







