Question

Use of the Geometryreplacer

  • 31 January 2017
  • 9 replies
  • 24 views

Badge

I have managed so far to extract a bunch of features from the output of a HttpCaller. All features are meant to be linestrings. In an attribute, conveniently called Linestring there is a list of coordinates, for example:

52.1626086 4.5000322 52.1632634 4.5000649 52.1633422 4.4997202 52.1634249 4.4993502 52.1634390 4.4993159.

To the best of my knowledge, I can use a GeometryReplacer that is pointed towards the attribute Linestring and has as encoding GML. Which should result in linestring geometries. However the conversion fails, without any noticable messages in the log. Does anybody have any suggestions?

Thanks in advance


9 replies

Userlevel 2
Badge +16

By formatting the linestring like this

LINESTRING (52.1626086 4.5000322, 52.1632634 4.5000649, 52.1633422 4.4997202, 52.1634249 4.4993502, 52.1634390 4.4993159)

using StringConcatenator (add "LINESTRING(" before and ")" after) and StringReplacer (replace 52. with ,52.) you can use the GeometryReplacer option Well Known Text.

Userlevel 5

You list of coordinates isn't valid GML as such, but one way to fix it could be to incorporate your coordinate list in a GML block, e.g.

<gml:LineString gml:id="1" srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
    <gml:posList srsDimension="2">52.1626086 4.5000322 52.1632634 4.5000649 52.1633422 4.4997202 52.1634249 4.4993502 52.1634390 4.4993159</gml:posList>
 </gml:LineString >

Result after the GeometryReplacer set to GML:

0684Q00000ArLe2QAF.png

Userlevel 5

By formatting the linestring like this

LINESTRING (52.1626086 4.5000322, 52.1632634 4.5000649, 52.1633422 4.4997202, 52.1634249 4.4993502, 52.1634390 4.4993159)

using StringConcatenator (add "LINESTRING(" before and ")" after) and StringReplacer (replace 52. with ,52.) you can use the GeometryReplacer option Well Known Text.

Won't that result in a comma too much? E.g.

 

LINESTRING (,52.1626086 4.50003...

 

Userlevel 1
Badge +21

gml for a linestring would normally look something like this

<gml:LineString xmlns:gml="http://www.opengis.net/gml/3.2" gml:id="id-ef29f851-759c-48ab-b15e-db0fbd2de521-0" srsDimension="2">
<gml:posList>0 0 0 10 10 10</gml:posList>
</gml:LineString>

So you could just create a new attribute adding the tags in before and behind. Only reliable if they genuinely are all linestrings. Remember to set the correct axis order in the geometry replacer

Userlevel 3
Badge +17

Hi @pimverver, I was able to create a line geometry from this GML fragment. Here, the attribute called "_coordinates" stores the space-delimited coordinate list.

<gml:LineString>
<gml:posList>@Value(_coordinates)</gml:posList>
</gml:LineString>

Is there any difference from yours?

Userlevel 2
Badge +16
Won't that result in a comma too much? E.g.

 

LINESTRING (,52.1626086 4.50003...

 

You are right. It should be <space>52. replaced by ,52.

 

 

Userlevel 3
Badge +17

By formatting the linestring like this 

LINESTRING (52.1626086 4.5000322, 52.1632634 4.5000649, 52.1633422 4.4997202, 52.1634249 4.4993502, 52.1634390 4.4993159)

 using StringConcatenator (add "LINESTRING(" before and ")" after) and StringReplacer (replace 52. with ,52.) you can use the GeometryReplacer option Well Known Text.

For what it's worth, this string expression returns the OGC WKT representation. Assuming "_coordinates" stores the space-delimited coordinate list.

 

LINESTRING(@ReplaceRegEx(@Value(_coordinates),(.+?\s+.+?)\s+,"\1,"))

 

Badge

You list of coordinates isn't valid GML as such, but one way to fix it could be to incorporate your coordinate list in a GML block, e.g.

<gml:LineString gml:id="1" srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
    <gml:posList srsDimension="2">52.1626086 4.5000322 52.1632634 4.5000649 52.1633422 4.4997202 52.1634249 4.4993502 52.1634390 4.4993159</gml:posList>
 </gml:LineString >

Result after the GeometryReplacer set to GML:

0684Q00000ArLe2QAF.png

By replacing the coordinates with the variable @Value(Linestring), as suggested by @takashi, thereby referring to my Linestring attribute, I got the geometries. Thank you! Wow!
Userlevel 5
Badge +26

I think I suggested the GeometryReplacer to be able to handle a space-separated list of XY (or XYZ) coordinates a few years ago. I'll make an Idea out of it, if y'all could vote for it that'd be nice :)

Reply