ThinkGeo.com    |     Documentation    |     Premium Support

Getting a bounding box of a Postgres Layer doesn't work

Hi Ben,


we tried out to display a Postgre Layer by getting a bounding box (see example code). It throws following error:


The layer doesn' have a bounding box


The same procedure with a shape file works very well.


Regards Joerg


Imports System
Imports System.Web.UI
Imports ThinkGeo.MapSuite.Core
Imports ThinkGeo.MapSuite.WebEdition
 
Partial Public Class LoadAPostgreSQLFeatureLayer : Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Map1.MapBackground.BackgroundBrush = New GeoSolidBrush(GeoColor.FromHtml("#B3C6D4"))
            Map1.MapUnit = GeographyUnit.Meter
 
 
            Dim connectString As String = "Server=geo-04;userId=postgres;Password=geodata;DataBase=swisscom;" '172.16.2.6
            Dim postgreLayer1s As New PostgreSqlFeatureLayer(connectString, "hausanschluss", "id")
            postgreLayer1s.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.Capital1 
            postgreLayer1s.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20
            postgreLayer1s.Open()
            Map1.CurrentExtent = postgreLayer1s.GetBoundingBox()
            postgreLayer1s.Close()
            Map1.StaticOverlay.Layers.Add(postgreLayer1s)
 
        End If

    End Sub


 



Joerg,  
  
 That’s a bug; we forgot to rewrite the HasBoundingBox property in PostgreLayer. Thanks for reporting! We will fix it in the upcoming version. 
  
 It’s easy to work around though. You can call the relative FeatureSource to get the BoudingBox like  
 
Map1.CurrentExtent = postgreLayer1s.FeatureSource.GetBoundingBox() 
 
 Or you can inherit the PostgreSqlFeatureLayer class, override the HasBoudningBox property and make it true.  Both ways will work fine. 
  
 Thanks! 
  
 Ben