4

I created a WMS layer from a PostGIS table with a fraction of total polygons in GeoServer. Everything displayed fine.

Then, I added the rest of the polygons to the table in postgis. For some reason its not updating the layer. I tried restarting geoserver and its still not updating. How do I get geoserver to update the layer?

I use Open layers WMS layer and OpenLayers.Protocol.WFS.fromWMSLayer(polygons) to get polygon data.

-N

UPDATE: I tried to click Compute from data/Compute from bounding box links to get the new MBR. Unfortunately, it did not update, so here's as much info as I can think to provide.

I have a set of polygons scattered around the US. They are from a pair of SHP files in WGS_1984. I started testing the system with a small set of 100 polygons and now that the system works, I wanted to add the the other polygons to the data. I used shp2sql to create a new table in postgis. Then I used a INSERT INTO polygons (SELECT from ...) to add them to the table that geoserver uses. Now there is about 50k polygons in the table.

I tried updating the MBR as answers below suggest. Here are the current settings of the layer in geoserver:

Native SRS: EPSG:4326 Declared SRS: EPSG:900913

When I hit Compute from data for Native bounding box it gives me:

(Min x,Min y, Max x, Max y)

-10Mil, 5Mil, -10mil, 5Mil

and for the Declared:

-95.xxx,40.xxx,-95.xxx,43.xxx

For whatever reason, they are now updating correctly. The MBR should cover most of the US now and not just that little portion in the middle.

1

4 Answers 4

3

Did you update the bounding box on the datastore page?

If it isn't that then we'll need more details of where you added the data, how you added the data and what errors and messages you get in the log file.

Update

Something is wrong with your data - -10Mil, 5Mil, -10mil, 5Mil is completely wrong if your data is in 4326 (-180,180,-90,90). You may need to check what the actual data in the table looks like.

The easiest way to add a second shapefile to a table is the -a flag (see http://postgis.refractions.net/docs/ch04.html#shp2pgsql_usage)

1
  • Thanks for pointing me there. For some reason I don't think its updating correctly. I updated my question with more details. For some reason the BB are not being updated correctly
    – Nate
    Nov 18, 2011 at 19:01
2

So here is what I did that fixed it, but its not ideal.

For some reason neither the layer nor the data store updated when I would add data. The layer did not see the new polygons I added. The data store did not see new tables when I added them either.

So I had to create a new PostGIS data store and used the same table to create a new layer. That updated the data, but it would be nice to have the option to update the layer without having to create a new one.

2

The easiest way to achieve that is erasing the geoserver cache manually. You can find the cache location at the file geoserver-directory/WEB-INF/web.xml, there is a variable called GEOSERVER_DATA_DIR, if its not present you can add it and specify the location of the cache directory (mine is /geosrverdata):

<context-param>
   <param-name>GEOSERVER_DATA_DIR</param-name>
    <param-value>/geoserverdata</param-value>
</context-param> 

Then restart tomcat. Inside of this directory you will find this:

/geoserverdata# ls
global.xml  gwc  security  styles  wcs.xml  wfs.xml  wms.xml  workspaces

inside of gwc you will find a directory for each layer, erase the content of each directory but don't delete the directory itself.

You could automate this work with a cron job, and you could erase the cache every two days or every month or even every 15 minutes.

But remeber that the clients(google maps, open layers, etc) could still using old data, so also make sure to erase the cache at the clients.

0

Geoserver automatically copies your datatable from your database into "geoserver." Live updates should be done to that table, not your original. The advantage here is that it helps you host both development data and production data side by side.

2
  • I am not sure what you are trying to say here. What do you mean when you say that 'Geoserver automatically copies your datatable from your database into "geoserver."'? Could you clarify this statement? Jan 27, 2013 at 15:02
  • I'm running OpenGeo 3. When I load a table into PostGIS under the database for my user ID and then using the Geoserver console to load the layer from the PostGIS store Geoserver copies the table from the database under my user ID into the database named "geoserver." When I update the one under my user ID (bshender in my case) the update is not shown in geoserver automatically. I'd have to manually add it again. But, if I run an insert statement on the copied table under the "geoserver" database the updated data is immediately served by Geoserver via WFS to my OpenLayers page.
    – bshender
    Jan 28, 2013 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.