Skip to main content
Solved

Coordinate value formatting in XML output


I am using FME 2021.2 with a PostGIS reader and an XML Templater and XML Formatter to write an XML output file. This works fine, but the coordinate X/Y output appears in scientific notation as below:

 <Vertex>

  <X>2.010340655257836E6</X>

  <Y>6.7378739141772166E6</Y>

 </Vertex>

I have tried all kinds of different things, however I can't get FME to format the output they way I want it like below:

    <Vertex>

      <X>2010340.655257836</X>

      <Y>6737873.914177217</Y>

    </Vertex>

This code fragment in the XML Templater works:

<Vertex>

 <X>{geom:get-x-coord()}</X>

 <Y>{geom:get-y-coord()}</Y>

</Vertex>

This does not:

<Vertex>

 {

 let $l := geom:get-x-coord()

 let $r := @Format(%.2f,$l)

 return $r

 }

</Vertex>

I can't figure out how to pass the X value above into the format function, or find another workaround.

Best answer by debbiatsafe

Hi @sdfghjk7777​ 

Please try the following in the XMLTemplater

<Vertex>
    <X>{xs:decimal(geom:get-x-coord())}</X>
    <Y>{xs:decimal(geom:get-y-coord())}</Y>
</Vertex>

This returns decimal notation coordinates in my tests. I hope this information helps.

View original
Did this help you find an answer to your question?

2 replies

debbiatsafe
Safer
Forum|alt.badge.img+20
  • Safer
  • Best Answer
  • June 2, 2022

Hi @sdfghjk7777​ 

Please try the following in the XMLTemplater

<Vertex>
    <X>{xs:decimal(geom:get-x-coord())}</X>
    <Y>{xs:decimal(geom:get-y-coord())}</Y>
</Vertex>

This returns decimal notation coordinates in my tests. I hope this information helps.


Thank you, that solved my problem. You guys are fantastic. I am just not familiar enough with all the xsd syntactical elements in combination with using the XML Templater.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings