As the title says I converted/imported a KML file into my PostGIS database using the ogr2ogr command. Now I am trying to publish each table as a seperate layer onto a GeoServer. I know about cURL, but as far as I can see I would have to have a new command for each table in the db. I have 124 tables I need to publish so doing that one by one would be labor intensive. Is there anyway straight-forward way to streamline this process?
You will want to use this example to build up a script: http://docs.geoserver.org/stable/en/user/rest/examples/curl.html#adding-a-postgis-table
Using Python, you could list all the tables in your postgis database, then craft a HTML call (using urllib) to publish each one.
Issues you might have include styling, to name just one. And you might want to set up a metadata table to read from (could be a CSV or spreadsheet) in order to set up the specifics for each table.
When you have a table with your specifics for your 124 tables, then use the python script to set it all up on GeoServer. Perhaps you write your script to do the following (assuming you have your datastore set up):
- delete your workspace and all layers, if they exist
- create your workspace
- populate the workspace with all your tables, using parameters from your metadata spreadsheet
That way, if it works, you're good. And if it doesn't, or you want an additional 20 tables, you can simply re-run the script. And, if it doesn't work, you can fix the problem and re-run the script!
Good luck =)
Edit: note that there is an excellent python library to hit the GeoServer API with: https://github.com/boundlessgeo/gsconfig