A have a problem similar to Why does st_intersection return non-polygons, but this time in Oracle. SDO_OVERLAPS is true for two polygons, and SDO_GEOM.RELATE with the mask 'determine' says OVERLAPBDYINTERSECT. However, SDO_GEOM.SDO_INTERSECTION returns a LINESTRING. I do understand, that SDO_GEOM.SDO_INTERSECTION returns a LINESTRING, since inspecting the geometries I would think, that the geometries share just a border. So what I do not understand is, why do SDO_OVERLAPS and SDO_GEOM.RELATE report, that these polygons overlap?
My polygons are in SRID 25832 as given below.
MULTIPOLYGON (((698985.94 6167518.54, 698978.2 6167472.42, 698978.74 6167454.55, 698977.43 6167449.98, 698976.25 6167445.86, 698970.71 6167437.43, 698963.2 6167429.88, 698960.01 6167426.67, 698958.43 6167424.83, 698937.66 6167400.72, 698925.43 6167386.53, 698901.71 6167353.91, 698876.51 6167313.75, 698864.62 6167296.17, 698847.52 6167262.63, 698836.1 6167235.78, 698834.09 6167231.54, 698826.83 6167216.93, 698824.31 6167204.35, 698822.09 6167204.79, 698808.74 6167178.12, 698806.88 6167169.49, 698798.62 6167161.68, 698782.01 6167136.17, 698770.26 6167115.94, 698754.86 6167084.58, 698724.06 6167009.8, 698721.4 6166987.42, 698692.78 6166929.5, 698648.77 6166845.25, 698636.84 6166822.99, 698629.96 6166814.59, 698619.09 6166797.03, 698609.01 6166784.5, 698582.8 6166742.11, 698565.32 6166714.01, 698550.41 6166689.13, 698529.58 6166655.42, 698527.57 6166652.09, 698512.71 6166627.51, 698502.06 6166609.94, 698498.12 6166603.44, 698496.02 6166599.54, 698474.11 6166558.43, 698464.19 6166532.15, 698452.26 6166513.57, 698447.31 6166499.65, 698437.18 6166479.95, 698402.34 6166402.32, 698382.89 6166357.8, 698375.94 6166341.89, 698367.26 6166320.78, 698366.14 6166317.49, 698334.96 6166246.45, 698336.52 6166244.08, 698329.46 6166226.47, 698321.69 6166184.66, 698311.16 6166131.38, 698307.04 6166112.13, 698262.27 6166121.6, 698219.7 6166132.92, 698214.96 6166132.79, 698142.06 6166240.41, 697976.28 6166329.01, 697862.56 6166426.6, 697675.81 6166308.88, 697303.27 6166612.66, 697101.35 6166523.15, 696776.36 6166716.02, 696747.15 6167047.53, 696553.17 6167180.09, 696527.43 6167279.09, 696453.09 6167430.1, 696345.66 6167515.84, 696321.87 6167633.86, 696322.4 6167638.1, 696432.67 6167967.62, 696385.59 6168080.19, 696337.13 6168099.34, 696094.03 6168225.88, 696086.71 6168295.21, 696085.15 6168314.16, 696085.43 6168370.63, 696089.78 6168433.68, 696104.64 6168520.24, 696098.03 6168583.63, 696059.2 6168685.38, 696073.22 6168764.87, 696088.29 6168826.75, 696034.77 6168985.87, 696019.17 6169042.41, 696012.68 6169074.01, 696010.52 6169088.54, 696004.15 6169144.98, 696002.99 6169183.19, 696001.11 6169187.42, 696001.09 6169187.61, 696002.51 6169215.68, 696007.49 6169260.16, 696023.51 6169331.44, 696043.72 6169390.49, 696049.35 6169401.04, 696052.37 6169510.44, 696056.9 6169545.27, 696060.89 6169562.31, 696106.23 6169711.22, 696111.9 6169715.05, 696123.25 6169721.92, 696215.1 6169769.11, 696229.15 6169783.47, 696222.32 6169822.4, 696236.31 6170319.56, 696311.79 6170052.04, 696469.64 6170097.76, 696551.94 6170099.86, 696794.59 6170471.48, 696773.92 6169987.3, 696841.34 6170010.16, 696841.57 6170011.66, 697203.92 6170383.95, 697146.89 6170429.24, 697138.09 6170527.67, 697143.64 6170544.57, 697205.27 6170655.09, 697267.85 6170660.89, 697406.83 6170589.4, 697408.22 6170588.45, 697459.48 6170608.72, 697462.17 6170618.31, 697530.28 6170771.27, 697596.32 6170793.69, 697649.75 6170787.81, 697782.33 6170585.87, 697879.05 6170599.47, 697887.14 6170674.72, 697921.38 6170770.16, 697893.45 6170873.79, 697959.64 6171001.48, 697989.84 6171028.99, 697999.66 6171033.08, 698088.67 6170902.76, 698236.63 6170869.46, 698243.46 6170864.86, 698289.0 6170811.92, 698116.13 6170448.1, 698200.82 6170258.79, 698179.34 6170071.72, 698247.03 6169996.46, 698291.83 6169985.75, 698432.68 6169915.71, 698680.58 6169922.66, 698721.72 6169867.81, 698721.42 6169860.31, 698720.69 6169854.74, 698720.33 6169851.99, 698740.43 6169854.23, 698742.24 6169854.41, 698743.81 6169854.6, 698791.12 6169859.88, 698826.28 6169863.78, 698868.54 6169868.54, 698875.93 6169869.36, 699008.5 6169884.26, 699045.27 6169887.82, 699068.48 6169889.39, 699088.31 6169890.73, 699093.68 6169891.09, 699094.71 6169891.16, 699123.65 6169893.11, 699125.29 6169893.22, 699126.99 6169893.17, 699181.52 6169897.02, 699204.3 6169899.47, 699255.56 6169905.6, 699289.67 6169909.67, 699324.6 6169914.16, 699335.29 6169915.56, 699335.7 6169905.1, 699336.02 6169897.09, 699336.11 6169895.01, 699336.3 6169890.27, 699334.28 6169874.83, 699334.14 6169874.14, 699329.23 6169849.64, 699329.59 6169822.75, 699329.79 6169807.12, 699329.85 6169803.23, 699329.88 6169801.25, 699329.94 6169796.23, 699329.98 6169793.76, 699330.0 6169792.03, 699330.12 6169787.99, 699330.68 6169769.02, 699331.99 6169725.05, 699336.61 6169692.44, 699336.32 6169687.55, 699335.37 6169683.86, 699335.11 6169682.86, 699332.42 6169678.61, 699328.48 6169672.67, 699320.16 6169660.11, 699317.72 6169655.56, 699316.59 6169652.64, 699314.99 6169646.83, 699314.62 6169644.71, 699314.19 6169642.3, 699313.71 6169636.74, 699313.49 6169634.26, 699309.86 6169598.24, 699305.74 6169522.7, 699304.3 6169499.73, 699301.41 6169447.28, 699296.86 6169363.61, 699289.64 6169260.48, 699284.83 6169191.68, 699284.35 6169173.03, 699284.4 6169144.27, 699281.69 6169120.86, 699279.33 6169101.53, 699278.29 6169086.94, 699279.31 6169070.6, 699279.14 6169060.18, 699277.71 6169039.74, 699276.91 6169021.39, 699275.3 6169007.58, 699275.83 6168990.67, 699276.67 6168979.56, 699280.21 6168964.98, 699281.24 6168953.75, 699274.9 6168897.39, 699272.26 6168864.96, 699271.52 6168858.07, 699268.72 6168832.32, 699266.37 6168823.64, 699250.35 6168676.57, 699234.82 6168518.09, 699226.63 6168480.66, 699224.93 6168472.45, 699220.45 6168450.73, 699220.28 6168449.92, 699219.9 6168448.06, 699219.39 6168445.55, 699215.25 6168425.39, 699213.82 6168413.17, 699212.55 6168412.58, 699208.28 6168391.57, 699203.94 6168377.51, 699199.7 6168360.09, 699194.23 6168333.97, 699194.0 6168332.84, 699193.54 6168330.66, 699192.07 6168323.67, 699190.56 6168315.78, 699188.33 6168305.18, 699187.6 6168304.06, 699187.42 6168303.1, 699186.1 6168292.65, 699185.84 6168291.13, 699185.25 6168287.68, 699183.01 6168276.3, 699182.66 6168274.49, 699181.55 6168274.95, 699175.09 6168229.9, 699163.01 6168232.46, 699158.27 6168206.8, 699159.11 6168196.53, 699161.97 6168186.54, 699167.6 6168175.56, 699169.79 6168168.02, 699169.37 6168166.76, 699163.53 6168149.28, 699158.17 6168133.49, 699153.34 6168121.34, 699151.33 6168115.3, 699139.83 6168087.47, 699123.85 6168033.17, 699101.07 6167955.76, 699096.63 6167939.43, 699074.87 6167859.57, 699065.9 6167826.42, 699059.93 6167804.75, 699058.44 6167799.3, 699050.59 6167770.45, 699043.96 6167728.54, 699031.13 6167674.83, 699030.41 6167671.02, 699025.31 6167644.04, 699023.61 6167636.66, 699019.52 6167621.72, 699015.08 6167609.24, 699011.76 6167599.93, 699002.58 6167580.05, 698998.71 6167568.98, 698992.52 6167540.98, 698987.17 6167524.74, 698985.94 6167518.54)))
MULTIPOLYGON (((695804.47 6166608.43, 695737.37 6166980.94, 695667.03 6167012.02, 695477.06 6167082.19, 695387.32 6167013.26, 695329.91 6166957.31, 695302.89 6166906.19, 695298.16 6166845.2, 695344.14 6166774.84, 695435.94 6166712.73, 695439.25 6166711.41, 695804.47 6166608.43)), ((698214.96 6166132.79, 698142.06 6166240.41, 697976.28 6166329.01, 697862.56 6166426.6, 697675.81 6166308.88, 697303.27 6166612.66, 697101.35 6166523.15, 696776.36 6166716.02, 696399.06 6166351.69, 696246.01 6166357.98, 695936.74 6166566.48, 695865.41 6166582.86, 695806.11 6166605.23, 695769.44 6166571.02, 695614.94 6166399.72, 695601.96 6166388.53, 695173.07 6166138.52, 695148.45 6166125.48, 695002.23 6166165.04, 694625.56 6165748.37, 694611.16 6165610.52, 694612.69 6165604.06, 694695.6 6165479.55, 694595.06 6165098.14, 694636.06 6164905.24, 694691.39 6164696.75, 694790.68 6164611.75, 695048.64 6164570.2, 695445.27 6164901.75, 695568.87 6164904.53, 696052.95 6165108.51, 696070.37 6165162.19, 696247.21 6165374.81, 696339.18 6165415.3, 696520.44 6165404.71, 696570.74 6165413.38, 696730.68 6165488.0, 696850.75 6165588.44, 696892.21 6165635.71, 697083.46 6165682.7, 697097.91 6165684.09, 697103.35 6165686.31, 697128.44 6165683.68, 697198.23 6165629.82, 697278.74 6165592.65, 697334.45 6165575.89, 697374.71 6165571.04, 697376.89 6165571.04, 697452.75 6165554.08, 697492.980000001 6165548.73, 697603.76 6165545.74, 697704.69 6165553.29, 697756.65 6165513.45, 697974.9 6165304.92, 697985.06 6165334.31, 697995.55 6165364.35, 698000.0 6165376.89, 698003.42 6165386.31, 698015.1 6165419.24, 698026.78 6165453.05, 698037.81 6165483.72, 698048.71 6165515.14, 698059.25 6165544.52, 698069.22 6165573.08, 698080.33 6165604.75, 698091.71 6165636.24, 698096.940000001 6165651.0, 698097.58 6165653.73, 698098.0 6165655.84, 698103.25 6165669.46, 698103.28 6165683.2, 698106.66 6165700.72, 698112.980000001 6165736.2, 698122.51 6165787.84, 698135.68 6165861.72, 698145.59 6165919.19, 698144.34 6165928.99, 698158.31 6166000.1, 698166.17 6166043.16, 698176.18 6166088.55, 698186.1 6166139.35, 698186.13 6166139.52, 698214.96 6166132.79)))
The problem seems to be related to one of the polygons having wrong orientation. Appearantly you cannot trust the Oracle spatial operators or functions, when a geometry is registered with a "wrong" orientation. Here a three simple examples showing that:
select sdo_geom.relate(sdo_geometry('POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))', 25832), 'determine', sdo_geometry('POLYGON((0 1, 1 1, 1 2, 0 2, 0 1))', 25832), 0.05)
from dual
; -- correct orientation: TOUCH
select sdo_geom.relate(sdo_geometry('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))', 25832), 'determine', sdo_geometry('POLYGON((0 1, 0 2, 1 2, 1 1, 0 1))', 25832), 0.05)
from dual
; -- both wrong orientation, south-north: COVERS
select sdo_geom.relate(sdo_geometry('POLYGON((0 1, 0 2, 1 2, 1 1, 0 1))', 25832), 'determine', sdo_geometry('POLYGON((0 0, 0 1, 1 1, 1 0, 0 0))', 25832), 0.05)
from dual
; -- both wrong orientation, north-south: OVERLAPBDYINTERSECT
I write "wrong" in quotation marks, since in my opinion strictly speaking there is no such thing as a wrong orientation. You could consistently assert, that the interior of a polygon is on the left side of the boundary when travelling in the direction given by the sequence of points. Thus a simple polygon in "wrong" orientation would mean a punched hole in the world. But Oracle seems not to implement the same orientation logic in the RELATE functionality and the INTERSECTION functionality.