Add support for closed linestrings by converting them to polygons.

 Fixes #246.

Please review.