Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_data / src / org / gvsig / fmap / data / index / spatial / SpatialIndexFactory.java @ 23285

History | View | Annotate | Download (2.57 KB)

1 22609 jiyarza
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {{Company}}   {{Task}}
26
 */
27
28 23285 jiyarza
package org.gvsig.fmap.data.index.spatial;
29 22609 jiyarza
30
import org.apache.log4j.Logger;
31
32 23285 jiyarza
import org.gvsig.fmap.data.index.IndexException;
33
import org.gvsig.tools.extensionPoint.ExtensionPoint;
34
import org.gvsig.tools.extensionPoint.ExtensionPointsSingleton;
35 22609 jiyarza
36 23023 jiyarza
37
/**
38
 *
39
 * @author jyarza
40
 *
41
 */
42 22609 jiyarza
public abstract class SpatialIndexFactory {
43
44
        private static Logger logger = Logger.getLogger(SpatialIndexFactory.class);
45
46
47
        public interface Factories {
48
                public static final String GT2_QUADTREE = "QuadTreeGt2Factory";
49
                public static final String JSI_RTREE = "RTreeJsiFactory";
50
                public static final String JTS_QUADTREE = "QuadTreeJtsFactory";
51
                public static final String SPATIALINDEX_RTREE = "RTreeSptLibFactory";
52
                public static final String DEFAULT = GT2_QUADTREE;
53
        }
54
55
56
        public static final String EXTENSION_POINT_NAME =  "SpatialIndexFactory";
57
        private static ExtensionPoint ep = new ExtensionPoint(EXTENSION_POINT_NAME, "Spatial Index Factory");
58
59
        static {
60
                ExtensionPointsSingleton.getInstance().put(ep);
61
                logger.debug("factory static code executed");
62
        }
63
64
        public static SpatialIndexFactory getFactory(String type) throws InstantiationException, IllegalAccessException {
65
                if (type == null) type = Factories.DEFAULT;
66
                return (SpatialIndexFactory) ep.create(type);
67
        }
68
69
        protected static void registerFactory(String key, String description, Class value) {
70
                ep.put(key, description, value);
71
                logger.debug(key + " registered.");
72
        }
73
74
75
        public SpatialIndex createSpatialIndex() throws IndexException {
76
                return createSpatialIndex(null);
77
        }
78
79
        public abstract SpatialIndex createSpatialIndex(SpatialIndexParameters params) throws IndexException;
80
}