Add a function that tries to fix invalid polygons

This helper function tries two techniques mentioned in the
helpful document here:

  http://s3.opengeo.org/postgis-power.pdf

(Thanks to Matthew Somerville for pointing that out.)

Those are:

  ST_Buffer(geom, 0)

... and

  ST_BuildArea(
    ST_Union(
        'LINESTRING EMPTY;,
        ST_ExteriorRing(
          'POLYGON((...));
        )
    )
  )

... except that we want to do these without a database
connection, so try to do everything with GEOS functions.
Unfortunately, there isn't an equivalent of ST_BuildArea
available via GEOS, as far as I can tell.  ST_BuildArea,
however, begins by using GEOSPolygonize which we can use
via Shapely, and produces good results on simple
examples.

The result returned is that from the first of these
methods that produces a valid polygon whose perimeter
length is within 1% of the original's perimeter length.
mapit_global_import: try to fix invalid polygons

This also should ensure that we don't import any invalid
polygons.
Factor out fix_invalid_geos_multipolygon
Add doctests for fix_invalid_geos_multipolygon
Fix the case where there are no valid or fixable polygons

Doing cascaded_union on a MultiPolygon that contains no
polygons turns out to give the error:

    django.contrib.gis.geos.error.GEOSException:
        Could not initialize GEOS Geometry with given input.

So we need to avoid doing the cascaded_union if there are no
polygons.  This commit also adds a doctest for this case.

This commit also ensures that we always return a MultiPolygon,
even if the result of the cascade_union is a Polygon.
Merge branch 'fix-invalid-helper'