Hi, I would like to create polygons from a field in my GeoEvent Definition called Polygon.
The data is formatted like this:
"57.71127941662247,12.523986568755383 57.635773125999144,12.45961803332399 57.576614311073236,12.436624888552302 57.71127941662247,12.523986568755383"
Ie latitude1,longitude1 latitude2,longitude2 ... latitudeN,longitudeN
I would like it to be:
”[[12.523986568755383, 57.71127941662247],[12.45961803332399, 57.635773125999144],[12.436624888552302, 57.576614311073236], [12.523986568755383, 57.71127941662247]]
Ie [[longitude1, latitude1], [longitude2,latitude2], ... [longitudeN,latitudeN]]
And then map the string to a Geometry field.
Is it possible to construct Regular Expressions in Field calculator to switch the positions of lat and long in a string?
I am not very familiar with RegEx so any help are appriciated.
Having a projection similar to WGS84 but with the latitude coordinat in the first positon and longitude in the second position would be another option but I dont know if it exists?
Edited by RJ Sunderman:
You can work with an event field as a String and use a GeoEvent Field Calculator to add information such as spatial reference to produce a JSON String representation of a Geometry. Look for additional detail on working with Geometries in GeoEvent in 'Appendix A' of the GeoEvent Extension Introduction tutorial. Look for the section titled "Using a Field Calculator Processor to compute a geometry".
Unfortunately, the regular expression support extended by GeoEvent does not support the concept of back references. So you won’t be able to pattern match \([0-9][0-9.]*\)\([0-9][0-9.]*\) and replace the pattern with \2\1 to swap the latitude and longitude. Developing a custom processor using the SDK is probably a better approach than trying to do this using out-of-the-box functionality.
Update 31-March-2016 - RJ Sunderman:
Thanks go to Maarten Tromp for his comments in the thread Swap coordinate pairs in a Polygon
It is indeed possible to use RegEx back references to swap the latitude and longitude values if you use the correct syntax. Within a GeoEvent Field Calcualtor you would use $2$1 (not \2\1 as I originally tried).