<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Swap coordinate pairs in a Polygon in ArcGIS GeoEvent Server Questions</title>
    <link>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621763#M2716</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/7493"&gt;Maarten Tromp&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you able to use RegEx in the string processing? Otherwise you may want to use the sdk and extend it:&lt;/P&gt;&lt;P&gt;&lt;A href="http://server.arcgis.com/en/geoevent-extension/latest/administer/extending-the-geoevent-extension.htm" title="http://server.arcgis.com/en/geoevent-extension/latest/administer/extending-the-geoevent-extension.htm"&gt;Extending the GeoEvent Extension—Real-Time Data Feeds and Sensors | ArcGIS for Server&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 03 Feb 2015 12:31:50 GMT</pubDate>
    <dc:creator>XanderBakker</dc:creator>
    <dc:date>2015-02-03T12:31:50Z</dc:date>
    <item>
      <title>Swap coordinate pairs in a Polygon</title>
      <link>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621762#M2715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an "Poll an External Website for JSON" Input connector. The Polygon information in the json is wrapped in a string and looks like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="EN-US" style="color: windowtext; font-family: 'courier new', courier;"&gt;"\"type\":\"polygon\",\"centerLat\":\"53.2841903320603\",\"centerLng\":\"6.1497098207473755\",\"polygonVertices\":[{\"lat\":53.284613668968,\"lon\":6.1477410793304},{\"lat\":53.28426089025,\"lon\":6.1476981639862},{\"lat\":53.283766995153,\"lon\":6.1516785621643},{\"lat\":53.284318617876,\"lon\":6.1517214775085}]}"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: windowtext;"&gt;With some string processing I am able to make a valid Geometry and send it to an Hosted FeatureService. The polygon looks like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: windowtext; line-height: 1.5; font-family: 'courier new', courier;"&gt;"{""rings"":[[[53.284613668968,6.1477410793304],[53.28426089025,6.1476981639862],[53.283766995153,6.1516785621643],[53.284318617876,6.1517214775085]]],""spatialReference"":{""wkid"":4326}}}"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: windowtext; line-height: 1.5;"&gt;The location is east of Somalia instead of the Netherlands because latitude and longitude are in the wrong order.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: windowtext; line-height: 1.5;"&gt;Is there a way to swap the coordinate pairs in the polygon?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: windowtext; line-height: 1.5;"&gt;Kind Regards, Maarten Tromp&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2015 11:43:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621762#M2715</guid>
      <dc:creator>MaartenTromp</dc:creator>
      <dc:date>2015-02-03T11:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Swap coordinate pairs in a Polygon</title>
      <link>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621763#M2716</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/7493"&gt;Maarten Tromp&lt;/A&gt;‌,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are you able to use RegEx in the string processing? Otherwise you may want to use the sdk and extend it:&lt;/P&gt;&lt;P&gt;&lt;A href="http://server.arcgis.com/en/geoevent-extension/latest/administer/extending-the-geoevent-extension.htm" title="http://server.arcgis.com/en/geoevent-extension/latest/administer/extending-the-geoevent-extension.htm"&gt;Extending the GeoEvent Extension—Real-Time Data Feeds and Sensors | ArcGIS for Server&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2015 12:31:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621763#M2716</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-02-03T12:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Swap coordinate pairs in a Polygon</title>
      <link>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621764#M2717</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/3100"&gt;Xander Bakker&lt;/A&gt;, good to hear from you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My RegEx knowledge is limited, one of those handy things that doesn't stick very well:-(&lt;/P&gt;&lt;P&gt;There is a RegEx Processor in GeoEvent:&lt;/P&gt;&lt;P&gt;&lt;A href="http://server.arcgis.com/en/geoevent-extension/latest/process-event-data/processors.htm#ESRI_SECTION1_9A081054F37F4631927E47F57A2E1662" title="http://server.arcgis.com/en/geoevent-extension/latest/process-event-data/processors.htm#ESRI_SECTION1_9A081054F37F4631927E47F57A2E1662"&gt;Processors—Real-time Data Feeds and Sensors | ArcGIS for Server&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any idea How to swap the two numbers in the PolygonString with RegEx?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Maarten&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2015 16:30:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621764#M2717</guid>
      <dc:creator>MaartenTromp</dc:creator>
      <dc:date>2015-02-03T16:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: Swap coordinate pairs in a Polygon</title>
      <link>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621765#M2718</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/7493" target="_blank"&gt;Maarten Tromp&lt;/A&gt;‌, nice to hear from you too and good to see you're doing some interesting stuff!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;RegEx isn't my string either, but I do note you have some additional quotes in your output string.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;{
"rings" : [
&amp;nbsp; [ [-97.06326,32.759], [-97.06298,32.755], [-97.06153,32.749], [-97.06326,32.759] ]
],
"spatialReference" : {"wkid" : 4326}
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;... and it woud be better to close the polygon (append the first item if the list of coordinates to the end of the list)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would expect it to be possible to extract all ocurrences of lat and lon and form the correct list of coordinates using regex.&lt;/P&gt;&lt;P&gt;Maybe this can help: &lt;A href="http://www.regexr.com/" title="http://www.regexr.com/" rel="nofollow noopener noreferrer" target="_blank"&gt;RegExr: Learn, Build, &amp;amp; Test RegEx&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, what do I hear, you're not going to the DevSummit this year?&lt;/P&gt;&lt;P&gt;I will be strange...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck, Xander&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:30:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621765#M2718</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T02:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Swap coordinate pairs in a Polygon</title>
      <link>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621766#M2719</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;It looks like the extra quotes and missing closing vertices is not an issue because the polygons appear in the Hosted FeatureService correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Notepad++ the correct result is created by using this RegEx to Search:&lt;/P&gt;&lt;P&gt;([0-9]+\.[0-9]+?),([0-9]+(\.[0-9]+)?)&lt;/P&gt;&lt;P&gt;And then this to replace:&lt;/P&gt;&lt;P&gt;\2,\1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But how to get this to work in the Processor "Field Calculator (Regular Expression)"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Found it out myself by using the "Field Calculator" Processor and use this as expression:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;replaceAll(polygonString2,'([0-9]+\.[0-9]+?),([0-9]+(\.[0-9]+)?)','$2,$1')&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards, Maarten Tromp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Feb 2015 18:34:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621766#M2719</guid>
      <dc:creator>MaartenTromp</dc:creator>
      <dc:date>2015-02-03T18:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Swap coordinate pairs in a Polygon</title>
      <link>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621767#M2720</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the Processor Field calculator can be compared with the field calculator available at desktop and Python is supported you could try this (sorry no regex):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def constructJSON(in_string):
&amp;nbsp;&amp;nbsp;&amp;nbsp; in_string = in_string.replace('\"','')
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst = in_string.split('polygonVertices:')
&amp;nbsp;&amp;nbsp;&amp;nbsp; use = str(lst[1][:-1]).replace("lat","'lat'").replace("lon","'lon'")
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_use = eval(use)
&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_crds = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dct_crd in lst_use:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_crds.append([dct_crd['lon'], dct_crd['lat']])


&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_crds.append(lst_crds[0])
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct = {"rings":[],"spatialReference":{"wkid":4326}}
&amp;nbsp;&amp;nbsp;&amp;nbsp; dct["rings"] = [lst_crds]
&amp;nbsp;&amp;nbsp;&amp;nbsp; # return "'{0}'".format(dct)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return dct&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Exucute with:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;in_string = '"\"type\":\"polygon\",\"centerLat\":\"53.2841903320603\",\"centerLng\":\"6.1497098207473755\",\"polygonVertices\":[{\"lat\":53.284613668968,\"lon\":6.1477410793304},{\"lat\":53.28426089025,\"lon\":6.1476981639862},{\"lat\":53.283766995153,\"lon\":6.1516785621643},{\"lat\":53.284318617876,\"lon\":6.1517214775085}]}"'
print constructJSON(in_string)&lt;/PRE&gt;&lt;P&gt;returns:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;{'rings': [[[6.1477410793304, 53.284613668968], [6.1476981639862, 53.28426089025], [6.1516785621643, 53.283766995153], [6.1517214775085, 53.284318617876], [6.1477410793304, 53.284613668968]]], 'spatialReference': {'wkid': 4326}}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure if the dictionary serves you or that it has to be casted to string.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:30:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-geoevent-server-questions/swap-coordinate-pairs-in-a-polygon/m-p/621767#M2720</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T02:30:32Z</dc:date>
    </item>
  </channel>
</rss>

