square/border_patrol — pull request #4 by kkwteh (2013-04-12 16:40:51+00:00)
Title: International Date Line Patch

Hi Zach,

I'm a new hire at Square (Risk Team Quant, starting in June).

I thought it would be fun to try and get border_patrol to work for polygons crossing the International Date Line.

I got it to work without having to add too many lines of code. The basic approach is to check if a polygon crosses the IDL when it's created, and change the coordinates of the points to a new coordinate system if it does. The new coordinate system works for polygons crossing the IDL, but not for polygons crossing the Prime Meridian (longitude 0).

I included unit tests with my code. It comes at a cost of ~60% increase in the benchmark runtime.

user system total real
colorado region 0.410000 0.000000 0.410000 ( 0.407283)
multi polygon region 1.020000 0.000000 1.020000 ( 1.031006)

It might not be at all appropriate for the applications you have in mind, but it might be worth a look.

Cheers,
Kevin