Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Could anyone help me figure out the best way to get the overlapping line segment of 2 line sdo_geometry objects?

my query looks like this:

select SDO_GEOM.SDO_INTERSECTION(SHAPE, :SHAPE, 0.5) as geom
from MyTable 
where MDSYS.SDO_OVERLAPS(SHAPE, :SHAPE) = 'TRUE'

the geometry objects in the table are all lines as is eth parameter being passed in, but the geometry being returned for all results is a point, not a line.

share|improve this question
    
Just a wild guess, is that there may be some option to specify the output geometry type. In many packages the default output is a line, so check O-S to see if you can modify the output. I know it can be done in other packages, but for specific input geometries. –  Dan Patterson May 16 '13 at 22:57

1 Answer 1

Are you sure the lines are overlapping, not just crossing each other?

create table test (TestID number, shape SDO_GEOMETRY);
Insert into test values (1, SDO_GEOMETRY(2002, NULL, null, SDO_ELEM_INFO_ARRAY(1,2,1),  SDO_ORDINATE_ARRAY (1,1, 4,4)));
Insert into test values (2, SDO_GEOMETRY(2002, NULL, null, SDO_ELEM_INFO_ARRAY(1,2,1),  SDO_ORDINATE_ARRAY (1,4, 4,1)));
insert into user_sdo_geom_metadata values ('test', 'SHAPE', SDO_DIM_ARRAY(SDO_DIM_ELEMENT('Lat', -180, 180, 0.05), SDO_DIM_ELEMENT('Long', -90, 90, 0.05)), NULL);
create index test_indx on test(shape) indextype is mdsys.spatial_index;
select SDO_GEOM.SDO_INTERSECTION(SHAPE, SDO_GEOMETRY(2002, NULL, null, SDO_ELEM_INFO_ARRAY(1,2,1),  SDO_ORDINATE_ARRAY (2,2, 5,5)), 0.5) as geom
from test 
where MDSYS.SDO_OVERLAPS(SHAPE, SDO_GEOMETRY(2002, NULL, null, SDO_ELEM_INFO_ARRAY(1,2,1),  SDO_ORDINATE_ARRAY (2,2, 5,5))) = 'TRUE';

Results in

SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(2, 2, 4, 4))
SDO_GEOMETRY(2001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(2, 2))

In the second case, a line can't be returned because the lines only intersect at a point. Playing around with this, the only ways I could filter the result set was based on gtype or testing to see in the intersection of the A and B shapes is covered by the A shape.

select SDO_GEOM.SDO_INTERSECTION(SHAPE, SDO_GEOMETRY(2002, NULL, null, SDO_ELEM_INFO_ARRAY(1,2,1),  SDO_ORDINATE_ARRAY (2,2, 5,5)), 0.5) as geom
from test
where MDSYS.SDO_OVERLAPBDYDISJOINT(SHAPE, SDO_GEOMETRY(2002, NULL, null, SDO_ELEM_INFO_ARRAY(1,2,1),  SDO_ORDINATE_ARRAY (2,2, 5,5))) = 'TRUE'
and SDO_GEOM.SDO_INTERSECTION(SHAPE, SDO_GEOMETRY(2002, NULL, null, SDO_ELEM_INFO_ARRAY(1,2,1),  SDO_ORDINATE_ARRAY (2,2, 5,5)), 0.5).SDO_GTYPE = 2002;

SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(2, 2, 4, 4))

or:

select SDO_GEOM.SDO_INTERSECTION(SHAPE, SDO_GEOMETRY(2002, NULL, null, SDO_ELEM_INFO_ARRAY(1,2,1),  SDO_ORDINATE_ARRAY (2,2, 5,5)), 0.5) as geom
from test
where MDSYS.SDO_OVERLAPBDYDISJOINT(SHAPE, SDO_GEOMETRY(2002, NULL, null, SDO_ELEM_INFO_ARRAY(1,2,1),  SDO_ORDINATE_ARRAY (2,2, 5,5))) = 'TRUE'
and MDSYS.SDO_COVERS (SHAPE, SDO_GEOM.SDO_INTERSECTION(SHAPE,SDO_GEOMETRY(2002, NULL, null, SDO_ELEM_INFO_ARRAY(1,2,1),  SDO_ORDINATE_ARRAY (2,2, 5,5)), 0.5)) = 'TRUE';

SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(2, 2, 4, 4))

These may not be the best solutions, but hopefully it gets you in the right direction.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.