Revision 1631

View differences:

org.gvsig.raster.postgis/tags/2.0.0/distribution/distribution.xml
1
<assembly>
2
</assembly>
0 3

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.io/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.raster.postgis.io.DefaultPostGISRasterIOLibrary
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.io/src/main/java/org/gvsig/raster/postgis/io/DefaultPostGISRasterIOLibrary.java
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.raster.postgis.io;
23

  
24
import org.gvsig.fmap.dal.DALFileLibrary;
25
import org.gvsig.fmap.dal.DALLibrary;
26
import org.gvsig.raster.impl.store.AbstractRasterFileDataParameters;
27
import org.gvsig.tools.ToolsLibrary;
28
import org.gvsig.tools.library.AbstractLibrary;
29
import org.gvsig.tools.library.Library;
30
import org.gvsig.tools.library.LibraryException;
31
/**
32
 *
33
 * @author Nacho Brodin (nachobrodin@gmail.com)
34
 */
35
public class DefaultPostGISRasterIOLibrary extends AbstractLibrary {	
36

  
37
	public DefaultPostGISRasterIOLibrary() {
38
		super(DefaultPostGISRasterIOLibrary.class,Library.TYPE.IMPL);
39
		require(ToolsLibrary.class);
40
		require(DALLibrary.class);
41
		require(DALFileLibrary.class);
42
	}
43
	
44
	@Override
45
	protected void doInitialize() throws LibraryException {
46
		//RasterLibrary.wakeUp();
47
	}
48

  
49
	@Override
50
	protected void doPostInitialize() throws LibraryException {
51
		PostGISRasterServerExplorerParameters.registerDynClass();
52
		
53
		PostGISRasterProvider.register();
54
		PostGISRasterDataParameters.registerDynClass();
55
		PostGISRasterDataParameters.registerPersistence();
56
	}
57
}
0 58

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.io/src/main/java/org/gvsig/raster/postgis/io/PostGISRasterCoreException.java
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.raster.postgis.io;
23

  
24
/**
25
 * This exception is thrown when the pool of threads fails
26
 *
27
 * @author Nacho Brodin (nachobrodin@gmail.com)
28
 */
29
public class PostGISRasterCoreException extends Exception {
30
	private static final long serialVersionUID = 1L;
31
	
32
	String message;
33

  
34
	public PostGISRasterCoreException() {
35
		super();
36
	}
37

  
38
	/**
39
	 * Crea ThreadPoolException.
40
	 *
41
	 * @param message
42
	 */
43
	public PostGISRasterCoreException(String message) {
44
        super();
45
        this.message = message;
46
	}
47

  
48
	/**
49
	 * Crea ThreadPoolException.
50
	 *
51
	 * @param message
52
	 * @param cause
53
	 */
54
	public PostGISRasterCoreException(String message, Throwable cause) {
55
		super(format(message, 200), cause);
56
	}
57

  
58
	/**
59
	  * Crea ThreadPoolException.
60
	 *
61
	 * @param cause
62
	 */
63
	public PostGISRasterCoreException(Throwable cause) {
64
		super(cause);
65
	}
66
    
67
    /**
68
     * Cuts the message text to force its lines to be shorter or equal to 
69
     * lineLength.
70
     * @param message, the message.
71
     * @param lineLength, the max line length in number of characters.
72
     * @return the formated message.
73
     */
74
    private static String format(String message, int lineLength){
75
        if (message.length() <= lineLength) return message;
76
        String[] lines = message.split("\n");
77
        String theMessage = "";
78
        for (int i = 0; i < lines.length; i++) {
79
            String line = lines[i].trim();
80
            if (line.length()<lineLength)
81
                theMessage += line+"\n";
82
            else {
83
                String[] chunks = line.split(" ");
84
                String newLine = "";
85
                for (int j = 0; j < chunks.length; j++) {
86
                    int currentLength = newLine.length();
87
                    chunks[j] = chunks[j].trim();
88
                    if (chunks[j].length()==0)
89
                        continue;
90
                    if ((currentLength + chunks[j].length() + " ".length()) <= lineLength)
91
                        newLine += chunks[j] + " ";
92
                    else {
93
                        newLine += "\n"+chunks[j]+" ";
94
                        theMessage += newLine;
95
                        newLine = "";
96
                    }
97
                }
98
                
99
            }
100
        }
101
        return theMessage;
102
    }
103
}
0 104

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.io/src/main/java/org/gvsig/raster/postgis/io/PostGISRasterServerExplorer.java
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
package org.gvsig.raster.postgis.io;
24

  
25
import java.util.List;
26

  
27
import org.gvsig.fmap.dal.DALLocator;
28
import org.gvsig.fmap.dal.DataManager;
29
import org.gvsig.fmap.dal.DataServerExplorerParameters;
30
import org.gvsig.fmap.dal.DataStoreParameters;
31
import org.gvsig.fmap.dal.NewDataStoreParameters;
32
import org.gvsig.fmap.dal.exception.DataException;
33
import org.gvsig.fmap.dal.exception.InitializeException;
34
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
35
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider;
36
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices;
37

  
38
/**
39
 * Server explorer for a PostGIS raster server
40
 * @author Nacho Brodin (nachobrodin@gmail.com)
41
 */
42
 @SuppressWarnings("unchecked")
43
public class PostGISRasterServerExplorer implements DataServerExplorerProvider {
44
	public static final String                    NAME                     = PostGISRasterProvider.NAME;
45
	private PostGISRasterServerExplorerParameters parameters               = null;
46
	
47
	public PostGISRasterServerExplorer(
48
			PostGISRasterServerExplorerParameters parameters,
49
			DataServerExplorerProviderServices services)
50
			throws InitializeException {
51
		this.parameters = parameters;
52
	}
53
	
54
	public DataServerExplorerProviderServices getServerExplorerProviderServices() {
55
		return null;
56
	}
57

  
58
	public boolean add(String provider, NewDataStoreParameters parameters,
59
			boolean overwrite) throws DataException {
60
		return false;
61
	}
62

  
63
	public boolean canAdd() {
64
		return false;
65
	}
66

  
67
	public boolean canAdd(String storeName) throws DataException {
68
		return false;
69
	}
70

  
71
	public NewDataStoreParameters getAddParameters(String storeName)
72
			throws DataException {
73
		return null;
74
	}
75

  
76
	public List getDataStoreProviderNames() {
77
		return null;
78
	}
79

  
80
	public DataServerExplorerParameters getParameters() {
81
		return null;
82
	}
83

  
84
	public String getProviderName() {
85
		return null;
86
	}
87

  
88
	public List list() throws DataException {
89
		return null;
90
	}
91

  
92
	public List list(int mode) throws DataException {
93
		return null;
94
	}
95

  
96
	public void remove(DataStoreParameters parameters) throws DataException {
97
		
98
	}
99

  
100
	public void dispose() {
101
		
102
	}
103
	
104
	public DataStoreParameters getStoreParameters() throws PostGISRasterCoreException {
105
		DataManager manager = DALLocator.getDataManager();
106
		PostGISRasterDataParameters params = null;
107
		try {
108
			params = (PostGISRasterDataParameters) manager.createStoreParameters(PostGISRasterProvider.NAME);
109
			params.setURI(parameters.getHost());
110
		} catch (InitializeException e) {
111
			throw new PostGISRasterCoreException("Error initializating parameters", e);
112
		} catch (ProviderNotRegisteredException e) {
113
			throw new PostGISRasterCoreException("Provider not registered", e);
114
		}
115
		return params;
116
	}
117
	
118
}
0 119

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.io/src/main/java/org/gvsig/raster/postgis/io/PostGISRasterProvider.java
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.raster.postgis.io;
23

  
24
import java.awt.geom.AffineTransform;
25
import java.util.ArrayList;
26
import java.util.Collections;
27
import java.util.Iterator;
28
import java.util.List;
29

  
30
import org.gvsig.fmap.dal.DALLocator;
31
import org.gvsig.fmap.dal.DataManager;
32
import org.gvsig.fmap.dal.DataStore;
33
import org.gvsig.fmap.dal.coverage.RasterLocator;
34
import org.gvsig.fmap.dal.coverage.dataset.Buffer;
35
import org.gvsig.fmap.dal.coverage.datastruct.BandList;
36
import org.gvsig.fmap.dal.coverage.datastruct.DatasetBand;
37
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
38
import org.gvsig.fmap.dal.coverage.exception.BandNotFoundInListException;
39
import org.gvsig.fmap.dal.coverage.exception.NotSupportedExtensionException;
40
import org.gvsig.fmap.dal.coverage.exception.ProcessInterruptedException;
41
import org.gvsig.fmap.dal.coverage.exception.RasterDriverException;
42
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters;
43
import org.gvsig.fmap.dal.exception.DataException;
44
import org.gvsig.fmap.dal.exception.InitializeException;
45
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
46
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
47
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer;
48
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
49
import org.gvsig.fmap.dal.spi.DataStoreProviderServices;
50
import org.gvsig.fmap.dal.store.db.DBStoreParameters;
51
import org.gvsig.metadata.MetadataLocator;
52
import org.gvsig.raster.cache.tile.provider.TileListener;
53
import org.gvsig.raster.gdal.io.GdalDataParameters;
54
import org.gvsig.raster.gdal.io.GdalProvider;
55
import org.gvsig.raster.impl.buffer.DefaultRasterQuery;
56
import org.gvsig.raster.impl.datastruct.BandListImpl;
57
import org.gvsig.raster.impl.datastruct.DatasetBandImpl;
58
import org.gvsig.raster.impl.provider.DefaultRasterProvider;
59
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
60
import org.gvsig.raster.impl.store.DefaultStoreFactory;
61
import org.gvsig.tools.ToolsLocator;
62
import org.gvsig.tools.task.TaskStatus;
63
import org.slf4j.Logger;
64
import org.slf4j.LoggerFactory;
65
/**
66
 * This class represents the data access just for PostGIS raster databases.
67
 * @author Nacho Brodin (nachobrodin@gmail.com)
68
 */
69
public class PostGISRasterProvider extends GdalProvider {
70
	public static String           NAME                     = "PostGIS Raster Store";
71
	public static String           DESCRIPTION              = "PostGIS Raster file";
72
	public static final String     METADATA_DEFINITION_NAME = "PostGISRasterStore";
73
	private static final String    OVERVIEW_PREFIX          = "o_";
74
	
75
	private DBServerExplorer       dbServerExplorer         = null;
76
	private DBStoreParameters      dbParameters             = null;
77
	private ArrayList<Overview>    overviews                = null;
78
	private DataManager            dataManager              = DALLocator.getDataManager();
79
	private DefaultRasterProvider  selectedProvider         = null;
80
	private Overview               mainOverview             = null;
81
	private static Logger          logger                   = LoggerFactory.getLogger(PostGISRasterProvider.class.getName());
82
	
83
	class Overview implements Comparable<Overview> {
84
		public int                         width               = 0;
85
		public int                         height              = 0;
86
		public int                         factor              = 0;
87
		public double                      pxSizeOverview      = 0;
88
		public DefaultRasterProvider       provider            = null;
89
		
90
		public Overview() {
91
			
92
		}
93
		
94
		public Overview(int f, int w, int h, PostGISRasterDataParameters p) throws NotSupportedExtensionException {
95
			this.width = w;
96
			this.height = h;
97
			this.factor = f;
98
			if(p != null)
99
				createProvider(p);
100
			this.pxSizeOverview = getExtent().width() / (double)w;
101
		}
102
		
103
		public void createProvider(PostGISRasterDataParameters p) throws NotSupportedExtensionException {
104
			GdalDataParameters gdalParams = new GdalDataParameters();
105
			gdalParams.setURI(p.getURI());
106
			try {
107
				this.provider = new GdalProvider(gdalParams, storeServices);
108
			} catch (NotSupportedExtensionException e) {
109
				logger.info("===>" + gdalParams.getURI() + " " + e.getMessage(), e);
110
			}
111
			this.width = (int)provider.getWidth();
112
			this.height = (int)provider.getHeight();
113
			this.pxSizeOverview = provider.getExtent().width() / (double)this.width;
114
		}
115
		
116
		public int compareTo(Overview o) {
117
			if(factor < o.factor)
118
				return -1;
119
			if(factor > o.factor)
120
				return 1;
121
			return 0;
122
		}
123
	}
124
	
125
	public static void register() {
126
		RasterLocator.getManager().registerFileProvidersTiled(PostGISRasterProvider.class);
127
		
128
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
129
		if (dataman != null && !dataman.getStoreProviders().contains(NAME)) {
130
			dataman.registerStoreProvider(NAME,
131
					PostGISRasterProvider.class, PostGISRasterDataParameters.class);
132
		}
133

  
134
		if (!dataman.getExplorerProviders().contains(PostGISRasterProvider.NAME)) {
135
			dataman.registerExplorerProvider(PostGISRasterServerExplorer.NAME, PostGISRasterServerExplorer.class, PostGISRasterServerExplorerParameters.class);
136
		}
137
		dataman.registerStoreFactory(NAME, DefaultStoreFactory.class);
138
	}
139
	
140
	public PostGISRasterProvider() {
141
		
142
	}
143
	
144
	public PostGISRasterProvider (PostGISRasterDataParameters params,
145
			DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
146
		super(params, storeServices, ToolsLocator.getDynObjectManager()
147
				.createDynObject(
148
						MetadataLocator.getMetadataManager().getDefinition(
149
								DataStore.METADATA_DEFINITION_NAME)));
150
		init(params, storeServices);
151
	}
152
	
153
	/**
154
	 * Creates data base references and loads structures with the information and metadata
155
	 * @param params load parameters
156
	 * @throws NotSupportedExtensionException
157
	 */
158
	public void init (AbstractRasterDataParameters params,
159
			DataStoreProviderServices storeServices) throws NotSupportedExtensionException {
160
		try {
161
			setParam(storeServices, params);
162
			mainOverview = new Overview();
163
			mainOverview.createProvider((PostGISRasterDataParameters)param);
164
			mainOverview.factor = 1;
165
			file = ((GdalProvider)mainOverview.provider).getNative();
166
			setColorInterpretation(file.getColorInterpretation());
167
			setColorTable(file.getColorTable());
168
			noData = file.getNoDataValue();
169
			wktProjection = file.getProjectionRef();
170
			//CrsWkt crs = new CrsWkt(wktProjection);
171
			//IProjection proj = CRSFactory.getCRS("EPSG:23030");
172
			ownTransformation = file.getOwnTransformation();
173
			externalTransformation = (AffineTransform)ownTransformation.clone();
174
			bandCount = file.getRasterCount();
175
			load();
176
		} catch (Exception e) {
177
			throw new NotSupportedExtensionException("Gdal library can't be initialized with this PostGIS raster parameters", e);
178
		} 
179

  
180
		//Obtenemos el tipo de dato de gdal y lo convertimos el de RasterBuf
181
		int[] dt = new int[file.getDataType().length];
182
		for (int i = 0; i < dt.length; i++)
183
			dt[i] = rasterUtil.getRasterBufTypeFromGdalType(file.getDataType()[i]);
184
		setDataType(dt);
185
		
186
		PostGISRasterDataParameters p = (PostGISRasterDataParameters)params;
187
		//Object obj = p.getDynValue(PostGISRasterDataParameters.FIELD_DBPARAMS);
188
		dbParameters = (DBStoreParameters)p.getDynValue(PostGISRasterDataParameters.FIELD_DBPARAMS);
189
		dbServerExplorer = (DBServerExplorer)p.getDynValue(PostGISRasterDataParameters.FIELD_DBEXPLORER);
190
	}
191
	
192
	/*
193
	 * (non-Javadoc)
194
	 * @see org.gvsig.raster.impl.provider.RasterProvider#getRMFFile()
195
	 */
196
	public String getRMFFile() {
197
		if(uri.startsWith("PG:host=")) {
198
			String uri = getURI().replace("'", "");
199
			return uri + ".rmf";
200
		} else 
201
			return fileUtil.getNameWithoutExtension(uri) + ".rmf";
202
	}
203
	
204
	/**
205
	 * Reads overviews from database. The overviews in PostGIS raster are loaded 
206
	 * in separated tables. The name of those tables is the same that the original table
207
	 * with a overview prefix. Now this prefix is "o_X_" where the X is a factor scale.
208
	 * 
209
	 * For that reason the overview object contains the DataParameter which correspond
210
	 * to each table.
211
	 * @throws DataException 
212
	 * @throws DataException
213
	 */
214
	@SuppressWarnings("unchecked")
215
	private void readOverviews() throws DataException  {
216
		if(overviews == null) {
217
			overviews = new ArrayList<Overview>();
218
			String mainHost = ((PostGISRasterDataParameters)param).getURI();
219

  
220
			String mainTable = dbParameters.getTable();
221
			List parameters = dbServerExplorer.list();
222

  
223
			int mainFactor = 1; 
224
				
225
			if(isOverview(mainTable, mainTable)) {
226
				mainFactor = getFactor(mainTable);
227
			}
228
			overviews.add(mainOverview);
229
			
230
			Iterator iter = parameters.iterator();
231
			while (iter.hasNext()) {
232
				DBStoreParameters p = (DBStoreParameters) iter.next();
233
				String tname = p.getTable();
234

  
235
				try {
236
					if(isOverview(mainTable, tname)) {
237
						Overview o = new Overview();
238
						o.factor = (getFactor(tname) / mainFactor);
239
						o.width = (int)(getWidth() / o.factor);
240
						o.height = (int)(getHeight() / o.factor);
241
						o.pxSizeOverview = getExtent().width() / (double)o.width;
242
						o.createProvider(createParameters(mainHost, mainTable, tname));
243
						overviews.add(o);
244
					}
245
				} catch (NumberFormatException e) {
246
				} catch (PostGISRasterCoreException e) {
247
				} catch (ValidateDataParametersException e) {
248
				} catch (NotSupportedExtensionException e) {
249
				}
250
			}
251
			Collections.sort(overviews);
252
		}
253
	}
254
	
255
	/**
256
	 * Returns true if tname is an overview of mainTable
257
	 * @param mainTable
258
	 * @param tname
259
	 * @return
260
	 */
261
	private boolean isOverview(String mainTable, String tname) throws NumberFormatException {
262
		if(mainTable.compareTo(tname) != 0) {
263
			return ((tname.endsWith(mainTable) && tname.startsWith(OVERVIEW_PREFIX)) ||
264
					(tname.startsWith(OVERVIEW_PREFIX) && mainTable.startsWith(OVERVIEW_PREFIX) && getFactor(tname) > getFactor(mainTable)));
265
		}
266
		return false;
267
	}
268
	
269
	/**
270
	 * Gets the overview factor number reading the name of the table
271
	 * @param tname
272
	 * @return
273
	 * @throws NumberFormatException
274
	 */
275
	private int getFactor(String tname) throws NumberFormatException {
276
		String factor = tname.substring(tname.indexOf('_') + 1);
277
		factor = factor.substring(0, factor.indexOf('_'));
278
		return new Integer(factor);
279
	}
280
	
281
	/**
282
	 * Creates the list of parameters
283
	 * @param mainHost
284
	 * @param mainTable
285
	 * @param tableName
286
	 * @return
287
	 * @throws PostGISRasterCoreException 
288
	 * @throws PostGISRasterCoreException
289
	 * @throws ProviderNotRegisteredException 
290
	 * @throws InitializeException 
291
	 * @throws ValidateDataParametersException 
292
	 */
293
	@SuppressWarnings("deprecation")
294
	private PostGISRasterDataParameters createParameters(String mainHost, String mainTable, String tableName) throws PostGISRasterCoreException, ValidateDataParametersException, InitializeException, ProviderNotRegisteredException {
295
		String newHost = mainHost.replaceFirst(mainTable, tableName);
296
		
297
		PostGISRasterServerExplorerParameters explorerParams = (PostGISRasterServerExplorerParameters) dataManager.createServerExplorerParameters(PostGISRasterServerExplorer.NAME);
298
		explorerParams.setHost(newHost);
299
		PostGISRasterServerExplorer explorer = (PostGISRasterServerExplorer) dataManager.createServerExplorer(explorerParams);
300
		RasterDataParameters storeParameters = (RasterDataParameters)explorer.getStoreParameters();
301
		storeParameters.setURI(newHost);
302
		return (PostGISRasterDataParameters)storeParameters;
303
	}
304
	
305
	/**
306
	 * Selects the right overview. The right overview means the first 
307
	 * one with a pixel size lesser or equals than the original. 
308
	 * @param pixels
309
	 * @param mts
310
	 */
311
	private void overviewSelector(int pixels, double mts) {
312
		this.selectedProvider = overviews.get(overviews.size() - 1).provider;
313
		//System.out.println("*************" + overviews.get(overviews.size() - 1).pxSizeOverview + "**************");
314
		double pxSizeRequest = mts / (double)pixels;
315
		for (int i = overviews.size() - 1; i > 0; i--) {
316
			Overview ovb = overviews.get(i);
317
			if(pxSizeRequest <= ovb.pxSizeOverview) {
318
				this.selectedProvider = ovb.provider;
319
				//System.out.println(ovb.pxSizeOverview);
320
			}
321
		}
322
		//System.out.println("***************************");
323
	}
324
	
325
	/*
326
	 * (non-Javadoc)
327
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.raster.cache.tile.provider.TileListener)
328
	 */
329
	public void getWindow(Extent ex, int bufWidth, int bufHeight, 
330
			BandList bandList, TileListener listener, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
331
//		PostGISRasterDataParameters p = (PostGISRasterDataParameters)param;
332
//		Buffer buf = RasterLocator.getManager().createBuffer(getDataType()[0], bufWidth, bufHeight, getBandCount(), true);
333
//		TileCacheManager m = TileCacheLocator.getManager();
334
//		Tile tile = m.createTile(-1, 0, 0);
335
//		
336
//		//Creamos un BandList con todas las bandas del fichero
337
//		BandList bl = new BandListImpl();
338
//		for(int i = 0; i < getBandCount(); i++) {
339
//			try {
340
//				DatasetBand band = new DatasetBandImpl(selectedProvider.getURIOfFirstProvider(), i, getDataType()[i], getBandCount());
341
//				bl.addBand(band, i);
342
//			} catch(BandNotFoundInListException e) {
343
//				//No a?adimos la banda
344
//			}
345
//		}
346
//		
347
//		if(p.getNumberOfBlocks() > 1) {
348
//			for (int i = 0; i < p.getNumberOfBlocks(); i++) {
349
//				GdalNative gdal;
350
//				try {
351
//					gdal = new GdalNative(p.getURI() + " column='rast' where='rid = " + i + "'");
352
//					gdal.readWindow(buf, bandList, 0, 0, gdal.width, gdal.height, bufWidth, bufHeight);
353
//					Extent ext = gdal.getExtentWithoutRot();
354
//					tile.setUl(new Point2D.Double(ext.getULX(), ext.getULY()));
355
//					tile.setLr(new Point2D.Double(ext.getLRX(), ext.getLRY()));
356
//					tile.setData(new Object[]{buf, null, null});
357
//					listener.tileReady(tile);
358
//				} catch (GdalException e) {
359
//					throw new RasterDriverException("", e);
360
//				} catch (IOException e) {
361
//					throw new RasterDriverException("", e);
362
//				} catch (TileGettingException e) {
363
//					throw new RasterDriverException("", e);
364
//				}
365
//			}
366
//		}
367
		super.getWindow(ex, bufWidth, bufHeight, bandList, listener, status);
368
	}
369

  
370
	/*
371
	 * (non-Javadoc)
372
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(org.gvsig.fmap.dal.coverage.datastruct.Extent, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer)
373
	 */
374
	public Buffer getWindow(Extent ex, BandList bandList, Buffer rasterBuf, TaskStatus status) 
375
		throws ProcessInterruptedException, RasterDriverException {
376
		return super.getWindow(ex, bandList, rasterBuf, status);
377
	}
378

  
379
	/*
380
	 * (non-Javadoc)
381
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer, boolean)
382
	 */
383
	public Buffer getWindow(double ulx, double uly, double w, double h, 
384
			BandList bandList, Buffer rasterBuf, boolean adjustToExtent, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
385
		return super.getWindow(ulx, uly, w, h, bandList, rasterBuf, adjustToExtent, status);
386
	}
387

  
388
	/*
389
	 * (non-Javadoc)
390
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(double, double, double, double, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer, boolean)
391
	 */
392
	public Buffer getWindow(Extent extent, 
393
			int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf, boolean adjustToExtent) throws ProcessInterruptedException, RasterDriverException {
394

  
395
		try {
396
			readOverviews();
397
		} catch (DataException e) {
398
			throw new RasterDriverException("Overviews can't be read", e);
399
		}
400

  
401
		overviewSelector(bufWidth, extent.width());
402
		//Creamos un BandList con todas las bandas del fichero
403
		BandList bl = new BandListImpl();
404
		for(int i = 0; i < getBandCount(); i++) {
405
			try {
406
				DatasetBand band = new DatasetBandImpl(selectedProvider.getURIOfFirstProvider(), i, getDataType()[i], getBandCount());
407
				bl.addBand(band, i);
408
			} catch(BandNotFoundInListException e) {
409
				//No a?adimos la banda
410
			}
411
		}
412
		bl.setDrawableBands(bandList.getDrawableBands());
413

  
414
		DefaultRasterQuery q = (DefaultRasterQuery)RasterLocator.getManager().createQuery();
415
		q.setAreaOfInterest(extent, bufWidth, bufHeight);
416
		q.setBandList(bandList);
417
		q.setBuffer(rasterBuf);
418
		q.setAdjustToExtent(adjustToExtent);
419
		return selectedProvider.getDataSet(q);
420
	}
421

  
422
	/*
423
	 * (non-Javadoc)
424
	 * @see org.gvsig.raster.impl.provider.DefaultRasterProvider#getWindowRaster(int, int, int, int, int, int, org.gvsig.fmap.dal.coverage.datastruct.BandList, org.gvsig.fmap.dal.coverage.dataset.Buffer)
425
	 */
426
	public Buffer getWindow(int x, int y, int w, int h, 
427
			int bufWidth, int bufHeight, BandList bandList, Buffer rasterBuf, TaskStatus status) throws ProcessInterruptedException, RasterDriverException {
428
		return super.getWindow(x, y, w, h, bandList, rasterBuf, status);
429
	}
430

  
431
	/*
432
	 * (non-Javadoc)
433
	 * @see org.gvsig.raster.impl.provider.RasterProvider#isTiled()
434
	 */
435
	/*public boolean isTiled() {
436
		PostGISRasterDataParameters p = (PostGISRasterDataParameters)param;
437
		return p.getNumberOfBlocks() > 1;
438
	}*/
439

  
440
}
0 441

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.io/src/main/java/org/gvsig/raster/postgis/io/PostGISRasterServerExplorerParameters.java
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
package org.gvsig.raster.postgis.io;
24

  
25
import org.gvsig.fmap.dal.DataServerExplorerParameters;
26
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
27
import org.gvsig.tools.ToolsLocator;
28
import org.gvsig.tools.dataTypes.DataTypes;
29
import org.gvsig.tools.dynobject.DelegatedDynObject;
30
import org.gvsig.tools.dynobject.DynClass;
31
import org.gvsig.tools.dynobject.DynField;
32
import org.gvsig.tools.dynobject.DynObjectManager;
33

  
34
/**
35
 * Parameters for the PostGIS Raster provider
36
 * @author Nacho Brodin (nachobrodin@gmail.com)
37
 */
38
public class PostGISRasterServerExplorerParameters extends AbstractDataParameters implements DataServerExplorerParameters {
39
	public static final String     DYNCLASS_NAME       = "PostGISRasterServerExplorerParameters";
40
	protected static final String  FIELD_HOST          = "host";
41
	protected static DynClass      DYNCLASS            = null;
42
	private DelegatedDynObject     delegatedDynObject  = null;
43
	
44
	public PostGISRasterServerExplorerParameters() {
45
		super();
46
		initialize();
47
	}
48

  
49
	protected void initialize() {
50
		this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
51
				.getDynObjectManager().createDynObject(
52
						DYNCLASS);
53
	}
54
	
55
	@SuppressWarnings("deprecation")
56
	public static void registerDynClass() {
57
		DynObjectManager dynman = ToolsLocator.getDynObjectManager();
58
		DynClass dynClass;
59
		DynField field;
60
		
61
		if(dynman == null)
62
			return;
63
		
64
		if (DYNCLASS == null) {
65
			dynClass = dynman.add(DYNCLASS_NAME);
66

  
67
			field = dynClass.addDynField(FIELD_HOST);
68
			field.setTheTypeOfAvailableValues(DynField.ANY);
69
			field.setDescription("Uniform Resource Identifier (File name or URL)");
70
			field.setType(DataTypes.STRING);
71
			field.setMandatory(true);
72
			
73
			DYNCLASS = dynClass;
74
		}
75

  
76
	}
77
	
78
	protected DelegatedDynObject getDelegatedDynObject() {
79
		return delegatedDynObject;
80
	}
81
	
82
	/**
83
	 * Gets the assigned host
84
	 * @return
85
	 */
86
	public String getHost() {
87
		return (String) this.getDynValue(FIELD_HOST);
88
	}
89

  
90
	/**
91
	 * Assign the host to this explorer
92
	 * @param host
93
	 */
94
	public void setHost(String host) {
95
		this.setDynValue(FIELD_HOST, host);
96
	}
97

  
98
	/*
99
	 * (non-Javadoc)
100
	 * @see org.gvsig.fmap.dal.DataStoreParameters#getDataStoreName()
101
	 */
102
	public String getDataStoreName() {
103
		return PostGISRasterProvider.NAME;
104
	}
105
	
106
	/*
107
	 * (non-Javadoc)
108
	 * @see org.gvsig.fmap.dal.DataStoreParameters#getDescription()
109
	 */
110
	public String getDescription() {
111
		return PostGISRasterProvider.DESCRIPTION;
112
	}
113

  
114
	public String getExplorerName() {
115
		return PostGISRasterProvider.NAME;
116
	}
117
}
0 118

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.io/src/main/java/org/gvsig/raster/postgis/io/PostGISRasterDataParameters.java
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
package org.gvsig.raster.postgis.io;
24

  
25
import org.gvsig.fmap.dal.DataParameters;
26
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer;
27
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
28
import org.gvsig.tools.ToolsLocator;
29
import org.gvsig.tools.dynobject.DelegatedDynObject;
30
import org.gvsig.tools.dynobject.DynClass;
31
import org.gvsig.tools.dynobject.DynField;
32
import org.gvsig.tools.dynobject.DynObjectManager;
33
import org.gvsig.tools.dynobject.DynStruct;
34
import org.gvsig.tools.persistence.PersistenceManager;
35
import org.gvsig.tools.persistence.PersistentState;
36
import org.gvsig.tools.persistence.exception.PersistenceException;
37

  
38
/**
39
 * Parameters for the PostGIS provider
40
 * @author Nacho Brodin (nachobrodin@gmail.com)
41
 */
42
public class PostGISRasterDataParameters extends AbstractRasterDataParameters {
43
	public static final String         DYNCLASS_NAME                = "PostGISRasterDataParameters";
44
	protected DelegatedDynObject       delegatedDynObject           = null;
45
	private static DynClass            DYNCLASS                     = null;
46
	public static final String         FIELD_DBPARAMS               = "DBPARAMS";
47
	public static final String         FIELD_DBEXPLORER             = "DBEXPLORER";
48
	protected static final String      FIELD_BLOCKS                 = "BLOCKS";
49
	
50
	public static void registerDynClass() {
51
		DynObjectManager dynman = ToolsLocator.getDynObjectManager();
52
		DynClass dynClass;
53
		DynField field;
54
		
55
		if(dynman == null)
56
			return;
57
		
58
		if (DYNCLASS == null) {
59
			dynClass = AbstractRasterDataParameters.registerDynClass(DYNCLASS_NAME);
60
			
61
			field = dynClass.addDynFieldObject(FIELD_DBPARAMS);
62
			field.setDescription("Parameters for the selected table");
63
			field.setClassOfValue(Object.class);
64
			field.setMandatory(false);
65
			
66
			field = dynClass.addDynFieldObject(FIELD_DBEXPLORER);
67
			field.setDescription("Explorer for databases");
68
			field.setClassOfValue(Object.class);
69
			field.setMandatory(false);
70
			
71
			field = dynClass.addDynFieldLong(FIELD_BLOCKS);
72
			field.setDescription("Number of blocks of the selected table.");
73
			field.setClassOfValue(Long.class);
74
			field.setMandatory(true);
75
			
76
			DYNCLASS = dynClass;
77
		}
78
	}
79
	
80
	public PostGISRasterDataParameters() {
81
		super();
82
		initialize();
83
	}
84
	
85
	protected void initialize() {
86
		this.delegatedDynObject = (DelegatedDynObject) ToolsLocator
87
				.getDynObjectManager().createDynObject(
88
						DYNCLASS);
89
	}
90
	
91
	/*
92
	 * (non-Javadoc)
93
	 * @see org.gvsig.fmap.dal.DataStoreParameters#getDataStoreName()
94
	 */
95
	public String getDataStoreName() {
96
		return PostGISRasterProvider.NAME;
97
	}
98

  
99
	/*
100
	 * (non-Javadoc)
101
	 * @see org.gvsig.fmap.dal.DataStoreParameters#getDescription()
102
	 */
103
	public String getDescription() {
104
		return PostGISRasterProvider.DESCRIPTION;
105
	}
106

  
107
	/*
108
	 * (non-Javadoc)
109
	 * @see org.gvsig.raster.impl.store.AbstractRasterDataParameters#loadFromState(org.gvsig.tools.persistence.PersistentState)
110
	 */
111
	public void loadFromState(PersistentState state)
112
	throws PersistenceException {
113
		super.loadFromState(state);
114
	}
115

  
116
	/*
117
	 * (non-Javadoc)
118
	 * @see org.gvsig.raster.impl.store.AbstractRasterDataParameters#saveToState(org.gvsig.tools.persistence.PersistentState)
119
	 */
120
	public void saveToState(PersistentState state) throws PersistenceException {
121
		super.saveToState(state);
122
	}	
123

  
124
	public static void registerPersistence() {
125
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
126
		DynStruct definition = manager.getDefinition("PostGISRasterDataParameters_Persistent");
127
		if( definition == null ) {
128
			definition = manager.addDefinition(
129
					PostGISRasterDataParameters.class,
130
					"PostGISRasterDataParameters_Persistent",
131
					"PostGISRasterDataParameters Persistent",
132
					null, 
133
					null
134
			);
135
			AbstractRasterDataParameters.registerPersistence(definition);
136
		}
137
	}
138

  
139
	@Override
140
	protected DelegatedDynObject getDelegatedDynObject() {
141
		return delegatedDynObject;
142
	}
143

  
144
	public boolean isOverridingHost() {
145
		return false;
146
	}
147

  
148
	public void setOverrideHost(boolean over) {
149
		
150
	}
151
	
152
	public DataParameters getDBStoreParameters() {
153
		return (DataParameters) this.getDynValue(FIELD_DBPARAMS);
154
	}
155
	
156
	public void setDBStoreParameters(DataParameters dbStoreParameters) {
157
		this.setDynValue(FIELD_DBPARAMS, dbStoreParameters);
158
	}
159
	
160
	public DBServerExplorer getDBExplorer() {
161
		return (DBServerExplorer) this.getDynValue(FIELD_DBEXPLORER);
162
	}
163
	
164
	public void setDBExplorer(DBServerExplorer dbStoreParameters) {
165
		this.setDynValue(FIELD_DBEXPLORER, dbStoreParameters);
166
	}
167
	
168
	/**
169
	 * Gets the number of blocks of the selected table
170
	 * @return
171
	 */
172
	public long getNumberOfBlocks() {
173
		return (Long) this.getDynValue(FIELD_BLOCKS);
174
	}
175

  
176
	/**
177
	 * Gets the number of blocks of the selected table
178
	 * @param host
179
	 */
180
	public void setNumberOfBlocks(long blocks) {
181
		this.setDynValue(FIELD_BLOCKS, blocks);
182
	}
183
}
0 184

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.io/pom.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3
	<modelVersion>4.0.0</modelVersion>
4
	<artifactId>org.gvsig.raster.postgis.io</artifactId>
5
	<packaging>jar</packaging>
6
	<name>org.gvsig.raster.postgis.io</name>
7
	<parent>
8
		<groupId>org.gvsig</groupId>
9
		<artifactId>org.gvsig.raster.postgis</artifactId>
10
		<version>2.0.0</version>
11
	</parent>
12
    <properties>
13
        <build-dir>${basedir}/../../build</build-dir>
14
    </properties>
15
	<dependencies>
16
		<dependency>
17
			<groupId>org.gvsig</groupId>
18
			<artifactId>org.gvsig.raster.cache.lib.api</artifactId>
19
            <scope>compile</scope>
20
		</dependency>
21
        <dependency>
22
            <groupId>org.gvsig</groupId>
23
            <artifactId>org.gvsig.raster.cache.lib.impl</artifactId>
24
            <scope>compile</scope>
25
        </dependency>
26
		<dependency>
27
			<groupId>org.gvsig</groupId>
28
			<artifactId>org.gvsig.raster.lib.api</artifactId>
29
            <scope>compile</scope>
30
		</dependency>
31
        <dependency>
32
            <groupId>org.gvsig</groupId>
33
            <artifactId>org.gvsig.raster.lib.impl</artifactId>
34
            <scope>compile</scope>
35
        </dependency>
36
        <dependency>
37
            <groupId>org.gvsig</groupId>
38
            <artifactId>org.gvsig.fmap.dal</artifactId>
39
            <scope>compile</scope>
40
        </dependency>
41
        <dependency>
42
            <groupId>org.gvsig</groupId>
43
            <artifactId>org.gvsig.fmap.dal</artifactId>
44
            <classifier>spi</classifier>
45
            <scope>compile</scope>
46
        </dependency>
47
        <dependency>
48
            <groupId>org.gvsig</groupId>
49
            <artifactId>org.gvsig.fmap.dal.file</artifactId>
50
            <scope>compile</scope>
51
        </dependency>
52
        <dependency>
53
            <groupId>org.gvsig</groupId>
54
            <artifactId>org.gvsig.fmap.dal.db</artifactId>
55
            <scope>compile</scope>
56
        </dependency>
57
        <dependency>
58
            <groupId>org.gvsig</groupId>
59
            <artifactId>org.gvsig.metadata.lib.basic.api</artifactId>
60
            <scope>compile</scope>
61
        </dependency>
62
        <dependency>
63
            <groupId>org.gvsig</groupId>
64
            <artifactId>org.gvsig.projection</artifactId>
65
            <scope>compile</scope>
66
        </dependency>
67
        <dependency>
68
            <groupId>org.gvsig</groupId>
69
            <artifactId>org.gvsig.compat</artifactId>
70
            <scope>compile</scope>
71
        </dependency>
72
        <dependency>
73
            <groupId>org.gvsig</groupId>
74
            <artifactId>org.gvsig.fmap.geometry</artifactId>
75
            <scope>compile</scope>
76
        </dependency>
77
		<dependency>
78
            <groupId>org.gvsig</groupId>
79
            <artifactId>org.gvsig.tools.lib</artifactId>
80
            <scope>compile</scope>
81
        </dependency>
82
        <dependency>
83
			<groupId>org.gvsig</groupId>
84
			<artifactId>org.gvsig.raster.gdal.io</artifactId>
85
            <scope>compile</scope>
86
		</dependency>
87
        <dependency>
88
			<groupId>org.gvsig</groupId>
89
			<artifactId>org.gvsig.jgdal</artifactId>
90
            <scope>compile</scope>
91
		</dependency>
92
        <dependency>
93
            <groupId>org.gvsig</groupId>
94
            <artifactId>org.gvsig.jgdal</artifactId>
95
            <classifier>${native_classifier}</classifier>
96
            <type>tar.gz</type>
97
            <scope>runtime</scope>
98
        </dependency>
99
	</dependencies>
100
</project>
0 101

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.swing/org.gvsig.raster.postgis.swing.impl/src/test/java/org/gvsig/raster/postgis/swing/impl/TestConnectionChooserPanel.java
1
package org.gvsig.raster.postgis.swing.impl;
2

  
3

  
4
import javax.swing.JFrame;
5

  
6
import org.gvsig.raster.postgis.swing.impl.addlayer.ConnectionChooserPanel;
7
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
8

  
9
public class TestConnectionChooserPanel {
10
		private int                          w        = 300;
11
		private int                          h        = 100;
12
		private JFrame                       frame    = new JFrame();
13
		private ConnectionChooserPanel       ui       = null;
14

  
15
		public TestConnectionChooserPanel() {
16
			new DefaultLibrariesInitializer().fullInitialize(true);
17
			ui = new ConnectionChooserPanel(true);
18
			frame.getContentPane().add(ui);
19
			frame.setSize(w, h);
20
			frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
21
			frame.setVisible(true);
22
		}
23

  
24
		public static void main(String[] args) {
25
			new TestConnectionChooserPanel();
26
		}
27
	}
0 28

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.swing/org.gvsig.raster.postgis.swing.impl/src/test/java/org/gvsig/raster/postgis/swing/impl/TestAddLayerPanel.java
1
package org.gvsig.raster.postgis.swing.impl;
2

  
3

  
4
import java.text.DecimalFormat;
5

  
6
import javax.swing.JFrame;
7

  
8
import org.gvsig.raster.postgis.swing.impl.addlayer.AddPostGISRasterLayerDialog;
9
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer;
10

  
11
public class TestAddLayerPanel {
12
		private int                          w        = 300;
13
		private int                          h        = 400;
14
		private JFrame                       frame    = new JFrame();
15
		private AddPostGISRasterLayerDialog  ui       = null;
16

  
17
		public TestAddLayerPanel() {
18
			new DefaultLibrariesInitializer().fullInitialize(true);
19
			ui = new AddPostGISRasterLayerDialog();
20
			frame.getContentPane().add(ui);
21
			frame.setSize(w, h);
22
			frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
23
			frame.setVisible(true);
24
		}
25

  
26
		public static void main(String[] args) {
27
			DecimalFormat decFormat = new DecimalFormat("#.###");
28
			//double d1 = Double.parseDouble("2.0037508E7");
29
			double d2 = Double.parseDouble("-2.003750834E7");
30
			String s = decFormat.format(d2);
31
			System.out.println(s.replace(",", "."));
32
			new TestAddLayerPanel();
33
		}
34
	}
0 35

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.swing/org.gvsig.raster.postgis.swing.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.raster.postgis.swing.impl.PostGISRasterSwingImplLibrary
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.swing/org.gvsig.raster.postgis.swing.impl/src/main/resources/org/gvsig/raster/postgis/swing/impl/i18n/text.properties
1
select_db=Selecci?n de conexi?n
2
tables_chooser=Elecci?n de tablas
3
subdataset_chooser=Elecci?n de subdataset
4
tile_cache=Uso de cach\u00e9 de teselas local
5
tile_cache_tooltip=Marque esta casilla para usar la cach\u00e9 de teselas de almacenamiento local.
0 6

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.swing/org.gvsig.raster.postgis.swing.impl/src/main/java/org/gvsig/raster/postgis/swing/impl/PostGISRasterSwingImplLibrary.java
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.raster.postgis.swing.impl;
23

  
24
import java.util.Locale;
25

  
26
import org.gvsig.andami.IconThemeHelper;
27
import org.gvsig.i18n.Messages;
28
import org.gvsig.raster.postgis.swing.PostGISRasterSwingLibrary;
29
import org.gvsig.raster.postgis.swing.PostGISRasterSwingLocator;
30
import org.gvsig.tools.library.AbstractLibrary;
31
import org.gvsig.tools.library.Library;
32
import org.gvsig.tools.library.LibraryException;
33

  
34
/**
35
 * Library for default swing implementation initialization and configuration.
36
 * 
37
 * @author gvSIG team
38
 * @version $Id$
39
 */
40
public class PostGISRasterSwingImplLibrary extends AbstractLibrary {
41

  
42
	public PostGISRasterSwingImplLibrary() {
43
		super();
44
	}
45
	
46
	@Override
47
	public void doRegistration() {
48
	    this.registerAs(PostGISRasterSwingLibrary.class, Library.TYPE.IMPL);
49
	}
50
	
51
    @Override
52
    protected void doInitialize() throws LibraryException {
53
    	PostGISRasterSwingLocator
54
            .registerSwingManager(DefaultPostGISRasterSwingManager.class);
55
        
56
        
57
        if (!Messages.hasLocales()) {
58
            Messages.addLocale(Locale.getDefault());
59
        }
60
        
61
        Messages.addResourceFamily("org.gvsig.raster.postgis.swing.impl.i18n.text",
62
            PostGISRasterSwingImplLibrary.class.getClassLoader(),
63
            PostGISRasterSwingImplLibrary.class.getClass().getName()); 
64
        
65
        registerIcons();
66
    }
67

  
68
    @Override
69
    protected void doPostInitialize() throws LibraryException {
70
    }
71
    
72
    private void registerIcons() {
73
		IconThemeHelper.registerIcon(null, "icon-jdbc", this);
74
    }
75
}
0 76

  
org.gvsig.raster.postgis/tags/2.0.0/org.gvsig.raster.postgis.swing/org.gvsig.raster.postgis.swing.impl/src/main/java/org/gvsig/raster/postgis/swing/impl/DefaultPostGISRasterSwingManager.java
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.raster.postgis.swing.impl;
23

  
24
import org.gvsig.raster.postgis.swing.AddLayerUI;
25
import org.gvsig.raster.postgis.swing.PostGISRasterSwingManager;
26
import org.gvsig.raster.postgis.swing.PostGISRasterWindowManager;
27
import org.gvsig.raster.postgis.swing.impl.addlayer.AddPostGISRasterLayerDialog;
28
import org.gvsig.tools.ToolsLocator;
29
import org.gvsig.tools.i18n.I18nManager;
30

  
31
/**
32
 * Default implementation of the {@link CartociudadSwingManager}.
33
 * 
34
 * @author gvSIG Team
35
 * @version $Id$
36
 */
37
public class DefaultPostGISRasterSwingManager implements PostGISRasterSwingManager {
38

  
39
    private PostGISRasterWindowManager postGISRasterWindowManager;
40
    private I18nManager i18nmanager = null;
41
   // private DataManager dataManager = null;
42

  
43
    public DefaultPostGISRasterSwingManager() {
44
        this.i18nmanager = ToolsLocator.getI18nManager();       
45
       // this.dataManager = DALLocator.getDataManager();
46
    }
47

  
48
    public String getTranslation(String key) {
49
        return this.i18nmanager.getTranslation(key);
50
    }
51

  
52
    public PostGISRasterWindowManager getWindowManager() {
53
        return postGISRasterWindowManager;
54
    }
55

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff