Add method to encode linestring