Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.osm / org.gvsig.osm.provider / src / main / java / org / gvsig / osm / provider / OSMRasterLibrary.java @ 8814

History | View | Annotate | Download (3.74 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23

    
24
package org.gvsig.osm.provider;
25

    
26
import java.util.ArrayList;
27
import java.util.List;
28

    
29
import org.gvsig.fmap.dal.DALFileLibrary;
30
import org.gvsig.fmap.dal.DALLibrary;
31
import org.gvsig.fmap.dal.FileHelper;
32
import org.gvsig.fmap.dal.spi.DALSPILocator;
33
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
34
import org.gvsig.metadata.exceptions.MetadataException;
35
import org.gvsig.tools.library.AbstractLibrary;
36
import org.gvsig.tools.library.LibraryException;
37

    
38
/**
39
 * GoogleMaps Library to register provider commponents
40
 * @author fdiaz
41
 *
42
 */
43
public class OSMRasterLibrary extends AbstractLibrary {
44

    
45
    // Para calcular los pixel size por zoom level GoogleMaps utiliza el tama?o de 256
46
    // pero nuestro proveedor servir? tiles de 640
47
    static int OSM_TILE_SIZE = 256;
48
//    static int TILE_SIZE = 640;
49
    public static int MAX_ZOOM_LEVEL = 22;
50

    
51
    @Override
52
    public void doRegistration() {
53
        registerAsServiceOf(DALLibrary.class);
54
        require(DALFileLibrary.class);
55
//        require(OSMLibrary.class);
56
    }
57

    
58
        @Override
59
        protected void doInitialize() throws LibraryException {
60
        }
61

    
62
        @Override
63
        protected void doPostInitialize() throws LibraryException {
64
                List<Throwable> exs = new ArrayList<Throwable>();
65

    
66
                FileHelper.registerParametersDefinition(
67
                                OSMRasterProviderParameters.PARAMETERS_DEFINITION_NAME,
68
                                OSMRasterProviderParameters.class, "OSMRasterParameters.xml");
69
                try {
70
                        FileHelper.registerMetadataDefinition(
71
                            OSMRasterProvider.METADATA_DEFINITION_NAME,
72
                            OSMRasterProvider.class, "OSMRasterMetadata.xml");
73
                } catch (MetadataException e) {
74
                        exs.add(e);
75
                }
76

    
77
        try {
78
            FileHelper.registerParametersDefinition(OSMRasterServerExplorerParameters.PARAMETERS_DEFINITION_NAME,
79
                OSMRasterServerExplorerParameters.class, "OSMRasterParameters.xml");
80

    
81
        } catch (RuntimeException e) {
82
            exs.add(e);
83
        }
84

    
85

    
86
                DataManagerProviderServices dataman = DALSPILocator.getDataManagerProviderServices();
87

    
88

    
89
                try {
90
            if (!dataman.getStoreProviders()
91
                .contains(OSMRasterProvider.NAME)) {
92
                dataman.registerStoreProviderFactory(
93
                    new OSMRasterProviderFactory(
94
                        OSMRasterProvider.NAME,
95
                        OSMRasterProvider.DESCRIPTION));
96
            }
97
                } catch (RuntimeException e) {
98
                        exs.add(e);
99
                }
100

    
101
        try {
102
            if (!dataman.getExplorerProviders().contains(OSMRasterServerExplorer.NAME)) {
103
                OSMRasterServerExplorerFactory factory = new OSMRasterServerExplorerFactory(OSMRasterServerExplorer.NAME, OSMRasterServerExplorer.DESCRIPTION);
104
                dataman.registerServerExplorerFactory(factory);
105
            }
106
        } catch (RuntimeException e) {
107
            exs.add(e);
108
        }
109

    
110

    
111
                if (exs.size() > 0) {
112
                        throw new LibraryException(this.getClass(), exs);
113
                }
114
        }
115
}