Skip to content

Commit

Permalink
Update docs, remove references to the indexed shapefile store, fix us…
Browse files Browse the repository at this point in the history
…age of long winded constructors
  • Loading branch information
aaime committed Apr 7, 2013
1 parent c951a61 commit d67d4d2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 47 deletions.
48 changes: 10 additions & 38 deletions docs/user/library/data/datastore.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,28 +89,17 @@ These examples bring up a couple of questions:

We are using a FactoryFinder (rather than just saying new
ShapefileDataStore ) so GeoTools can have a look at your specific
fiel choose the right implementation for the job.

Currently GeoTools has two implementations:

* ShapefileDataStore

Provided by **ShapefileDataStoreFactory** for direct access to a
shapefile, suitable for shapefiles located on network shares and web
services

* IndexedShapefileDataStore

Provided by **IndexedShapefileDataStoreFactory** to makes use of
(or create) a spatial index for fast access
configuration and choose the right implementation for the job.
Store implementation might change in time, accessing the stores via the
factory ensures your client code does not need to be changed when this happens.


* Q: What do we put it the Map?

That's a hard question which forces us to read the documentation:

* :doc: `shape` (user guide)
* `ShapefileDataStoreFactory <http://docs.geotools.org/stable/javadocs/org/geotools/data/shapefile/ShapefileDataStoreFactory.html>`_ (javadocs)
* `IndexedShapefileDataStoreFactory <http://docs.geotools.org/stable/javadocs/org/geotools/data/shapefile/indexed/IndexedShapefileDataStoreFactory.html>`_ (javadocs)

This information is also available at runtime via the
**DataStoreFactorySpi,getParameterInfo()** method. You can use this
Expand Down Expand Up @@ -170,12 +159,12 @@ You can also dodge the FactoryFinder and make use of the following quick hacks.

This is not wise (as the implementation may change over time) but here is how it is done.

* Use new ShapefileDataStore::
* Use ShapefileDataStore::
File file = new File("example.shp");
URI namespace = new URI("refractions");
boolean useMemoryMapped = true;
DataStore shapefile = new ShapefileDataStore( example.toURL(), namespace, useMemoryMapped );
DataStore shapefile = new ShapefileDataStore( example.toURL());
shapefile.setNamespace(new URI("refractions"));
shapefile.setMemoryMapped(true ;
String typeName = shapefile.getTypeName(); // should be "example"
FeatureType schema = shapefile.getSchema( typeName ); // should be "refractions.example"
Expand All @@ -188,26 +177,9 @@ This is not wise (as the implementation may change over time) but here is how it
application can we ask you to use the DataStoreFactoryFinder. It will
let the library sort out what implementation is appropriate.

* Use new IndexedShapefileDataStore::
File file = new File("example.shp");
URI namespace = new URI("refractions");
boolean memoryMapped = true;
boolean createIndex = true;
byte treeType = IndexedShapefileDataStore.TREE_QIX;
DataStore shapefile = new IndexedShapefileDataStore( example.toURL(), namespace, memoryMapped, createIndex, treeType );
String typeName = shapefile.getTypeName(); // should be "example"
...
This hack may be fine for a quick code example, but in a real
application can we ask you to use the DataStoreFactoryFinder. It will
let the library sort out what implementation is appropriate.

* Use IndexedShapefileDataStoreFactory::
* Use ShapefileDataStoreFactory::
FileDataStoreFactorySpi factory = new IndexedShapefileDataStoreFactory();
FileDataStoreFactorySpi factory = new ShapefileDataStoreFactory();
File file = new File("example.shp");
Map map = Collections.singletonMap( "url", file.toURL() );
Expand Down
17 changes: 15 additions & 2 deletions docs/user/library/data/shape.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,22 @@ The following connection parameters are available:
| "charset" | Optional: Chartset used to decode strings in the |
| | DBF file |
+-------------------------+----------------------------------------------------+
| "timezone | Optional: Timezone used to parse dates in the |
| "timezone" | Optional: Timezone used to parse dates in the |
| | DBF file |
+-------------------------+----------------------------------------------------+
| "memory mapped buffer" | Optional: memory map the files (unadvisable for |
| | large files under windows, defaults to false) |
+------------------------------------------------------------------------------+
| "cache memory maps" | Optional: when memory mapping, cache and reuse |
| | memory maps (defaults to true) |
+------------------------------------------------------------------------------+
| "create spatial index" | Optional: if false, won't try to create a spatial |
| | index if missing (defaults to true) |
+------------------------------------------------------------------------------+
| "enable spatial index" | Optional: if false, the spatial index won't be used|
| | even if available (and won't be created if missing |
+-------------------------+----------------------------------------------------+



This information is also in the `javadocs <http://docs.geotools.org/latest/javadocs/org/geotools/data/shapefile/ShapefileDataStoreFactory.html>`_ .
Expand Down Expand Up @@ -134,7 +147,7 @@ Supports:

Limitations:

* only work with MultiLineStirngs, MultiPolygon or MultiPoint. GIS data often travels
* only work with MultiLineStrings, MultiPolygon or MultiPoint. GIS data often travels
in herds - so being restricted to the plural form is not a great limitation.
* only work with fixed length strings (you will find the FeatureType
has a restriction to help you check this, and warnings will be produced if
Expand Down
2 changes: 1 addition & 1 deletion docs/user/library/main/internal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ And a couple that are no longer used:
AbstractDataStore
^^^^^^^^^^^^^^^^^

The **AbstractDataStore** is the super class for ShapefileDataStore and the legacy JDBC DataStores.
The **AbstractDataStore** is an old base class for DataStore implementations, currently used only by MemoryDataStore and PropertyDataStore. All new stores use **ContentDataStore** instead.

.. image:: /images/AbstractDataStore.PNG

Expand Down
12 changes: 6 additions & 6 deletions docs/user/welcome/use.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ Bad practice with direct dependency on ShapeFileDataStoreFactory::
ShapeFileDataStore = factory.createDataStore( file );

This code example would have been fine for GeoTools 2.1, however for GeoTools 2.2 an "indexed"
shapefile datastore was created with far better performance. The factory would be smart enough
to create an IndexedShapeFileDataStore if an index file was available.
shapefile datastore was created with far better performance.

Here is a replacement that allows GeoTools to return an indexed datastore if one is available::
Expand Down Expand Up @@ -365,7 +364,7 @@ Sometimes you just need to go ahead and code it like you mean it. The GeoTools p

You can just use a specific factory that is known to you::
DataStoreFactorySpi factory = new IndexedShapefileDataStoreFactory();
DataStoreFactorySpi factory = new ShapefileDataStoreFactory();
File file = new File("example.shp");
Map map = Collections.singletonMap( "url", file.toURL() );
Expand Down Expand Up @@ -394,11 +393,12 @@ You can skip the whole Factory madness and just do normal Java coding::
File file = new File("example.shp");
URI namespace = new URI("refractions");
boolean useMemoryMapped = true;
ShapefileDataStore shapefile = new ShapefileDataStore( example.toURL(), namespace, useMemoryMapped );
ShapefileDataStore shapefile = new ShapefileDataStore( example.toURL());
shapefile.setNamespace(namespace);
shapefile.setMemoryMapped(true);

You are depending on a exact class here, violating the plug-in system and so on. Chances are that GeoTools should not let you do this (by making the constructor package visible and forcing you to use the associated DataStoreFactory instead).

This option is fine for quick hacks, you may find that the ShapefileDataStore has additional methods (to handle such things as forcing the "prj" file to be rewritten.::
This option is fine for quick hacks, you may find that the ShapefileDataStore has additional methods (to handle such things as forcing the "prj" file to be rewritten)::
shapefile.forceSchemaCRS( CRS.decode( "EPSG:4326" ) );

1 comment on commit d67d4d2

@jodygarnett
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Andrea it looks good

Please sign in to comment.