ORA-13199: SRID -1 does not exist.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Feneck91
Posts: 50
Joined: Mon 12 Aug 2013 13:52

ORA-13199: SRID -1 does not exist.

Post by Feneck91 » Fri 25 Oct 2013 14:22

Working with Entity Framework + Code First.

I first use WellKnownBinary SpatialServiceType => Works fine but when I create migration (Entity Framework / Code First), entity Framework say that WellKnownBinary is not supported (command line = Add-Migration Version_1 -ProjectName "myprojectDAL" -StartUpProjectName "myproject" -force).

I use NetTopologySuite, to use it I must execute code :
OracleEntityProviderConfig.Instance.SpatialOptions.SpatialServiceType = SpatialServiceType.NetTopologySuite;
And reference :
- SharpMap.dll
- NetTopologySuite.dll
- GeoAPI.dll
- PowerCollections.dll
As indicate here : http://blogs.devart.com/dotconnect/enha ... resql.html

Ok, I can create migration. But...
I have a table that use DbGeometry field. This field created from a shape file (.shp).
2 Way to load it :
via ShapeFile.DataProvider (to use it, I must initialise GeoAPI with GeoAPI.GeometryServiceProvider.Instance = new NetTopologySuite.NtsGeometryServices();)

Code: Select all

ShapeFile shapeFile = new ShapeFile(_strFilePath, true);
                                int iNbFeature = shapeFile.GetFeatureCount();
                                FeatureDataRow fdr = shapeFile.GetFeature(0);
                                geometry = DbGeometry.FromBinary(fdr.Geometry.AsBinary(),fdr.Geometry.SRID);
Or with arcobject (arcgis)

Code: Select all

FileInfo file = new FileInfo(_strFilePath);
IWorkspaceFactory pShpWorkspaceFactory = new ShapefileWorkspaceFactory();
// Open folder as workspace
IFeatureWorkspace pWorkspace = pShpWorkspaceFactory.OpenFromFile(file.DirectoryName,0) as IFeatureWorkspace;
if (pWorkspace != null)
{   // Open file
    IFeatureClass featureClass = pWorkspace.OpenFeatureClass(file.Name);
    Marshal.ReleaseComObject(pWorkspace);

    foreach(IFeature feat in featureClass.SearchIter())
    {
        if (geometry == null)
        {
            if (feat.Shape.SpatialReference is IGeographicCoordinateSystem)
            {
                IWkb pw = (IWkb) feat.Shape;
                IGeographicCoordinateSystem geoCoordinate = feat.Shape.SpatialReference as IGeographicCoordinateSystem;
                int cBytes = pw.WkbSize;
                byte [] aBytes = new byte[cBytes];
                pw.ExportToWkb(ref cBytes, out aBytes[0]);
                geometry = DbGeometry.FromBinary(aBytes,geoCoordinate.FactoryCode);
....
In both case I have internal geometry.CoordinateSystemId equals to -1. When added to database, it create something link :
MDSYS.SDO_GEOMETRY(2003,-1,NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,1), MDSYS.SDO_ORDINATE_ARRAY(34.0000000000001, 33.0000000000001, 36.0000000000001, 33.0000000000001, 36.0000000000001, 31,34.0000000000001, 31,34.0000000000001, 33.0000000000001))

The second parameter is -1, it is the SRID.
When Reload the table, I have an exception as :
ORA-13199: SRID -1 does not exist.
ORA-06512: at "MDSYS.MD", line 1723
ORA-06512: at "MDSYS.MDERR", line 17

When using WellKnownBinary as SpatialServiceType I have not this problem.
I solve by using DbGeography.DefaultCoordinateSystemId as second parameter of DbGeometry.FromBinary function but it don't seems to be a good way.

What is this SRID ? How to initialize it correctly, why sometimes it's work well and dometimes not depending of SpatialServiceType ?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: ORA-13199: SRID -1 does not exist.

Post by Shalex » Mon 28 Oct 2013 14:23

Feneck91 wrote:What is this SRID ? How to initialize it correctly, why sometimes it's work well and dometimes not depending of SpatialServiceType ?
The definition of SRID is available at http://en.wikipedia.org/wiki/SRID. Try setting a default SRID explicitly: http://www.devart.com/dotconnect/oracle ... tSRID.html. Does it help?

Post Reply