Check for the_geom before calculating geometry_types

Fixes #1599