ThinkGeo.com    |     Documentation    |     Premium Support

General problem opening a postgre Layer

 


Hi,



I want to display data from a Postgres layer and get the following german error code "Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt" spreaded over the hole mapping window.  In english sounds this similar to "The object reference wasn't set to an object instance" . Have someone an idea what the reason for the error message can be.


Regards


Jörg


Sub LoadPostgreFeatureLayer()


End If


End Try


End SubPrivate 




        Try



       

            Dim connectString As String = "Server=localhost;userId=postgres;Password=geodata;DataBase=kapfen;"

            Dim postgreLayer As New PostgreSqlFeatureLayer(connectString, "ackerland", "gid")





            postgreLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(180, 102, 255, 102), GeoColor.StandardColors.DarkGreen, 1)

            postgreLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20

            Map1.StaticOverlay.Layers.Add(postgreLayer)



         End Try

    End Sub


 


 


 


 


 


 


 


 


 


 



Joerg, 


We know this exception is very common that when calling a method of an object which equals to nothing, it throws it. Inside the PostGre layer for example, we checks the “Geometries” Column and if it doesn’t exist, we might throw that exception. This is an issue that we should have a more meaningful exception description instead of letting the internal exception directly throw out with that “Object reference not set to an instance of an object”.
 
I have added it to our Issue Tracking System and in next version we will avoid throwing that general exception in PostgreLayer. For now, please check your PostGre database and make sure it has the”Geometries” columns.
 
BTW: Here is a reference how to post code, with that you can make your code really nice.
gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/4941/afv/topic/Default.aspx
 
Thanks,
 
Ben

Hi Ben, 



thank You for Your answer. It was the rigth hint. 



We have tested now to load POSTGRES layers which have less data and succeded with all three geometry types. Now is our question how much data in a layer is Mapsuite able to display. We append a POSTGRES backup file with much more data which we coudn't display. We get only the known error message “Object reference not set to an instance of an object”. 



Regards Joerg 



 



448-Test_Geodata.zip (76.7 KB)

Joerg, 
  
 We met some difficulties when retrieving your data. Just wonder what’s the version of your PostGre? Our PostGre is 8.3.4 within Windows Server 2003 Standard Edition and we get it by running “Select Version()” in SQL. 
   
 Ben 


Hi Ben,


we are using also version 8.3.4. Here the result from the version query -->


"PostgreSQL 8.3.4, compiled by Visual C++ build 1400".


We gave you a plain backup dump of one layer containing 2500 points


Regard Jörg.



Sorry our Postgre server has some issues these days so we cannot test it. We will work on this once it is ready. Sorry for the delay. 
  
 Ben

Hi Ben, 



thank you much for your information. I hope your Postgre server will work soon. 



We have still a lot of problems with Postgres Layers. Mostly we can render them but we aren't able to edit them (with less exeptions). The code record


Dim features As Collection(Of Feature) = testlayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns)


returns an error like


"The object of the type "System.DBNull" can't be changed to the type "System.Byte[ ]" 




I would like to send you such an example Postgre areaLayer (This layer I can render but not edit) so that you can try editing on it if your server will work again.. 



Regards Jörg  


 


 


 


 



457-Test_Geodata.zip (3.83 KB)

Joerg,



Our Postgre server is finally working. We  recreated your problem and yes, that's 2 bugs of our PostgreExtension.dll. Here we built a new dll for you which works fine with your 2 pieces of data in this post. Please have a try and let me know if you have any issues.



Thanks,



Ben



465-PostgreExtension.zip (11.4 KB)

Hi Ben,


thank you very much. Now I get the message


We can not find a valid Srid, please check the table exists. If this is a View, please set the Srid property on class.. Parametername: Srid


But the layer a want to render has a srid and an other layer out of the same database works very well.


I send you again a layer as backup file which can't be rendered to support@thinkgeo.com.


Regards Joerg



Joerg, 
  
 I got your data and seems the Srid info needs to be set. Can you have a try? 
  
 
postGreLayer.Srid = 31467;
 
  
 Ben.

Hi Ben,


wonderfull. This little statement rendered my large layer in the map display.


Although I have tested whether the large layer has the right srid and the have. So I wonder why I need the statement, but it is ok. Now it works.


Many Thanks to you


Best Regards


Jörg



Joerg, 
  
 If you didn’t set that property, the map would look for the SRID in the System Tables, if could not find it, it would throw that exception. I’m not sure why it didn’t find it in your System Tables, but any way, set it explicitly is also a right way. 
  
 Thanks, 
  
 Ben