Java Mapscript - querybyattribut SOLVED
umberto.nicoletti at GMAIL.COM
Fri Apr 14 09:23:51 EDT 2006
I GOT IT!
try to run the attached Java source. If you pass it two arguments the
first being the path to the map file and the second the string to
search for and you pass
"Südliche Weinstraße" as the second it will work!
So why does it fail when "Südliche Weinstraße" is inside the Java
code? That is a problem that only happens when javac compiles the
source: javac translates all characters to unicode and in doing that
it gets the german characters wrong.
To solve this give javac the following option: -source 1.4
For more see this link:
On 4/13/06, Umberto Nicoletti <umberto.nicoletti at gmail.com> wrote:
> This is probably not related only to java mapscript, so please read on.
So I was wrong...but I'll leave the proof to the reader ;-)
> On 3/30/06, Oliver Wesp <wesp at gdv.com> wrote:
> > Dear List,
> > I' struggling with queryByAttributes on an attribute field with german
> > umlauts using java mapscript.
> > The odd thing is that the same thing works fine with php mapscript and
> > when I use expressions in my mapfile. I'm using a shapefile as datasource.
> Could someone of the other mapserver developers shed some light on this issue?
> I have a clue to give: php mapscript is using a different regex
> library and this explains why the match does not happen for Java
> mapscript, while it does happen in php mapscript. If I am right also
> the mapserver cgi should be affected and possibly all other mapscript
> It would be very interesting if someone could report on similar
> experiences with the cgi-bin version of mapserver.
> > Here is what I do:
> > layer.queryByAttributes(map,"KREIS_NAME", "/Südliche Weinstraße/",
> > mapscriptConstants.MS_MULTIPLE);
> > layer.open();
> > System.out.println( "Result Count: " +layer.getNumResults() );
> > layer.close();
> > The result is always null while replacing the qstring with something
> > that doesn't contain special characters (e.g.
> > 'Mainz-Bingen') works fine.
> > As noted above the following layer definition in a mapfile works fine
> > LAYER
> > NAME kreis
> > STATUS DEFAULT
> > TYPE polygon
> > DATA "/tmp/subset"
> > TEMPLATE "kreis.html"
> > CLASSITEM KREIS_NAME
> > CLASS
> > NAME Boundary
> > COLOR 128 128 0
> > OUTLINECOLOR 0 0 0
> > EXPRESSION /Südliche Weinstraße/
> > END
> > END
> > but this does not:
> > layer.setClassitem("KREIS_NAME");
> > classObj cl = new classObj(layer);
> > cl.setName("Classname");
> > cl.setExpression("/Südliche Weinstraße/");
> > I use Mapserver 4.8.1 on W2k, Tomcat 5.0.28.
> > I can provide some sample data, just in case someone likes to reproduce.
> > Any help is appreciated.
> > best regards
> > Oliver
> > --
> > Dipl.-Geogr. Oliver Wesp
> > Gesellschaft fuer geografische Datenverarbeitung
> > Binger Strasse 49-51
> > D-55218 Ingelheim
> > fon: +49 6132 714818
> > fax: +49 6132 714828
> > http: www.gdv.com
More information about the mapserver-users