Skip to main content
Solved

Configuring the JSONTemplater


nedwaterman
Contributor
Forum|alt.badge.img+9

Hi all,

I'm having issues configuring the JSONTemplater to output my data.

I currently have 7 rows, with 2 unique IncidentIDs. I'd like to aggregate the postcode data and geometry for these 2 IncidentIDs so that the json can be used on a webmap showing all the postcodes associated with an incident:

 

imageI've configured my ROOT and SUB templates but the JSONTemplater fails at the root. Can anyone see what I am doing wrong?

imageROOT:

{ "type":"FeatureCollection",

"features":

[

fme-process-features("SUB")

]

}

 

 

SUB:

 

{

    "type":"Feature",

"properties":{"Postcode":fme:get-attribute("POSTCODE")},

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

}

 

Thanks in advance

N

Best answer by takashi

Hi @nedwaterman​ ,

The reason for the error in the Root expression is a typo in the function name.

wrong: fme-process-features("SUB")

correct: fme:process-features("SUB")

 

However, if you intend to aggregate Polygons to form a MultiPolygon for each Incident_ID, I don't think JSONTemplater works as expected.

In that case, I think you can create polygon geometry from the "_geometry" attribute value with GeometryRelacer, aggregate the polygons with Aggregator grouping by Incident_ID, then write the features with GeoJSON writer.

 

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

3 replies

nielsgerrits
VIP

With these settings it works for me:

ROOT

{
	"type": "FeatureCollection",
	"features": [fme:process-features("SUB")]
}

SUB

{
	"type": "Feature",
	"properties": {
		"Postcode": fme:get-attribute("POSTCODE")
	},
	"geometry": fme:get-attribute("_geometry")
}

 


takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • Best Answer
  • October 22, 2023

Hi @nedwaterman​ ,

The reason for the error in the Root expression is a typo in the function name.

wrong: fme-process-features("SUB")

correct: fme:process-features("SUB")

 

However, if you intend to aggregate Polygons to form a MultiPolygon for each Incident_ID, I don't think JSONTemplater works as expected.

In that case, I think you can create polygon geometry from the "_geometry" attribute value with GeometryRelacer, aggregate the polygons with Aggregator grouping by Incident_ID, then write the features with GeoJSON writer.

 


nedwaterman
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • October 23, 2023
takashi wrote:

Hi @nedwaterman​ ,

The reason for the error in the Root expression is a typo in the function name.

wrong: fme-process-features("SUB")

correct: fme:process-features("SUB")

 

However, if you intend to aggregate Polygons to form a MultiPolygon for each Incident_ID, I don't think JSONTemplater works as expected.

In that case, I think you can create polygon geometry from the "_geometry" attribute value with GeometryRelacer, aggregate the polygons with Aggregator grouping by Incident_ID, then write the features with GeoJSON writer.

 

Thanks both for your help - much appreciated!


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