SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT – 13356 Issues

I have been doing a lot of work recently with processing the errors reported by Oracle’s MDSYS.SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function.

The results that are output from this function are not well documented with some outputs only being discovered by having bad geometries that generate those errors!

But it was interesting for me to note that the function only ever reports the first duplicate vertex of a geometry when the error is 13356.

Here are some examples (using simple linestrings – 2002 – and multilinestrings – 2006) you can try yourself:

 -- Single duplicate in single linestring
 select sdo_geom.validate_geometry_with_context(MDSYS.SDO_GEOMETRY(2002, NULL, NULL, 
         MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1), MDSYS.SDO_ORDINATE_ARRAY(50.0, 15.0, 55.0, 15.0, 55.0, 15.0, 15.0, 60.0)),0.005) as contextError 
   from dual;
 
 
 CONTEXTERROR
 ------------
 13356 [Element <1>] [Coordinate <2>]
  
  
 -- Multiple duplicates in single linestring
 select sdo_geom.validate_geometry_with_context(MDSYS.SDO_GEOMETRY(2002, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1), 
         MDSYS.SDO_ORDINATE_ARRAY(50.0, 15.0, 55.0, 15.0, 55.0, 15.0, 55.0, 15.0, 60.0, 15.0)),0.005) as contextError 
   from dual;
  
  
 CONTEXTERROR
 ------------
 13356 [Element <1>] [Coordinate <2>]
  
  
 -- Two duplicates in first element, single duplicate in second of multilinestring
 select sdo_geom.validate_geometry_with_context(MDSYS.SDO_GEOMETRY(2006, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1,7,2,1), 
         MDSYS.SDO_ORDINATE_ARRAY(50.0, 15.0, 55.0, 15.0, 55.0, 15.0, 60.0, 15.0, 60.0, 15.0, 65.0, 15.0)),0.005) as contextError 
   from dual;
  
  
 CONTEXTERROR
 ------------
 13356 [Element <1>] [Coordinate <2>]
  
  
 -- No duplicates in first element, single duplicate in second of multilinestring
 select sdo_geom.validate_geometry_with_context(MDSYS.SDO_GEOMETRY(2006, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1,5,2,1), 
         MDSYS.SDO_ORDINATE_ARRAY(50.0, 15.0, 55.0, 15.0, 60.0, 15.0, 60.0, 15.0, 65.0, 15.0)),0.005) as contextError 
   from dual;
  
  
 CONTEXTERROR
 ------------
 13356 [Element <2>] [Coordinate <1>]
  
  
 -- Triple duplicate in first element, single duplicate in second of multilinestring
 select sdo_geom.validate_geometry_with_context(MDSYS.SDO_GEOMETRY(2006, NULL, NULL, MDSYS.SDO_ELEM_INFO_ARRAY(1,2,1,9,2,1), 
         MDSYS.SDO_ORDINATE_ARRAY(50.0, 15.0, 55.0, 15.0, 55.0, 15.0, 55.0, 15.0, 60.0, 15.0, 60.0, 15.0, 65.0, 15.0)),0.005) as contextError 
   from dual;
  
  
 CONTEXTERROR
 ------------
 13356 [Element <1>] [Coordinate <2>]

I would have expected that all duplicate points would have been reported.

Oracle should fix this, of course, but in the meantime, if I get time, I will write a function that reports all duplicate points.

I hope this is of help to someone.