Reputation: 77
I have a polygon in table 2 with its id, no and geometry. In table 1 I have polygons with the same fields. The polygon in table2 in intersects with a few polygons from table 1.What I am trying to do is clip of the polygons which overlap polygon from table 2 and insert the same fields and geometry in table 3. So if polygon from table 2 has 2 overlaps I want to get rid of those overlaps and just get the rest into a new table.The following code is for returning the clipped part of the geometry .How do I get the geometry for the polygon after the clipping is done.
insert into table 3
select a.store_id,b.store_id,a.store_number,a.client_id,sdo_geom.sdo_intersection(b.geometry,a.geometry,0.005)
from table_1 a, table_2 b
where b.store_id=34746
and sdo_anyinteract(b.geometry,a.geometry)='True';
Upvotes: 1
Views: 1615
Reputation: 143
I think you're trying to clip a single geometry with multiple geometries? sdo_difference only allows 1(single) geometry entity to clip another (single) geometry entity.
I have a similar requirement and solved it with sdo_aggr_union. This is now a part of Oracle Locator in 12c.
with minisegs as (
SELECT seg.seg_cnn cnn,SDO_GEOM.SDO_DIFFERENCE(seg.shape,(
select SDO_AGGR_UNION(SDOAGGRTYPE(node.geometry, 0.005))
from node_poly node
where SDO_RELATE(node.geometry,seg.shape, 'mask = anyinteract') = 'TRUE')) geom
from mv_act_segs seg)
select cnn,sdo_geom.sdo_length(geom,0.01) len, geom from minisegs
where geom is not null
and sdo_geom.sdo_length(geom,0.01)>5
this is clipping a line segment node(point) buffers on both ends. In this case I needed to create a single geometry object from multiple objects for the sdo_difference to work. for subsequent process I needed to filter out short/null segments.
Upvotes: 1
Reputation: 1927
Instead of using sdo_geom.sdo_intersection
, you probably want to use sdo_geom.sdo_difference
- this acts as a minus operation:
Upvotes: 1