It would be helpful to share andrea’s response to the email list also, this is a shared resource and we can all learn from the discussions here.
As for including the user email list CC works, or using reply-to-all. I tend to use “reply to all” as the default for my email program because of participating on these community lists. The only thing to be careful of with reply to all is when folks cross post to the same email to multiple email lists - you end up getting a warning from any you are not subscribed to. Jody On Mon, Jun 28, 2021 at 11:53 PM Peter Friess <pk.fri...@t-online.de> wrote: > Hi Jody, > > Thanks for your response. I already had received an answer from Andrea > which helped me solve my problem. Please, see below. > > It seems I made a mistake when answering to the response from Andrea, as > you did not get informed, that my problem was solved. I appreciate the work > of all involved in GeoTools, that one can ask questions and get help. > Please, let me know how to correctly communicate; adding always *GeoTools > Users <geotools-gt2-users@lists.sourceforge.net> > <geotools-gt2-users@lists.sourceforge.net>* to the cc? > > Regards, > > Peter > ---------------------------------------------------------------------------------------------------------------------------------------- > > > Thanks for the quick response. Now, I know what I did wrong. Here is the > version that works: > > public static Filter oddCorrectionNumberFilter() { > List<Expression> parStrSubstringStart = new ArrayList<>(); > parStrSubstringStart.add(ff.property(CORRECTION)); > parStrSubstringStart.add(ff.literal(4)); > > List<Expression> parParseInt = new ArrayList<>(); > parParseInt.add(df.function("strSubstringStart", parStrSubstringStart, > null)); > > List<Expression> parModulo = new ArrayList<>(); > parModulo.add(df.function("parseInt", parParseInt, null)); > parModulo.add(ff.literal(2)); > > return ff.equals(df.function("modulo", parModulo, null), > ff.literal(1)); > } > > Before I made the mistake and added a function to the parameter list as: > > parParseInt.add(*ff.literal*(df.function("strSubstringStart", > parStrSubstringStart, null))); > > Regards, > > Peter > Am 27.06.2021 um 12:19 schrieb Andrea Aime: > Functions take Expression objects as arguments, and Function is an > Expression. > So just call them as you would do in any programming language? > > You do not say how you're trying to build the function calls, but I'm > assuming SLD? > If so, then it would be something like (warning, untested, you might have > to adjust it a bit): > > <ogc:Function name="modulo"> > <ogc:Function name="parseInt"> > <ogc:Function name="strSubstringStart"> > <ogc:PropertyName>myAttribute</ogc:PropertyName> > <ogc:Literal>3</ogc:Literal> > </ogc:Function> > </ogc:Function> > <ogc:Literal>2</ogc:LIteral> > </ogc:Function> > > By the way, I don't remember about a "modulo" function or operator, there > is a IEEERemainder it's a floating point one > > Cheers > Andrea > > ------------------------------------------------------------ > > Am 29.06.2021 um 01:18 schrieb Jody Garnett: > > I expect you can do what you need using an expression: > > Recode( modulo( strSubstringStart( attribute, ,3), 2), > 0, '#FF0000'. > 1, '#00GG00' > ) > > If you are using YSLD for styling you can define this as a variable for > reuse (for example polygon outline and fill): > > # define here > define: &mycolor Recode( modulo( strSubstringStart( attribute, ,3), 2), 0, > '#FF0000'. 1, '#00GG00') > > # reuse as needed > - polygon: > stroke-color: *mycolor > fill-color: *mycolor > fill-opacity: 0.25 > > If you do need to write your own Java function there are lots of ways to > reuse function code: > > - Many of the functions have a static method (making the > implementation easier to test). When writing your own function you can make > use of these static methods to reuse functionality. The static method > approach is used for the original autogenerated functions: > FilterFunction_greatThan.java > > <https://github.com/geotools/geotools/blob/main/modules/library/main/src/main/java/org/geotools/filter/function/FilterFunction_greaterThan.java> > - You can also create functions, or filters, and make use of them > directly in your implementation. The implementation of > FilterFunction_equalTo > > <https://github.com/geotools/geotools/blob/main/modules/library/main/src/main/java/org/geotools/filter/function/FilterFunction_equalTo.java> > was > replaced to reference the create a filter (thus using the exact same > implementation). > - You can also extend an existing implementation to reuse code and > register your new function with factory spi. > > Another fun idea would be to make something like a function defined by a > CQL expression. This would only help readability, there would not be a > performance benefit. > -- > Jody Garnett > > > On Sat, 26 Jun 2021 at 04:04, Peter Friess <pk.fri...@t-online.de> wrote: > >> Hi There, >> >> I was wondering if there exists a way of combining several functions >> into one. I mean, that I can use the result of one function as input >> parameter into the next function etc., kind of chaining functions. >> Concrete: I have a feature which has among others a String attribute >> which looks like "PC_L1", PC_L2" etc. i.e a numbered identifier. I want >> to color code the features, by using a modulo function on the number >> (even with a certain color, odd with a certain color). I therefore need >> to extract the number with "strSubstringStart" convert it to an integer >> with "parseInt" and then use "modulo". Is it possible to do this >> somehow? If yes, how? >> >> Thanks in advance >> >> Peter Friess >> >> PS: if this is not possible, I need to introduce another attribute for >> just the number. >> >> >> >> _______________________________________________ >> GeoTools-GT2-Users mailing list >> GeoTools-GT2-Users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users >> > -- -- Jody Garnett
_______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users