Question

Passing features in series

  • 22 April 2016
  • 8 replies
  • 4 views

Badge

I have a polygon layer that I want to use to clip some other map layers and write out the results to a series of GeoPDFs (one for each polygon).

I’ve made a workspace that does it for individual polygons. From there I had hoped fanout would work to create individual files, however the Page Object in the PDFPageFormatter scales to the entire extent of the layer, not each individual polygon.

Is there a way to pass the individual polygons through one at a time and have them trigger the rest of the workflow as they go? I have attempted variations using WorkspaceRunners or Looping in a custom transformer) but none of these seem to result in anything getting passed to the writer.


8 replies

Badge +22

If I understand correctly you have a functioning workspace that does exactly what you want when dealing with a single polygon.

 

 

If that's the case have you considered a master workspace that serializes the geometry of each feature into an attribute (GeometryExtractor) and passes that as a parameter to the worker workspace via a workspaceRunner.

 

 

The worker workspace would have a creator followed by a geometryReplacer (Source pointing to the parameter) instead of a standard reader for your clipper polygon.

 

 

That way the workspace would be run once for each polygon, each one producing a single GeoPDF file.
Userlevel 2
Badge +17

Hi @bigclyde, I think you can modify the extents (world rectangle) for each polygon with this procedure after the PDFPageFormatter.

  1. BoundsExtractor: Extract extents (_xmin, _ymin, _xmax, _ymax) of each polygon.
  2. StringConcatenator (or AttributeCreator): Overwrite pdf_world_rectangle with a string containing coordinates of the extents separated by whitespace, like this.
@Value(_xmin) @Value(_ymin) @Value(_xmax) @Value(_ymax)
Badge

If I understand correctly you have a functioning workspace that does exactly what you want when dealing with a single polygon.

 

 

If that's the case have you considered a master workspace that serializes the geometry of each feature into an attribute (GeometryExtractor) and passes that as a parameter to the worker workspace via a workspaceRunner.

 

 

The worker workspace would have a creator followed by a geometryReplacer (Source pointing to the parameter) instead of a standard reader for your clipper polygon.

 

 

That way the workspace would be run once for each polygon, each one producing a single GeoPDF file.

Thanks jdh,

The features do get passed to the worker workspace and it does generate PDFs. However there is clearly something I don’t understand about passing geometry between workspaces. I tried a lot of different ways of passing it through but the GeometryReplacer kicked everything out of the Rejected port, so my ‘map’ window in the PDF was blank.

That said, there was no difficulty passing regular attributes through so I was able to query back to the database by running the name field into a FeatureReader and from that I got the correct result. I don't know if that's the best or most efficient way, but it does the job.

Thanks

Badge

Hi @bigclyde, I think you can modify the extents (world rectangle) for each polygon with this procedure after the PDFPageFormatter.

  1. BoundsExtractor: Extract extents (_xmin, _ymin, _xmax, _ymax) of each polygon.
  2. StringConcatenator (or AttributeCreator): Overwrite pdf_world_rectangle with a string containing coordinates of the extents separated by whitespace, like this.
@Value(_xmin) @Value(_ymin) @Value(_xmax) @Value(_ymax)

Thanks takashi,

I did try this method too and it produced all the PDFs, but for some reason they all came out the same.  The workspace seems to have passed the same thing to the writer over and over.  I poked at it for awhile but never quite figured it out.

Userlevel 2
Badge +17

Thanks takashi,

I did try this method too and it produced all the PDFs, but for some reason they all came out the same. The workspace seems to have passed the same thing to the writer over and over. I poked at it for awhile but never quite figured it out.

@bigclyde, sounds like there might be an issue in other part of the workspace than PDF styling. Can you post your workspace file or its screenshot?

Badge +3

No need per se for a workspacerunner.

Though if you do not, the entire proces will run trough all pdf's before writing starts. (not handy if you need to oupt large amounts of pdf's)

With a WSR you can set it to wait to complete.

Proces

Id your polygons if they are not yet.

Clipp the layers, then group them by the previously created ID (ie with a

aggregator).

To set the world_rectangle you can directly create the attribute in a attributecreator using the boundsextractor. You thne need to line it up with pageframe.

World_rectangle must have same aspect ratio as pageframe..else it might "clip" content.

Option:

Boundingboxaccumulator, grouped by same id.

Send to Original and BB to PDF_styler. (can hide BB or use ase frame)

Send to PDF_Pageformatter. (where you format frame) Give both same pageframe extent

Send to writer. Set writer to fanout dataset, in navigator panel.

Need scaling tho..

Without pdf formatter and just the styler (if at all, because you can write all pdf attributes directly to the writer)) it'll focus to extent full page.

PDf formatter makes things more complex..because it does not calculate the asoect ratio and page to wordl frame extent. Not without your guidancce it seems.

Badge +3

Using pdf styler you have no such issues.

Using pdf formatter you have to calculate

pdf_frame_rectangle based on

pdf_world_rectangle , page size, page margins whilst maintaining their aspect ratio.

pdf_world_rectangle need to be in sync with the pdf_frame_rectangle.

The first you get from the BB the latter you must calculate.

U need to calulate the rw reactangle (lke BB extents) to point

I use this from a very old workspace to control the modern pdf formatter. Because it is a tricky bit to built (to me at least..;)). (lots of expressions )

I hoped it would be done by the pdf-formatter. Alas. No such luck, if i enter just the

pdf_world_rectangle it will not do a full page pdf. Just boxed content somewhere on the page.

This has been discussed earlier, and i have not test the fme2016 version (yet afaik).

Badge

One more option would be to create a custom transformer from PDFPageFormatter and use Group By <polygon identifier> within the custom transformer. This will force the PDFPageFormatter to process each 'polygon based' group separately.

Reply