Skip to main content

Hey folks,

 

I'm in a bit of a trouble. The readout of an xml file gives me an attribute that contains coordinates.

 

The attribute's content is like this:

'47.609703,9.858943 47.620427,9.867245 47.613033,9.92076 47.600331,9.930115 47.612142,9.960663 47.61008,9.972698 47.631773,9.980192 47.609703,9.858943 47.609703,9.858943'

Please be aware that i shortend the count of numbers.

All I am trying is to build a polygon with these coordinates to write an Esri shapefile.

The PolygonBuilder/AreaBuilder won't help because it needs polylines to work with.

 

Thanks you so much,

Ed

The GeometryReplacer can do this for you after you format the string to match a WKT.


If you rebuild the GML you can use a geometryReplacer

 

 

<gml:Polygon>   <gml:exterior>     <gml:LinearRing>       <gml:coordinates>@Value(_coord)</gml:coordinates>     </gml:LinearRing>   </gml:exterior> </gml:Polygon>

I'd first try one of the GeometryReplacer suggestions, or just use the GML reader, which I think might pull geometry out of any XML file.

The long way around would be to use an AttributeSplitter to split the attribute at each space character, a ListExploder, SubstringExtractors (to get out each x/y), and a VertexCreator to turn those values into points. Then a PointConnector.

But there shouldn't be a need to self-parse XML like that. I feel sure you'll be able to handle the content directly in a much easier way.


The GeometryReplacer can do this for you after you format the string to match a WKT.

Syntax of WKT for polygon:

 

POLYGON ((@Value(_coords)))

 

will result in:

 

POLYGON ((47.609703,9.858943 47.620427,9.867245 47.613033,9.92076 47.600331,9.930115 47.612142,9.960663 47.61008,9.972698 47.631773,9.980192 47.609703,9.858943 47.609703,9.858943)))

 

 


Reply