[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [udig-devel] Layer Attribute Query
|
Jody,
Thanks for the pointers. I resolved it by using:
CompareFilter filter1 =
filterFactory.createCompareFilter(Filter.COMPARE_EQUALS);
filter1.addLeftValue(filterFactory.createAttributeExpression("SHORT_NAME"));
filter1.addRightValue(filterFactory.createLiteralExpression(polygonID1));
CompareFilter filter2 =
filterFactory.createCompareFilter(Filter.COMPARE_EQUALS);
filter2.addLeftValue(filterFactory.createAttributeExpression("SHORT_NAME"));
filter2.addRightValue(filterFactory.createLiteralExpression(polygonID2));
Thanks
Andy
-----Original Message-----
From: udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx
[mailto:udig-devel-bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Jody Garnett
Sent: 16 August 2007 05:27
To: User-friendly Desktop Internet GIS
Subject: Re: [udig-devel] Layer Attribute Query
A bit of a warning Andy, code like the following:
>
> Feature feature1 = source.getFeatures(filter1).features().next();
>
> Feature feature2 = source.getFeatures(filter2).features().next();
>
Will cause lots of problems - you need to call FeatureIterator.close()
after you are done using FeatureIterator - otherwise you will end up
leaking database connections or holding files open.
>
> but I would like to perform an attribute query on a field rather than
> an ID query, I am trying a new filter
>
I think you actually mean to check for the "literal" string "CAWSAND DG
RAN" ?
>
> CompareFilter filter1 =
> filterFactory.createCompareFilter(CompareFilter./COMPARE_EQUALS/);
>
>
filter1.addLeftValue(filterFactory.createAttributeExpression("Short_name"));
>
> filter1.addRightValue(filterFactory.createAttributeExpression("CAWSAND
> DG RAN"));
>
There should be a filterFactory method for creating a literal - and you
can pass in your String.
Cheers,
Jody
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel