[Gvsig_english] Loading data using vector file

Jorge Sanz jsanz at prodevelop.es
Tue May 13 14:14:29 CEST 2008


Hi Luca

Not directly, you should develop an extension (maybe using the scripting API) to get the path to the raster file from the attributes table and creating a new layer from that file (FLyrRaster) and after that loading it to the view.

In the scripting manual you have some of this features with samples, maybe loading a raster file is not present but it's quite simple if you have the source file path. 

In java you should do something like that (quite rude code, without checkings and so on) after you get the file path and create the "myRasterFile" object:

/*create raster layer from file*/
RasterAdapter adapter = new RasterFileAdapter(myRasterFile);
Driver d = LayerFactory.getDM().getDriver("gvSIG Image Driver");
adapter.setDriver(d);
Flayer layer = new FLyrRaster();
((FLyrRaster) layer).setSource(adapter);

/*load flayer into current view*/
IWindow iwin = PluginServices.getMDIManager().getActiveWindow();
MapContext mapcontext = ((View) iwin).getMapControl()
							.getMapContext();
mapcontext.getLayers().addLayer(layer);


Not sure if all code is correct (not tested as a whole, cut and pasted from different places), maybe other smarter developers can add some comments or corrections.

Hope it helps
--
Jorge Gaspar Sanz Salinas
Ingeniero en Geodesia y Cartografía
Prodevelop S.L. - Valencia - España
Tlf.:  96.351.06.12 - Fax:   96.351.09.68 
jsanz[en]prodevelop[punto]es
http://www.prodevelop.es

De: gvsig_internacional-bounces at runas.cap.gva.es [mailto:gvsig_internacional-bounces at runas.cap.gva.es] En nombre de Luca Casagrande
Enviado el: martes, 13 de mayo de 2008 13:38
Para: Users and Developers mailing list
Asunto: [Gvsig_english] Loading data using vector file

Hello everybody!

I am trying to find a good way for doing this task..any help is appreciate:

I have a polygon vector file that for each area, has got in the attribute table, the name of the Image Raster Data
covering that surface. Is there any way for loading that raster clicking on the polygon?

Thanks

--
Luca Casagrande
Gubbio (PG)

"Siamo tutti in una fogna, ma che alcuni di noi guardano le stelle" O. Wilde




More information about the Gvsig_internacional mailing list