Revision 10626 trunk/extensions/extGeoreferencing/src/org/gvsig/georeferencing/utils/GeoLayerFactory.java

View differences:

GeoLayerFactory.java
26 26
import org.gvsig.georeferencing.gui.dialog.GeoreferencingDialog;
27 27

  
28 28
import com.iver.andami.PluginServices;
29
import com.iver.cit.gvsig.fmap.DriverException;
29
import com.iver.cit.gvsig.exceptions.layers.LoadLayerException;
30 30
import com.iver.cit.gvsig.fmap.ViewPort;
31 31
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
32 32
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
......
44 44
 * @author Nacho Brodin (brodin_ign@gva.es)
45 45
 */
46 46
public class GeoLayerFactory{
47
	
47

  
48 48
	//**********************Params********************************
49
	
49

  
50 50
	//**********************End Params****************************
51
	
51

  
52 52
	//**********************Vars**********************************
53
	
53

  
54 54
	//**********************End Vars**********************************
55
	
55

  
56 56
	//**********************Classes***********************************
57
	
57

  
58 58
	//**********************End Classes*******************************
59 59

  
60 60
	//**********************Methods***********************************
61
	
62
	
61

  
62

  
63 63
	/**
64 64
	 * Crea una capa FLyrPoints a partir de los par?metros de entrada.
65 65
	 * @param lyGeoRaster	Capa a georreferenciar
......
72 72
	 * @param rightViewPort	ViewPort de la miniimagen de coordenadas en pixels
73 73
	 * @return Capa de puntos creada.
74 74
	 */
75
	public static FLyrPoints createFLyrPoints(	FLyrGeoRaster lyGeoRaster, 
76
												Point2D[] pixel, 
77
												Point2D[] map, 
75
	public static FLyrPoints createFLyrPoints(	FLyrGeoRaster lyGeoRaster,
76
												Point2D[] pixel,
77
												Point2D[] map,
78 78
												boolean[] active,
79
												Point2D[] leftCenter, 
79
												Point2D[] leftCenter,
80 80
												Point2D[] rightCenter,
81 81
												ViewPort[] leftViewPort,
82 82
												ViewPort[] rightViewPort){
83 83
		GeoPointPersistence	geoPointPersistence = new GeoPointPersistence();
84 84
		FLyrPoints lyrPoints = new FLyrPoints(lyGeoRaster, geoPointPersistence);
85 85
		geoPointPersistence.setLyrPoints(lyrPoints);
86
		
86

  
87 87
		lyrPoints.getPointManager().newEmptyPoint();
88 88
		GeoreferencingToolsModule.setEnabled(true);
89 89
		View theView = null;
......
101 101
			lyrPoints.setRightViewPort(pos, rightViewPort[i]);
102 102
			lyrPoints.getPointManager().updateData(pos + 1, pixel[i], map[i], lyrPoints.getPointManager().getDialog(), theView);
103 103
		}
104
		
104

  
105 105
		if(lyrPoints.getCountPoints() > 0){
106 106
			GeoreferencingDialog grd = lyrPoints.getPointManager().getDialog();
107 107
			grd.getConectorPanel().getDataPointsTabPanel().
......
110 110
				getTablePointsPanel().getTableControlerPanel().setNItems(lyrPoints.getCountPoints());
111 111
			lyrPoints.getPointManager().selectPoint(0, grd);
112 112
		}
113
		
113

  
114 114
		return lyrPoints;
115 115
	}
116 116

  
117 117
	/**
118
	 * Crea una capa Raster de georreferenciaci?n a partir del nombre driver, fichero y proyecci?n y 
119
	 * coordenadas de georeferenciaci?n. Esta funci?n es para georeferenciar 
118
	 * Crea una capa Raster de georreferenciaci?n a partir del nombre driver, fichero y proyecci?n y
119
	 * coordenadas de georeferenciaci?n. Esta funci?n es para georeferenciar
120 120
	 * capas raster. Para imagenes que no tienen georeferenciaci?n hay que asignarle
121 121
	 * una temporal, normalmente a partir de la vista activa.
122 122
	 *
......
128 128
	 * @param heightPxImg Alto en pixeles de la imagen
129 129
	 *
130 130
	 * @return Nueva capa de tipo raster.
131
	 * @throws LoadLayerException
131 132
	 *
132 133
	 * @throws DriverIOException
133 134
	 */
134 135
	public static FLyrGeoRaster createLayer(String layerName, RasterDriver d,
135
		File f, IProjection proj, double widthPxImg, double heightPxImg) throws DriverException {
136
		File f, IProjection proj, double widthPxImg, double heightPxImg) throws LoadLayerException {
136 137
		RasterAdapter adapter = new RasterFileAdapter(f);
137 138
		adapter.setDriver(d);
138 139
		GeoPointPersistence	geoPointPersistence = new GeoPointPersistence();
139 140
		StackZoom zoom = new StackZoom();
140 141
		FLyrGeoRaster lyrGeoRaster = new FLyrGeoRaster(geoPointPersistence, zoom);
141 142
		geoPointPersistence.setLyrPoints(lyrGeoRaster.getFLyrPoints());
142
		
143

  
143 144
		if (lyrGeoRaster != null) {
144 145
			lyrGeoRaster.setName(layerName);
145 146
			lyrGeoRaster.setSource(adapter);
146 147
			lyrGeoRaster.setProjection(proj);
147 148
			lyrGeoRaster.setImageDimension(widthPxImg, heightPxImg);
148
			try {
149
				lyrGeoRaster.load();
150
			} catch (DriverIOException e) {
151
				throw new DriverException(e);
152
			}
153
	        
149
			lyrGeoRaster.load();
154 150
			lyrGeoRaster.setVisible(true);
155
		}else 
151
		}else
156 152
			return null;
157 153
		return lyrGeoRaster;
158 154
	}
159
	
155

  
160 156
	/**
161 157
	 * Crea una capa Raster a partir del nombre driver, fichero y proyecci?n.
162 158
	 *
......
166 162
	 * @param proj Proyecci?n.
167 163
	 *
168 164
	 * @return Nueva capa de tipo raster.
165
	 * @throws LoadLayerException
169 166
	 *
170 167
	 * @throws DriverIOException
171 168
	 */
172 169
	public static FLyrRaster createLayer(String layerName, RasterDriver d,
173
		File f, IProjection proj) throws DriverException {
170
		File f, IProjection proj) throws LoadLayerException {
174 171
		RasterAdapter adapter = new RasterFileAdapter(f);
175 172
		adapter.setDriver(d);
176 173

  
......
179 176

  
180 177
		capa.setSource(adapter);
181 178
		capa.setProjection(proj);
182
		try {
183
			capa.load();
184
		} catch (DriverIOException e) {
185
			throw new DriverException(e);
186
		}
187
		
179
		capa.load();
180

  
188 181
		return capa;
189 182
	}
190 183
	//**********************End Methods********************************
191
	
184

  
192 185
	//**********************Setters & Getters**************************
193
	
186

  
194 187
	//**********************End Setters & Getters*********************
195 188
}

Also available in: Unified diff