Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Set Map Extent

Hello Jody,

Compound command, thanks! that is just what I need it :) I tried doing this :

	List<UndoableMapCommand> commands = new ArrayList<UndoableMapCommand>();
	commands.add(new AddLayersCommand(dataHandles));
	commands.add(new SetViewportBBoxCommand(new ReferencedEnvelope(new Envelope (2000000, 8669445.545, -3334722.765, 3334722.78), DefaultGeographicCRS.WGS84)));
        map.sendCommandASync(net.refractions.udig.project.command.factory.SelectionCommandFactory.getInstance().createUndoableCompositeCommand(commands));

This sets the extent fine, but most times the rendering of the layer stops (I dont know why, maybe a timeout?), and I have to manually refresh (I can see the log message 
!ENTRY net.refractions.udig.project 1 0 2011-03-11 10:43:11.000 !MESSAGE After 2 seconds unable to cancel mars_orbital Renderer)

I fixed it adding a refresh command after the first two. Probably its not a good solution, it is slow, but it works:

				List<MapCommand> commands = new ArrayList<MapCommand>();
				commands.add(new AddLayersCommand(dataHandles));
				commands.add(new SetViewportBBoxCommand(new ReferencedEnvelope(new Envelope (2000000, 8669445.545, -3334722.765, 3334722.78), DefaultGeographicCRS.WGS84)));
	                        commands.add( new AbstractNavCommand() {
					@Override
					public Command copy() {
						return null;
					}
					@Override
					public String getName() {
						return null;
					}
					@Override
					protected void runImpl(IProgressMonitor arg0)
							throws Exception {
						mapviewer.getRenderManager().refresh(null);
					}
				});
	                        map.sendCommandASync(SelectionCommandFactory.getInstance().createCompositeCommand(commands));
			
Thanks :)

Joaquín Rodríguez-Guerra Urcelay

Unidad de Sistemas de Procesamiento de Ciencia y de Observación de la Tierra / Science and Earth Observing Processing Systems Unit

GMV AEROSPACE AND DEFENCE, S.A.
Isaac Newton, 11
P.T.M. Tres Cantos
E-28760 Madrid
Tel. +34 91 807 21 00 / 7695
Fax +34 91 807 21 99
www.gmv.com

________________________________________
De: udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx [udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx] En nombre de Jody Garnett [Jody.Garnett@xxxxxxxxxxxx]
Enviado el: viernes, 11 de marzo de 2011 5:18
Para: User-friendly Desktop Internet GIS
Asunto: Re: [udig-devel] Set Map Extent

I think that adding a layer to an empty map is special; in that it tries to show the contents of the first layer. This was done to allow layers with unknown and known CRSs to be mixed without driving users nuts.

Can you reverse the order; add your layers and then set the map bounds after? Preferably as part of a compound command...

Jesse can you remember how the map size is done? I think with interceptors.


Jody

On 11/03/2011, at 1:06 AM, Joaquín Rodriguez-Guerra Urcelay wrote:

> Hello,
>
> I am trying to set the extent in the mapviewer (RCP example) programatically after adding some layers with no luck. If I put a button in the toolbar to execute the following action when clicked:
>
>    class SetExtentAction extends Action {
>        public SetExtentAction() {
>            super("Set Extent"); //$NON-NLS-1$
>        }
>        public void run() {
>               ReferencedEnvelope bounds = new ReferencedEnvelope(new Envelope (2000000, 8669445.545, -3334722.765, 3334722.78), DefaultGeographicCRS.WGS84);
>               map.sendCommandASync(new SetViewportBBoxCommand(bounds));
>        }
>    }
>
> It works, but I need to click a button and I would prefer to set the bounds from the code so I dont have to click a button.
>
> If I use this:
>       map.getViewportModelInternal().setBounds(new ReferencedEnvelope(new Envelope (2000000, 8669445.545, -3334722.765, 3334722.78),DefaultGeographicCRS.WGS84));
> After creating the map, it works if I dont add layers, but it seems like everytime a layer is added the map is zoomed to the layer extent.
> Since the layers are added using
>       map.sendCommandASync(new AddLayersCommand(dataHandles));
> I dont know where to place the code for setting the extent, and which method to use (map.getViewportModelInternal().setBounds or SetViewportBBoxCommand), where would be a good place??
>
> Thank you!!
>
> Joaquín Rodríguez-Guerra Urcelay
>
> ______________________
> This message including any attachments may contain confidential
> information, according to our Information Security Management System,
> and intended solely for a specific individual to whom they are addressed.
> Any unauthorised copy, disclosure or distribution of this message
> is strictly forbidden. If you have received this transmission in error,
> please notify the sender immediately and delete it.
>
> ______________________
> Este mensaje, y en su caso, cualquier fichero anexo al mismo,
> puede contener informacion clasificada por su emisor como confidencial
> en el marco de su Sistema de Gestion de Seguridad de la
> Informacion siendo para uso exclusivo del destinatario, quedando
> prohibida su divulgacion copia o distribucion a terceros sin la
> autorizacion expresa del remitente. Si Vd. ha recibido este mensaje
> erroneamente, se ruega lo notifique al remitente y proceda a su borrado.
> Gracias por su colaboracion.
>
> ______________________
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel

_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel

______________________
This message including any attachments may contain confidential 
information, according to our Information Security Management System,
 and intended solely for a specific individual to whom they are addressed.
 Any unauthorised copy, disclosure or distribution of this message
 is strictly forbidden. If you have received this transmission in error,
 please notify the sender immediately and delete it.

______________________
Este mensaje, y en su caso, cualquier fichero anexo al mismo,
 puede contener informacion clasificada por su emisor como confidencial
 en el marco de su Sistema de Gestion de Seguridad de la 
Informacion siendo para uso exclusivo del destinatario, quedando 
prohibida su divulgacion copia o distribucion a terceros sin la 
autorizacion expresa del remitente. Si Vd. ha recibido este mensaje 
 erroneamente, se ruega lo notifique al remitente y proceda a su borrado. 
Gracias por su colaboracion.

______________________



Back to the top