Hi

I think the naming and usage of ShapefileDataStore.isLocal() aka 
ShpFiles.isLocal() is not consistant.

The JavaDoc says: "Determine if the location of this shapefile is local or 
remote."

But it would return false for
 http://localhost/some.shp
and for
 jar://some.jar!some.shp
and for
 jar://http://localhost/some.jar!some.shp
which all are somewhat local

Looking at where the method is used in Geotools, it looks like it is mostly 
used 

A) to see if the folder of the shapefile is writable. So done in:
>    public void createSchema(SimpleFeatureType featureType) throws
> IOException { if (!isLocal()) {
>            throw new IOException(
>                    "Cannot create FeatureType on remote shapefile");
>        }

B) to prevent ShpFiles.exists(ShpFileType fileType) from throwing an 
IllegalArgumentException:

At the moment ShpFiles.exists() can only be called when "isLocal() == true", 
because its converted to a File and then File.exists() is called. 




Due to the above limitations, we get the code below from 
ShapefileRenderer.java: 1178, that i really want to ask about.
>    public IndexInfo useIndex( ShapefileDataStore ds ) throws IOException,
> StoreException { IndexInfo info;
>
>        ShpFiles shpFiles = ShapefileRendererUtil.getShpFiles(ds);
>        if (ds.isLocal()) {
>
>            if (!shpFiles.exists(SHX)) {
>                info = new IndexInfo(IndexType.NONE, shpFiles);
>                LOGGER.fine("No indexing");
>            } else if (shpFiles.exists(QIX)) {
>                info = new IndexInfo(IndexType.QIX, shpFiles);
>                LOGGER.fine("Using quad tree");
>            } else {
>                info = new IndexInfo(IndexType.NONE, shpFiles);
>                LOGGER.fine("No indexing");
>            }
>        } else {
>            info = new IndexInfo(IndexType.NONE, shpFiles);
>            LOGGER.fine("No indexing");
>        }

At the moment an index is only used when it's a "file://" URL.
Is there a reason to only use indexes when we are really local? 
Is there a reason to only use indexes when we the shapefile is writable? 

I would suggest:
1.) Make ShpFile.exists(ShpFileType fileType) work on any URLs, falling back to 
an URL.openConnection/catch Exception test if it can not be converted to a 
File.
2.) Rename isLocal to isWritable and add a File.canWrite check for all parts
3.) Remove isLocal() where it only used to prevent an IllegalArguemntException 
from exists() - that would include ShapefileRenderer.useIndex() 

Optionions? Discussion! Explanations!
Shall i open a Wish-JIRA and add a patch for the above proposals?

My motivation: I use Shapefiles that are stored inside JARs and I want to use 
them with index.

Greetings
Steve

-- 
wiki² - Softwareentwicklung
Stefan Krüger
Straßburger Weg 26
53113 Bonn

email   [email protected]
mobile  0151 50543949   
webpage wikisquare.de
skype   alfonx

reclaim your net - http://tor.eff.org
enforce privacy - http://www.pgpi.org
pgp key id: 51B576FD - http://pgp.mit.edu

Please note that according to the German law on data retention,
information on every electronic information exchange with me is
retained for a period of six months.



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Geotools-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to