NHibernate.Spatial
NHibernate.Spatial copied to clipboard
Oracle Dialect
Hi; I want to use NHibernate Spatial With Oracle, Can I ? Thanks
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!
NetTopologySuite has some code to convert mdsys.geometry to SdoGeometry. Maybe @SehirBilisim could take a look at that and implement the Oracle Dialect.
@peetw Now this is a level of ambition I can admire ;) Do you have some ideas on how to move forward with this?
@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 hi, I saw this, https://github.com/mapspiral/NetSdoGeometry , helpful ?
@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;
@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;
}
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。
now, I can use NHibernate.Spatial.Oracle.dll on my own.
don't forget change inner to public
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 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 :)
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 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.