Hi Nenad,

Nice question !

One way would be to write a filter function to do the lookup for you.
Something like this...

import org.geotools.filter.FunctionExpressionImpl;

public class ExternalLookupFunction extends FunctionExpressionImpl {

    public ExternalLookupFunction() {
        super("ExternalLookup");
    }

    @Override
    public int getArgCount() {
        return 4;
    }

    @Override
    public Object evaluate(Object feature) {
        Object returnValue = null;

        // get the value from the feature to lookup in the external
        // table join field
        Object joinValue = getExpression(0).evaluate(feature);

        String tableName = getExpression(1).evaluate(feature, String.class);
        String joinFieldName = getExpression(2).evaluate(feature, String.class);
        String valueFieldName = getExpression(3).evaluate(feature,
String.class);

        // Connect to table (or check for existing connection, cache etc. as
        // relevant to your app)
        // ...

        // Look up join value in external table join field to identify
table record
        // ...

        // Get value from value field and return it
        // ...

        return returnValue;
    }
}


Then (I think) you can refer to this in your SLD document like this.

<FeatureTypeStyle>
   <Rule>
       <Filter>
           <PropertyIsEqualTo>
               <Function name="ExternalLookup">
                   <PropertyName>some feature attribute</PropertyName>
                   <Literal>external table name</Literal>
                   <Literal>external table join field</Literal>
                   <Literal>external table value field</Literal>
               </Function>
               <Literal>35</Literal>
           </PropertyIsEqualTo>
       </Filter>


Someone else here will probably have a much easier way of doing all that :-)

Hope this helps - please let us know.

Michael

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to