Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_data / src / org / gvsig / fmap / data / index / SpatialIndexFactory.java @ 23023

History | View | Annotate | Download (2.52 KB)

1
/* 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
package org.gvsig.fmap.data.index;
29

    
30
import org.apache.log4j.Logger;
31

    
32
import com.iver.utiles.extensionPoints.ExtensionPoint;
33
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
34

    
35

    
36
/**
37
 * 
38
 * @author jyarza
39
 *
40
 */
41
public abstract class SpatialIndexFactory {
42

    
43
        private static Logger logger = Logger.getLogger(SpatialIndexFactory.class);
44
        
45
        
46
        public interface Factories {
47
                public static final String GT2_QUADTREE = "QuadTreeGt2Factory";
48
                public static final String JSI_RTREE = "RTreeJsiFactory";
49
                public static final String JTS_QUADTREE = "QuadTreeJtsFactory";
50
                public static final String SPATIALINDEX_RTREE = "RTreeSptLibFactory";
51
                public static final String DEFAULT = GT2_QUADTREE;
52
        }
53
        
54
        
55
        public static final String EXTENSION_POINT_NAME =  "SpatialIndexFactory";
56
        private static ExtensionPoint ep = new ExtensionPoint(EXTENSION_POINT_NAME, "Spatial Index Factory");
57
        
58
        static {                
59
                ExtensionPointsSingleton.getInstance().put(ep);
60
                logger.debug("factory static code executed");
61
        }
62

    
63
        public static SpatialIndexFactory getFactory(String type) throws InstantiationException, IllegalAccessException {
64
                if (type == null) type = Factories.DEFAULT;
65
                return (SpatialIndexFactory) ep.create(type);
66
        }
67
        
68
        protected static void registerFactory(String key, String description, Class value) {
69
                ep.put(key, description, value);
70
                logger.debug(key + " registered.");
71
        }
72
        
73
        
74
        public SpatialIndex createSpatialIndex() throws IndexException {
75
                return createSpatialIndex(null);
76
        }        
77

    
78
        public abstract SpatialIndex createSpatialIndex(SpatialIndexParameters params) throws IndexException;
79
}