Skip to main content

Hi All,

I am trying to create json file using the json templater . input for this file has postGIS file with geometry in wkt format . i tried to convert using json templater but it not giving the desired output . can somebody help me with this ? i am uploading the json format file which is my desired output for this . file name examplebody.json

also i am attaching the screenshot of the out put which i am getting.

Looks like you should be using the GeoJSON writer rather than the text writer. That way you can also leave out the JSONTemplater.

If needed, you should first use the GeometryReplacer to convert the WKT to an FME geometry.


Looks like you should be using the GeoJSON writer rather than the text writer. That way you can also leave out the JSONTemplater.

If needed, you should first use the GeometryReplacer to convert the WKT to an FME geometry.

thank you david . i tried using geojson writer but still i get the different output. below is the screenshot of desired output.


thank you david . i tried using geojson writer but still i get the different output. below is the screenshot of desired output.

Can you show us what you got using the GeoJSON writer?


Can you show us what you got using the GeoJSON writer?

sure . this is the output i am getting using the Geojson writer.

 

My input has two geometry columns as geometry 1 and geometry 2 which is a same geometry but with time stamps .


Any particular reason for storing the geometries as text attributes in addition to the regular GeoJSON geometry definition?

Also I'm not sure GeoJSON allows for multiple geometries such as this. Is there any chance that you create an aggregate geometry of geometry_1 and geometry_2 and use that instead?


Hi @gis2020, I think this workflow generates your desired result if each input feature contains a line geometry.

JSONTemplater Root Expression:

{|
    fme:process-features("SUB")
|}

JSONTemplater SUB Expression:

{
    "geometry"||fme:get-attribute("_count") : fme:get-json-attribute("_geometry")
}

0684Q00000ArKN4QAN.png

 

Alternatively, this would work as well.

JSONTemplater Root Expression:

{|
    for $g at $i in fme:get-json-list-attribute("_list{}._geometry")
    return
    {
        "geometry"||$i : $g
    }
|}

0684Q00000ArKKeQAN.png


Reply