Skip to main content

Hi FME'ers,

This is going to be a short-ish Question-of-the-Week, because I'm working on revamping the weekly quiz for next week. Fortunately it can be a quick post because both the question poster and myself were using the same transformer - the HTMLReportGenerator - for our respective tasks.

Question of the Week

Q) I'm using an HTMLReportGenerator to create a table that should have 10 rows. However, I get the 10 expected rows, plus many more that simply say "None."

Asked here.

A) Well, my job here is made easier by the fact that the user (@rwardrup) answered their own question. But it was an understandable issue since the HTMLReportGenerator can be a bit unintuitive. Let's take a quick look at what it does and how it works.

The HTMLReportGenerator

So the HTMLReportGenerator... well it generates a page of reports in HTML format. It can create plain text, or lists, or tables, or pretty much most HTML type objects. There are even options to create maps. It looks like this:

 

 

On the left side (1) are the list of HTML components to create. On the right hand side (2) are the parameters for the currently selected component.

The HTMLReportGenerator is a great transformer to use with FME Server, because it's a way to stream back results into a web page, using the HTML writer. I'll show you how below.

But first, let's consider what a "page", a "report", and a "component" are, and how they differ...

HTML Terminology

Basically we have a 1:M hierarchy here. A page is made up of a series of reports, and a report is made up of a series of components.

In FME the HTML format writer produces a page; each HTMLReportGenerator transformer produces a report, and each item listed under Page Contents in the transformer is a component.

HTML Format WriterPageHTMLReportGenerator TransformerReportPage ContentHTML Component

 

So.. given this workspace:

...with the transformer set up as above, I'll get a single page of HTML, with a single report, with three components in it.

If I want more pages, I would fan out the HTML writer; if I want more reports, I would add more HTMLReportGenerator transformers; if I want more components, I would add more contents in the transformer parameters.

So where's the problem?

HTMLReportGenerator Confusion

When you haven't used this transformer before then it's natural to put all your features into a single HTMLReportGenerator and create a single report.

But that doesn't work when different features need a separate set of components. For example, in the forum question, the user put spatial features into the transformer to create a map, and non-spatial records into the same transformer to create a table, and they all got combined:

I figured it out. I had two transformers feeding into the HTMLReportGenerator. For some reason, the HTMLReportGenerator was generating table rows for the map data, and not just the actual rows that should be in the table.

What they really needed was two separate reports, each with different components:

I created another HTMLReportGenerator for the map data, and fed both of them into an HTMLLayoutter, and all is well.

So if you want to use the HTMLReportGenerator, it's important to think of each set of data as creating a separate report. The HTMLLayouter transformer can then be used to put those reports into a required order on the HTML page.

The FME Monday Quiz

Like I mentioned, I'm working on the setup for the FME weekly quiz, and am switching to quiz responses generated using the HTMLReportGenerator. Here's what the workspace looks like:

The lower 3 HTMLReportGenerators are the important ones. One generates the score response; another generates a record of what you submitted and timestamps it; the third generates a list of the top ten scores.

If I put those into the same HTMLReportGenerator then I'd get the same extra records in my top-ten list that the OP got in their question.

I could have use the same transformer for the score report and submission record, but I want them to go into separate parts of the page, with the top-ten table in between, which I can only do by making them separate reports. Notice the AttributeCreators and Sorter which set the report order for the output.

Technically I don't really need a HTMLLayouter - the layout I want is the default anyway - but it's a good habit to include it.

Note: You'll see next week what the results look like! I'm not giving it away here.

Streaming from Server

Oh, I mentioned streaming from Server. All I do is publish the workspace and make the HTML writer a streaming service:

When you enter your answers into the quiz next week, it will run this workspace on FME Server. The response you get is streamed back directly into the web browser through this HTML writer. Simple.

Oh, I realize next Monday is a public holiday in some parts of the world, so I'll post on Monday but leave the quiz open an extra day to give you time to enter.

Other Notable Questions

There are a few other questions I noticed this week...

  • Did you know there is an FME sub on Reddit? Obviously I'd sooner you ask your FME-related questions in this community, but here was an interesting question this week. The question is why the AreaOnAreaOverlayer starts its _overlap count at 1, whereas the other overlayers start counting from 0? The reason is that the AreaOnAreaOverlayer counts each area itself as an overlap (i.e. it overlaps itself) so it automatically has one overlap; whereas a LineOnAreaOverlayer is two different geometries, so it doesn't have any overlaps by default. But why count an area as overlapping itself? I think it's because the overlayers also break the features at their overlap point and an area feature could self-intersect (like a fishtail, bow, or figure-of-eight)! The same logic applies to LineOnLineOverlayer (a line could self-intersect, therefore it should be overlayed against itself). The PointOnPointOverlayer doesn't count itself as an overlap, but that's likely because a point can't self-intersect. So the OP there is correct: there is a difference between the transformers that you need to be aware of, but I strongly suspect that difference is by design, and not a logic flaw in FME.

 

  • How do you resize an image without degredation? It's great to see the steps @philippeb is taking on his journey through 3D data. @daveatsafe gives sound advice: Images are always georeferenced in FME. Resampling the image changes the number of pixels, but not the georeference location of the image. It stays in the same place, but with lower resolution. To change the extents of the image as well as the resolution then requires use of the Scaler transformer.

 

  • How do you write a CSV file with two header lines? I would have thought add an extra record, but the answer is to use both the Textfile and CSV writers in combination! That's why I like watching the forums. Often the answer is not something I would have expected. It's all our combined knowledge that makes the community strong.

 

Have a great weekend everyone, and see you next week for the revamped FME quiz!

Mark

Be the first to reply!

Reply