1 Reply Latest reply: Feb 23, 2012 2:42 AM by Simon Greener RSS

    to split a polygon

    904890
      Hi Grus,

      I have a task where i have to draw a 30 meter buffer around roads feature class and wherever it comes across intersection there that buffer should be splitted according with intersection,
      for example if it is T inetersect, then polygon should be splitted in three piece, or if it has four exit points, then it should be splitted in four piece, please anyone can guide me how can i achieve this task?

      Thanks in advance,

      Mich
        • 1. Re: to split a polygon
          Simon Greener
          Mich,

          Not easy to do.

          The following example is for a T intersection with three linestring centrelines.

          No searching (sdo_anyinteract etc) is done. This is purely an example which
          you are welcome to generalise.

          What I do is:

          1. Extend the main centreline from the start end (not the end involved in the intersection).
          This uses an Extend function in the GEOM package of my free pl/sql packages on my website.
          2. Buffer the original centreline and treat it as a linestring;
          3. Aggregate the lines together to form a single multilinestring.
          4. Clip the multilinestring of 3 using a buffer of the original linestring.
          5. Pump the result of 4 into ST_PolygonBuilder (I am using the Java Topology Suite's polygon builder
          available via the Spatial Companion 4 Oracle (SC4O) package + java from my website (used to be called JTS package).

          I am modifying ST_PolygonBuilder to take an Array of Geometries rather than a result set.
          set serveroutput on size unlimited
          declare
            lines  sys_refcursor;
            v_geom mdsys.sdo_geometry;
          begin
            open lines for 
          select codesys.sc4o.st_intersection(c.mLines, d.buff,3) as lines
            from (select sdo_aggr_concat_lines(b.geom) as mLines 
                    from (select 'LineExtend' as ltype, codesys.GEOM.extend(sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(5,0,5,5)),3,0.005,'START') as geom from dual union all
                          select 'IntLine1'   as ltype, sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,5,5,5)) as geom from dual union all
                          select 'IntLine2'   as ltype, sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(5,5,10,5)) as geom from dual union all
                          select 'buffer'     as ltype, sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),a.buff.sdo_ordinates) as geom 
                           from (select codesys.sc4o.st_buffer(sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(5,0,5,5)),3,2) as buff
                                   from dual ) a
                         ) b
                  ) c,
                  (select codesys.sc4o.st_buffer(sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(5,0,5,5)),3,2) as buff
                    from dual ) d;
             v_geom := codesys.sc4o.ST_PolygonBuilder(lines,3);
             dbms_output.put_line(v_geom.get_wkt());
          end;
          anonymous block completed
          MULTIPOLYGON (((5.0 5.0, 8.0 5.0, 7.94 5.59, 7.77 6.15, 7.49 6.67, 7.12 7.12, 6.67 7.49, 6.15 7.77, 5.59 7.94, 5.0 8.0, 4.41 7.94, 3.85 7.77, 3.33 7.49, 2.88 7.12, 2.51 6.67, 2.23 6.15, 2.06 5.59, 2.0 5.0, 5.0 5.0)), ((4.41 -2.94, 5.0 -3.0, 5.0 5.0, 2.0 5.0, 2.0 0.0, 2.06 -0.59, 2.23 -1.15, 2.51 -1.67, 2.88 -2.12, 3.33 -2.49, 3.85 -2.77, 4.41 -2.94)), ((5.0 -3.0, 5.59 -2.94, 6.15 -2.77, 6.67 -2.49, 7.12 -2.12, 7.49 -1.67, 7.77 -1.15, 7.94 -0.59, 8.0 0.0, 8.0 5.0, 5.0 5.0, 5.0 -3.0)))
          Pity one can't attach and image to this email... 'cos it works...

          I modified the code to allow for non-ref cursor based approach. Here it is.
          select codesys.sc4o.ST_PolygonBuilder(
                    codesys.T_GeometrySet(
                       codesys.sc4o.st_intersection(c.mLines, 
                                                    codesys.sc4o.st_buffer(sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(5,0,5,5)),3,2),
                                                    3)),3) as result
            from (select sdo_aggr_concat_lines(b.geom) as mLines 
                    from (select 'LineExtend' as ltype, codesys.GEOM.extend(sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(5,0,5,5)),3,0.005,'START') as geom from dual union all
                          select 'IntLine1'   as ltype, sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(0,5,5,5)) as geom from dual union all
                          select 'IntLine2'   as ltype, sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(5,5,10,5)) as geom from dual union all
                          select 'buffer'     as ltype, sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),a.buff.sdo_ordinates) as geom 
                           from (select codesys.sc4o.st_buffer(sdo_geometry(2002,null,null,sdo_elem_info_array(1,2,1),sdo_ordinate_array(5,0,5,5)),3,2) as buff
                                   from dual ) a
                         ) b
                  ) c;
          regards
          Simon

          Edited by: sgreener on Feb 23, 2012 7:41 PM