Return ambiguous, rather than undefined, centroid.

This is a fix for #1039, and related to #1037 #1011.
Merge branch 'fix-centroid' into 3.2