NHibernate.Spatial icon indicating copy to clipboard operation
NHibernate.Spatial copied to clipboard

Oracle Dialect

Open mahmudkoc opened this issue 7 years ago • 13 comments

Hi; I want to use NHibernate Spatial With Oracle, Can I ? Thanks

mahmudkoc avatar Jun 12 '17 14:06 mahmudkoc

Hi @SehirBilisim,

We made an honest attempt to get the Oracle dialect working properly, but without improved support for user types in the Oracle ODP drivers, this is not possible. Sorry!

andrerav avatar Jun 12 '17 14:06 andrerav

NetTopologySuite has some code to convert mdsys.geometry to SdoGeometry. Maybe @SehirBilisim could take a look at that and implement the Oracle Dialect.

Diaaz avatar Jun 14 '17 13:06 Diaaz

@peetw Now this is a level of ambition I can admire ;) Do you have some ideas on how to move forward with this?

andrerav avatar Jun 29 '17 16:06 andrerav

@andrerav Haha, sorry to disappoint! I was merely re-opening based on @Diaaz's comment and hoping that maybe, just maybe, someone (perhaps @SehirBilisim? :wink:) would see it in the future and run with it.

Plus it serves as pseudo-documentation for anyone else wondering whether it's supported.

peetw avatar Jun 29 '17 16:06 peetw

@peetw hi, I saw this, https://github.com/mapspiral/NetSdoGeometry , helpful ?

rightthgir avatar Oct 29 '18 03:10 rightthgir

@peetw I find a bug, public class OracleGeometryWriter
private void AddPolygon(SdoGeometry sdoGeometry, IPolygon polygon)

et = ElementType.INTERIOR_RING_STRAIGHT_SEGMENTS; coords = polygon.InteriorRings[i - 1].Coordinates; ---> coords = polygon.InteriorRings[(int)i/3 - 1].Coordinates;

rightthgir avatar Oct 30 '18 01:10 rightthgir

@peetw I found a bug.

oracle when Geomerty. srid = 0, oracle srid = null. so , I change like this

    public SdoGeometry Write(IGeometry geometry)
    {
        // TODO:
        //_builder.SetSrid(geometry.SRID);
        //WriteGeometry(geometry);
        //return _builder.ConstructedGeometry;

        //return null;
        var geom = this.WriteGeometry(geometry);

        if (geometry.SRID < 1)  // by  zhou yijun 2018-10-29
        {
            geom.sdo_Srid = null;
        }
        else
        {
            geom.sdo_Srid = geometry.SRID;
        }

        //
        return geom;
    }

rightthgir avatar Oct 30 '18 01:10 rightthgir

private SdoGeometry WritePoint(IGeometry geometry) { var dim = this.GetCoordDimension(geometry); var lrsDim = this.GetCoordinateLrsPosition(geometry); var isLrs = (lrsDim != 0); var coord = this.ConvertCoordinates(geometry.Coordinates, dim, isLrs); var sdoGeometry = new SdoGeometry { GeometryType = (int)SDO_GTYPE.POINT, Dimensionality = dim, LRS = lrsDim, sdo_Srid = geometry.SRID, ElemArray = new[] { 1, (decimal)SDO_ETYPE.ETYPE_SIMPLE_POINT, 1 }, OrdinatesArray = coord }; sdoGeometry.PropertiesToGTYPE(); // by zhou yijun return sdoGeometry; }

writePoint , writeWriteLineString , .........

I added this " sdoGeometry.PropertiesToGTYPE(); // by zhou yijun", so , this._sdo_gtype He can have a value ahead of time, so,I can use this class on my own。

rightthgir avatar Oct 30 '18 01:10 rightthgir

now, I can use NHibernate.Spatial.Oracle.dll on my own.

don't forget change inner to public

rightthgir avatar Oct 30 '18 01:10 rightthgir

So just to be clear, the Oracle dialect doesn't work with Oracle as it stands? I would need to make the modifications that @rightthgir has done? If that's the case could we ask @rightthgir to submit a PR?

spatialbits avatar Jul 23 '19 22:07 spatialbits

@spatialbits I've not had any experience of working with it, so I can't say for sure. However, based on @andrerav 's comment, I doubt it does. We also don't currently release a NuGet package for it either.

We're always happy to accept PR's though if you do have success in getting it working :)

peetw avatar Jul 25 '19 19:07 peetw

Thanks @peetw . For the time being we're OK with just the SQLServer dialect but Oracle may be needed in the future. I note that there does appear to be a Nuget package for the Oracle spatial dialect: https://www.nuget.org/packages/NHibernate.Spatial.Oracle/4.0.3.4000-alpha1/

spatialbits avatar Jul 26 '19 15:07 spatialbits

@spatialbits np :) The pre-release version is not "official" and is based on a very old version of NHibernate (you'll see that it was released in July 2015). The code is currently in the repo, but we do not maintain it or release NuGet packages for it as part of a standard release.

peetw avatar Jul 29 '19 12:07 peetw