[Cityengine tutorial documentation]-03 map control tutorial

Source: Internet
Author: User
Tags user definition

This document is an ESRI cityengine learning document. It is an official example of cityengine_2011_tutorial 3.
The Chinese Translation of "tutorial_03_map_control _ 2011_2" is prepared by the Chinese translation of netizens in winter.


Tutorial Introduction

A city contains many objects. It is very troublesome and unlikely to control each building by setting its properties. First, you will learn how to use CGA rule parameters in this tutorial, and then you will learn how to use maps to control the attributes of your city.



Part 1: Understanding CGA rule attributes
Tutorial settings

Import the "tutorial_03_mapcontrol" project in your cityengine Workspace

Open the scenario "tutorial_03_mapcontrol/scenes/mapcontroltutorial_01.cej"


Layers in current scenario

Map layer: terrain

Map layer: water body

Road Network Layer (including plot shape)


Where do rule parameters come from?

When you select a plot shape and view its attribute information in the "Inspector" window, you will find that it is not assigned rule parameters (The rule parameter group is empty ), this situation changes when a rule is applied to this shape.

Select all elements in the block layer in the scene window

[Shapes] --> [Assign rule file...] select the rule file "rules/simplebuildingshells_01.cga"

Select another element of the plot data. An Attribute named "height" is displayed in the "Inspector" window.


Where does this property come from? When you apply rules to your shape, the attribute information of the Rule file is displayed as the attribute (Rule attribute) of the block data. The height value is from the rule file.

Click the "rule file" link in the "Inspector" window to open the rule file. In the upper left corner, the definition of "height" is placed.

// Height value

ATTR Height = 80

This value is used to define the height of a building in the Rule file. Select this element again.

[Shapes]-> [generate]

You will get an 80-meter-tall building model.

Now change the height value from 80 to 150 in the "Inspector" window ". Observe the changes in height from rule definition to user definition. The elevation of the current building is changed by the value directly defined in "Inspector. The height values of other unselected plot elements are still read from the rule file.


Rebuild the building and you can see that the height of the building has changed. Now, your scenario should be shown in.


Similarly, you can open the scenario "tutorial_03_mapcontrol/scenes/mapcontroltutorial_02.cej" to view the results of this tutorial.


Part 2 control the height of buildings in a city
Tutorial settings

Continue or enable the scenario "tutorial_03_mapcontrol/scenes/mapcontroltutorial_02.cej" based on the first scenario"


Map

Use the current settings to generate some buildings, as shown in your city.


Ing maps can generate a variety of changes to the height of a building. This sentence does not sound convincing now. Now we will use the map below to control the height of all buildings at one time, instead of using the method for manually setting the CGA model attribute in the first part.



The red band in the ing map represents the height of the building in the region. By comparing ing maps and topographic maps, you will find that the map we want to create is distributed along the corner of the lake, and the other part is in the upper left corner of the map.


Create map layers

Create a new map layer [layer]-> [new map layer]

Name the layer "skyline map", select "mapping", and click Next.

Select “skylinemap.png from the “maps”folder for “mapping.pdf"

Confirm that the arrangement is centered and disable the keep proportion button.

Set the size of X and Y to 3000.

Right-click to create a new drawing property


Name this attribute "skylinevalue"

We need to use the red band of the image to control the height, so select "red" in the channel drop-down box"

The building height should be between 20 (0% red) and 200 (100% red) meters. Therefore, enter 20 as the minimum value "minimum", and 200 as the maximum value "maximum ".

Click Finish to create a map layer.


TIPS: In the "Inspector" window, adjust the elevation offset of the mapped map layer to better observe the map. Change the "Alpha" value to make it transparent.

Because the selected "height (height)" value already exists in the Rule file, we can use the ing map to control the rule parameters. Now we apply the rule file to the block.

Select All plot data elements

Click the connection button of the Rule attribute "height" in the "Inspector" window to start the connection editor ).

Select the "layer attribute" layer attribute ", and in the drop-down box, select the" skyline map "layer and Its Attribute" skylinevalue"


TIPS: After the ing layer is set, "?" is displayed in the value. Symbol. This indicates that the selected target contains different values.

Select a plot element and observe its attribute value in the "Inspector" window. The "height" value is controlled by "skyline map.


Select some plot elements in the lake Bay Area and generate buildings

Select a lot in the box.

[Shapes]-> [generate models]


The current work has brought initial results to our scenario. Now we will use the CGA syntax for further improvement. Open the rule file "rules/simplebuildingshells_02.cga" (double-click this file in the file navigation window) and view the following functions:

// Calc height with variation

Getheight (area) =

Case area> 600: rand () + height

Case area> 200: rand () + height/2

Else: rand (15, 30)

In this rule, the height of the horizon is not directly used to determine the building height, these user-defined functions define the building height according to the following description (read the CGA Modeling Language tutorial to learn CGA rules and functions)

Only high-rise buildings are built on a large area of land

To add some changes to the building height, a random value is introduced to the height value.

Select block layers in the "scene" Window

[Shapes]-> [Assign rule file ...], Select the rule file "rules/simplebuildingshells_02.cga"

[Shapes]-> [generate models]

After completing the second part of this tutorial, your scenario should be shown in.


You can also openTutorial_03_mapcontrol/scenes/mapcontroltutorial_03.cejTo view


Part 3: land use types of buildings controlled by map
Tutorial settings

Continue or enable the scenario "tutorial_03_mapcontrol/scenes/mapcontroltutorial_03.cej" based on the first scenario"


Control the land use types of buildings

A city usually has different land use types. This section describes how to set attributes for three different types of land. In the map below, blue represents the commercial area, red represents the industrial area, and green represents the residential area.




Create a "Land Use" map layer

Observe the three CGA attributes in "rules/simplebuildingshells_03.cga" before creating a layer.

// Land-Use Type

ATTR t_industrial = 0

ATTR t_1_cial = 0

ATTR t_residential = 0

The map layer to be created must have a matched name to indicate the attribute information.

Click the eye icon in the "scene" window to hide the ing layer.

Create a new map layer [layer]-> [new map layer ...]

Name the layer "landuse types", select "mapping", and click Next

Select the “areatypes.png file from the maps folder.

Confirm that the alignment is centered and disable the keep ratio button.

Set X and Z to 3000

Create three map attributes

Name the first attribute "t_industrial" and select the corresponding channel from the drop-down list.

Name the second attribute "t_residential" and select the corresponding channel from the drop-down list.

Name the third attribute "T _ commercial" and select the corresponding channel from the drop-down list.

We will re-assign values to these attributes in the Rule file, so the default maximum and minimum values are 0 and 1, which is a good ing in subsequent use.

Click Finish to create a map layer.


TIPS: In the "Inspector" window, adjust the elevation offset of the new map layer to better observe the map. Change the "Alpha" value to make it transparent.

Select the new map layer and view its attributes in the "Inspector" window. Confirm that the three CGA attributes have been correctly defined. You can use this window to modify the map layer settings.


Evaluate the current land use map

Select all elements of the block layer

Application rule file "rules/simplebuildingshells_03.cga"

Set the data source for the land use parameter of the "landuse type" Layer


Before the building is finally generated, view the rule file "rules/simplebuildingshells_03.cga" and locate the color description and function "functionlandusetypecolor.

// Color declarations

Red = "# ffaaaa"

Green = "# aaffaa"

Blue = "# aaaaff"

White = "# ffffff"

// Functions

Landusetypecolor =

Case t_industrial> t_commercial & t_industrial> t_residential: red

Case t_1_cial> t_industrial & t_1_cial> t_residential: Blue

Case t_residential> t_industrial & t_residential> t_1_cial: Green

Else: white

This function is used to analyze the input values of the land use map and return the corresponding values based on these values. If the color channel value from the map is greater than that of other channels, the corresponding land use color is returned. Red indicates the industrial zone, blue indicates the economic zone, and Green indicates the center zone. Landusetypecolor calls the land use color function to generate buildings. Now all the buildings are generated in the scene.

Select a lot layer in the "scene" Window

Click Generate in the top toolbar


Similarly, you can open "tutorial_03_mapcontrol/scenes/mapcontroltutorial_04.cej" to view this part.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.