Skip to main content

Hi all

Im struggling to hit a specific gml setup and for this I need to split up a line of coordinates every 4 coordinates (I have no idea why the gml has to be this way.). I guessing i need to use regular expressions but im stumped as to how to write one that gives the right result.

an example string of coordinates that i have extracted using geometryextractor -> GML v2.1.2 looks like this:

711744.265,6175978.47 711791.544,6175982.446 711792.0123,6175979.7872 711792.5482,6175976.5078 711772.1563,6175974.7882 711755.5244,6175973.3985 711755.7058,6175970.729 711758.604,6175934.878 711722.2771,6175932.0269 711681.914,6175928.848 711683.786,6175998.563 711704.5651,6176000.163 711742.48,6176003.089 711744.265,6175978.47

but it needs to look like this for the gml to work for its intended purpose:

711744.265,6175978.47 711791.544,6175982.446 711792.0123,6175979.7872 711792.5482,6175976.5078 711772.1563,6175974.7882 711755.5244,6175973.3985 711755.7058,6175970.729 711758.604,6175934.878 711722.2771,6175932.0269 711681.914,6175928.848 711683.786,6175998.563 711704.5651,6176000.163 711742.48,6176003.089 711744.265,6175978.47

As you can see it repeats every 4 xxx.xxx,xxx.xxx untill only two are left.

Can anyone help me write and expression?

coordinate-string.txt

I see the forum swallowed the white spaces every 4th repetition so i have uploaded a text file with before/after

basicaly i have to replace every 4th white space with 17 whitespaces.


splitstringcoordinateexample.fmw

I have added a small workspace that does the tick (I think).

 

 

With a regex each coordinate is grouped and stored as a list. Each fourth element is then added a series of spaces, similar to your example. The latter is written to a new text file.

 

The example should work for the example .txt file you have added here.

 

 

 

Hopefully this solves your problem?


The StringReplacer could also work for you.

  • Mode: Replace Regular Expression
  • Text to Replace: ((\\S+\\s+){3}\\S+)\\s+
  • Replacement Text: \\1<17 spaces>


Hi all

Thank you so much for your time, i have been away over the weekend so just saw your replies now. Your solutions worked as a charm 🙂 thank you!


Reply