CityEngine: creating multiple medians

3352
6
Jump to solution
11-01-2014 12:11 PM
BrendanHarmon
New Contributor

Hi, I would like some advice on creating multiple medians. I'm working with the Redlands Redevelopment 2014 street_construction rule. I'd like to be able to create extra medians between the bike lanes and the street lanes for example.  Any advice on how to go about it?

Changes to street_construction.cga

attr Median_Right = false

attr Median_Left = fase

medianWidthAdjusted = case oneWayStreet: 0 else : Median_width

medianWidthAdjustedRight = medianWidthAdjusted(0)

medianWidthAdjustedLeft = medianWidthAdjusted(2)

medianWidthAdjusted(dir) = case (dir == 0 && Median_Right) || (dir == 2 && Median_Left) : Median_width  else : 0

availableForLanesRound1 = streetWidth - parkingLaneWidth(0) - parkingLaneWidth(2) - bikeLaneWidth(0) - bikeLaneWidth(2) - medianWidthAdjusted(0) - medianWidthAdjusted(2)

StreetsidesStep3 -->

  case Protected_Bike_Lanes:

  split(v,unitSpace,0) {

  bikeLaneWidthRight : BikeLane(0) |

  parkingLaneWidthRight : Parking(0) |

  medianWidthAdjusted : Median(0)

  laneCountRight * laneWidthAdjusted : Lanes(0) |

  laneCountLeft * laneWidthAdjusted : Lanes(2) |

  medianWidthAdjusted : Median(2)

  parkingLaneWidthLeft : Parking(2) |

  bikeLaneWidthLeft : BikeLane(2) }

  else:

  split(v,unitSpace,0) {

  parkingLaneWidthRight : Parking(0) |

  bikeLaneWidthRight : BikeLane(0) |

  medianWidthAdjusted : Median(0)

  laneCountRight * laneWidthAdjusted : Lanes(0) |

  laneCountLeft * laneWidthAdjusted : Lanes(2) |

  medianWidthAdjusted : Median(2)

  bikeLaneWidthLeft : BikeLane(2) |

  parkingLaneWidthLeft : Parking(2) }

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

You are in the right part of the code. The rule "StreetsidesStep3" has two cases. One where the bike lane is protected by the parking, and the other where bike lanes swap with parking. In both cases, the whole road is being split into right and left lanes, parking, median, and bike lanes. The parameters (0) and (2) tell which side of the street you are on. So you could add more cases here, or just rearrange these cases. In any case, that rule is the place to do it. Does this make sense? If not, I can elaborate.

Chris

View solution in original post

0 Kudos
6 Replies
MatthiasBuehler
Occasional Contributor III

Hi,

I don't know the rules by heart, so I cannot comment on the changes ..

The easiest is to stop the rule execution step by step to see what each line of code does, with a '.' (dot) at the right points. when you have found the rule that cuts up the street shape, add your additional split code in there.

I assume that's what you try .. what's not working ? something specific ?

Matthias Buehler

Head of 3D Technologies

twitter: @MattB3D

---------------------------------

Garsdale Design Limited

matthias.buehler@garsdaledesign.co.uk

www.garsdaledesign.co.uk

0 Kudos
BrendanHarmon
New Contributor

Thanks for the advice - I should set break points and step through as if debugging. That'll be a much better way of understanding the code than just trying to read it.

0 Kudos
by Anonymous User
Not applicable

You are in the right part of the code. The rule "StreetsidesStep3" has two cases. One where the bike lane is protected by the parking, and the other where bike lanes swap with parking. In both cases, the whole road is being split into right and left lanes, parking, median, and bike lanes. The parameters (0) and (2) tell which side of the street you are on. So you could add more cases here, or just rearrange these cases. In any case, that rule is the place to do it. Does this make sense? If not, I can elaborate.

Chris

0 Kudos
by Anonymous User
Not applicable

Also, the lane widths seen in each case all add up to the available space. There are not any approximate operators (~). This doesn't mean you can't use them. But it makes it easier to debug if the math double checks itself.

0 Kudos
BrendanHarmon
New Contributor

Ah, I have a related question. I'd like to be able to set the streetWidth by style, but I can't seem to change the streetWidth from the value set in segments's Street Parameters. Using the Redlands Redevelopment's Street Construction rule,  I tried this:

Removed:

@Hidden

attr streetWidth = 0

Added:

@Group("ROAD LAYOUT")

@Order(0) @Range(3,64)

attr styleStreetWidth = 0

streetWidth = styleStreetWidth

&

style Residential_Road

attr styleStreetWidth = 14

When I applied the rule and style to a street segment, the width remained 7.  How can I change this with a style?  Can I override the shape parameters?

I also tried to directly set the streetWidth to a value and it still didn't work:

attr streetWidth = 14

0 Kudos
BrendanHarmon
New Contributor

Thanks!  That makes sense.

0 Kudos