Cannot initialize SpatialServiceType

Cannot initialize SpatialServiceType

Postby Feneck91 » Wed 15 Jul 2015 10:11

Hello,

I have a problem with Spatial service initialization...

When I try to initialize spatial service type like :
Code: Select all
            var config = Devart.Data.PostgreSql.Entity.Configuration.PgSqlEntityProviderConfig.Instance;
            config.SpatialOptions.SpatialServiceType = SpatialServiceType.NetTopologySuite;

I have an exception : Cannot cast object type 'Devart.Data.PostgreSql.Entity.Spatials.PgSqlNetTopologySuiteSpatialServices" in type "Devart.Common.Entity.EntitySpatialServices" ?

If I initialize like
Code: Select all
            var config = Devart.Data.PostgreSql.Entity.Configuration.PgSqlEntityProviderConfig.Instance;
            config.SpatialOptions.SpatialServiceType = WellKnownBinary;

It't work but I have later an exception : "This functionality is not supported by Well-Known Binary (WKB) spatial service."

I worked with Oracle version, uninstall it (old version not compatible with Devart PostgreSQL 7.3) and install new version of Devart PostgreSQL.
Update NetTopologySuite to 1.13.3

Didn't understand the problem !
Thanks for reply.

I have removed and add Devart.Data / Devart.Data.Linq / Devart.Data.PostgresSQL / Devart.Data.PostgresSQL.Entity / Devart.Data.PostgresSQL.Entity.Spatials
I can call config.SpatialOptions.SpatialServiceType = SpatialServiceType.NetTopologySuite;

But now, when I migrate database, I have an error : the geometry type doesn't exists.
I do :
Code: Select all
            // Initialise GeoAPI
            GeoAPI.GeometryServiceProvider.Instance = new NetTopologySuite.NtsGeometryServices();

            var config = Devart.Data.PostgreSql.Entity.Configuration.PgSqlEntityProviderConfig.Instance;
           
            config.Workarounds.IgnoreSchemaName = true;

            // Tronque les clefs étrangère à 30 caractères sinon impossible de créer le schéma de la base de données, les clefs
            // étrangères générées sont tout simplement trop longues !
            config.CodeFirstOptions.TruncateLongDefaultNames = true;

            // Configur options to use
            // NetTopologySuite need: GeoAPI
            //                                       NetTopologySuite
            //                                       PowerCollections
            //                                       SharpMap
            // http://blog.devart.com/enhanced-entity-framework-spatials-support-for-oracle-mysql-and-postgresql.html

            config.SpatialOptions.AlwaysUseGeometryDefaultSrid = true;
            config.SpatialOptions.AlwaysUseGeographyDefaultSrid = true;

            config.SpatialOptions.SpatialServiceType = Devart.Data.PostgreSql.Entity.Configuration.SpatialServiceType.NetTopologySuite;
Feneck91
 
Posts: 37
Joined: Mon 12 Aug 2013 13:52

Re: Cannot initialize SpatialServiceType

Postby Feneck91 » Fri 17 Jul 2015 06:42

I have re-install PosgreSQL and PosGis, recreate Spatial databse.
All working well now.
Feneck91
 
Posts: 37
Joined: Mon 12 Aug 2013 13:52

Re: Cannot initialize SpatialServiceType

Postby Shalex » Fri 17 Jul 2015 11:48

Thank you for your feedback.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Cannot initialize SpatialServiceType

Postby Feneck91 » Thu 26 Nov 2015 08:31

Same problem after updating project to Visual 2015 + Update Devart dotConnect for PostgreSQL.
Code: Select all
        protected override void InitDatabaseModel()
        {
            GeoAPI.GeometryServiceProvider.Instance = new NetTopologySuite.NtsGeometryServices();

            var config = Devart.Data.PostgreSql.Entity.Configuration.PgSqlEntityProviderConfig.Instance;
           
            config.Workarounds.IgnoreSchemaName = true;

            // Tronque les clefs étrangère à 30 caractères sinon impossible de créer le schéma de la base de données, les clefs
            // étrangères générées sont tout simplement trop longues !
            config.CodeFirstOptions.TruncateLongDefaultNames = true;

            // Configurer les options spatiales à utiliser
            // NetTopologySuite demande à utiliser : GeoAPI
            //                                       NetTopologySuite
            //                                       PowerCollections

            config.SpatialOptions.AlwaysUseGeometryDefaultSrid = true;
            config.SpatialOptions.AlwaysUseGeographyDefaultSrid = true;

---> HERE EXCEPTION -->            config.SpatialOptions.SpatialServiceType =  Devart.Data.PostgreSql.Entity.Configuration.SpatialServiceType.NetTopologySuite;

            base.InitDatabaseModel();
        }

Exception : {"Impossible d'effectuer un cast d'un objet de type 'Devart.Data.PostgreSql.Entity.Spatials.PgSqlNetTopologySuiteSpatialServices' en type 'Devart.Common.Entity.EntitySpatialServices'."}
In english : {"cannot cast object of type 'Devart.Data.PostgreSql.Entity.Spatials.PgSqlNetTopologySuiteSpatialServices' to type 'Devart.Common.Entity.EntitySpatialServices'."}
What does it mean ?
Trying to uninstall / reinstall PostgreSQL + Postgis ...
Really angry ! When the production database will be used, I'll not able to destroy database each time I update software !

And I'm not sure this workaroud will work again ! The last time this has worked, I don't know really why !!
This don't work...
I have removed GeoAPI 1.7.4 / NetTopologySuite.1.14.0
replaced by
GeoAPI 1.7.2 / NetTopologySuite.1.13.3.2
Trying...

EDIT : Calling
Code: Select all
var tmpInstance = Devart.Data.PostgreSql.Entity.Spatials.PgSqlNetTopologySuiteSpatialServices.Instance;

Seem to resolve the problem. How this instance is created usually ?

Problem not solved, exception because NetTopologySuite cannot be loaded !
Problem with visual studio 2105 ? Compiled into 32 bits mode ?

EDIT : we have rebuild NetTopologySuite 1.14.0, I don't need anymore to call :
Code: Select all
var tmpInstance = Devart.Data.PostgreSql.Entity.Spatials.PgSqlNetTopologySuiteSpatialServices.Instance;

But, it seems that devart try to load 1.13.1 NetTopologySuite version, exceptions are raised :
[quote]Impossible de charger le fichier ou l'assembly 'NetTopologySuite, Version=1.13.1.0, Culture=neutral, PublicKeyToken=null' ou une de ses dépendances. La définition trouvée du manifeste de l'assembly ne correspond pas à la référence de l'assembly. (Exception de HRESULT : 0x80131040)/quote]

Not work since monday, please help me !
Feneck91
 
Posts: 37
Joined: Mon 12 Aug 2013 13:52

Re: Cannot initialize SpatialServiceType

Postby Feneck91 » Fri 27 Nov 2015 14:15

I understand...

  • Use NetTopologySuite 1.13.2 (only ?)
  • Use GeoAPI (I use 1.7.4 version)
  • Be carefull, PostgresSQL tools migration make reference to EF5, no EF6 (use Devart.Data.PosgreSql.Entity version 7.4.543.6 and not version 7.4.543.0)
  • Be carefull, PostgresSQL tools migration make reference to EF5, no EF6 (use Devart.Data.PosgreSql.Entity.Spatials version 7.4.543.6 and not version 7.4.543.0)
  • When I use the code : Devart.Data.PostgreSql.Entity.Spatials.PgSqlNetTopologySuiteSpatialServices.Instance;
    It's work because Visual also copy Devart.Data.PosgreSql.Entity.Spatials to output directory, without this line it does not do it ! So, make Copy Local to True to be sure the dll will be copied to executable folder.

It should be work now...
Feneck91
 
Posts: 37
Joined: Mon 12 Aug 2013 13:52

Re: Cannot initialize SpatialServiceType

Postby Shalex » Fri 27 Nov 2015 15:45

Thank you for sharing your experience.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Cannot initialize SpatialServiceType

Postby Feneck91 » Mon 23 May 2016 12:50

Is latest version now support NetTopologySuite 1.14.0 ?
Feneck91
 
Posts: 37
Joined: Mon 12 Aug 2013 13:52

Re: Cannot initialize SpatialServiceType

Postby Shalex » Thu 26 May 2016 09:31

Feneck91 wrote:Is latest version now support NetTopologySuite 1.14.0 ?
No, it doesn't.

This feature is on our roadmap, right after the .NET Core support. An approximate timeframe for its implementation is one or two months.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Cannot initialize SpatialServiceType

Postby Shalex » Fri 09 Dec 2016 16:05

dotConnect for PostgreSQL v7.7 includes the following features:
  • Signed versions of NetTopologySuite GIS library are supported in EF5/EF6
  • NetTopologySuite 1.14 is supported in EF5/EF6
  • GeoAPI 1.7.4 is supported in EF5/EF6
For more information, refer to http://forums.devart.com/viewtopic.php?f=3&t=34690.
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44

Re: Cannot initialize SpatialServiceType

Postby Feneck91 » Tue 03 Jan 2017 13:16

I'm making migration, It's seem to compile...
But SpatialServiceType.NetTopologySuite is now obsolete.
Need to use SpatialServiceType.NetTopologySuiteUnsigned or SpatialServiceType.NetTopologySuiteSigned ?

SpatialServiceType.NetTopologySuiteUnsigned throws exceptions, SpatialServiceType.NetTopologySuiteSigned seems to work fine.
Feneck91
 
Posts: 37
Joined: Mon 12 Aug 2013 13:52

Re: Cannot initialize SpatialServiceType

Postby Shalex » Wed 04 Jan 2017 09:07

That is correct.

JIC:
  • The NetTopologySuiteSigned and NetTopologySuiteUnsigned members are added to the SpatialServiceType enum in EF5/EF6
  • The behaviour is changed: the functionality of SpatialServiceType.NetTopologySuiteSigned is moved to Devart.Data.PostgreSql.Entity.EF5.dll / Devart.Data.PostgreSql.Entity.EF6.dll
Shalex
Devart Team
 
Posts: 7654
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for PostgreSQL