Skip to content

Explicit Tiling

mtbeek32 edited this page Jan 8, 2023 · 14 revisions

introduction

For some time/memory intensive operations, like determining the dwelling type of each pand in the BAG, an explicit tiling of polygons is used to limit the number of objects worked on simultaneously.

example

unit TileDomain := ='union_unit('+AsItemList('CreateTiles/LoopPolygons/'+string(CreateTiles/TileSet/name)+'/shape')+')'
{  
    attribute geometry (poly) := ='union_data(.,'+AsItemList('CreateTiles/LoopPolygons/'+string(CreateTiles/TileSet/name)+'/shape/geometry')+')';
}

container CreateTiles
{
    parameter<float32> NrofTiles_horizontal := 5f; 
    parameter<float32> NrofTiles_vertical   := 5f;
   
    // bounding box of The Netherlands
    parameter<meter> x_min := 0[meter];
    parameter<meter> x_max := 280000[meter]; 
    parameter<meter> y_min := 300000[meter];
    parameter<meter> y_max := 625000[meter];
   
    parameter<meter> x_interval := (x_max - x_min) / NrofTiles_horizontal;
    parameter<meter> y_interval := (y_max - y_min) / NrofTiles_vertical;
   
    unit<uint32> TileSet := range(uint32, 0, uint32(NrofTiles_horizontal * NrofTiles_vertical))
    {
       attribute<uint32> values     := id(.);
       attribute<string> name       := 'Tile'+ string(values);
       attribute<uint32> row_number := values / NrofTiles_horizontal[uint32];
       attribute<uint32> col_number := mod(values, NrofTiles_horizontal[uint32]);
    }
   
    container LoopPolygons := for_each_ne(
      TileSet/name
     ,'CreatePolygons('+string(TileSet/values)+','+string(TileSet/row_number)+','+string(TileSet/col_number)+')'
    );
   
    template CreatePolygons
    {
	   parameter<uint32> TileNumber;
	   parameter<uint32> row_number;
	   parameter<uint32> col_number;
	       
	   unit<uint32> shape: nrofrows = 1
	   {
	      attribute<rdc> left_top     := const(point(x_min + col_number[float32]      * x_interval, y_max - row_number[float32]        * y_interval, rdc), .);
	      attribute<rdc> right_top    := const(point(x_min + (col_number[float32]+1f) * x_interval, y_max - row_number[float32]        * y_interval, rdc), .);
	      attribute<rdc> right_bottom := const(point(x_min + (col_number[float32]+1f) * x_interval, y_max - (row_number[float32] + 1f) * y_interval, rdc), .);
	      attribute<rdc> left_bottom  := const(point(x_min + col_number[float32]      * x_interval, y_max - (row_number[float32] + 1f) * y_interval, rdc), .);
	           
	      attribute<rdc> geometry (poly) := points2sequence(pointset/point, pointset/sequence, pointset/order);
	   }
	   unit<uint32> pointset: nrofrows = 5
	   {
	      attribute<rdc>    point    := union_data(., shape/left_top, shape/right_top, shape/right_bottom, shape/left_bottom, shape/left_top);
	      attribute<shape>  sequence := const(0,., shape);
	      attribute<uint32> order    := id(.);
	   }
    }
}
Clone this wiki locally