is this inconvenience , just for me ? Am i alone in this?

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
costeakai
Posts: 16
Joined: Wed 02 Aug 2017 12:16

is this inconvenience , just for me ? Am i alone in this?

Post by costeakai » Mon 25 Sep 2017 06:12

Hi,
Thanks for your product, with its incredible value for developers.
Devart's product is THE ONLY ONE standing up to Microsoft as far as providing spatial capabilities to EntityFramework, and is leaving MS in the dust when things are coming to synchronization.
I'v hit a nasty inconvenience: when using

Code: Select all

 PgSqlEntityProviderConfig.SpatialOptions.SpatialServiceType = SpatialServiceType.NetTopologySuite; 
and having a postgresql table with a geography column , with srid=4326 (wgs84), the Devart DbGeography column returned from an spatial EntityFramework query , has the Length property returning degrees , not meters.
I can get around this , by getting the st_length from a native postgis query , but it's cumbersome and it's slowing down things: it's NOT EntityFramework...
Why do i say this? because the Length of a MicrosoftSqlServer wgs84 DbGeography column, returns meters not degrees like NetTopologySuite does. Well, i guess i'm asking too much , i knew it , but it's worth a try ...

costeakai
Posts: 16
Joined: Wed 02 Aug 2017 12:16

Re: is this inconvenience , just for me ? Am i alone in this?

Post by costeakai » Tue 26 Sep 2017 16:49

i'm so gone, that i'v just NOW remembered that there's also a SqlGeography (from DbGeometry , or from DbGeography, or from SqlGeometry).
This doesn't make up for an entityframework query , but makes it a whole lot easier to handle the results from the native postgis query , within the CSharp-code, without running around from c# to postgis and back ...

Code: Select all

   

void ZTest_PEBUNE_ges_36_LineString(SqlGeometry SqlPolygon , SqlGeometry SqlExtRing , int polyg_nr , ref double maxDiff )
{

   DbGeometry mPolygon = DbGeometry.FromBinary(SqlExtRing.STAsBinary().Buffer , (int)SqlExtRing.STSrid);
DbGeography gPolygon = DbGeography.FromBinary(mPolygon.AsBinary(), mPolygon.CoordinateSystemId);
byte[] bytegPolygon = gPolygon.AsBinary();
string s1 = @"('\x" , s2="";
//gou2.ToList().ForEach(b => s2 += b.ToString("x2"));
List<byte> g2l = bytegPolygon.ToList();
int cil = g2l.Count;
List<string> csil = new List<string>();
csil.Add(s1);

foreach(byte b in g2l)
   csil.Add(b.ToString("x2"));

csil.Add(@"',4326)");
PgSqlCommand pgCommand = (PgSqlCommand)_PgSqlConnection.CreateCommand(); 
pgCommand.CommandText = string.Format( @"select st_length(rrr.g2) as lll , rrr.g2 g2  from (select st_geomfromwkb{0}::geography g2 ) rrr",string.Join("",csil)); // merge OK
PgSqlDataReader pgReader = pgCommand.ExecuteReader();
pgReader.Read();
      double m = pgReader.GetDouble(0); 
   Debug.WriteLine(string.Format("p_g.Length:{0} {1}",gPolygon.Length , m)); 
      byte[] ou2 =   pgReader.GetFieldValue<byte[]>(1);
      DbGeography gCountryPolygon = DbGeography.FromBinary(ou2);
      double lll = (double)gCountryPolygon.Length; // degrees 37.0784

SqlGeography sgPoly = SqlGeography.STGeomFromWKB(SqlPolygon.STAsBinary(),(int)SqlPolygon.STSrid);

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

Re: is this inconvenience , just for me ? Am i alone in this?

Post by Shalex » Wed 27 Sep 2017 15:51


costeakai
Posts: 16
Joined: Wed 02 Aug 2017 12:16

Re: is this inconvenience , just for me ? Am i alone in this?

Post by costeakai » Thu 29 Mar 2018 09:48

Hi,
Thank for your interest


Yes. Fully

Post Reply