2

Geometry is in PostgreSQL database. It is valid.

Geometry is exported as GML and then inserted into Oracle database.

Then function SDO_UTIL.RECTIFY_GEOMETRY(geometry, tolerance) is called, which reports geometry as being not valid. More exactly, function

sdo_geom.validate_geometry_with_context(geometry, tolerance) 

gives error

13367 [Element <1>] [Ring <1>].

I understand that Oracle uses tolerance, which means that Oracle sees some points as being same, which will cause errors. Using different tolerance makes errors go away. However changing tolerance is not an option, because I need application to work with the given tolerance.

What should I do with geometries in PostGIS to ensure that they will be valid in Oracle after importing to Oracle? (provided I know the tolerance that will be used in Oracle beforehand).

Examples:

select sdo_geom.validate_geometry_with_context(SDO_UTIL.FROM_GMLGEOMETRY('<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:3301"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>564588.6,6438154.86 564592.9,6438149.4 564595.88,6438139.8 564604.32,6438069.13 564602,6438066.15 564595.38,6438064 564594.06,6438060.03 564593.56,6438047.95 564591.74,6438043.64 564573.37,6438036.69 564555.16,6438032.56 564549.87,6438033.55 564547.55,6438037.69 564546.23,6438043.98 564544.24,6438046.95 564540.1,6438047.78 564534.48,6438047.62 564531.83,6438046.13 564531.5,6438042.49 564533.65,6438024.45 564537.62,6438009.39 564540.44,6438003.43 564543.41,6438002.1 564546.89,6438001.44 564591.08,6438005.25 564604.32,6438006.24 564609.62,6438005.41 564609.85,6438005.02 564609.86,6438004.96 564611.6,6438002.1 564613.26,6437992.84 564616.9,6437964.04 564617.73,6437958.74 564616.9,6437952.12 564614.06,6437948.97 564582.31,6437943.02 564500.38,6437928.29 564433.52,6437916.54 564333.64,6437898.53 564243.69,6437883.77 564217.87,6437877.64 564209.59,6437878.47 564201.81,6437885.09 564197.51,6437893.53 564193.37,6437904.95 564184.27,6437928.45 564171.69,6437951.46 564164.24,6437960.73 564157.13,6437974.46 564142.56,6437999.79 564127.67,6438030.24 564126.18,6438036.69 564128,6438040.83 564131.47,6438043.31 564136.61,6438043.15 564145.54,6438041.33 564153.65,6438041.66 564175.83,6438043.81 564193.87,6438046.29 564277.45,6438055.89 564300.12,6438061.85 564342.49,6438075.26 564452.88,6438112.66 564509.65,6438131.36 564521.73,6438131.86 564526.2,6438127.89 564528.35,6438117.96 564531.33,6438113.16 564535.47,6438112.49 564549.37,6438116.3 564555.5,6438121.6 564559.63,6438134.34 564564.6,6438141.62 564571.72,6438142.78 564575.52,6438144.93 564578.17,6438150.89 564582.64,6438154.86 564588.6,6438154.86</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>564609.86,6438004.96 564609.58,6438005.41 564605.53,6438006.05 564607.18,6438005.22 564609.91,6438004.57 564609.86,6438004.96</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>564607.18,6438005.22 564606.51,6438005.37 564609.03,6438004.27 564607.18,6438005.22</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>564584.79,6438130.2 564579.49,6438131.2 564576.18,6438131.03 564571.88,6438129.04 564572.21,6438125.4 564575.52,6438124.25 564578.17,6438123.25 564580.32,6438122.59 564583.63,6438122.59 564585.29,6438124.08 564586.45,6438127.06 564584.79,6438130.2</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>564574.49,6438043.78 564573.81,6438043.92 564565.46,6438041.86 564565.87,6438040.02 564566.08,6438038.24 564566.56,6438038.17 564574.91,6438040.22 564574.91,6438040.43 564574.49,6438043.78</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>564418.96,6437980.92 564414.32,6437981.75 564410.02,6437980.92 564404.72,6437979.1 564401.41,6437974.96 564400.25,6437970.49 564402.57,6437968.01 564405.55,6437966.02 564411.18,6437963.87 564415.65,6437963.54 564419.62,6437964.7 564422.43,6437968.01 564424.09,6437972.15 564422.93,6437977.28 564418.96,6437980.92</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>'), 0.005) from dual;


select SDO_UTIL.RECTIFY_GEOMETRY(SDO_UTIL.FROM_GMLGEOMETRY('<gml:Polygon xmlns:gml="http://www.opengis.net/gml" srsName="EPSG:3301"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>564588.6,6438154.86 564592.9,6438149.4 564595.88,6438139.8 564604.32,6438069.13 564602,6438066.15 564595.38,6438064 564594.06,6438060.03 564593.56,6438047.95 564591.74,6438043.64 564573.37,6438036.69 564555.16,6438032.56 564549.87,6438033.55 564547.55,6438037.69 564546.23,6438043.98 564544.24,6438046.95 564540.1,6438047.78 564534.48,6438047.62 564531.83,6438046.13 564531.5,6438042.49 564533.65,6438024.45 564537.62,6438009.39 564540.44,6438003.43 564543.41,6438002.1 564546.89,6438001.44 564591.08,6438005.25 564604.32,6438006.24 564609.62,6438005.41 564609.85,6438005.02 564609.86,6438004.96 564611.6,6438002.1 564613.26,6437992.84 564616.9,6437964.04 564617.73,6437958.74 564616.9,6437952.12 564614.06,6437948.97 564582.31,6437943.02 564500.38,6437928.29 564433.52,6437916.54 564333.64,6437898.53 564243.69,6437883.77 564217.87,6437877.64 564209.59,6437878.47 564201.81,6437885.09 564197.51,6437893.53 564193.37,6437904.95 564184.27,6437928.45 564171.69,6437951.46 564164.24,6437960.73 564157.13,6437974.46 564142.56,6437999.79 564127.67,6438030.24 564126.18,6438036.69 564128,6438040.83 564131.47,6438043.31 564136.61,6438043.15 564145.54,6438041.33 564153.65,6438041.66 564175.83,6438043.81 564193.87,6438046.29 564277.45,6438055.89 564300.12,6438061.85 564342.49,6438075.26 564452.88,6438112.66 564509.65,6438131.36 564521.73,6438131.86 564526.2,6438127.89 564528.35,6438117.96 564531.33,6438113.16 564535.47,6438112.49 564549.37,6438116.3 564555.5,6438121.6 564559.63,6438134.34 564564.6,6438141.62 564571.72,6438142.78 564575.52,6438144.93 564578.17,6438150.89 564582.64,6438154.86 564588.6,6438154.86</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>564609.86,6438004.96 564609.58,6438005.41 564605.53,6438006.05 564607.18,6438005.22 564609.91,6438004.57 564609.86,6438004.96</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>564607.18,6438005.22 564606.51,6438005.37 564609.03,6438004.27 564607.18,6438005.22</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>564584.79,6438130.2 564579.49,6438131.2 564576.18,6438131.03 564571.88,6438129.04 564572.21,6438125.4 564575.52,6438124.25 564578.17,6438123.25 564580.32,6438122.59 564583.63,6438122.59 564585.29,6438124.08 564586.45,6438127.06 564584.79,6438130.2</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>564574.49,6438043.78 564573.81,6438043.92 564565.46,6438041.86 564565.87,6438040.02 564566.08,6438038.24 564566.56,6438038.17 564574.91,6438040.22 564574.91,6438040.43 564574.49,6438043.78</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates>564418.96,6437980.92 564414.32,6437981.75 564410.02,6437980.92 564404.72,6437979.1 564401.41,6437974.96 564400.25,6437970.49 564402.57,6437968.01 564405.55,6437966.02 564411.18,6437963.87 564415.65,6437963.54 564419.62,6437964.7 564422.43,6437968.01 564424.09,6437972.15 564422.93,6437977.28 564418.96,6437980.92</gml:coordinates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>'), 0.005) from dual;

EDIT: Added error message shown by Oracle.

1

1 Answer 1

2
+100

Make sure your data is clean, remove points that are duplicates, very small interior angles, overlaps, nonsnapped geometry which is done in oracle through fatal checks and preprocessing scripts. Try 32 SDO_UTIL Package (Utility) which " Converts a geography markup language (GML 3.1.1) fragment to a Spatial geometry " then try running preprocessiong, error checks, etc. http://docs.oracle.com/cd/B12037_01/appdev.101/b10826/sdo_objrelschema.htm#i1004087

You could also try processing in a postgresql postgis database and export as a shapefile and import as a shapefile into oracle through the SDE

4
  • I need some explanation here. How to remove points that are duplicates? ST_SnapToGrid, as Ragi suggested? How to remove small interior angles? If there are overlaps, wouldn't it show up in PostgreSQL already (as invalid geometry)?. What do You mean remove "nonsnapped geometry"?
    – Rauni
    Commented Jan 28, 2013 at 7:25
  • You said "Try 32 SDO_UTIL Package". I asked for an algorithm that I could use in PostgreSQL. How could I run Oracle package in PostgreSQL? I know that it is possible to run C code in PostgreSQL, but how to run this package? What processing do You mean in "processing in postgresql database"? What would exporting as shapefile change, compared to exporting as GML? Error would still occur only after importing to Oracle.
    – Rauni
    Commented Jan 28, 2013 at 7:28
  • Don't reinvent the wheel and use standard industry packages is my approach here, unless your an expert in programming and Oracle. Oracle is much more rigorous than Postgres for geographic objects and so has a higher standard. Using their tool would create a data that was importable. There tool would use those algorithms that programmers familiar with oracle use to create data that is ingestible by Oracle databases. Oracle is set up to accept shape files, etc.
    – lewis
    Commented Jan 29, 2013 at 15:38
  • OK, I will try this approach too. I will wait until tomorrow to see if someone else comments; if not, I will accept Your answer and follow up later whether these ideas worked. Thank You for Your time!
    – Rauni
    Commented Jan 30, 2013 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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