formula in .cga to choose façade textures with attr from GIS data, filter on year&use

187
2
02-26-2014 12:32 AM
KennethLindhardt
Occasional Contributor
Hi,
Now I finally have some time allocated to CItyEngine.
I would like to create a rule file, that I can use to automatically generate 3D buildings with attributes assigned to the building polygons from a geodatabase.
I saw Matthias??? thread ???GIS data mini tutorial??? and it???s almost similar to what I would like, but I face some issues.
I would like to automatically assign textures to my buildings, and it need to change the texture depending on the year the building is from, and the building use. So a building from 1940 to 1960 used as a office, would randomly take textures from folder A. Then a building from 1960 to 1980 used as office, would randomly take a texture from folder B. A building from 1940 to 1960 used as a school would randomly take a texture from folder C etc. but of course with a little more folder structure. Depending on how many building uses the geodata brings this can result in a lot of different folders and a lot of rule typing, but I need some help to get this to work.
When I read the ???GIS data mini tutorial??? it had me start thinking how this could actually be done. If I set a attr to 0, it will take the data given from the GIS data. But this would not work for me, since the attribute is not giving me an information I can actually use.
What my thought was, was to create for example ???attr dateBuilt = 0 (next line) attr buildingUse = 0, but then I would need the rule to actually read the attributes from the GIS data and calculate which folder to choose from. IF dateBuilt = 1943 and buildingUse = school ; lookup folder C.
Has this been done?
Can it be done?
And how is it done? (I only need some guidance not a complete rule;-)
0 Kudos
2 Replies
KennethLindhardt
Occasional Contributor
So I thought a little more about this. Maybe it would be smarter to have the calculation done in Python, and make it bring up a value inside a new attribute, like the one I was trying to calculate inside the rule itself. So if I have a new attribute �??façade�?� that are giving me different kinds of values. Then I guess the rule would be a lot easier to manage, but I still need it to look up a specific folder depending on which value the façade attribute gives me. So if the attribute value returns 41 (4 = 1940 �?? 1960 & 1 = school) (just an example) Then I will need the value 41 to randomly take a texture from folder a.
Doesn�??t that sounds a little easier, and it is possible? (Just the rule, not the Phyton scripting)
0 Kudos
MatthiasBuehler1
Frequent Contributor II
Hi,


yes, this is possible and has been done e.g. in the Paris Example.



usually, you need to create a few functions that create the logic to find the appropriate texture, using fileRandom() or so.

check the string operations in the CGA reference.

Matt
0 Kudos