Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Problem while programmatically adding the project through RCP tutorial

Welcome to udig-devel:

A couple of questions for you inline...

I am new to UDIG I want to display a default map when a RCP application is   started. I am following RCP tutorial. 

Which tutorial is that? There is one on making a custom application on the website; and an RCP tutorial as part of the commercial training materials.

I am able to add the layer to the map but not able to view the   map. I am using the countries.shp file available with demo data.

Okay :-) Your test data sounds fine. Since you are using createPartControl() you must be following the commercial training materials.
Next question is what version of uDig you are using? This material was last checked in January on an earlier version of Eclipse.

I have added following piece of code in createPartControl() method of MapView class
ProjectRegistry projectRegistry = ProjectPlugin.getPlugin().getProjectRegistry();
 
            Project udigProject = projectRegistry.getProject("D:\\Example Resources\\ProjectTemplates\\temp.udig");
 
            List<IMap> list = udigProject.getElements(IMap.class);
 
            IMap map1 = list.get(0);
 
            List<ILayer> projectLayers = map1.getMapLayers();
            System.out.println("projectLayers" + map1.getName() + "layerCount : " + projectLayers.size() + " bounds : " + map1.getBounds(null).getMinX());
            map = (Map) map1 ;
              map.sendCommandSync(BasicCommandFactory.getInstance().createAddManyLayers(projectLayers));
            ReferencedEnvelope bounds = map.getViewportModel().getBounds();
            System.out.println("Bounds are : " + bounds.getMinX() + bounds.getMaxX());
            map.getViewportModelInternal().setBounds(bounds);
           
            map.getViewportModelInternal().setCRS(DefaultGeographicCRS.WGS84);
            map.sendCommandASync(new SetViewportBBoxCommand(bounds));
            mapviewer.setMap(map);


Your handling of bounds is a bit circular.
Viewport model should reflect the bounds of the screen (the returned ReferencedEnvelope includes both the bounds and the crs).

You are mixing up changing the internal state (you should only do that before the thing is displayed; or as part of a command); and issuing commands that will happen "later" when the map is available. Because you are using two ways of doing things I am not sure what exactly will happen when.

Can you give yourself a button to "show extent" and issue a command to set the bounds after the map is on screen (just to show something working). You can then study the state of the map in the debugger and try and reproduce it here in the createPartControl() method.

The printMapAction shows the name of the layer and the information that the layer is visible , but the map is not  shown .
I followed similar forums and found out the extent needs to be set for display of the map. I am trying to set the bounds and CRS through these statements.
 
map.getViewportModelInternal().setBounds(bounds);
            map.getViewportModelInternal().setCRS(DefaultGeographicCRS.WGS84);

Try and set the bounds and crs in one go using a referenced Envelope.

            map.sendCommandASync(new SetViewportBBoxCommand(bounds));

This would cause the map to be set to the extent+bounds described by the referenced envelope "bounds" undoing the work you did above.

Am I missing   something   or doing something wrong   ?  I am able to get and set the bounds of Viewport but cannot   find any method to set the bounds of the  Map object.

The Map is made up of several things:
- layers (managed the contents of the map)
- viewport (managed the bounds of the map)
- edit manager and so forth

So yes you are correct - the viewport model is the bounds for the map (and also the current time, elevation etc...).
The slides in the course material you are studying covered some of this in day 3 materials.
 
Appreciate, if I can get some insight in this scenario.

Hope the above helps; report back what you find.

Thanks & Regards
Nidhi

Cheers,
Jody
PS. Next time you post to a public list you may want to remove your company footer talking about the email being confidential

DISCLAIMER:
-----------------------------------------------------------------------------------------------------------------------

The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. 
It shall not attach any liability on the originator or HCL or its affiliates. Any views or opinions presented in 
this email are solely those of the author and may not necessarily reflect the opinions of HCL or its affiliates. 
Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of 
this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have 
received this email in error please delete it and notify the sender immediately. Before opening any mail and 
attachments please check them for viruses and defect.

-----------------------------------------------------------------------------------------------------------------------


Back to the top