Updated non-test code for Boost 1.56 compatibility
This is necessary because Boost::Optional now implements explicit operator bool.  This commit makes the code clearer, fixes a number of bugs, and uses remove_spikes from Boost Geometry if Boost is at least 1.56.