Trying to use Spatial Data

Trying to use Spatial Data

Postby avalor » Thu 03 Apr 2014 08:43

Hi! I'm adapting source code from a SQLServer project to Oracle Database using dotConnect.
This project uses spatial classes such DbGeography. I managed to recreate the model successfully, but I'm running into problems at runtime.

When accessing to the Latitude property of a DbGeography object retrieved from Database, I first got a NotSupportedException: 'This functionality is not supported by Default spatial service.'. So I digged in docs and found this page http://www.devart.com/dotconnect/oracle/docs/ChoosingSpatialService.html where I found that I needed to use the SharpMap Spatial Service. So I added the required configuration:
Code: Select all
<Devart.Data.Oracle.Entity xmlns="http://devart.com/schemas/Devart.Data.Oracle.Entity/1.0">
    <SpatialOptions SpatialServiceType="SharpMap" />   
</Devart.Data.Oracle.Entity>
and the required reference to Devart.Data.Oracle.Entity.Spatials.

When I tried to run that query again, I received a FileNotFoundExceptio for assembly: 'SharpMap, Version=0.9.4507.23599, Culture=neutral, PublicKeyToken=null', which I was hoping, since I haven't installed the SharpMap package!

So I tried to install the SharpMap package from NuGet. I tried last version 1.1, since it's supported since dotConnect 8.3.115. Sadly, I cannot install this package due to version dependences. SharpMap requires a lot of packages in a precise version, which is incompatible with other packages installed. For example, it requires Newtonsoft.Json = 4.5.11 when WebGrease (a package used in MVC project) requires version >= 5.0.4.

As you can see, this is quite a package hell!. My questions are:

A) It is right that the only way I can use Latitute/Longitude properties and Distance method from DbGeography is using SharpMap? Is there any other way?
B) Do I have to deal with all these packages dependencies problem or there is a way (through manual copying libraries) to make it work?
Last edited by avalor on Fri 04 Apr 2014 08:34, edited 1 time in total.
avalor
 
Posts: 15
Joined: Tue 18 Feb 2014 17:39

Re: Trying to use Spatial Data

Postby avalor » Thu 03 Apr 2014 10:01

Well, taking steps in the right direction, I've able to use SharpMap just deploying SharpMap.dll and ProjNet.dll. First I've tried with SharpMap.dll 1.1.0.0 and ProjNet.dll 1.3.0.3, but I was receiving a
Code: Select all
System.TypeLoadException: No se puede cargar el tipo 'SharpMap.Geometries.Geometry' del ensamblado 'SharpMap, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null'.

Then I switched to SharpMap.dll 0.9.0.0 and ProjNet.dll 1.2.0.0 and now it's working. Well, sort of... now I'm having a
Code: Select all
System.Exception: Geometrytype '' is not supported.

In this post forum http://forums.devart.com/viewtopic.php?f=30&t=27426 I found another user with same problem, due to using Express Edition of Oracle. The solution in that post lead me to this new Spatial Provider, NetTopologySuite, which does not appear anywhere in the docs section. More info here: http://forums.devart.com/viewtopic.php?f=1&t=27556.

So, I'm trying to use this new NetTopologySuite. I will report later with the results :)
Last edited by avalor on Fri 04 Apr 2014 08:35, edited 1 time in total.
avalor
 
Posts: 15
Joined: Tue 18 Feb 2014 17:39

Re: Trying to use Spatial Data

Postby avalor » Fri 04 Apr 2014 08:33

Finally, using 'NetTopologySuite' works perfectly. Just install NTS package from NuGet and got all needed libraries, except for SharpMap.dll 1.1.0.0 which I retrieved from their website.

Still not working in Express Editions of Oracle, which was expected.

I hope this helps future users to get started with Spatial with dotConnect and save time!

PS: The Spatial docs section needs to be updated to include this new Spatial System!
avalor
 
Posts: 15
Joined: Tue 18 Feb 2014 17:39

Re: Trying to use Spatial Data

Postby Shalex » Fri 04 Apr 2014 11:51

Thank you for your feedback. The Entity Framework Spatials support in dotConnect products is described in our blog article at http://blog.devart.com/enhanced-entity-framework-spatials-support-for-oracle-mysql-and-postgresql.html.
Shalex
Devart Team
 
Posts: 7616
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle