Search code examples
sqlpostgresqlviewpostgisgeoserver

Why a well running view gets zero values in the native bounding box in Geoserver?


I am working on a remote db and I have all privileges as a user. I have created a spatial relational db that consists of 5 tables and one of them has the geometry column. When I'm trying to publish only the table with the geometry which has srid GGRS87, EPSG:2100, the native bbox is computing well but when I'm trying to create a view either from PostGIS or via Geoserver, the Native BBox gives values (-1,-1,0,0) and also the Lat/Lon BBox doesn't have the correct ones.The view in the db runs correctly, merging all the 5 tables.Lastly, I notice that when I create the view via Geoserver, the column of SRID doesn't show up to set it from there.

What could be possibly go wrong with the connection between PostGIS and Geoserver or it is sth else? Thanks!

CREATE VIEW buildings AS
SELECT 
  id_owner,id_building,address_name,address_num,
  region,x,y,closing_file
FROM owner
JOIN owner_property 
  ON owner.id_owner = owner_property.owner_id
JOIN building 
  ON property.building_id=building.id_building;


Solution

  • Your view seems to have no geometry, and consequently no SRS. You most likely forgot to insert it into your view or, as your screenshot suggests, the coordinate pairs are split into two columns - x and y. So just use ST_MakePoint with x and y in the query used to create the view ..

    CREATE VIEW buildings_reinspection_file AS
    SELECT 
      id_owner,id_building,address_name,address_num,
      region,inspection_num,reinspection_num,reinspection_date,
      approval_num,ownership_perc,building_assessm,color_tagged,
      construction_type,ST_MakePoint(x,y,2100),closing_file
    FROM owner
    JOIN owner_property 
      ON owner.id_owner = owner_property.owner_id
    JOIN property 
      ON owner_property.property_id = property.id_property
    JOIN building 
      ON property.building_id=building.id_building
    JOIN financial_assist 
      ON property.financial_assist_id=financial_assist.id_financial_assist;
    

    .. and try to publish it again in GeoServer. If the column you created in the table building containing the geometry is called point, just replace the ST_MakePoint(x,y,2100) by building.point.