Skip to main content
I have a test filter after the WebMapTIler (which puts aattributes _num_tiles) and I am also counting the number of tiles produced with a COUNTER transform with the results called _count.

 

 

Directly after this I have a TestFillter setup as follows

 

 

 

 

IF @Value(_count) >= @Value(_num_tiles)   DONE

 

Else If @Evaluate((@Value(_count))%10) = 0   SEND

 

Else IGNORE

 

 

well, what happens is that I get an item on the SEND port every ten features,

 

 

But I never get the DONE item.

 

 

What gives?

 

 

 

 

Hi,

 

 

What kind of value does "_num_tiles" contain?

 

 

Takashi
Hi,

 

 

try inserting an inspection point  (a fantastic tool for debugging) just before the TestFilter so that you can pause and inspect the features as they enter. Pay particular attention to the values of "_count" and "_num_tiles" to check that they are always present and always contain a numeric value.

 

 

David
Hmm...

 

Programlogically it seems to me that the values, wich are belonging to the same feature (if im reading this right) always are probably equal.

 

You count the tiles, and prduce the num_tiles feature....is'nt that kinda the same?

 

So it will never end. Even whne processing the features should have been ready...the values wil always be equal.

 


..basically u are just filtering every tenth record (feature)

 

the DONE and IF are superfluos.

 

 

You get the same result by just testing on

 

@Evaluate((@Value(_count))%10) = 0

Let me give some more info, since I see everyone is trying to help, but we don't have an answer yet.

 

 

_num_tiles is a new feature in the WebMapTiler for FME2014. I asked for it and Dave C. added it! The WebMapTiler takes a Raster (geocoded) and divides it up into many 256x256 PNG or JPG files (an image pyramid). In my case. I wanted to know at the start how many there were going to be generated. And then I also a havve a COUNTER transform to count the number of features coming out. 

 

 

Every mod 10 items. I want to send a HTTP GET (REST) message to a server saying how things are going, and then when it is all done (which might not be a MOD 10 value) it sends a DONE signal to the server.

 

 

OK, so the Inspector says all is going well, I can see the count increasing and the value of _num_tiles is fine. If I take out the TESTFILTER, then it will send the message every feature.

 

 

So now I know the problem is with the syntax of the filter in the TESTFILTER.

 

 

Does that clarify?

 

 

pI have had this problem with the TestFilter before, probably relates to @Value() or quoting, or some other thing at the Python level.

 

 

 

 

 
I guess that "_num_tiles" contains the number of tiles (256x256 = 65536 in your case). If so, I think this number is greater than the range of "_count" (0 - 65535).

 

i.e. "@Value(_count) >= @Value(_num_tiles)" will be always false. Did you check actual value of "_num_tiles" ?
so, I think if you specify 1 to "Count Start" parameter of the Counter, "_count" of the last feature will be equal to "_num_tiles". 
Right now, _num_tiles is typically 2900- 10,0000. I am not creating a pyramid for the whole world.

 

 

 


I was wrong, thought 256x256 is the number of tiles...   Is _count of the last feature indeed equal to _num_tiles?
the WebMapTiler says that is going to create _num_tiles of features, and count  incremented every time it spits one out. So yes, count should eventually reach _num_tiles.

 

 

I did try making the test for _num_tiles-1000 but that also does not work, and I know that the count goes way beyond that. So I clearly need help on the python syntax in the if,then,else if. Which was my original question.

 

 

 


Need Python?

 

Since the PythonCaller cannot be appended output ports, it will not behave exact same as the TestFilter. But it can append new attributes to the input feature depending on the condition. For example: ----- # Assume "_num_tiles" and "_count" always contain integer. import fmeobjects   def processFeature(feature):     num_tiles = int(feature.getAttribute('_num_tiles'))     count = int(feature.getAttribute('_count'))     job = 'IGNORE'     if num_tiles <= count:         job = 'DONE'     elif count % 10 == 0:         job = 'SEND'     feature.setAttribute('_job', job) -----   A PythonCaller with this script appends an attribute named "_job" to each input feature; value of "_job" will be "DONE", "SEND" or "IGNORE". Specify "_job" to "Attributes To Expose" on the PytonCaller parameter settings, then you can branch the process according to its value.
...but, I'd like to know why the TestFilter doesn't work. This image is a mock-up to reproduce the situation (FME 2013 SP4). Tested with _num_tiles = 50, it looks to work expectedly. Are there some differences from yours?

 


No I am not interested in a PythonCaller. But the TestFilter uses Python interpreter below the covers, so the syntax is python.

 

 

I needed to jump to FME2014, so I am missing the "OR" in the annotation, but believe me, it has PASS Criteria of "One Test (OR)".  The screen shot is the same as yours. I submitted a help request to SAFE (we are under maintenance).

 

 

 


This website is not sharing the image link, but here it is:

 

 

https://www.dropbox.com/s/srcldlp2lrclmkf/FME-TestFilter.jpg

 

 

 


There is a difference between my mock-up and your workflow. You specified 0 to "Count Start" to the Counter. For example, if 5 features come, "_count" can be 0, 1, 2, 3, 4. I think it will not reach 5.
That was it, the old "off by one" error on loop completion. I did not understand the sematics of the counter, I though it would do a ++count, and not a count++,

 

 

 


Off-by-one is a traditional programmer's error, I also do it sometimes. Let's take care!

Reply