Skip to content

Commit

Permalink
General Refactor/Bug Fix
Browse files Browse the repository at this point in the history
Drop simplied rules (only used in crosswalks), Remove duplicate code in ColorAndReport rule, Fix Parking Endcap Paint. More changes for that likely to come as projections and "decals" are used.
  • Loading branch information
d-wasserman committed Jun 15, 2020
1 parent 846d365 commit 77705a2
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 130 deletions.
100 changes: 35 additions & 65 deletions rules/Complete_Street.cga
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* File: Complete Street.cga
* Created: 10/30/2015 Oct 2015
* Last Updated: 05/24/2020
* Last Updated: 6/14/2020
* Author: David J. Wasserman- As Part of and Based on Work from Esri Redlands
* License: ESRI Attribution License and Apache License.
* Source: https://github.com/d-wasserman/Complete_Street_Rule
Expand Down Expand Up @@ -574,8 +574,8 @@ const Brake_Reaction_Dist = 1.47*Design_Speed*Brake_Reaction_Time
const Braking_Dist = 1.075*((Design_Speed*Design_Speed)/Deceleration_Rate)# Time spent actually braking
const Stopping_Sight_Dist = Brake_Reaction_Dist+Braking_Dist
##Unit Conversion- in terms of number of unit per meter,meter^2, or meter^3- convert by unit *conversion factor==new unit
const SquareFeet =10.7639 #per meter ^2
const Feet =3.28084 #per meter ^1
const SquareFeet =10.7639 #per meter ^2
const Miles =0.00062137 #per meter ^1
const Inches =39.3701 #per meter ^1
const CubicFeet =35.3147 #per meter ^3
Expand Down Expand Up @@ -1554,17 +1554,14 @@ ApproachMarkings(dir,lanenumber,lanestotal,markings) --> # is used for textures
normalizeUV(0,v,separatePerFace)
scaleUV(0,1,(case (lanenumber==lanestotal-1):.95 else: 1))# Scale UV in V direction slightly to remove light line on lane closer to centerline.
texture(LanesFolder+"/lanes_4"+markings+"_14x14m.jpg")
color( _ThematicRouter ("Auto","drive_lane"))#If Display Thematics==Usage, goes to usage, if not, Thematic.
ModeReporter("Auto")
Delete_Texture
#TODO-More combinations
ColorAndReport("Auto","drive_lane")

MainLaneMarkings(dir,lanenumber,markings)--> #Ground Textured Rule
tileUV(0,~14,~ Lane_Width ) # the tileUV operation makes sure that one unit in u-space corresponds to approx 14 meters, the v-coord is not touched in the case of 0 as parameter
scaleUV(0,_uScale,1/4) # flip direction if needed, handle short lanes with _uScale, and scaling the v coord for the texture (e.g. a street with 2 lanes has v coords from 0 to 2, this means it has to map onto 0 to 2/8 on our texture with its 8 lanes)
texture( LanesFolder+"/lanes_4"+markings+"_14x14m.jpg")
color( _ThematicRouter ("Auto","drive_lane"))#If Display Thematics==Usage, goes to usage, if not, Thematic.
ModeReporter("Auto")
Delete_Texture
ColorAndReport("Auto","drive_lane")

#This rule contains the reports for the lanes defined by the lanes rule, no bike/pking lanes etc.
LaneReporting(dir,lanestotal,lanenumber,stopType,laneType)-->
report("Lane Width.Actual Lane Width (ft)",geometry.dv(0,unitSpace)*Feet) #Used to provide lane widths in feet
Expand Down Expand Up @@ -1740,9 +1737,7 @@ HOVlaneStamp(dir)--> #Ground Textured Rule
rotateUV(0,90)
tileUV(0,~ Transit_Lane_Width ,~Transit_Lane_Width )#Lane width is used for texture size because it can repeat if need for large streets and because it allows the text to stay in scale with that of a Bus or car.
texture(LanesFolder+"/HOV_Diamond"+".jpg")#If Black change the stamp chosen, might make more elegant later.
color( _ThematicRouter ("Shared Mobility","hov_lane"))#If Display Thematics==Usage, goes to usage, if not, Thematic.
ModeReporter("Shared Mobility")
Delete_Texture
ColorAndReport("Shared Mobility","hov_lane")#If Display Thematics==Usage, goes to usage, if not, Thematic.
##############################################################
#Non-Carlane Split Space- This is the space where
#parking, bike, and buffer lanes are constructed.
Expand Down Expand Up @@ -2056,9 +2051,7 @@ DoBi_Scooter_Parking_Stamp(Side,ParkingWidth,ParkingLength)--> #Ground Textured
setupProjection(0,scope.xz,'1,'1)
texture(LanesFolder +"/MicromobilityParking.jpg")
projectUV(0)
color( _ThematicRouter ("Shared Mobility","bike_parking"))
ModeReporter("Shared Mobility")
Delete_Texture
ColorAndReport("Shared Mobility","bike_parking")

Carshare_Parking_Split(Side,Color,ParkingWidth,ParkingLength)-->
split(u,unitSpace,0) {~ParkingLength:Carshare_Parking_Allocation(Side,Color,ParkingWidth,ParkingLength)}*
Expand All @@ -2080,9 +2073,7 @@ Carshare_Parking_Stamp(Side)--> #Ground Textured Rule
scaleUV(0,case (Side=="Right" || Lane_Distribution==1) && Lane_Distribution!=0:1 else: -1,
case (Side=="Right" || Lane_Distribution==1) && Lane_Distribution!=0:1 else: -1)
scaleUV(0,case rightHandTraffic: 1 else: -1,case rightHandTraffic: 1 else: -1)
color( _ThematicRouter ("Shared Mobility","parking_lane"))
ModeReporter("Shared Mobility")
Delete_Texture
ColorAndReport("Shared Mobility","parking_lane")

Bus_Stop_Allocation(Side,Color,StampWidth)-->
report("Curbside Management.Bus Stop Length (m)",geometry.du(0,unitSpace))
Expand Down Expand Up @@ -2110,9 +2101,7 @@ Project_Zebra_Stripe(Color,Mode_Class,LabelID)--> #Ground Textured Rule
setupProjection(0,scope.xz,'1,'1)
texture(LanesFolder +"/crosswalk_zebra_"+Color+".jpg")
projectUV(0)
color( _ThematicRouter (Mode_Class,LabelID))
ModeReporter(Mode_Class)
Delete_Texture
ColorAndReport(Mode_Class,LabelID)

Parklet_Insert(ParkingLength,Rotation)-->
alignScopeToGeometry(yUp, largest, 1)
Expand All @@ -2135,11 +2124,9 @@ AngledNoseIn(Side,ParkingType,SpaceNumber,TotalSpacesonSide,ParkingLength,Parkin

tileUV(0,~ParkingLength,~ParkingWidth)
texture(LanesFolder+"/AngledParking.jpg")
color( _ThematicRouter ("Storage","parking_lane"))#If Display Thematics==Usage, goes to usage, if not, Thematic.
ParkingReport(Side,case SpaceNumber==1: false else:true,false)#Don't include last spot
ModeReporter("Storage")
Delete_Texture

ColorAndReport("Storage","parking_lane")

AngledNoseOutParking(Side,ParkingType,SpaceNumber,TotalSpacesonSide,ParkingLength,ParkingWidth)-->
AngledParkingCar((case Side=="Right":0 else:2),ParkingType,ParkingLength, ParkingWidth,SpaceNumber)
scaleUV(0,1,(case Side=="Right":
Expand All @@ -2148,10 +2135,8 @@ AngledNoseOutParking(Side,ParkingType,SpaceNumber,TotalSpacesonSide,ParkingLengt
(case Parking_Protection_Bool :-1 else:1)))
tileUV(0,~ParkingLength,~ParkingWidth)
texture(LanesFolder+"/AngledParking.jpg")
color( _ThematicRouter ("Storage","parking_lane"))#If Display Thematics==Usage, goes to usage, if not, Thematic.
ParkingReport(Side,case SpaceNumber==1: false else:true,false) #Don't include last spot
ModeReporter("Storage")
Delete_Texture
ColorAndReport("Storage","parking_lane")

ParallelParking(Side,ParkingType,SpaceNumber,TotalSpacesonSide,ParkingLength,ParkingWidth)-->
case SpaceNumber==TotalSpacesonSide-2:#1 from index total, 1 from additional split- Start
Expand Down Expand Up @@ -2192,9 +2177,10 @@ ParkingInsertCap (Rotation,Obj_Path)--> #Ground Textured Rule
rotateScope(0,Rotation,0)
i(StencilFolder+Obj_Path)
extrude(sharrowHeight)
tileUV(0,7,7)
cleanupGeometry(all,0.001)
texture(LanesFolder+"/asphalt_painted_white_7x7m.jpg")
normalizeUV(0,uv, separatePerFace)
setupProjection(0,scope.xz,2,2,2,2,2)
texture(LanesFolder+"/asphalt_painted_" + "white" + "_7x7m.jpg")
projectUV(0)
color( _ThematicRouter ("Storage","parking_lane"))#If Display Thematics==Usage, goes to usage, if not, Thematic.
Delete_Texture

Expand Down Expand Up @@ -2863,34 +2849,34 @@ CrosswalkDirector(crosswalkType,uvSet)-->
case crosswalkType == "transverse" : CrosswalkTransverse(uvSet)
case crosswalkType == "dashed" : CrosswalkDashed(uvSet)
case crosswalkType == "ladder" : CrosswalkLadder(uvSet)
case crosswalkType == "solid" : AsphaltPainted( Crosswalk_Color)
case crosswalkType == "solid" : AsphaltPainted(Crosswalk_Color,"Conflict Zones","crosswalk")
case crosswalkType == "custom" : CrosswalkWalkway(true)
case crosswalkType == "ladder custom": CrosswalkLadderWalkway(uvSet)
case crosswalkType == "raised custom": CrosswalkRaised(uvSet)
else : CrosswalkContintental

CrosswalkContintental -->
split(v,uvSpace,0){ (ceil(geometry.vMin-0.01)-geometry.vMin): Asphalt
split(v,uvSpace,0){ (ceil(geometry.vMin-0.01)-geometry.vMin): Asphalt("Conflict Zones","crosswalk")
| ~1: CrosswalkStripes(1)
| geometry.vMax-floor(geometry.vMax+0.01): Asphalt }
| geometry.vMax-floor(geometry.vMax+0.01): Asphalt("Conflict Zones","crosswalk") }

CrosswalkLadder(uvSet) -->
split(u,uvSpace,uvSet){ 0.17: AsphaltPainted( Crosswalk_Color)
split(u,uvSpace,uvSet){ 0.17: AsphaltPainted( Crosswalk_Color,"Conflict Zones","crosswalk")
| ~1 : CrosswalkStripes(1)
| 0.17: AsphaltPainted( Crosswalk_Color ) }
| 0.17: AsphaltPainted( Crosswalk_Color ,"Conflict Zones","crosswalk")}

CrosswalkTransverse(uvSet) -->
split(u,uvSpace,uvSet){ 0.27: AsphaltPainted( Crosswalk_Color )
| ~1 : Asphalt
| 0.27: AsphaltPainted( Crosswalk_Color ) }
split(u,uvSpace,uvSet){ 0.27: AsphaltPainted( Crosswalk_Color ,"Conflict Zones","crosswalk")
| ~1 : Asphalt("Conflict Zones","crosswalk")
| 0.27: AsphaltPainted( Crosswalk_Color ,"Conflict Zones","crosswalk")}

CrosswalkLadderWalkway(uvSet)-->
split(u,uvSpace,uvSet){ 0.27: AsphaltPainted( Crosswalk_Color)
split(u,uvSpace,uvSet){ 0.27: AsphaltPainted( Crosswalk_Color,"Conflict Zones","crosswalk")
| ~1 : CrosswalkWalkway(false)
| 0.27: AsphaltPainted( Crosswalk_Color) }
| 0.27: AsphaltPainted( Crosswalk_Color,"Conflict Zones","crosswalk")}
CrosswalkDashed(uvSet) -->
split(u,uvSpace,uvSet){ 0.17: CrosswalkStripes(0.6)
| ~1 : Asphalt
| ~1 : Asphalt("Conflict Zones","crosswalk")
| 0.17: CrosswalkStripes(0.6) }

CrosswalkStripes(stripeWidth) --> #Ground Textured Rule
Expand Down Expand Up @@ -3345,36 +3331,22 @@ Asphalt(Usage,LabelID) --> #Ground Textured Rule
tileUV(0,14,14)
cleanupGeometry(all, 0.001)
texture( LanesFolder+"/asphalt_14x14m.jpg")
color( _ThematicRouter (Usage,LabelID))#If Display Thematics==Usage, goes to usage, if not, Thematic-strings might have other purpose later.
ModeReporter(Usage)
Delete_Texture

Asphalt --> #Ground Textured Rule
tileUV(0,14,14)
cleanupGeometry(all, 0.001)
texture( LanesFolder+"/asphalt_14x14m.jpg")
Delete_Texture
ColorAndReport(Usage,LabelID)

AsphaltPainted(paintColor,Usage,LabelID) --> #Ground Textured Rule
case paintColor!="black":# This makes sure that if the color is black, it is thrown into Asphalt Reporting
tileUV(0,7,7)
cleanupGeometry(all,0.001)
texture(LanesFolder+"/asphalt_painted_" + paintColor + "_7x7m.jpg")
color( _ThematicRouter (Usage,LabelID))#If Display Thematics==Usage, goes to usage, if not, Thematic.
ModeReporter(Usage)
set(material.name,str(material.name)+"_"+str(paintColor))
Delete_Texture
ColorAndReport(Usage,LabelID)
else:#If Black redirect to asphalt rule.
Asphalt(Usage,LabelID)

AsphaltPainted(paintColor) --> #Ground Textured Rule
case paintColor!="black":# This makes sure that if the color is black, it is thrown into Asphalt Reporting
tileUV(0,7,7)
cleanupGeometry(all,0.001)
texture(LanesFolder+"/asphalt_painted_" + paintColor + "_7x7m.jpg")

else:#If Black redirect to asphalt rule.
Asphalt
ColorAndReport(Usage,LabelID)-->
color( _ThematicRouter (Usage,LabelID))#If Display Thematics==Usage, goes to usage, if not, Thematic.
ModeReporter(Usage)
Delete_Texture

ModeReporter(Usage)-->
case reportingOn:
Expand Down Expand Up @@ -3879,9 +3851,7 @@ Rumble_Strip--> #Ground Textured Rule
tileUV(0,~Rumble_Strip_Len,~Rumble_Strip_Wid)
rotateUV(0,90)
texture(LanesFolder+"/Rumble_Strip.jpg")
color( _ThematicRouter ("Auto"))
ModeReporter("Auto")
Delete_Texture
ColorAndReport("Auto","asphalt")

Drainage--> #Ground Textured Rule
case geometry.dv(0,unitSpace)> Lane_Width /3 && Space_Management=="Flag":#Will flag the drainage area as Red if it is >1/3 the laneWidth-I mean really 1/3 of a lane is drainage? Put a bike lane or something
Expand Down
Loading

0 comments on commit 77705a2

Please sign in to comment.