001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2003-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2001-2003, The Open Planning Project
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.data.shapefile.indexed;
018:
019: import java.io.IOException;
020: import java.net.MalformedURLException;
021: import java.net.URI;
022: import java.net.URL;
023: import java.nio.charset.Charset;
024: import java.util.Collections;
025: import java.util.HashMap;
026: import java.util.Map;
027:
028: import org.geotools.data.DataSourceException;
029: import org.geotools.data.DataStore;
030: import org.geotools.data.DataStoreFactorySpi.Param;
031: import org.geotools.data.memory.CollectionSource;
032: import org.geotools.data.shapefile.ShapefileDataStore;
033: import org.geotools.data.shapefile.ShapefileDataStoreFactory;
034:
035: import com.vividsolutions.jts.geom.Geometry;
036:
037: /**
038: * This factory is maintained for GeoTools 2.3 code that made use of
039: * IndexedShapefileDataStoreFactory directly.
040: *
041: * @deprecated Please use ShapefileDataStoreFactory, it can create an IndexedDataStore if appropriate
042: * @author Chris Holmes, TOPP
043: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/indexed/IndexedShapefileDataStoreFactory.java $
044: * @version $Id: IndexedShapefileDataStoreFactory.java 26202 2007-07-11 18:23:09Z jgarnett $
045: */
046: public class IndexedShapefileDataStoreFactory extends
047: ShapefileDataStoreFactory {
048:
049: /**
050: * This implementation only tries to make an IndexedShapefileDataStore.
051: *
052: * @param params
053: *
054: *
055: * @throws IOException DOCUMENT ME!
056: * @throws DataSourceException
057: */
058: public DataStore createNewShapefile(Map params) throws IOException {
059: URL url = null;
060: DataStore ds = null;
061:
062: try {
063: url = (URL) URLP.lookUp(params);
064:
065: Boolean idx = (Boolean) CREATE_SPATIAL_INDEX.lookUp(params);
066:
067: if (idx == null) {
068: idx = Boolean.TRUE;
069: }
070:
071: URI namespace = (URI) NAMESPACEP.lookUp(params);
072:
073: Charset dbfCharset = (Charset) DBFCHARSET.lookUp(params);
074: if (dbfCharset == null)
075: dbfCharset = Charset.forName("ISO-8859-1");
076:
077: ds = new IndexedShapefileDataStore(url, namespace, false,
078: idx.booleanValue(),
079: IndexedShapefileDataStore.TREE_QIX, dbfCharset);
080: } catch (MalformedURLException mue) {
081: throw new DataSourceException(
082: "Unable to attatch datastore to " + url, mue);
083: }
084:
085: return ds;
086: }
087:
088: public String getDisplayName() {
089: return "Shapefile (Indexed)";
090: }
091:
092: // public DataSourceMetadataEnity createMetadata( Map params )
093: // throws IOException {
094: //
095: // URL url = (URL) URLP.lookUp(params);
096: // Boolean mm = (Boolean) MEMORY_MAPPED.lookUp(params);
097: // Boolean idx = (Boolean) CREATE_SPATIAL_INDEX.lookUp(params);
098: //
099: // String server;
100: // String name;
101: // if( url.getProtocol().equals("file")){
102: // server = "localhost";
103: // name = url.getPath();
104: // }
105: // else {
106: // server = url.getHost()+":"+url.getPort();
107: // name = url.getFile();
108: // }
109: // return new DataSourceMetadataEnity( server, name, "Shapefile access for "+url );
110: // }
111:
112: }
|