Extracted more common code for ROI shapes to refactor polyline and
polygon selection