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 / BingMapsBandTileManager.java @ 8780
History | View | Annotate | Download (3.77 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 |
package org.gvsig.raster.bingmaps.provider; |
24 |
|
25 |
import java.io.IOException; |
26 |
import java.nio.Buffer; |
27 |
|
28 |
import org.slf4j.Logger; |
29 |
import org.slf4j.LoggerFactory; |
30 |
|
31 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
32 |
import org.gvsig.fmap.dal.raster.spi.RasterStoreProvider; |
33 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
34 |
import org.gvsig.raster.lib.buffer.api.Band; |
35 |
import org.gvsig.raster.lib.buffer.api.BandInfo; |
36 |
import org.gvsig.raster.lib.buffer.api.BandTileManager; |
37 |
import org.gvsig.raster.lib.buffer.api.TileStruct; |
38 |
|
39 |
|
40 |
/**
|
41 |
* @author fdiaz
|
42 |
*
|
43 |
*/
|
44 |
public class BingMapsBandTileManager implements BandTileManager { |
45 |
|
46 |
private static final Logger logger = LoggerFactory.getLogger(BingMapsBandTileManager.class); |
47 |
|
48 |
private int bandNumber; |
49 |
private int zoomLevel; |
50 |
|
51 |
private TileStruct tileStruct;
|
52 |
private BingMapsImage bingMapsImage;
|
53 |
|
54 |
/**
|
55 |
* @param tileStruct
|
56 |
* @param bingMapsImage
|
57 |
* @param zoomLevel
|
58 |
* @param bandNumber
|
59 |
* @param provider
|
60 |
*/
|
61 |
public BingMapsBandTileManager(TileStruct tileStruct, BingMapsImage bingMapsImage, int zoomLevel, int bandNumber, RasterStoreProvider provider) { |
62 |
this.bandNumber = bandNumber;
|
63 |
this.tileStruct = tileStruct;
|
64 |
this.zoomLevel = zoomLevel;
|
65 |
this.bingMapsImage = bingMapsImage;
|
66 |
} |
67 |
|
68 |
@Override
|
69 |
public boolean isSupportedSave() { |
70 |
return false; |
71 |
} |
72 |
|
73 |
@Override
|
74 |
public Band load(int row, int col, int dataType) throws IOException { |
75 |
|
76 |
int tileRow=(int)row/getRowsPerTile(); |
77 |
int tileCol=(int)col/getColumnsPerTile(); |
78 |
|
79 |
try {
|
80 |
return bingMapsImage.fetchTile(bandNumber, this.zoomLevel, tileRow, tileCol); |
81 |
} catch (ValidateDataParametersException | CreateEnvelopeException | CloneNotSupportedException e) { |
82 |
throw new IOException("Can't load band.", e); |
83 |
} |
84 |
} |
85 |
|
86 |
@Override
|
87 |
public void save(Buffer buffer, int row, int rows, int col, int cols, int dataType) throws IOException { |
88 |
throw new UnsupportedOperationException(); |
89 |
} |
90 |
|
91 |
/* (non-Javadoc)
|
92 |
* @see org.gvsig.raster.lib.buffer.api.BandTileManager#getBandInfo()
|
93 |
*/
|
94 |
@Override
|
95 |
public BandInfo getBandInfo() {
|
96 |
// TODO Auto-generated method stub
|
97 |
return null; |
98 |
} |
99 |
|
100 |
/* (non-Javadoc)
|
101 |
* @see org.gvsig.raster.lib.buffer.api.BandTileManager#getRowsPerTile()
|
102 |
*/
|
103 |
@Override
|
104 |
public int getRowsPerTile() { |
105 |
return tileStruct.getRowsPerTile();
|
106 |
} |
107 |
|
108 |
/* (non-Javadoc)
|
109 |
* @see org.gvsig.raster.lib.buffer.api.BandTileManager#getColumnsPerTile()
|
110 |
*/
|
111 |
@Override
|
112 |
public int getColumnsPerTile() { |
113 |
return tileStruct.getColumnsPerTile();
|
114 |
} |
115 |
|
116 |
/* (non-Javadoc)
|
117 |
* @see org.gvsig.raster.lib.buffer.api.BandTileManager#getTileStruct()
|
118 |
*/
|
119 |
@Override
|
120 |
public TileStruct getTileStruct() {
|
121 |
return this.tileStruct; |
122 |
} |
123 |
|
124 |
} |