[udig-devel] Dynamicaly construct a Project-Map-Layers from a wms webservice

Jesse Eichar jeichar.w at gmail.com
Thu May 15 00:23:57 PDT 2008


Here is another way:

CatalogPlugin cp = CatalogPlugin.getDefault();
IServiceFactory sf = cp.getServiceFactory();

List<IService> new_services = sf.createService(new URL("http://192.168.2.11:8081/geoserver/wms 
"));
List<IGeoResource> resources = new ArrayList<IGeoResource>()
	
for ( IService srv:new_services){
	for( IGeoResource resource = srv.members(monitor) ){
		System.out.println(resource.getId().getRef())
	        if( layersIWant.contains(resource.getId().getRef()) ){
			resources.add(resource);
	 	}
	}
}

ApplicationGIS.addLayersToMap(map, resources)
//or
ApplicationGIS.createAndOpenMap(resources)

I think a quick explanation is required though.  First of all  
createService should only return services that are "equivalent". So a  
WFS and a WMS layer might be returned however when either is added to  
a map the layer can resolve to either.  But that is more the design  
that will apply later.  For now the above code will always return a  
single WMS service with the IGeoResources being the layers that are  
contained in the WMS.

A second note is that WMS layers can be hierarchical.  So members  
returns all the layers in a flat list.  service.resources() maintains  
the hierarchy but you have to traverse the hierarchy your self.  For  
an example use udig to load:

http://wms.geobase.ca/wms-bin/cubeserv.cgi?request=getCapabilities

try expanding some of the nodes and you will see what I mean.

Hope this helps,
Jesse

On 14-May-08, at 6:14 PM, Frederic Renard wrote:

> Hi everybody,
>
> I 'am (hard) searching who to create dynamicaly an entire udig map  
> project. My goal is to build
> and display maps/layers project with a user authorisation control at  
> login time.
> I'am searching for examples. I can retrieve layers using GeoTools,  
> but not with Udig.
> Do someone have this kind of example?
>
> A mix of Udig and geotools:
> --------------------
> .....
> 		CatalogPlugin cp = CatalogPlugin.getDefault();
> 		IServiceFactory sf = cp.getServiceFactory();
>
> 		List<IService> new_services = sf.createService(new URL("http://192.168.2.11:8081/geoserver/wms 
> "));
> 			
> 		for ( IService srv:new_services){
> 			if (srv.canResolve(WebMapServer.class)){
> 				WebMapServer wms=srv.resolve(WebMapServer.class, null);
> 				if (srv.getStatus()==Status.CONNECTED)	 
> System.out.println("CONNECTED ");			
> 				List<org.geotools.data.ows.Layer> layerList =  
> wms.getCapabilities().getLayerList();
> 				for (org.geotools.data.ows.Layer lrs :layerList ){
> 					System.out.println("REMOTE LAYER : " +	lrs.getName());			
> 				}
> 			}else
> 				System.out.println("Resolved !! NO :-( ");
> 		}
> .....
> --------------------
> Big thanks,
>
> Frederick.
>
> -----Message d'origine-----
> De : udig-devel-bounces at lists.refractions.net [mailto:udig-devel-bounces at lists.refractions.net 
> ] De la part de udig-devel-request at lists.refractions.net
> Envoyé : mercredi 14 mai 2008 17:01
> À : udig-devel at lists.refractions.net
> Objet : udig-devel Digest, Vol 49, Issue 33
>
> Send udig-devel mailing list submissions to
> 	udig-devel at lists.refractions.net
>
> To subscribe or unsubscribe via the World Wide Web, visit
> 	http://lists.refractions.net/mailman/listinfo/udig-devel
> or, via email, send a message with subject or body 'help' to
> 	udig-devel-request at lists.refractions.net
>
> You can reach the person managing the list at
> 	udig-devel-owner at lists.refractions.net
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of udig-devel digest..."
>
>
> Today's Topics:
>
>   1. Re: Re: creating a temporary layer and crs (andrea antonello)
>   2. Re: google plugin (andrea antonello)
>   3. Re: uDig release (andrea antonello)
>   4. Re: 52north WPS plugin uDig integration problem (Jesse Eichar)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 14 May 2008 15:59:07 +0200
> From: "andrea antonello" <andrea.antonello at gmail.com>
> Subject: Re: [udig-devel] Re: creating a temporary layer and crs
> To: "User-friendly Desktop Internet GIS"
> 	<udig-devel at lists.refractions.net>
> Message-ID:
> 	<116eb44a0805140659w4f835f82o4c8fca3f14e5cd15 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Thanks for the answers guys.
>
> Jody: I need to define the crs also for the temporary layer, which
> doesn't back up on a ShapefileDataStore. My coordinates are drawn as
> if they were epsg:4326, but using my coordinates metric UTM.
>
> Jesse: that is a news for me, I didn't this that Geometry JTS should
> knkow about projections, since it is "just" a geometry engine. Hmmm, I
> see a setSRID(int srid), which I imagine to be the thing I should do,
> but what is srid? The epsg code? The doc says the id of the spatial
> reference system.
>
>
> Andrea
>
>
> On Wed, May 14, 2008 at 1:15 AM, Jody Garnett <jgarnett at refractions.net 
> > wrote:
>> Can you "force" the projection in the ShapefileDataStore when you are
>> creating it?
>>
>> Jody
>>
>>>
>>>
>>>
>>> Huh, I found were I already heard about it :)
>>>
>>> http://jira.codehaus.org/browse/UDIG-970
>>>
>>> Any news about this?
>>>
>>> Andrea
>>>
>>>
>>> On Mon, May 12, 2008 at 11:53 AM, andrea antonello
>>> <andrea.antonello at gmail.com> wrote:
>>>
>>>
>>>> Hi, I think I had this problem before, but not on temporary layers.
>>>> I am creating one with:
>>>>
>>>>       IGeoResource resource =
>> CatalogPlugin.getDefault().getLocalCatalog()
>>>>               .createTemporaryResource(fet.getSchema());
>>>>       try {
>>>>
>>>>           FeatureStore fStore =  
>>>> resource.resolve(FeatureStore.class,
>>>>                   new NullProgressMonitor());
>>>>           fStore.addFeatures(fet);
>>>>       } catch (IOException e) {
>>>>           e.printStackTrace();
>>>>       }
>>>>       ApplicationGIS.addLayersToMap(ApplicationGIS.getActiveMap(),
>>>>               Collections.singletonList(resource), -1);
>>>>
>>>>
>>>> But I get:
>>>>
>> org 
>> .geotools 
>> .referencing.operation.projection.PointOutsideEnvelopeException:
>>>> Longitude 607659°34.4'E is out of range (±180°).
>>>>
>>>> since it is trying to interprete my coordinates as lat/long.  
>>>> Since on
>>>> a featurestore I can't force a crs, how can I solve this?
>>>>
>>>> Ciao
>>>> Andrea
>>>>
>>>>
>>>>
>>>
>>> _______________________________________________
>>> 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
>>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 14 May 2008 16:09:12 +0200
> From: "andrea antonello" <andrea.antonello at gmail.com>
> Subject: Re: [udig-devel] google plugin
> To: "User-friendly Desktop Internet GIS"
> 	<udig-devel at lists.refractions.net>
> Message-ID:
> 	<116eb44a0805140709g2391a93dk6d2b4fe22d401588 at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
>> The net.refractions.catalog.google plugin is a lie :-) It actually  
>> hits a
>> database at refractions that contains results we harvested using a  
>> bunch of
>> google searches. It needs to be thrown out and replaces with  
>> something that
>> uses a YahooId and hits up their search services; google no longer  
>> wants to
>> play with anyone not using javascript.
>
> Yeah, that was what I was thinking. I see a google2 plugin in the list
> and was wondering what that could mean.
>
>> Oh I think you are asking about making a google plug-in that hits  
>> up the
>> google maps data? As far as I know nobody has built it yet.
>
> But that would not be legal, right? Since that should be javascript?
> I've seen the JXMapViewersomthing from swing-wx that supports all that
> stuff, I can't understand why they have no legal issues. In fact that
> probably that is because it it can be used also for nasa,
> openstreetmaps and yahoo (even if I get it a bit shifted) and whatever
> else.
>
>>> Is it functional to udig 1.1.x? I would love to try it out, since  
>>> Ineed an
>> exact rectangle reprojected in my proj from google map. That
>>> would give me a way to export it to tiff and worldfile. Can this  
>>> be done?
>>>
>>>
>> The google projection is available to you from GeoTools; at least  
>> on uDig
>> trunk, for details see the geotools documentation - you can type in  
>> the WKT
>> definition and export your tiff as needed.
>
> No, I really wanted to have some cartography to show up the background
> when doing certain tasks. Also when working on field with a mobile
> connection that could be a nice thing.
> Well, I guess to many legal issues.
>
> Andrea
>
>
>
>
>>
>> Jody
>> _______________________________________________
>> User-friendly Desktop Internet GIS (uDig)
>> http://udig.refractions.net
>> http://lists.refractions.net/mailman/listinfo/udig-devel
>>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 14 May 2008 16:23:43 +0200
> From: "andrea antonello" <andrea.antonello at gmail.com>
> Subject: [udig-devel] Re: uDig release
> To: "User-friendly Desktop Internet GIS"
> 	<udig-devel at lists.refractions.net>
> Message-ID:
> 	<116eb44a0805140723g7467a7edt97428a40a6433b9c at mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> Hi Tony,
> I tried with WMS and WFS loading a bunch of layers. They are heavy to
> load so I think I gain your described "far from the source" feeling.
> But nothing... I mean everything works like a charm. I am working on
> linux with the sdk.
>
> Andrea
>
> On Wed, May 14, 2008 at 3:56 PM, Jesse Eichar  
> <jesse.eichar at gmail.com> wrote:
>> Interesting.  A fair bit of work was done to the MapGraphics  
>> provided with
>> uDig in this last release(mainly for printing).  Most likely  
>> something went
>> wrong in MapGraphicRenderer...  I'm surprised though.  Have you  
>> tried with
>> out so many other layers?  I will try to look into this.
>>
>> I have been fixing a postgis and need to fix some styling bugs as  
>> well.
>>
>> Jesse
>>
>>
>>
>> On 14-May-08, at 2:54 PM, Tony Roth wrote:
>>
>>
>>>
>>>
>>>
>>> hi jesse,
>>>
>>> first: thanks for you efforts for each problem with uDig!
>>>
>>> let's try to figure out what i've done so far (same goes for your  
>>> WIN
>>> release; both exe and sdk):
>>>
>>> 1. download the x86 installer 1.1-RC15 for windows from your and the
>>> official site
>>>
>>> 2. launch the install wizard and install uDig on my local space
>>> c:\programs\uDig\... as administrator
>>>
>>> 3. ok. the installer comes with JRE version 6 and libraries for  
>>> JAI and
>>> imageIO. now, starting uDig means that this version is used during
>> runntime.
>>> a local jdk/jre, i.e. an older one installed on my computer should  
>>> not
>> cause
>>> any problems. agree?
>>>
>>> 4. start uDig. fine. goto layer --> add data --> select WMS -->  
>>> enter
>> valid
>>> url to WMS --> select all resources shown --> finish the wizard. see
>>> screenshots 1-4
>>>
>>> 5. goto layer --> add yardsticklayer and gridlayer. see screens 5-7.
>>>
>>> ok, up to now everything works great. but enable/disable layers  
>>> ends in
>>> something strange:
>>>
>>> 6. enable / disable the yardsticklayer/gridlayer several times  
>>> sticks out
>> a
>>> scary rendering behaviour. see screens 8-9ff. deselect the  
>>> yardsticklayer.
>>> uups, the gridlayer is also removed from the map. but the checkbox  
>>> of the
>>> gridlayer is still enabled. the progress view says that uDig is
>> renedering.
>>> after 20 seconds - the TIMEOUT in (incrementalUpdate()) has  
>>> reached -
>>> rendering will finish but in an inconsistent state --> see screen 91
>>> (left-bottom)
>>>
>>> 7. I set up the sdk as shown in the wiki. same problem!
>>>
>>> 8. please have a look at the attached log-file. I think there is  
>>> nothing
>> to
>>> see that matches my problem but maybe you could find something.
>>>
>>> 9. I'm working on WindowsXP SP2, Athlon AMD 64 / 3500+, 2GB RAM,
>>> administrator-rights
>>>
>>> 10. do you think this could be a timing problem of the renderer- 
>>> threads
>>> because of network distance to the WMS. the distance is about 400  
>>> miles.
>>> schould that be a problem?
>>>
>>> 11. eyeryone else reported such problems?
>>>
>>>
>>> thanks a lot
>>> tony
>>>
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: Jesse Eichar [mailto:jesse.eichar at gmail.com]
>>>> Sent: Tuesday, May 13, 2008 9:08 AM
>>>> To: Tony Roth
>>>> Cc: 'andrea antonello'
>>>> Subject: Re: uDig release
>>>>
>>>> Hi you guys.  Keep this release quiet.  I realized that I hadn't
>>>> updated so I will be kicking out a new release today.
>>>>
>>>> WITH OUT CHANGING VERSION NUMBERS.
>>>>
>>>> The time stamp in the about box will be changed but there will be  
>>>> no
>>>> other indicator.
>>>>
>>>> I got access to the Refractions webdav again so I will put it up  
>>>> there.
>>>>
>>>> The changes are mainly just an added _eu translation.  What ever
>>>> language that is..  A spanish dialect maybe?  So it shouldn't  
>>>> affect
>>>> you.  But I just want you to be aware of the coming bundle.
>>>>
>>>> Jesse
>>>>
>>>> On 13-May-08, at 9:00 AM, Tony Roth wrote:
>>>>
>>>>
>>>>> great jesse!
>>>>>
>>>>> thx a lot. I was absent from friday until now.
>>>>> I'll try it after download sucessfully completetes...
>>>>>
>>>>> tony
>>>>>
>>>>>
>>>>>
>>>>>> -----Original Message-----
>>>>>> From: Jesse Eichar [mailto:jesse.eichar at gmail.com]
>>>>>> Sent: Friday, May 09, 2008 3:29 PM
>>>>>> To: andrea antonello
>>>>>> Cc: tony.roth at GMX.de
>>>>>> Subject: uDig release
>>>>>>
>>>>>> Hi guys.  I don't have access to Refractions server right now  
>>>>>> so I
>>>>>> put
>>>>>> the release online at: http://pragmaticdesign.net/downloads/RC15/
>>>>>>
>>>>>> Tony I have the change to the renderer included please try it  
>>>>>> out.
>>>>>> Andrea you too.  I send jody a message so that he can put it on  
>>>>>> the
>>>>>> refractions site.  But for now you can download it from here (my
>>>>>> personal site).
>>>>>>
>>>>>> Jesse
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>> < 
>> 1 
>> .GIF 
>> > 
>> < 
>> 1 
>> .GIF 
>> > 
>> < 
>> 2 
>> .GIF 
>> ><3.GIF><4.GIF><5.GIF><6.GIF><7.GIF><8.GIF><9.GIF><91.GIF><log.txt>
>>>
>>
>>
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 14 May 2008 16:51:06 +0200
> From: Jesse Eichar <jeichar.w at gmail.com>
> Subject: Re: [udig-devel] 52north WPS plugin uDig integration problem
> To: User-friendly Desktop Internet GIS
> 	<udig-devel at lists.refractions.net>
> Message-ID: <905503B2-DCC8-4CF8-8FA0-A311C8D1BC41 at gmail.com>
> Content-Type: text/plain; charset="windows-1252"
>
> Hi,  I think there is a particular version of uDig that you have to
> use... I don't remember which.  RC13 or 14 maybe?  I'm afraid that I
> have not used the plugin before.  But I do remember applying a patch
> so that the plugin will work with uDig.
>
> Jesse
>
> On 14-May-08, at 3:42 PM, McFarland, Craig wrote:
>
>> Hello,
>>
>> I've recently tried to use the WPS plugin for uDig provided by
>> 52north with the RC12 release of uDig.  However when I specify the
>> getCapabilities URL for the public ITC GeoServer WPS, the next
>> button becomes active but does nothing when clicking on it.  The
>> wizard screen will not advance.  I've looked in the uDig and this
>> seems to be the problem:
>>
>> !ENTRY org.eclipse.ui 4 0 2008-05-13 17:57:15.483
>> !MESSAGE Unhandled event loop exception
>> !STACK 0
>> java.lang.NullPointerException
>>            at
>> net
>> .refractions
>> .udig.catalog.ui.workflow.ConnectionState.next(ConnectionState.java:
>> 258)
>>            at
>> org
>> .n52
>> .wps
>> .client
>> .udig
>> .ui.WPSRegistryWizardPage.getNextPage(WPSRegistryWizardPage.java:440)
>>            at
>> net
>> .refractions
>> .udig
>> .catalog.internal.ui.ConnectionPage.getNextPage(ConnectionPage.java:
>> 238)
>>            at
>> org.eclipse.jface.wizard.WizardDialog.nextPressed(WizardDialog.java:
>> 813)
>>            at
>> org
>> .eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:
>> 369)
>>            at org.eclipse.jface.dialogs.Dialog
>> $2.widgetSelected(Dialog.java:616)
>>            at
>> org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:
>> 227)
>>            at
>> org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
>>            at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:
>> 938)
>>            at
>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
>>            at
>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
>>            at
>> org.eclipse.jface.window.Window.runEventLoop(Window.java:820)
>>            at org.eclipse.jface.window.Window.open(Window.java:796)
>>            at
>> org
>> .eclipse
>> .ui.actions.ImportResourcesAction.run(ImportResourcesAction.java:159)
>>            at
>> org
>> .eclipse
>> .ui
>> .actions
>> .BaseSelectionListenerAction
>> .runWithEvent(BaseSelectionListenerAction.java:168)
>>            at
>> org
>> .eclipse
>> .jface
>> .action
>> .ActionContributionItem
>> .handleWidgetSelection(ActionContributionItem.java:545)
>>            at org.eclipse.jface.action.ActionContributionItem.access
>> $2(ActionContributionItem.java:490)
>>            at org.eclipse.jface.action.ActionContributionItem
>> $5.handleEvent(ActionContributionItem.java:402)
>>            at
>> org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
>>            at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:
>> 938)
>>            at
>> org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3682)
>>            at
>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3293)
>>            at
>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2389)
>>            at
>> org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2353)
>>            at org.eclipse.ui.internal.Workbench.access
>> $4(Workbench.java:2219)
>>            at org.eclipse.ui.internal.Workbench
>> $4.run(Workbench.java:466)
>>            at
>> org
>> .eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:
>> 289)
>>            at
>> org
>> .eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:
>> 461)
>>            at
>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
>>            at
>> net
>> .refractions
>> .udig.internal.ui.UDIGApplication.run(UDIGApplication.java:41)
>>            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>> Method)
>>            at
>> sun
>> .reflect
>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>            at
>> sun
>> .reflect
>> .DelegatingMethodAccessorImpl
>> .invoke(DelegatingMethodAccessorImpl.java:25)
>>            at java.lang.reflect.Method.invoke(Method.java:597)
>>            at
>> org
>> .eclipse
>> .equinox
>> .internal
>> .app.EclipseAppContainer.callMethod(EclipseAppContainer.java:533)
>>            at
>> org
>> .eclipse
>> .equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:155)
>>            at
>> org
>> .eclipse
>> .core
>> .runtime
>> .internal
>> .adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:
>> 106)
>>            at
>> org
>> .eclipse
>> .core
>> .runtime
>> .internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java: 
>> 76)
>>            at
>> org
>> .eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:
>> 363)
>>            at
>> org
>> .eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:
>> 176)
>>            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
>> Method)
>>            at
>> sun
>> .reflect
>> .NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>>            at
>> sun
>> .reflect
>> .DelegatingMethodAccessorImpl
>> .invoke(DelegatingMethodAccessorImpl.java:25)
>>            at java.lang.reflect.Method.invoke(Method.java:597)
>>            at
>> org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:504)
>>            at org.eclipse.equinox.launcher.Main.basicRun(Main.java:
>> 443)
>>            at org.eclipse.equinox.launcher.Main.run(Main.java:1169)
>>            at org.eclipse.equinox.launcher.Main.main(Main.java:1144)
>>
>> I'm pretty new to plugins with Eclipse RCP so I'm not sure what is
>> going on.  I've tried to go to the 52north.org website the last
>> couple days and the connection always times out, so I'm not sure
>> what is going on with the site.  Anyone have any suggestions?   
>> Thanks,
>>
>>
>> Craig McFarland, Software Engineer
>> SRA C4ISR Center
>> 5000 Springfield Street, Suite 200
>> Dayton, OH 45431
>> Phone: (937) 910-6400 ex 495
>>
>>
>> "This electronic message transmission contains information from SRA
>> International, Inc. which may be confidential, privileged, or
>> proprietary.  The information is intended for the use of the
>> individual or entity named above. If you are not the intended
>> recipient, be aware that any disclosure, copying, distribution, or
>> use of the contents of this information is strictly prohibited. If
>> you have received this electronic information in error, please
>> notify us immediately by telephone at 866-584-2143."
>>
>> _______________________________________________
>> User-friendly Desktop Internet GIS (uDig)
>> http://udig.refractions.net
>> http://lists.refractions.net/mailman/listinfo/udig-devel
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: http://lists.refractions.net/pipermail/udig-devel/attachments/20080514/c8028f08/attachment.html
>
> ------------------------------
>
> _______________________________________________
> udig-devel mailing list
> udig-devel at lists.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel
>
>
> End of udig-devel Digest, Vol 49, Issue 33
> ******************************************
>
>
> _______________________________________________
> User-friendly Desktop Internet GIS (uDig)
> http://udig.refractions.net
> http://lists.refractions.net/mailman/listinfo/udig-devel



More information about the udig-devel mailing list