From: Jody G. <jga...@re...> - 2008-08-05 02:18:11
|
VASkO wrote: > Is there any method to get the clicked FeatureCollection from a Layer? > There are some examples of making a Filter for a BBOX query; usually you make abounding box the size of the pixel and perform a query that way. - http://docs.codehaus.org/display/GEOTDOC/Filter+Examples#FilterExamples-WhatdidIclickon > I have the following situation. I'm displaying many traffic time-schedules on a country map, each schedule is a LineString (see > attached code), constructed with the code below and not loaded directly from a shapefile. I'm adding each schedule to a different layer. So far so good, all is fine. I'm adding the feature collection for each schedule to it's own layer, apply a road style to it and do a render. > Okay; usually we make one postgis table for all the schedules; and then do one of those queries to see what is clicked on. In uDig when we have many layers and the user clicks we have two ways to handle the situation: - perform the BBOX query against the "selected" layer ... this does not match you use case - perofrm the BBOX query against all the layers and give the user of all the results to choose from (this is what we do for our info tool). > PROBLEM: I want to let the user click on a schedule of his choice and recognize it's attribute ("vezniredid"), which holds the ID of a > schedule. What is the easiest way to do this? Do i have to save my LineStrings to a shapefile to be able to use the filters on them? Is there a way to get the whole FeatureCollection out of a layer at all? > I am not too sure about the layer interface; when you make a layer using a collection to actually wraps the thing up in a MemoryDataStore using a DataUtilities method if I remember. You can ask the layer for the FeatureSource in order to make queries against this MemoryDataStore. But if you keep your feature collection around you can always go through the content yourself and use filter.evaulate( feature ) one at a time to see what is selected. > //finally pseudocode > add each layer with a LineString with it's own line style (different color) > Note you can create a Style that does this; have a Rule for each feature; not very fun but you can do it... Jody |