added toWkt method and added some extra structures to support this