[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Réf. : Re: [udig-devel] How-to render a Feature differently depending on some dynamic properties
|
Hello Jesse, Hi all,
Thanks for your response.
To be as clear as possible, let me explain what we want to do :
On our geographic database, there are areas. And some of these areas
(industrial or commercial areas) may contain some others features (like
business opportunities or vacant buildings).
What
we would like to do is to paint these areas containing certain kind of
features (like business opportunities) in blue, the one containing
vacant building in red and the one without any features ont them in
white.
We think there are 2 major problems :
- the number of rules and filters to manage will quickly become crazy (we have tried...) !!
-
if we use (layer-)sld, we need to query datas each time we display the
map and thus, modify filters (and rules)... does anyone has a free cray
for us (;-) ?
So we thought that the best way (already used in
another GIS) is to define "behaviour" not layer-computed but
object-computed so we just need to make calculation for objects that
are displayed... according to the map envelope and sld.
I am very curious to know how to do it and how the Udig's developpers will manage this problem if they have to do it...
Thanks in advance,
Sébastien PIAU
-----udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx a écrit : -----
Pour : User-friendly Desktop Internet GIS <udig-devel@xxxxxxxxxxxxxxxxxxxxx>
De : Jesse Eichar <jeichar@xxxxxxxxxxxxxxx>
Envoyé par : udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx
Date : 14/03/2006 12:17AM
Objet : Re: [udig-devel] How-to render a Feature differently depending on some dynamic properties
I think that if it is possible it is often better to use the SLD to manage dynamic behavior for the simple reason that there is less code to maintain...
A renderer would work as well that certainly is up to you. A note about the renderer tutorial: You need to import the net.refractions.udig.tutorials.catalog.property tutorial as well.
Remember that only 1 renderer is created for each layer and the RenderMetrics are used to determine whether a renderer is used for a layer.
Jesse
Hi all again,
I'm working with shp files and i would like to modify features apparences depending on some dynamic properties.
In order to do this, i'm found two way :
- i'm looking for creating my own renderer.
I've found the property.renderer tutorial on the Udig's SVN, but I don't know how to use it... I'm trying to open the "propertyService.properties" file in Udig, by the open dialog window still frozen.
- i'm using the SLD files and Style object. By this way, you can change some graphics attributes like the Mark
(a circle, square or star...), the color and so on.
The OGC SLD specification allow us to add some filters in rules to restrict the rule use. But, if we want to change only one feature display, we must modify or creating rules for all the other features. So I'm not sure that is the right way to do.
You'll find a sample code i use to get rules from a SLD file and how i modify their filters:
a) I'm mapping the SLD file rules and filter :
In fact i think we can also creating directly Style from the program, but for the moment we still using our own SLD file since this file is loaded at the same time as the shp file (please, look at the attachments for the SLD file)
public void getRulesFromSLDForLayer(String sLayerName){
//Getting the map
Map mCurrentMap = (Map) ApplicationGIS.getActiveMap();
//Getting all the layers
List<ILayer> l_lLayers = mCurrentMap.getMapLayers();
Layer lEntreprises500Layer = null;
//Looking for the desired layer (search by name)
for (ILayer lLayer : l_lLayers){
if (lLayer.getName().equalsIgnoreCase(sLayerName)){
lEntreprises500Layer = (Layer) lLayer;
}
}
//Now, we have the layer, we could...
//...Getting his StyleBlackBoard
StyleBlackboard sbb = lEntreprises500Layer.getStyleBlackboard();
//Getting his style
Style style = (Style) sbb.lookup(Style.class);
FeatureTypeStyle[] a_fts = style.getFeatureTypeStyles();
//getting the right "featuretypestyle" (by default only exist in the SLD file)
FeatureTypeStyle fts = a_fts[0];
//And finally, getting the rules!
List<Rule> l_rules = fts.rules();
//After, we can get the rules and setting the filter depending on the name
for (Rule rule : l_rules){
if (rule.getName().equals("normal")){
rSLDNormalRule = rule;
//Create an empty FID filter and setting it in the rule
fSLDNormalFilter = FilterFactoryFinder.createFilterFactory().createFidFilter();
//At this moment, the filter sounds like "not nothing" (
fSLDNormalFilter.not()
), so this rule (the "normal" one) is applyed to all the features
rSLDNormalRule.setFilter(fSLDNormalFilter.not());
}
if (rule.getName().equals("selected")){
rSLDSearchRule = rule;
//At this moment, the filter is only handled in order to change his value later,so, this rule (the "selected" one) isn't used
fSLDSearchFilter = (FidFilter) rule.getFilter();
}
}
}
b) Then I can change the filters contents "on the fly"
From the GUI, i'm getting a list of selected features FIDs, then i change the rules filters in order to modify the map display
public void modifieFiltresSLDPourEntreprises(){
//Test if the list of selected features has been changed
if ( ! l_sListeEntreprisesSelectionneesFids.equals(l_sNewListeEntreprisesSelectionneesFids)){
{
// If the lists of selected features have changed, we must modify the rules filters
if (l_sNewListeEntreprisesSelectionneesFids != null){
//Remove the old selected features from the filter...
fSLDSearchFilter.removeAllFids(l_sListeEntreprisesSelectionneesFids);
}
//... and adding the new ones
fSLDSearchFilter.addAllFids(l_sNewListeEntreprisesSelectionneesFids);
l_sListeEntreprisesSelectionneesFids.clear();
l_sListeEntreprisesSelectionneesFids.addAll(l_sNewListeEntreprisesSelectionneesFids);
}
}
}
2 - Currently, i'm looking for creating my own renderer.
I've found the property.renderer tutorial on the Udig's SVN, but I don't know how to use it... I'm trying to open the "propertyService.properties" file in Udig, by the open dialog window still frozen.
Questions:
1 - Could you tell me the right way in order to achieve the job?
2 - May i have some materials in order to use the tutorial please
Thanks,
Sebastien
<ENTREPRISE_500.sld>
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel