From 9c31e1ee1e68009d73fbbdb51bd2a4ae50315def Mon Sep 17 00:00:00 2001 From: cell42 Date: Thu, 11 Jan 2018 14:14:23 +0100 Subject: [PATCH] Update wellknown.js Added support for Point Z if point contains 3 coordinates --- wellknown.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wellknown.js b/wellknown.js index 0cf84a0..00dc3d4 100644 --- a/wellknown.js +++ b/wellknown.js @@ -252,7 +252,11 @@ function stringify (gj) { switch (gj.type) { case 'Point': - return 'POINT (' + pairWKT(gj.coordinates) + ')'; + if (gj.coordinates.length == 3) + return 'POINT Z (' + pairWKT(gj.coordinates) + ')'; + else if (gj.coordinates.length == 2) + return 'POINT (' + pairWKT(gj.coordinates) + ')'; + throw new Error("Invalid coordinates for point provided"); case 'LineString': return 'LINESTRING (' + ringWKT(gj.coordinates) + ')'; case 'Polygon': @@ -271,4 +275,4 @@ function stringify (gj) { } },{}]},{},[1])(1) -}); \ No newline at end of file +});