Refactored common code from polyline regions for DAWNSCI-891