Wilson Garden
Bengaluru Streets for People Challenge (February 2021)






















Last updated
/*
Road Width for One Side Parallel Parking : 8m
Road Width for Two Side Parallel Parking : 10.0m
Stall Intervals 7.0m, Stall Width: 2.0m, Aisle Width 2.5m, Lane Width 3.5m
Road Width for One Side 30 degree Parking : 12m
Stall Intervals 5.5m, Stall Width 5.0m,Aisle Width 3.5m, Lane Width 3.5m
*/
//Control Variables
//Max Block Area
mxa01 = (Math.PI*Math.Pow(400000,2)/1000000)/23;
//Lane Width
lnW01 = 2800;
//Turning Radius
tnR01 = 7000;
//Parallel Parking
pkW01 = 2400;
pkL01 = 7000;
//Deserialize blocks as Surfaces
blk01 = List.Flatten(Geometry.DeserializeFromSAB(DSOffice.Data.ImportCSV("G:\\My Drive\\Bengaluru-Competition\\Shantinagar\\Design\\20210208.csv",false)),-1);
blk02 = Blks04((Blks03(List.ShiftIndices(blk01,1),mxa01)),mxa01);
//Perimeter Curves
prm01 = PolyCurve.ByJoinedCurves(PolySurface.ByJoinedSurfaces(blk01).PerimeterCurves());
prm02 = PolyCurve.ByJoinedCurves(blk02.PerimeterCurves());
prm03 = prm02.Offset(-lnW01);
prm04 = prm03.Fillet(tnR01,false).Fillet(tnR01,true);
prm05 = prm04.Offset(-pkW01);
//Number of Car Parking spaces including periphery
crP01 = Math.Sum(List.Flatten(Math.Floor(List.RemoveIfNot(prm05.Explode()<1>,"Line").Length/pkL01),-1));
//Number of Car Parking spaces excluding main roads
crP02 = crP01 - Math.Floor((prm01.Length/2)/pkL01);
//Graphics
ctl01 = PolySurface.ByJoinedSurfaces(List.Flatten(blk01.PerimeterCurves().Extrude(Vector.ZAxis()),-1));
prk01 = Surface.ByLoft(List.Transpose([prm04,prm05]));
blk03 = prm05.Patch();
int01 = ctl01.Intersect(blk03);
//Color
clr01 = GeometryColor.ByGeometryColor(prk01,Color.ByARGB(255,0,0,255));
clr02 = GeometryColor.ByGeometryColor(blk03,Color.ByARGB(255,255,255,0));
clr03 = GeometryColor.ByGeometryColor(int01,Color.ByARGB(50,255,0,0));
[clr01,clr02,clr03];def Blks01(blks:var[]..[],mxar)
{
//Adjacent blocks with a common junction and total area less than max
blk00 = List.SortByKey(blks,blks[0].DistanceTo(blks))["sortedList"];
return [Imperative]
{
ind01 = 0;
ind02 = 0;
are01 = 0;
blk01 = [];
blk02 = [];
for (i in blk00)
{
if(i.DistanceTo(blk00[0])==0 && are01 < mxar)
{
blk01[ind01] = i;
ind01 = ind01 + 1;
are01 = i.Area/1000000 + are01;
}
else
{
blk02[ind02] = i;
ind02 = ind02 + 1;
}
}
return List.Flatten([PolySurface.ByJoinedSurfaces(blk01),blk02],-1);
}
};
def Blks02 (blks:var[]..[],mxar)
{
//Additional blocks if adjacent junction blocks area less than max
blk1 = [Imperative]
{
blk00 = Blks01(blks,mxar);
are01 = blk00[0].Area/1000000;
blk01 = [];
bln01 = List.Count(blks) != List.Count(blk00);
while (are01 < mxar && bln01)
{
are01 = blk01[0].Area/1000000;
blk01 = Blks01(blk00,mxar);
for (i in List.RestOfItems(blk01))
{
bln00 = (i.DistanceTo(blk01[0])==0) || false;
}
bln01 = bln00 && List.Count(RestOfItems(blk01))>0;
blk00 = blk01;
}
//return blk01;
return blk00;
}
blk2 = List.Count(blk1)>0?List.SortByKey(blk1,blk1[0].DistanceTo(blk1))["sortedList"]:blk1;
return blk2;
};def Blks03 (blks:var[]..[],mxar)
{
//Block groupings
return [Imperative]
{
bln01 = true;
blk03 = [];
ind01 = 0;
itr01 = 0;
while (bln01)
{
bln02 = List.Count(Blks01(blks,mxar))==List.Count(blks);
blk01 = Blks02(blks,mxar);
blk02 = List.RestOfItems(blk01);
blk03[ind01] = List.FirstItem(blk01);
bln01 = List.Count(blk02)>0;
ind01 = ind01 + 1;
blks = blk02;
}
return List.Flatten([blk03,blks],-1);
}
};
def Blks04 (blks:var[]..[],mxar)
{
//Merging small isolated blocks
blks1 = blks;
blk00 = blks1.Explode();
cnt01 = List.Count(blk00<1>);
are01 = Math.Sum(blk00.Area/1000000);
bln01 = are01<mxar/4;
blk01 = List.FilterByBoolMask(blks1,bln01);
blk02 = blk01["out"];
blk03 = blk01["in"];
dis01 = blk03<1>.DistanceTo(blk02<2>)==0;
ind01 = List.IndexOf(dis01<1>,true);
ind02 = 0;
blk04 = [Imperative]
{
for (i in ind01)
{
rep01 = List.Flatten([blk02[i],blk03[ind02]],-1);
blk02 = List.ReplaceItemAtIndex(blk02,i,rep01);
ind02 = ind02 + 1;
}
return blk02;
}