Preserve extra dimensions in closest point calculations

Previously, `getClosestPoint` would always return a 2D coordinate, irrespective of the dimension of the geometry.

This PR extends `getClosestPoint` to preserve higher dimensions. In simple cases these are simply copied from the closest point. For geometries with edges (e.g. line strings and polygons) these are linearly interpolated.