1. A method for generating a representation of a polyline formed by a sequence of points, comprising: determining an overcomplete set of geometric primitives that redundantly fit overlapping sections of the polyline, such that the set includes one or more types of geometric primitives, and each geometric primitive is fitted to a section of the polyline formed by a subset of the sequence of points; determining a local cost of each geometric primitive based on a combination of a fitting error between the geometric primitive and the section of the polyline and an encoding cost of the geometric primitive; determining join costs of pairs of adjacent geometric primitives based on a geometric quality of a join between a pair of adjacent geometric primitives and an encoding cost of a location of the join; and determining a combination of the geometric, primitives forming a connected path along a length of the polyline such that a sum of the local costs of the geometric primitives and the join costs of the pairs of adjacent geometric primitives in the combination is optimized, wherein steps of the method are performed by a processor.