Remove duplication in Polyline/Polygon classes