Revision 4439

View differences:

org.gvsig.raster.wmts/trunk/org.gvsig.raster.wmts/org.gvsig.raster.wmts.app.wmtsclient/src/main/java/org/gvsig/raster/wmts/app/wmtsclient/layer/FLyrWMTS.java
19 19

  
20 20
import org.cresques.cts.ICoordTrans;
21 21
import org.cresques.cts.IProjection;
22
import org.slf4j.Logger;
23
import org.slf4j.LoggerFactory;
22 24

  
23 25
import org.gvsig.fmap.dal.DALLocator;
24 26
import org.gvsig.fmap.dal.DataManager;
......
74 76
import org.gvsig.tools.task.SimpleTaskStatus;
75 77
import org.gvsig.tools.task.TaskStatusManager;
76 78

  
77
import org.slf4j.Logger;
78
import org.slf4j.LoggerFactory;
79

  
80 79
/**
81 80
 * WMTS Layer class.
82 81
 *
......
94 93
	private WMTSServerExplorer           wmtsExplorer              = null;
95 94
	private boolean                      deleteCache               = false;
96 95

  
96
	/**
97
	 * Register the persistence
98
	 */
97 99
	public static void registerPersistent() {
98 100
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
99 101
		DynStruct definition = manager.getDefinition("FLyrWMTS_Persistent");
......
116 118
		DefaultFLyrRaster.registerPersistence(definition);
117 119
	}
118 120

  
121
	/**
122
	 * Constructor
123
	 */
119 124
	public FLyrWMTS() {
120 125
		super();
121 126
		this.updateDrawVersion();
......
126 131
		}
127 132
	}
128 133

  
134
	/**
135
	 * @param host
136
	 * @param srs
137
	 * @return the data store
138
	 * @throws InitializeException
139
	 */
129 140
	public static DataStore createDataStore(String host, IProjection srs) throws InitializeException {
130 141
		DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator.getDataManager();
131 142
		RasterDataParameters params = null;
......
188 199
		} catch (NotAvailableStateException e) {
189 200
			logger.error("Fallo el estado de open. Closed=" + isClosed() + " Awake=" + isAwake(), this, e);
190 201
		}
191
		setProjection(this.dataStore.getProjection());
192
		setFullExtent(this.dataStore.getExtent().toRectangle2D());
202
        if (this.dataStore != null) {
203
            setProjection(this.dataStore.getProjection());
204
            setFullExtent(this.dataStore.getExtent().toRectangle2D());
205
        }
193 206
	}
194 207

  
195 208
	@SuppressWarnings("deprecation")
......
223 236
		enableStopped();
224 237

  
225 238
		if (isWithinScale(scale)) {
226
			if (!viewPort.getAdjustedExtent().intersects(getFullEnvelope()))
239
		    Envelope adjustedExtent = viewPort.getAdjustedEnvelope();
240
			if (!adjustedExtent.intersects(getFullEnvelope())) {
227 241
				return;
228
			Envelope adjustedExtent = viewPort.getAdjustedEnvelope();
242
			}
229 243
			Extent ext = rManager.getDataStructFactory().createExtent(
230 244
					adjustedExtent.getLowerCorner().getX(),
231 245
					adjustedExtent.getUpperCorner().getY(),
......
261 275

  
262 276

  
263 277
	/**
278
	 * @param g
279
	 * @param viewPort
280
	 * @param cancel
281
	 * @param scale
282
	 * @param properties
283
	 * @throws ReadException
264 284
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D,
265 285
	 * 		com.iver.cit.gvsig.fmap.ViewPort,
266 286
	 * 		com.iver.cit.gvsig.fmap.operations.Cancellable)
......
268 288
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet properties)
269 289
	throws ReadException {
270 290

  
291

  
271 292
	}
272 293

  
273
	public void _print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
274
			double scale) throws ReadException {
294
	/**
295
	 * @param g
296
	 * @param viewPort
297
	 * @param cancel
298
	 * @param scale
299
	 * @throws ReadException
300
	 */
301
	public void _print(Graphics2D g, ViewPort viewPort, Cancellable cancel,	double scale) throws ReadException {
275 302
		draw(null, g, viewPort, cancel,scale);
276 303
	}
277 304

  
......
287 314

  
288 315
	/**
289 316
	 * Inserta la extensi?n total de la capa en la proyeccion original.
317
	 * @param envelope
290 318
	 *
291
	 * @param fullExtent
292
	 *            Rect?ngulo.
293 319
	 */
294 320
	public void setFullEnvelope(Envelope envelope) {
295 321
		Envelope cur = this.getFullEnvelope();
......
304 330
		this.updateDrawVersion();
305 331
	}
306 332

  
333
	/**
334
	 * @return the properties.
335
	 */
307 336
	public HashMap<String, Object> getProperties() {
308 337
		HashMap<String, Object> info = new HashMap<String, Object>();
309 338
		WMTSDataParameters par = getWMTSParameters(getParameters());
......
496 525
    public DynObjectSet getInfo(Point p, double tolerance, Cancellable cancel, boolean fast)
497 526
    throws LoadLayerException, DataException {
498 527

  
499
    	Point2D pReal = getMapContext().getViewPort().toMapPoint(p);
528
        org.gvsig.fmap.geom.primitive.Point pReal = getMapContext().getViewPort().convertToMapPoint(p);
500 529
    	String fInfo = null;
501 530
    	try {
502 531
    		fInfo = getDataStore().getInfoByPoint(pReal.getX(), pReal.getY(), new CancelTaskImpl(cancel));
......
554 583
		}
555 584
    }
556 585

  
586
    /**
587
     * @return the data store parameters
588
     */
557 589
    @SuppressWarnings("deprecation")
558 590
	public DataStoreParameters getParameters() {
559 591
    	if(params == null) {
......
602 634

  
603 635
    /**
604 636
     * Gets the explorer
605
     * @return
637
     * @return the server explorer
606 638
     */
607 639
    public WMTSServerExplorer getExplorer() {
608 640
    	return this.wmtsExplorer;
......
650 682

  
651 683
	/**
652 684
	 * Assigns the flag to delete this layer from the cache
653
	 * @param selected
685
	 * @param deleteCache
654 686
	 */
655 687
	public void deleteCache(boolean deleteCache) {
656 688
		this.deleteCache = deleteCache;
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/store/DefaultRasterStore.java
108 108
	 */
109 109
	private List<ROI>                        rois                           = null;
110 110

  
111
	/**
112
	 * Constructor
113
	 */
111 114
	public DefaultRasterStore() {
112 115
		super();
113 116
	}
......
116 119
		provider.reload();
117 120
	}
118 121

  
122
	/**
123
	 * @param provider
124
	 */
119 125
	public void setProvider(RasterProvider provider) {
120 126
		this.provider = provider;
121 127
		parameters = (DataStoreParameters)provider.getDataParameters();
......
270 276
		return provider.getExtentWithoutRot();
271 277
	}
272 278

  
279
	/**
280
	 * @return the extent
281
	 */
273 282
	public Extent getLastSelectedView(){
274 283
		return provider.getView();
275 284
	}
......
346 355
		return this;
347 356
	}
348 357

  
358
	/**
359
	 * @param band
360
	 * @return the affine transform
361
	 */
349 362
	public AffineTransform getAffineTransform(int band){
350 363
		return provider.getAffineTransform();
351 364
	}
......
361 374
	 * esta matriz tendr? la georreferenciaci?n asociada en el worldfile o cabecera. Otras librerias como
362 375
	 * ermapper la petici?n a la libreria se hace en coordenadas geograficas que son las mismas en las
363 376
	 * que pide el usuario de gvSIG por lo que esta matriz en este caso se inicializa con la identidad.
364
	 * @return
377
	 * @return the own affine transform
365 378
	 */
366 379
	public AffineTransform getOwnTransformation() {
367 380
		return provider.getOwnAffineTransform();
......
871 884

  
872 885
	/**
873 886
	 * Gets the list of geo points associated to this provider
874
	 * @return
887
	 * @return GeoPointList
875 888
	 */
876 889
	public GeoPointList getGeoPointList() {
877 890
		return provider.getGeoPointList();
......
884 897
		provider.setGeoPointList(geoPointList);
885 898
	}
886 899

  
900
	/**
901
	 * @return the full envelope
902
	 */
887 903
	public Envelope getFullEnvelope() {
888 904
		Rectangle2D e = getExtent().toRectangle2D();
889 905
		try {
......
929 945
		this.rois = rois;
930 946
	}
931 947

  
948
	/**
949
	 * @param file
950
	 * @throws RmfSerializerException
951
	 */
932 952
	public void setROIsFiles(List<File> file) throws RmfSerializerException {
933 953
		getDataStore().saveROIFileListToRmf(file);
934 954
	}
935 955

  
956
	/**
957
	 * @return the ROI files
958
	 * @throws RmfSerializerException
959
	 */
936 960
	public List<File> getROIsFiles() throws RmfSerializerException {
937 961
		return getDataStore().getROIFileListFromRmf();
938 962
	}
......
966 990
	//Persistence
967 991
	//******************************
968 992

  
993
	/**
994
	 * Register persistence
995
	 */
969 996
	public static void registerPersistence() {
970 997
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
971 998
		DynStruct definition = manager.getDefinition(PERSISTENT_NAME);
......
1064 1091
			DataServerExplorerParameters explorerParams = null;
1065 1092
			explorerParams = datamanager.createServerExplorerParameters(explorerName);
1066 1093
			explorerParams.setDynValue("host", "");
1067
			explorerParams.setDynValue("axisorder", new Boolean(false));
1068 1094
			DataServerExplorer e = datamanager.openServerExplorer(explorerName, explorerParams);
1069 1095
			if(e instanceof RasterDataServerExplorer) {
1070 1096
				explorer = (RasterDataServerExplorer)e;
org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/datastruct/DatasetBandImpl.java
61 61
	//
62 62
	private int                    nBandsInThisProvider    = 0;
63 63

  
64
	/**
65
	 * Constructor
66
	 */
64 67
	public DatasetBandImpl() {
65 68

  
66 69
	}
......
250 253
		try {
251 254
			URI uri = state.getURI("fileName");
252 255
			if(uri != null) {
253
				File file = new File(uri);
254
				if(file.isFile() && file.exists())
255
					fileName = file.getAbsolutePath();
256
				else {
257
					fileName = uri.toString();
258
					if(uri.getScheme() == null || "file".equalsIgnoreCase(uri.getScheme()))
259
						fileName = uri.getPath();
260
				}
256
			    fileName = uri.toString();
257
                if (uri.getScheme() != null && "FILE".equalsIgnoreCase(uri.getScheme())) {
258
                    File file = new File(uri);
259
                    if (file.isFile() && file.exists()) {
260
                        fileName = file.getAbsolutePath();
261
                    } else {
262
                        fileName = uri.getPath();
263
                    }
264
                }
261 265
			}
262 266
		} catch(ClassCastException e) {
263 267
			fileName = state.getString("fileName");
......
289 293
		state.set("rasterBufBandToDrawList", rasterBufBandToDrawList);
290 294
	}
291 295

  
296
	/**
297
	 * Register persistence
298
	 */
292 299
	public static void registerPersistence() {
293 300
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
294 301
		DynStruct definition = manager.getDefinition(PERSISTENT_NAME);
org.gvsig.raster.wms/trunk/org.gvsig.raster.wms/org.gvsig.raster.wms.io/src/main/java/org/gvsig/raster/wms/io/WMSServerExplorerParameters.java
27 27

  
28 28
package org.gvsig.raster.wms.io;
29 29

  
30
import org.slf4j.Logger;
31
import org.slf4j.LoggerFactory;
32

  
30 33
import org.gvsig.fmap.dal.DataServerExplorerParameters;
31 34
import org.gvsig.fmap.dal.spi.AbstractDataParameters;
32 35
import org.gvsig.raster.impl.store.AbstractRasterDataParameters;
......
35 38
import org.gvsig.tools.dynobject.DynClass;
36 39
import org.gvsig.tools.dynobject.DynStruct;
37 40
import org.gvsig.tools.persistence.PersistenceManager;
41
import org.gvsig.tools.persistence.PersistentState;
42
import org.gvsig.tools.persistence.exception.PersistenceException;
38 43

  
39 44
/**
40 45
 * Parameters for the WMS provider
......
44 49
	protected static final String  FIELD_HOST          = "host";
45 50
	protected static DynClass      DYNCLASS            = null;
46 51
	private DelegatedDynObject     delegatedDynObject  = null;
47
	private static final String    FIELD_XYAXISORDER          = "xyaxisorder";
48
	
52
	private static final String    FIELD_XYAXISORDER   = "xyaxisorder";
53
    private static final String    OLD_FIELD_AXISORDER   = "axisorder";
54

  
55
    @SuppressWarnings("unused")
56
    private static final Logger logger = LoggerFactory.getLogger(WMSServerExplorerParameters.class);
57

  
58
	/**
59
	 *
60
	 */
49 61
	public WMSServerExplorerParameters() {
50 62
		super();
51 63
		initialize();
......
56 68
				.getDynObjectManager().createDynObject(
57 69
						registerDynClass());
58 70
	}
59
	
71

  
72
	/**
73
	 * @return the dynstruct
74
	 */
60 75
	public static DynStruct registerDynClass() {
61 76
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
62 77
		DynStruct definition = manager.getDefinition("WMSServerExplorerParameters_Persistent");
......
65 80
					WMSServerExplorerParameters.class,
66 81
					"WMSServerExplorerParameters_Persistent",
67 82
					"WMS Explorer DataParameters Persistency",
68
					null, 
83
					null,
69 84
					null
70 85
			);
71 86
		}
......
74 89

  
75 90
		definition.addDynFieldBoolean(FIELD_XYAXISORDER)
76 91
		.setDescription("Longitude first in axis order")
77
		.setMandatory(false);
92
		.setMandatory(false).setDefaultFieldValue(new Boolean(false));
78 93

  
79 94
		definition.addDynFieldString(FIELD_HOST)
80 95
		.setDescription("Uniform Resource Identifier (File name or URL)")
81
		.setMandatory(false);		
96
		.setMandatory(false);
82 97
		return definition;
83 98
	}
84
	
99

  
85 100
	protected DelegatedDynObject getDelegatedDynObject() {
86 101
		return delegatedDynObject;
87 102
	}
88
	
103

  
89 104
	/**
90 105
	 * Gets the assigned host
91
	 * @return
106
	 * @return the value of host field
92 107
	 */
93 108
	public String getHost() {
94 109
		return (String) this.getDynValue(FIELD_HOST);
......
102 117
		this.setDynValue(FIELD_HOST, host);
103 118
	}
104 119

  
120
	/**
121
	 * @return the provider name
122
	 */
105 123
	public String getDataStoreName() {
106 124
		return WMSProvider.NAME;
107 125
	}
108
	
126

  
127
    /**
128
     * @return the provider description
129
     */
109 130
	public String getDescription() {
110 131
		return WMSProvider.DESCRIPTION;
111 132
	}
......
116 137

  
117 138
	/**
118 139
	 * <p>Gets the behaviour of the WMS client with regards the axis order</p>
119
	 * 
140
	 *
120 141
	 * <p>Returns <code>true</code> if the WMS parser should assume that the
121 142
	 * order of the coordinates follows the XY axis order
122 143
	 * (the first coordinate corresponds to the horizontal X
123 144
	 * axis, while the second  coordinate corresponds to the
124 145
	 * vertical Y axis), regardless the protocol version and CRS in use.</p>
125
	 * 
146
	 *
126 147
	 * <p>Returns <code>false</code> if the WMS parser should decide the
127 148
	 * axis order based on the protocol version and the coordinate
128 149
	 * reference system (CRS) in use. In particular, if protocol
129 150
	 * version is >= 1.3.0, then the WMS parser assumes
130 151
	 * the axis order defined in the official EPSG registry for the
131 152
	 * CRS in use. For versions < 1.3.0, the XY axis order is assumed.</p>
132
	 * 
153
	 *
133 154
	 * <p>The default value is <code>false</code></p>.
134 155
	 * @see #setXyAxisOrder(boolean)
135
	 * @return
156
	 * @return true if axis order is x-y
136 157
	 */
137 158
	public boolean isXyAxisOrder() {
138 159
		if (hasDynValue(FIELD_XYAXISORDER)) {
......
153 174

  
154 175
	/**
155 176
	 * <p>Sets the behaviour of the WMS client with regards the axis order.<p>
156
	 * 
177
	 *
157 178
	 * <p>If set to <code>true</code>, then the XY axis order
158 179
	 * is assumed for all the WMS
159 180
	 * protocol versions and coordinate reference systems.</p>
160
	 * 
181
	 *
161 182
	 * <p>If set to <code>false</code>
162 183
	 * then the WMS parser will decide the axis order based on
163 184
	 * the protocol version and the coordinate reference system (CRS)
......
165 186
	 * version is >= 1.3.0, then the WMS parser assumes
166 187
	 * the axis order defined in the official EPSG registry for the
167 188
	 * CRS in use. For versions < 1.3.0, the XY axis order is assumed.</p>
168
	 * 
169
	 * 
189
	 *
190
	 *
170 191
	 * @param assumeXY
171 192
	 * @see #isXyAxisOrder()
172 193
	 */
173 194
	public void setXyAxisOrder(boolean assumeXY) {
174 195
		this.setDynValue(FIELD_XYAXISORDER, new Boolean(assumeXY));
175 196
	}
197

  
198

  
199
    public void loadFromState(PersistentState state) throws PersistenceException {
200
        super.loadFromState(state);
201

  
202
        // Entre la 2.1 y la 2.2 cambi? la clave de la propiedad axisorder a xyaxisorder
203
        // El siguiente bloque try catch es para mantener compatibilidad con los proyectos de ambas versiones
204
        try {
205
            setDynValue(FIELD_XYAXISORDER, state.get(OLD_FIELD_AXISORDER));
206
        } catch(Throwable t){
207
            //do nothing;
208
        }
209
    }
210

  
211

  
212
    public void setDynValue(String name, Object value) {
213
        if (OLD_FIELD_AXISORDER.equalsIgnoreCase(name)) {
214
            super.setDynValue(FIELD_XYAXISORDER, value);
215
        } else {
216
            super.setDynValue(name, value);
217
        }
218
    }
176 219
}

Also available in: Unified diff