VALUE @drawing TABLE = [AC_1M_Bndry_NWT_OnlyDiss_NoEskLak_NoHrbrEntr_Is_Union2_Dissolved2 Drawing]; VALUE @table TABLE = [AC_1M_Bndry_NWT_OnlyDiss_NoEskLak_NoHrbrEntr_Is_Union2_Dissolved2]; VALUE @w FLOAT64 = 500; -- ring width VALUE @max FLOAT64 = 10000; -- max radius VALUE @buffers TABLE = ( SELECT t.[OBJECTID] AS [source_id], t.[Shape], -- GEOM s.[Value] AS [radius], CASE s.[Value] WHEN 0 THEN NULL ELSE GeomBuffer(t.[Shape], s.[Value], 0) END AS [Buffer] FROM @table AS t CROSS JOIN (TABLE CALL ValueSequence(0, @max, @w)) AS s THREADS SystemCpuCount() / 2 + 1 BATCH 1 -- assign one source record at a time per thread ); --TABLE @buffers; SELECT b1.[source_id], b2.[radius], CASE WHEN GeomIsArea(b1.[Shape]) THEN GeomMergeAreasPair(b1.[Buffer], b2.[Buffer]) -- inner and outer areas combined ELSE [b2].[Buffer] -- for first buffer only -- iff source object is line or point END AS [Ring] INTO [Rings Table] FROM @buffers AS b1 INNER JOIN @buffers AS b2 ON b1.[source_id] = b2.[source_id] AND b1.[radius] = b2.[radius] - @w -- last row from b1 is excluded (unmatched) THREADS SystemCpuCount() / 2 + 1 BATCH 2 ; ALTER TABLE [Rings Table] ( ADD [mfd_id] INT64, -- filled automatically ADD INDEX [mfd_id_x] BTREE ([mfd_id]), ADD INDEX [Ring_x] RTREE ([Ring]), ADD PROPERTY 'FieldCoordSystem.Ring' ComponentCoordSystem(@drawing) ); CREATE DRAWING [Rings] ( PROPERTY 'Table' '[Rings Table]', PROPERTY 'FieldGeom' 'Ring' );