City-Style

324
1
10-02-2018 12:39 AM
MajdAlobied1
New Contributor II

When  i create City with CityEngine for Aachen City, how can i apply STYLE of Aachen?

Has anyone Tips or Tutorial please?

Thanks alot.

0 Kudos
1 Reply
CherylLau
Esri Regular Contributor

Option 1

The easiest way (and maybe not the cleanest way or best way) is to copy the Building_From_OpenStreetMap.cga rule from ESRI.lib into your own project and rename it (right click -> Rename).  Then, you can add your own style for Aachen at the bottom.

For example, you can customize the following attributes (but you don't have to, and you can delete the line from the style to use the default setting).  This will set the values for buildings that do not have OSM data.  For example, if a building does not have OSM data for number of levels or building height, then the attribute value for estimatedLevels is used instead.   Note:  In the code below, the attributes are set to fake values.  You'll have to insert your own appropriate values for your city.  You can use expressions like rint(rand(2,10)) to randomly pick the number of levels to be in the range [2,10].

style Aachen

attr estimatedLevels = 10
attr estimatedRoofForm = "flat"          // options: "flat", "shed", "gable", "half-hip", "hip", "pyramid", "gambrel", "mansard", "dome", "onion", "round", "saltbox"
attr estimatedNonFlatRoofForm = "gable"               
attr estimatedFloorHeight = 3
attr estimatedNonFlatRoofHeight = 3
attr estimatedBuildingForm = "extrusion"     // options: "extrusion", "setback top", "setback facade", "setback base", "setback everywhere"
attr estimatedBuildingColor = "#cccc66"
attr estimatedRoofColor = "#9999aa"
attr estimatedRepresentation = "solid color"     // options: "realistic with facade textures", "schematic facades", "solid color"

Option 2

Another way to create your own city's style is to create your own rule which imports the Building_From_OpenStreetMap.cga rule.  Both options are not ideal.  The difficult part about this is that you have to copy the hidden attributes from the Building_From_OpenStreetMap.cga rule to your new rule (so that object attributes will link correctly).  Then, you can add however many styles you want to the end of your new rule.  Then, you choose your style from the Inspector for your new rule (not for the OSM rule).  For example, here's what the new rule could look like.

import OSM:"/ESRI.lib/rules/Buildings/Building_From_OpenStreetMap.cga"



// ------------------------------
// Hidden Attributes
// ------------------------------

@Group("From Object Attributes", 2)

// from object attributes
@Hidden
attr height = -1
@Hidden
attr building__levels = -1
@Hidden
attr roof__height = -1
@Hidden
attr roof__shape = ""
@Hidden
attr building__colour = ""
@Hidden
attr roof__colour = ""

@Group("Estimated Attributes (can be set by styles)", 3)

// Note: These attributes can be overriden by styles.
// estimated attributes based on default values or overriden by styles
@Hidden
attr estimatedLevels = OSM.defaultLevels
@Hidden
attr estimatedRoofForm = OSM.defaultRoofForm                              // when no obj attr roof__height
@Hidden
attr estimatedNonFlatRoofForm = OSM.defaultNonFlatRoofForm               // when obj attr roof__height>0
@Hidden
attr estimatedFloorHeight = OSM.defaultFloorHeight
@Hidden
attr estimatedNonFlatRoofHeight = OSM.defaultNonFlatRoofHeight
@Hidden
attr estimatedBuildingForm = OSM.defaultBuildingForm
@Hidden
attr estimatedBuildingColor = OSM.defaultBuildingColor
@Hidden
attr estimatedRoofColor = OSM.defaultRoofColor
@Hidden
attr estimatedRepresentation = OSM.defaultRepresentation



// ------------------------------
// Start Rule
// ------------------------------

Lot -->
     OSM.Generate
     
     
// ------------------------------
// Styles
// ------------------------------

     
style Aachen

attr estimatedLevels = 10
attr estimatedRoofForm = "flat"               
attr estimatedNonFlatRoofForm = "gable"               
attr estimatedFloorHeight = 3
attr estimatedNonFlatRoofHeight = 3
attr estimatedBuildingForm = "extrusion"
attr estimatedBuildingColor = "#cccc66"
attr estimatedRoofColor = "#9999aa"
attr estimatedRepresentation = "solid color"
0 Kudos