gvsig-raster / org.gvsig.raster.gdal / tags / pre-remove-jgdal / org.gvsig.raster.gdal / org.gvsig.raster.gdal.io / src / main / java / org / gvsig / addo / Jaddo.java @ 3497
History | View | Annotate | Download (2.67 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 |
package org.gvsig.addo; |
23 |
import java.io.File; |
24 |
|
25 |
import org.gdal.gdal.Dataset; |
26 |
import org.gdal.gdal.gdal; |
27 |
import org.gvsig.jgdal.JNIBase; |
28 |
|
29 |
/**
|
30 |
* Clase para la construccion de overviews de un raster.
|
31 |
*
|
32 |
* 15-nov-2007
|
33 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
34 |
*/
|
35 |
public class Jaddo extends JNIBase implements IOverviewIncrement{ |
36 |
public final static int NEAREST = 0; |
37 |
public final static int AVERAGE = 1; |
38 |
public final static int AVERAGE_MP = 2; |
39 |
public final static int AVERAGE_MAGPHASE = 3; |
40 |
public final static int MODE = 4; |
41 |
|
42 |
private IOverviewIncrement incrementListener = null; |
43 |
private int value = 0; |
44 |
|
45 |
// private native int buildOverviewsNative(int resamplingAlg, String file, int[] overviews);
|
46 |
|
47 |
/**
|
48 |
* Construccion de overviews
|
49 |
*/
|
50 |
public void buildOverviews(int resamplingAlg, String file, int[] overviews) |
51 |
throws BuildingOverviewsException, WritingException {
|
52 |
File f = new File(file); |
53 |
if(!f.exists() || !f.isFile())
|
54 |
throw new BuildingOverviewsException("File does not exist."); |
55 |
if(!f.canWrite())
|
56 |
throw new WritingException("File is not writeable"); |
57 |
Dataset data = gdal.Open(file); |
58 |
if(data.BuildOverviews(overviews) >= 0) |
59 |
throw new BuildingOverviewsException("Problems building overviews"); |
60 |
} |
61 |
|
62 |
/**
|
63 |
* Devuelve el porcentaje del incremento.
|
64 |
* @return int
|
65 |
*/
|
66 |
public int getPercent() { |
67 |
return value;
|
68 |
} |
69 |
|
70 |
/**
|
71 |
* Asigna el porcentaje de incremento de la construccion de overview.
|
72 |
* Esto se hace automaticamente desde el callback que asigna el porcentaje.
|
73 |
*/
|
74 |
public void setPercent(int value) { |
75 |
this.value = value;
|
76 |
if(incrementListener != null) |
77 |
incrementListener.setPercent(value); |
78 |
} |
79 |
|
80 |
/**
|
81 |
* Asigna el listener para la asignacion del incremento
|
82 |
* @param incr IOverviewIncrement
|
83 |
*/
|
84 |
public void setIncrementListener(IOverviewIncrement incr) { |
85 |
this.incrementListener = incr;
|
86 |
} |
87 |
} |