Skip to main content
sdettling222
Known Participant
July 10, 2017
Answered

Best way to reorganize coordinates....

  • July 10, 2017
  • 2 replies
  • 1311 views

Hello All......

I need to reorganize longitudes and latitudes......

Here is what I have right now:

-81.93,39.19;-81.77,39.34;-81.38,39.2;-81.65,38.99

What I need is the following:

39.19,-81.93;39.34,-81.77;39.2,-81.38;38.99,-81.65

I have tried a number of methods, but just can't get it right. Now I going crazy.....

The above is represented with the #polygons# variable.

Any input would be appreciated.

Thank you so much!!!!

    This topic has been closed for replies.
    Correct answer BKBK

    <cfset newList = "">

    <!--- Treat oldList as list having delimiter ; --->

    <cfset oldList = "-81.93,39.19;-81.77,39.34;-81.38,39.2;-81.65,38.99">

    <cfloop list="#oldList#" index="element" delimiters=";">

        <!--- Reverse the coordinates, treating each list element as list having delimiter , --->

        <cfset x = listGetAt(element,2)>

        <cfset y = listGetAt(element,1)>

        <!--- Create newList as list having delimiter ; --->

        <cfset newList = listAppend(newList, x & "," & y, ";")>

    </cfloop>

    <cfoutput>

        oldList: #oldList# <br>

        newList: #newList#

    </cfoutput>

    2 replies

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    July 11, 2017

    <cfset newList = "">

    <!--- Treat oldList as list having delimiter ; --->

    <cfset oldList = "-81.93,39.19;-81.77,39.34;-81.38,39.2;-81.65,38.99">

    <cfloop list="#oldList#" index="element" delimiters=";">

        <!--- Reverse the coordinates, treating each list element as list having delimiter , --->

        <cfset x = listGetAt(element,2)>

        <cfset y = listGetAt(element,1)>

        <!--- Create newList as list having delimiter ; --->

        <cfset newList = listAppend(newList, x & "," & y, ";")>

    </cfloop>

    <cfoutput>

        oldList: #oldList# <br>

        newList: #newList#

    </cfoutput>

    sdettling222
    Known Participant
    July 12, 2017

    Thank you so much for your help!!!! I will try and implement.

    Appreciate your feedback!!!

    Inspiring
    July 11, 2017

    What have you tried? Show us some code....