Geometry hook

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
Svalentinh
Posts: 1
Joined: Mon 23 Jul 2018 13:46

Geometry hook

Post by Svalentinh » Mon 23 Jul 2018 14:12

Hi

An unusual inquiry that most likely requires a developer to answer.
We have very complex geometries. Sometimes NetTopologySuite fails to do intersection/differences in a robust way.

What we have done so far is to pass the calculation on to Oracle and let Oracle do the calculations using Oracles more advanced spatial engine. Its a rare case so performance is not a concern.
We have implemented an extension method on the DBGeometry type, but this is a pain since team members need to remember to use this and not the build in methods.

What we´re looking for i to extend the NTS spatial provider like below.

public class CustomNetTopologySuiteSpatialServices : EntityNetTopologySuiteSpatialServices
{
...
public override DbGeometry Intersection(DbGeometry geometryValue, DbGeometry otherGeometry)
{
var result = base.Intersection(geometryValue, otherGeometry);
if (!result.IsValid)
{
// Call Oracle
}

return result;
}
}

I.e. let NTS do the job and if it cannot then ask Oracle to do this.

The problem is to register this custom slightly extended version with EntityFramework. There does not seem to be any really good way. Since all config objects are Singletons there is no way to derive these.

The only way I´ve found so far is to enherit from DbConfiguration and in the constructor use reflection to do what Devart implementation does internally. Like so.

public class DataModelConfiguration : DbConfiguration
{
public DataModelConfiguration()
{
var result = typeof(EntitySpatialServices).GetMethods(BindingFlags.NonPublic | BindingFlags.Static);
var method = result.FirstOrDefault(x => x.GetParameters().Select(y
=>y.ParameterType).Contains(typeof(EntitySpatialServices)));
method.Invoke(this, new object[] { new CustomNetTopologySuiteSpatialServices() });
}
}

This of course is using non public API which we really does not like since this potentially would compromise upgrading.
Is there a way to accomplish such a task using only public API.

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

Re: Geometry hook

Post by Shalex » Wed 25 Jul 2018 17:45

We will investigate the question and notify you about the result.

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

Re: Geometry hook

Post by Shalex » Tue 31 Jul 2018 15:29

Starting from the next public build, the static EntitySpatialServices.SetDefault method will be public.

We will notify you when it is available for download.

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

Re: Geometry hook

Post by Shalex » Fri 10 Aug 2018 12:22

The new static method SetDefault is added to the EntitySpatialServices class in EF5/EF6: viewtopic.php?f=1&t=37559.

Post Reply