On Thu, Jan 26, 2012 at 4:59 PM, Chenglin Gan <chenglin.gan@…170…> wrote:
Hi,
My understanding about using shapefile as data source in GeoServer is that the first time a layer backed by shapefile is accessed through WMS or WFS, GeoServer checks if a quad-tree index (.qix) exists. If it doesn’t exist and the shapefile’s spatial extent is large enough, GeoServer will generate one. I have shapefile > 1GB. Once the .qix is generated, WMS and WFS response become extremely fast. But for the first time WMS/WFS request when the index is generated, it takes almost an hour to response. This becomes a problem each time I replace the shapefile with a new one. So my questions are:
- Can I configure GeoServer to use existing ESRI spatial index (.sbx) instead of .qix? Any downside of switching to .sbx?
Nope, that file format is not documented as far as I know, so we can’t make a reader.
Anyways, even if documentation popped up, someone would have to write the code to use it
- If I have to go with quad-tree index, how can I generate one offline before pushing the shapefile to GeoServer?
Hmm… we don’t have a stand-alone command line utility that can do the indexing.
There is a undocumented trick that can get it done, but it does not look that good.
On the command line, change directory into your geoserver/WEB-INF/lib directory
and then run the following (assuming java is in your path, and assuming you’re
going to fix the version number if gt-shapefile to match your version):
java -cp gt-shapefile-2.7.3.jar org.geotools.data.shapefile.indexed.ShapeFileIndexer /path/to/your/shapefile.shp
This will generate the .qix file offline.
If you don’t want to run from inside the geoserver WEB-INF/lib I believe you can copy the
gt-shapefile jar along with the following ones in whatever folder you prefer:
gt-data-2.7.3.jar gt-main-2.7.3.jar gt-api-2.7.3.jar jts-1.11.jar gt-referencing-2.7.3.jar vecmath-1.3.2.jar gt-metadata-2.7.3.jar gt-opengis-2.7.3.jar jsr-275-1.0-beta-2.jar
and then run the same command from there
Cheers
Andrea
–
Ing. Andrea Aime
GeoSolutions S.A.S.
Tech lead
Via Poggio alle Viti 1187
55054 Massarosa (LU)
Italy
phone: +39 0584 962313
fax: +39 0584 962313
mob: +39 339 8844549
http://www.geo-solutions.it
http://geo-solutions.blogspot.com/
http://www.youtube.com/user/GeoSolutionsIT
http://www.linkedin.com/in/andreaaime
http://twitter.com/geowolf