« Return to Thread: shp2geoserver: batch import for shapefiles

shp2geoserver: batch import for shapefiles

by stoyan :: Rate this Message:

Reply to Author | View in Thread

Greetings, according to this mailing list there doesn't exist a tool for batch importing shapefiles into GeoServer, so I thought I'd write one. Could you please have a look at my algorithm and let me know what steps I am missing:

def shp2geoserver(shp,datastoreid,sld,srs):
    copy the shapefile to data_dir\data
    add the new shapefile as a datastore element to data_dir\catalog.xml
    create index.xml under the data_dir\featureTypes\datastoreid dir

To run my script I stop GeoServer, run it, start GeoServer. The outcome is:
-the directories/files are populated as per the algorithm
-I can see the newly added datastores under http://localhost:8080/geoserver/config/data/store.do
-I can't see the newly added features under http://localhost:8080/geoserver/config/data/typeSelect.do 

Could someone please tell me what I am doing wrong? Am I forgetting to update some config files? Is this at all doable?

Here is some sample data:
added to <datastores> in catalog.xml
<datastore enabled="true" id="ds_south_australia_poly" namespace="topp">
      <connectionParams>
        <parameter name="create spatial index" value="true" />
        <parameter name="namespace" value="topp" />
        <parameter name="url" value="file:data/Topo_GA/100K/south_australia_poly.shp" />
        <parameter name="charset" value="ISO-8859-1" />
      </connectionParams>
</datastore>

...\data_dir\featureTypes\ds_south_australia_poly\index.html:
<featureType datastore = "ds_south_australia_poly" >
  <name>south_australia_poly</name>
  <SRS>4283</SRS>
  <SRSHandling>0</SRSHandling>
  <title>south_australia_poly_Type</title>
  <abstract>Generated from ds_south_australia_poly</abstract>
  <wmspath>/</wmspath>
  <numDecimals value = "8" />
  <keywords>south_australia_poly ds_south_australia_poly</keywords>
  <latLonBoundingBox dynamic = "false" miny = "-43" maxy = "-25" maxx = "141" minx = "129" />
  <nativeBBox dynamic = "false" miny = "-43" maxy = "-25" maxx = "141" minx = "129" />
  <styles default = "south_australia_poly" />
  <cacheinfo enabled = "false" maxage = "" />
  <maxFeatures>0</maxFeatures>
</featureType>

Many thanks,
Stoyan.

PS: I'll gladly publish the script here, once I get it working.

 « Return to Thread: shp2geoserver: batch import for shapefiles