Calculate Layer attr from shape attr

199
2
04-05-2018 11:45 PM
KennethLindhardt1
Occasional Contributor

Hi All, will it be possible to define the Layer attributes from a calculation of the shape attributes + the definition of the object attributes?

Let’s say I have 3 street types: major, minor and local. I can easily create a link between the Object attributes and the layer attributes:

 

attr StreetType  = getObjectAttr("type",false)

 

 

attr streetWidth =

case StreetType == "MAJOR" : 24

            case StreetType == "MINOR" : 13

            case StreetType == "LOCAL" : 5.7

             else : 10

 

But it’s not always that the Major road is exactly 24, that is defined by a combination of attributes set in the shape attributes Bike lane width Median width and such.

So at the end it will be something like in case the StreetType is MAJOR calculate these 6 shape attributes to get the street width

0 Kudos
2 Replies
ThomasFuchs
Esri Regular Contributor

Hi Kenneth,

thank you for your question. Below is a small example how to use two object attributes to set a layer attribute:

attr StreetType  = getObjectAttr("type",false)
attr bikeLanes  = 
     case getObjectAttr("bikeLanes",false) > 0 : rint(getObjectAttr("bikeLanes",false))
     else : 0 

attr streetWidth =
     case StreetType == "MAJOR" : 24 + 1.5*bikeLanes
     case StreetType == "MINOR" : 13 + 1.5*bikeLanes
     case StreetType == "LOCAL" : 5.7 + 1.5*bikeLanes
     else : 10

Further information and examples can be found in the CityEngine Help Mapping Object Attributes via Layer Attribute 

KennethLindhardt1
Occasional Contributor

Apparently I needed 6 months to think about this, sorry for that. Actually I don’t think this is exactly what I want, and now it’s even more necessary.

I want my rule/cga attributes to controle the width of the street, so how do I calculate the layer attributes with input from a rule attribute? Possible?

Otherwise I will need to update my calculations two different places, one in my rule, and then on the layer + is not that intuitive for people to remember to change the street type (Which define the width) two places, where one of the places can be controlled by a drop down, and the other needs to be typed in manually = mistakes will happen.

0 Kudos