Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.raster.bingmaps / org.gvsig.raster.bingmaps.provider / src / main / java / org / gvsig / raster / bingmaps / provider / BingMapsRasterLibrary.java @ 8824

History | View | Annotate | Download (3.46 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.raster.bingmaps.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.bingmaps.lib.api.BingMapsLibrary;
35
import org.gvsig.metadata.exceptions.MetadataException;
36
import org.gvsig.tools.library.AbstractLibrary;
37
import org.gvsig.tools.library.LibraryException;
38

    
39
/**
40
 * BingMaps Library to register provider commponents
41
 * @author fdiaz
42
 *
43
 */
44
public class BingMapsRasterLibrary extends AbstractLibrary {
45

    
46
    static int BING_MAPS_TILE_SIZE = 256;
47
    static int TILE_SIZE = 256;
48
    static int MAX_ZOOM_LEVEL = 23;
49

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

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

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

    
65
                FileHelper.registerParametersDefinition(
66
                                BingMapsRasterProviderParameters.PARAMETERS_DEFINITION_NAME,
67
                                BingMapsRasterProviderParameters.class, "BingMapsRasterParameters.xml");
68
                try {
69
                        FileHelper.registerMetadataDefinition(
70
                            BingMapsRasterProvider.METADATA_DEFINITION_NAME,
71
                            BingMapsRasterProvider.class, "BingMapsRasterMetadata.xml");
72
                } catch (MetadataException e) {
73
                        exs.add(e);
74
                }
75

    
76
                DataManagerProviderServices dataman = DALSPILocator.getDataManagerProviderServices();
77

    
78

    
79
                try {
80
            if (!dataman.getStoreProviders()
81
                .contains(BingMapsRasterProvider.NAME)) {
82
                dataman.registerStoreProviderFactory(
83
                    new BingMapsRasterProviderFactory(
84
                        BingMapsRasterProvider.NAME,
85
                        BingMapsRasterProvider.DESCRIPTION));
86
            }
87
                } catch (RuntimeException e) {
88
                        exs.add(e);
89
                }
90
                
91
        try {
92
            if (!dataman.getExplorerProviders().contains(BingMapsRasterServerExplorer.NAME)) {
93
                BingMapsRasterServerExplorerFactory factory = new BingMapsRasterServerExplorerFactory(BingMapsRasterServerExplorer.NAME, BingMapsRasterServerExplorer.DESCRIPTION);
94
                dataman.registerServerExplorerFactory(factory);
95
            }
96
        } catch (RuntimeException e) {
97
            exs.add(e);
98
        }
99

    
100

    
101

    
102
                if (exs.size() > 0) {
103
                        throw new LibraryException(this.getClass(), exs);
104
                }
105
        }
106
}