Polyline duplicates

Fix #2326, which was due to creation of a polyline with only two identical positions.  @bagnell also updated the polyline code to fail with the proper error message, since it wasn't throwing after removing duplicates.