xadhoom

Summing up the length of edges

Discussion created by xadhoom on May 24, 2012
Latest reply on May 30, 2012 by MBuehler-esristaff
Hi,

I´m currently diving into CGA scripts. I´ve checked out this forum, read some articles in the documentation and worked through several examples. Still some aspects of how CE evaluates rules remain a mystery to me. As a start I want to calculate the length of all edges at the side of a street. I tried the following code but the attributes are never set (the edge indices are correct though):
attr streetSideLengthMin = 0
attr streetSideLengthMax = 0

Street --> 
 SetupStreetAttributes
        print("After SetupStreetAttributes")

        <more code following here>

SetupStreetAttributes -->
 [comp(e){ all : calc}]

calc -->
 case comp.index == 0 || ((comp.index > 1) && ((comp.index - 1) % 3 == 0)):
  print("Before: " + streetSideLengthMin)
  set( streetSideLengthMin, streetSideLengthMin + scope.sx)
  print("After: " + streetSideLengthMin)
 else:
  case comp.index == 2 || ((comp.index > 3) && (comp.index % 3 == 0)):
   set( streetSideLengthMax, streetSideLengthMax + scope.sx)
  else:
   NIL


Probably I am completely misusing the rules here... ;-)

My goal is to initially calculate the two attributes and then go on executing the shape generation process based on the attribute values. I decided to use rules instead of functions because of the comp operator which actually comes in quiet handy here. Using "print" messages for debugging indicated that the execution order is not as expected e.g. like in usual programming languages. Even the print statement after "SetupStreetAttributes" seems to print to console before "SetupStreetAttributes" is actually executed.

I would be happy to understand why this approach doesn´t work and how the task could be achieved correctly. If anybody can point me to the appropriate docs I would be happy to go through it.

Regards,
Mirko

Outcomes