[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [udig-devel] Polygons drawn with PolygonTool not in my FeatureStore...
|
I don't see anything obvious I'm afraid. I could suggest another way
of doing this though. You could make a new Tool that extends the
PolygonTool and overrides the addAcceptBehaviours() method. The
overridden method would add a new behaviour which could either add
the created polygon to the Layer's black board (or just do nothing).
Then your search method could use the shape on the layer's blackboard
(you wouldn't need a dedicated layer for this) to construct the
search query. If you did not add any new behaviour (just overrode
the addAcceptBehaviours method with an empty method) then you could
use the shape on the EditBlackboard to construct your query. To get
the correct blackboard do: EditblackboardUtils.getEditBlackboard
( ApplicationGIS.createContext(layer.getMap), layer ).
Jesse
On Aug 2, 2007, at 7:11 AM, tony.roth@xxxxxx wrote:
One wish of my users is to get a 'geo referenced' search. (don't
know if
it's the correct english word)
They want to draw a polygon on the map, click on a search button,
enter
some additional restrictions for the query and finally send the
query. As
result they want the elements shown in the map.
I will use a dedicated polygon layer for that. The user can draw the
polygon with the PolygonTool. To prevent queries with more than one
polygon
the layer shll just store one feature/polygon. If the user draws a
polygon
the old one will be removed.
What's the best way to realize this?
I tried it this way but failed:
// Featuretypebuilder, Ressource,....
// finally I have the layer :
final Layer l = layer;
l.addListener(new ILayerListener(){
public void refresh(LayerEvent event) {
// debug print
System.out.println(event.getType().name());
if (event.getType()== EventType.EDIT_EVENT){
try {
FeatureStore fs = l.getGeoResource().resolve
(FeatureStore.class,
null);
FeatureIterator fI = fs.getFeatures().features();
List<Feature> featureList = new ArrayList<Feature>();
while (fI.hasNext()){
featureList.add(fI.next());
}
if (featureList.size() > 1){
// remove all features
fs.removeFeatures(Filter.NONE);
// add the last one
fs.addFeatures(DataUtilities.collection(new
Feature[]{featureList.get(featureList.size()-1)}));
l.refresh(null);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
Even I draw a some polygons and see them in my application ths
featureList
is empty. The event is thrown and the layerListener activated and the
FeatureStroe is not null.
What's wrong in my code? Or a bad approach? Has someone a better
idea to
realize this functionality?
Thank you,
tony roth
still using 1.1RC8 :)
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel