I have a flattened list (guaranteed to always be even in length) of points and I'm trying to generate WKT (Well Known Text) from it which looks like. So, for a list like:
0 = {java.lang.Double@23771} "21.0"
1 = {java.lang.Double@23772} "41.0"
2 = {java.lang.Double@23773} "22.0"
3 = {java.lang.Double@23774} "42.0"
4 = {java.lang.Double@23775} "23.0"
5 = {java.lang.Double@23776} "43.0"
6 = {java.lang.Double@23777} "24.0"
7 = {java.lang.Double@23778} "43.0"
8 = {java.lang.Double@23779} "21.0"
9 = {java.lang.Double@23780} "41.0"
I need my string to look like
POLYGON ((21.0 41.0, 22.0 42.0, 23.0 43.0, 24.0 44.0, 21.0 41.0))
In order to do so, I need to increment by two at a time through my list, outputting the ith and (i+1)th elements as pairs, separated by a comma.
If conditionals could evaluate for more than just presence of an attribute, something like:
POLYGON ((<geometry_coordinates:{n|<i0>: <if(i0)><n> <elseif(!i0)><n>, <endif>}>)) //notice the "not" operator
As added restriction, I'm using software that has ST4 embedded in it, so I don't have any control over the underlying Java code, so I have to be able to do it just through the ST4 syntax.
Thanks,
Grant