Revision 10626 trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/fmap/layers/FLyrGeoRaster.java
FLyrGeoRaster.java | ||
---|---|---|
35 | 35 |
import org.cresques.io.data.RasterMetaFileTags; |
36 | 36 |
import org.cresques.px.Extent; |
37 | 37 |
|
38 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
|
38 | 39 |
import com.iver.andami.PluginServices; |
39 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
40 | 40 |
import com.iver.cit.gvsig.fmap.MapContext; |
41 | 41 |
import com.iver.cit.gvsig.fmap.ViewPort; |
42 | 42 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
... | ... | |
88 | 88 |
* @param vp ViewPort solicitado por el usuario. |
89 | 89 |
* @return ViewPort transformado a coordenadas de la imagen. |
90 | 90 |
*/ |
91 |
public ViewPort toImageCoord(ViewPort vp) throws DriverException{
|
|
91 |
public ViewPort toImageCoord(ViewPort vp){ |
|
92 | 92 |
this.viewPortWithoutTransformation = vp; |
93 | 93 |
|
94 | 94 |
if(this.assignExtent == null) |
... | ... | |
141 | 141 |
* transformaci?n del viewPort. |
142 | 142 |
*/ |
143 | 143 |
public void draw(BufferedImage image, Graphics2D g, ViewPort vp, |
144 |
Cancellable cancel,double scale) throws DriverException { |
|
144 |
Cancellable cancel,double scale) throws ReadDriverException {
|
|
145 | 145 |
super.draw(image, g, this.toImageCoord(vp), cancel, scale); |
146 | 146 |
} |
147 | 147 |
|
... | ... | |
150 | 150 |
* transformaci?n del viewPort. |
151 | 151 |
*/ |
152 | 152 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
153 |
double scale, PrintRequestAttributeSet properties)throws DriverException { |
|
153 |
double scale, PrintRequestAttributeSet properties)throws ReadDriverException {
|
|
154 | 154 |
super.print(g, this.toImageCoord(viewPort), cancel, scale, properties); |
155 | 155 |
} |
156 | 156 |
|
... | ... | |
158 | 158 |
* Impresi?n de la capa de raster georeferenciado aplicando la |
159 | 159 |
* transformaci?n del viewPort. |
160 | 160 |
*/ |
161 |
public void _print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale) |
|
162 |
throws DriverException { |
|
161 |
public void _print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale) { |
|
163 | 162 |
_print(g, this.toImageCoord(viewPort), cancel, scale); |
164 | 163 |
} |
165 | 164 |
|
... | ... | |
173 | 172 |
Point2D p = new Point2D.Double(); |
174 | 173 |
double wcWidth = 0.0, wcHeight = 0.0; |
175 | 174 |
double mapImgX = 0, mapImgY = 0; |
176 |
try{ |
|
177 |
wcWidth = getFullExtent().getWidth(); |
|
178 |
wcHeight = getFullExtent().getHeight(); |
|
179 |
|
|
175 |
wcWidth = getFullExtent().getWidth(); |
|
176 |
wcHeight = getFullExtent().getHeight(); |
|
180 | 177 |
//La esquina superior izquierda de la vista es minX,maxY y la de la imagen minX,minY |
181 |
double pixelImgX = pixel.getX(); |
|
182 |
double pixelImgY = getImageHeight() - pixel.getY(); |
|
183 |
|
|
178 |
double pixelImgX = pixel.getX(); |
|
179 |
double pixelImgY = getImageHeight() - pixel.getY(); |
|
184 | 180 |
//Hallamos el pto en coordenadas reales con una regla de tres |
185 |
mapImgX = (((pixelImgX * wcWidth) / widthPxImg)); |
|
186 |
mapImgY = (((pixelImgY * wcHeight) / heightPxImg)); |
|
187 |
|
|
181 |
mapImgX = (((pixelImgX * wcWidth) / widthPxImg)); |
|
182 |
mapImgY = (((pixelImgY * wcHeight) / heightPxImg)); |
|
188 | 183 |
//Trasladamos a su ubicaci?n real |
189 |
mapImgX += this.getFullExtent().getMinX();
|
|
190 |
mapImgY += this.getFullExtent().getMinY();
|
|
184 |
mapImgX += this.getFullExtent().getMinX(); |
|
185 |
mapImgY += this.getFullExtent().getMinY(); |
|
191 | 186 |
|
192 |
|
|
193 |
}catch(DriverException ex){} |
|
194 | 187 |
p.setLocation(mapImgX, mapImgY); |
195 | 188 |
return p; |
196 | 189 |
} |
... | ... | |
227 | 220 |
//con el punto wcPoint |
228 | 221 |
double wcWidth = 0.0, wcHeight = 0.0, ptoWCX = 0.0, ptoWCY = 0.0; |
229 | 222 |
double pixelImgX = 0, pixelImgY = 0; |
230 |
try{ |
|
231 |
wcWidth = getFullExtent().getWidth(); |
|
232 |
wcHeight = getFullExtent().getHeight(); |
|
233 |
//Traslaci?n al origen ya que la imagen empieza en 0,0 |
|
234 |
ptoWCX = wcPoint.getX() - getFullExtent().getMinX(); |
|
235 |
ptoWCY = wcPoint.getY() - getFullExtent().getMinY(); |
|
236 |
//Hallamos el pto en pixeles con una regla de tres |
|
237 |
pixelImgX = ((ptoWCX * getImageWidth()) / wcWidth); |
|
238 |
pixelImgY = ((ptoWCY * getImageHeight()) / wcHeight); |
|
239 |
//La esquina superior izquierda de la vista es minX,maxY y la de la imagen minX,minY |
|
240 |
pixelImgY = getImageHeight() - pixelImgY; |
|
241 |
}catch(DriverException ex){} |
|
223 |
wcWidth = getFullExtent().getWidth(); |
|
224 |
wcHeight = getFullExtent().getHeight(); |
|
225 |
//Traslaci?n al origen ya que la imagen empieza en 0,0 |
|
226 |
ptoWCX = wcPoint.getX() - getFullExtent().getMinX(); |
|
227 |
ptoWCY = wcPoint.getY() - getFullExtent().getMinY(); |
|
228 |
//Hallamos el pto en pixeles con una regla de tres |
|
229 |
pixelImgX = ((ptoWCX * getImageWidth()) / wcWidth); |
|
230 |
pixelImgY = ((ptoWCY * getImageHeight()) / wcHeight); |
|
231 |
//La esquina superior izquierda de la vista es minX,maxY y la de la imagen minX,minY |
|
232 |
pixelImgY = getImageHeight() - pixelImgY; |
|
242 | 233 |
|
243 | 234 |
Point2D result = new Point2D.Double(); |
244 | 235 |
result.setLocation(pixelImgX, pixelImgY); |
... | ... | |
464 | 455 |
* Obtiene el extent de la capa |
465 | 456 |
* @return extent en Rectangle2D. |
466 | 457 |
*/ |
467 |
public Rectangle2D getFullExtent()throws DriverException {
|
|
458 |
public Rectangle2D getFullExtent() { |
|
468 | 459 |
if(assignExtent == null) |
469 | 460 |
return super.getFullExtent(); |
470 | 461 |
return assignExtent.toRectangle2D(); |
... | ... | |
475 | 466 |
* @return extent de la capa |
476 | 467 |
*/ |
477 | 468 |
public Extent getAssignExtent(){ |
478 |
try{ |
|
479 |
if(assignExtent == null) |
|
480 |
return new Extent( super.getFullExtent().getMinX(), |
|
481 |
super.getFullExtent().getMinY(), |
|
482 |
super.getFullExtent().getMaxX(), |
|
483 |
super.getFullExtent().getMaxY()); |
|
484 |
}catch(DriverException ex){} |
|
469 |
if(assignExtent == null) |
|
470 |
return new Extent( super.getFullExtent().getMinX(), |
|
471 |
super.getFullExtent().getMinY(), |
|
472 |
super.getFullExtent().getMaxX(), |
|
473 |
super.getFullExtent().getMaxY()); |
|
485 | 474 |
return assignExtent; |
486 | 475 |
} |
487 | 476 |
|
Also available in: Unified diff