ThinkGeo.com    |     Documentation    |     Premium Support

Geometry Type 3006 is not supported now ? PostgreSqlFeatureLayer

Hi when i get to this:      var ftshape = item2.GetShape();
I get this exception… 
 
System.ArgumentException : The format of the well known binary is incorrect.
Parameter name: wellKnownBinary
---- System.NotSupportedException : Geometry Type 3006 is not supported now.
 
What have i done wrong? :) I have just imported the shp file (that was working) into postgresql, and changed from ShapeFileFeatureLayer  to PostgreSqlFeatureLayer and then I get that exception?!?
         
 

//ShapeFileFeatureLayer sf = ServiceRouting.ShapeLayerHelper.GetShapeFileLayer(_shpFile);
       
               

        PostgreSqlFeatureLayer  sf = new  PostgreSqlFeatureLayer (Utils.Connections.Connectionstrings.GetSqlConnectionPG(), "zonep", "gid");
  FeatureLayer _feature = new InMemoryFeatureLayer();
                List<string> columns = new List<string>();                </string></string>
                columns.Add("price");
                
                sf.Open();
               var _featuress = sf.QueryTools.GetAllFeatures(columns);
                sf.Close();
                _feature.Open();
                
                _feature.FeatureSource.BeginTransaction();
                foreach (Feature item2 in _featuress)
                {
                    try
                    {
                        var ftshape = item2.GetShape();
 
How to fix? (Or is Geometry Type 3006 going to be implemented into PostgreSqlFeatureLayer  ?)
 
- Niels

Hi Niels, 
  
 Can you please send us your sample and the shape file? It’ll be easy to recreate your scenario. 
  
 Thanks, 
  
 Edgar

Hi I have uploadet the shp fileto ftp://ftp.thinkgeo.com/    filename:postgres3006.zip 
  
 The code that works with the file but not when using postg. is … 
  
 public static FeatureLayer GetZoneLayer(string countryShortIsoName) 
         { 
             FeatureLayer _feature = new InMemoryFeatureLayer(); 
             if (countryShortIsoName.ToUpper() == "DK") 
             { 
               
  // It works as shp file but not after import to postgresql 9.1 using postgis 2.0 
  // string _shpFile = @"C:\GisData\t2\PriserTilPriceTool_01-SWi_region.shp"; 
                 //ShapeFileFeatureLayer sf = ServiceRouting.ShapeLayerHelper.GetShapeFileLayer(_shpFile); 
  
                 PostgreSqlFeatureLayer sf = new PostgreSqlFeatureLayer(Utils.Connections.Connectionstrings.GetSqlConnectionPG(), "zone_price_dk", "gid"); 
                 List<string> columns = new List<string>();                 
                 columns.Add("price"); 
                  
                 sf.Open(); 
                 var _featuress = sf.QueryTools.GetAllFeatures(columns); 
                 sf.Close(); 
                 _feature.Open(); 
                  
                 _feature.FeatureSource.BeginTransaction(); 
                 foreach (Feature item2 in _featuress) 
                 { 
                     try 
                     { 
                         var ftshape = item2.GetShape(); 
                         var ttt = item2.ColumnValues; 
                         _feature.FeatureSource.AddFeature(item2.GetShape(),item2.ColumnValues ); 
                     } 
                     catch (Exception ex) 
                     { 
                         lLog.ErrorException(ex.Message, ex); 
                         throw; 
                     } 
                 } 
                 _feature.FeatureSource.CommitTransaction(); 
                 _feature.Close(); 
             } 
             return _feature; 
         } 
  
  
  
  
  
 - Niels

Niels,


I have tested the shape file you provided, which feature type is Multipolygon, works well when I call feature.GetShape() method and display it, so I think it might be something wrong while importing the shape file to postgre server, we suggest you to use the PostgreSqlFeatureSource.AddFeature() method to import the shape file to postgre server.


Regards,


Edgar



Hi I’m trying to import that shp file into postgres, but nothing is filled in the table (the user has insert rights)  
 Is there anything wrong with this code to upload the file?? 
  
 It runs fine just NO data in the table. 
  
 
string _shpFile = @“C:\GisData\t2\region.shp”;
                ShapeFileFeatureLayer sff = ServiceRouting.ShapeLayerHelper.GetShapeFileLayer(_shpFile);
                sff.Open();
                Npgsql.NpgsqlConnection conn = new Npgsql.NpgsqlConnection(Utils.Connections.Connectionstrings.GetSqlConnectionPG());
                conn.Open();                
                PostgreSqlFeatureSource sf = new PostgreSqlFeatureSource(Utils.Connections.Connectionstrings.GetSqlConnectionPG(), “region”, “gid”);
                sf.Srid = 0;
                sf.Open();
                sf.BeginTransaction();
                foreach (Feature item in sff.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns))
                {                    
                    sf.AddFeature(item);
                }
                sf.CommitTransaction();
                sf.Close();
 


Niels,


I tested with your file and code, it throws another exception, so I tried to remove the Srid = 0 from the code, and it works properly, 31 records were added to the database. Please try to remove the Srid = 0 from your code, I think it will work well for you.


Regards,


Edgar


 



And here are the pictures I got.





002_001_code.zip (680 Bytes)
009_008_007_006_005_004_003_002_001_code.txt (448 Bytes)

And here are the pictures I got.