Skip to main content
Question

How to generate a sequential value that resets to zero when it finds an existing value.?

  • December 23, 2019
  • 3 replies
  • 114 views

daveapegg
Contributor
Forum|alt.badge.img+4

Hi guys,

I have a long line of points that are 1 metre apart. At roughly each kilometre point there is a value, but it is not exactly 1000 metres between these points (sometime more, sometimes less). I'd like to count each of the points in sequence between the values, and then have the count reset itself to start at zero at the next value. I've tried the Counter and it will give me a zero at each row with a value but will continue the count, not resetting back to 1.

Any help will be greatly appreciated.

Cheers, Dave.

3 replies

danilo_fme
Evangelist
Forum|alt.badge.img+45
  • Evangelist
  • December 24, 2019

Hi @daveapegg

I simulated your case in my Note and in my tet I haved 5000 points.

With the transformer ModuloCounter I configurated the attribute Count Maximum = 1000.

The result was good.

 

Thanks,

Danilo

 

 

 

 


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • December 24, 2019

@daveapegg  To get Counter to reset, you need to change the "Counter Name" to

@Value(Attribute Name of Value to Reset on)

It's maybe not intuitive, but changing the "Counter Name" to a variable rather than the default of a single, fixed name (such as the default name of "counter"), means a new, virtual, counter is generated for each differently named Counter. So if you send features to Counter which have say Attribute Values "A", "B", "C" and the Counter Transformer is set to also use these values as the Counter Names, then 3 different and independent Counters get spawned rather than 1: Counter A, Counter B and Counter C, which each incrementing by +1 every time a value corresponding to the Counter Name is encountered in the features input into the Counter transformer.

You can also change the Counter to start/reset to the value of 1, rather than 0, if you wish, and also note that the default behaviour is for the count totals to be "Global" rather than "Local".

In Local Mode, any previous Counters generated by the same name will get wiped out and replaced by new Counters of the same name, whereas in Global Mode the counts within the Counter transformer will continue from any Counters with the same name previously spawned by previous Workspace Counter transformers.

 


daveapegg
Contributor
Forum|alt.badge.img+4
  • Author
  • Contributor
  • January 2, 2020
bwn wrote:

@daveapegg  To get Counter to reset, you need to change the "Counter Name" to

@Value(Attribute Name of Value to Reset on)

It's maybe not intuitive, but changing the "Counter Name" to a variable rather than the default of a single, fixed name (such as the default name of "counter"), means a new, virtual, counter is generated for each differently named Counter. So if you send features to Counter which have say Attribute Values "A", "B", "C" and the Counter Transformer is set to also use these values as the Counter Names, then 3 different and independent Counters get spawned rather than 1: Counter A, Counter B and Counter C, which each incrementing by +1 every time a value corresponding to the Counter Name is encountered in the features input into the Counter transformer.

You can also change the Counter to start/reset to the value of 1, rather than 0, if you wish, and also note that the default behaviour is for the count totals to be "Global" rather than "Local".

In Local Mode, any previous Counters generated by the same name will get wiped out and replaced by new Counters of the same name, whereas in Global Mode the counts within the Counter transformer will continue from any Counters with the same name previously spawned by previous Workspace Counter transformers.

 

Thank you!


Reply


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