[mapserver-users] msPostGISLayerWhichShapes() Error : java library set wrong query

Francesco Martinelli francesco.martinelli at ingv.it
Thu Jan 27 01:28:38 PST 2022


Thank you Jukka,
what you say could be the source of the problem,
but (I think) I have no direct control on how the library format the query
string I reported:
it is bundled within the call to the method
edu.umn.gis.mapscript.mapObj.draw()

*Here is the code*:
    mapObj myMap = new mapObj("myMapFile.map");
    rectObj originalMapView = myMap.getExtent();

    rectObj maxView = new rectObj(-1, -1, -1, -1,
myMap.getUnits().swigValue());
    maxView.setMinx(originalMapView.getMinx());
    maxView.setMaxx(originalMapView.getMaxx());
    maxView.setMiny(originalMapView.getMiny());
    maxView.setMaxy(originalMapView.getMaxy());

    rectObj myView = new rectObj(-1, -1, -1, -1, 3);
    myView.setMinx(*774076.75*);
    myView.setMaxx(*1014076.75*);
    myView.setMiny(*4875124.5*);
    myView.setMaxy(*5115124.5*);
    myMap.setExtent(myView);

    myMap.setSize(600, 600);

    pointObj mousePosition = new pointObj(300, 300, 0);
    myMap.zoomPoint(1, mousePosition, 600, 600, myView, maxView);
    myMap.draw();

*resulting in the error*:
*java.lang.UnknownError: msDrawMap():* Image handling error. Failed to draw
layer named 'MyLayer'.;*msPostGISLayerWhichShapes(): Query error*. Error
executing query. Check server logs
edu.umn.gis.mapscript.mapscriptJNI.mapObj_draw(Native Method)
edu.umn.gis.mapscript.mapObj.draw(mapObj.java:397)

*and in the ERROR file*:
[Wed Jan 26 17:14:19 2022].569532 msPostGISLayerWhichShapes(): Error
(ERROR:  parse error - invalid geometry
HINT:  "POLYGON((774076,75" <-- parse error at position 18 within geometry
) executing query: select "my_column"::text,ST_AsBinary(("the_geom"),'NDR')
as geom,"gid"::text from (SELECT * FROM classi_comuni WHERE tipo_area = 2
ORDER BY tipo_area DESC) AS confini where "the_geom" &&
ST_GeomFromText('*POLYGON((774076,75
4875124,5,774076,75 5115124,5,1014076,75 5115124,5,1014076,75
4875124,5,774076,75 4875124,5))*',find_srid('','classi_comuni','the_geom'))


Please any other idea on how I could solve it?

Thank you,
Francesco


Il giorno mer 26 gen 2022 alle ore 20:12 Rahkonen Jukka (MML) <
jukka.rahkonen at maanmittauslaitos.fi> ha scritto:

> Hi,
>
>
>
> I wonder if it could be related to which locale Java detects  on your
> computer – Italian (or Finnish) computer -> comma as a separator. Maybe
> something that deals around the same thing
> https://stackoverflow.com/questions/4713166/decimal-separator-in-numberformat
> .
>
>
>
> -Jukka Rahkonen-
>
>
>
> *Lähettäjä:* MapServer-users <mapserver-users-bounces at lists.osgeo.org> *Puolesta
> *Francesco Martinelli
> *Lähetetty:* keskiviikko 26. tammikuuta 2022 19.00
> *Vastaanottaja:* mapserver-users at lists.osgeo.org
> *Aihe:* [mapserver-users] msPostGISLayerWhichShapes() Error : java
> library set wrong query
>
>
>
> Hi all,
>
> I have a java program calling the method draw() of class
> edu.umn.gis.mapscript.mapObj
>
> after I compiled mapserver 7.6.4 on Ubuntu 20.04
>
>
>
> The result produce the following error:
>
> *java.lang.UnknownError: msDrawMap():* Image handling error. Failed to
> draw layer named 'MyLayer'.;*msPostGISLayerWhichShapes(): Query error*.
> Error executing query. Check server logs
> edu.umn.gis.mapscript.mapscriptJNI.mapObj_draw(Native Method)
> edu.umn.gis.mapscript.mapObj.draw(mapObj.java:397)
>
> In mapfile I set the parameters:
>
> *CONFIG* "MS_ERRORFILE" "myfile"
>
> *DEBUG* 6
>
> ...
>
> *LAYER*
>
>     *CONNECTIONTYPE* postgis
>
>     *DATA* "the_geom FROM (SELECT * FROM classi_comuni WHERE tipo_area =
> 2 ORDER BY tipo_area DESC) AS confini USING UNIQUE gid"
>
>     *CLASSITEM* "my_column"
>
> ...
>
> and in the error file I got the following message:
>
> [Wed Jan 26 17:14:19 2022].558530 msDrawMap(): rendering using
> outputformat named png24 (AGG/PNG).
> [Wed Jan 26 17:14:19 2022].569532 msPostGISLayerWhichShapes(): Error
> (ERROR:  parse error - invalid geometry
> HINT:  "POLYGON((774076,75" <-- parse error at position 18 within geometry
> ) executing query: select
> "my_column"::text,ST_AsBinary(("the_geom"),'NDR') as geom,"gid"::text from
> (SELECT * FROM classi_comuni WHERE tipo_area = 2 ORDER BY tipo_area DESC)
> AS confini where "the_geom" && ST_GeomFromText('*POLYGON((774076,75
> 4875124,5,774076,75 5115124,5,1014076,75 5115124,5,1014076,75
> 4875124,5,774076,75 4875124,5))*
> ',find_srid('','classi_comuni','the_geom'))
> [Wed Jan 26 17:14:19 2022].569545 msPostGISLayerWhichShapes(): Query
> error. Error executing query. Check server logs
> [Wed Jan 26 17:14:19 2022].569605 msDrawMap(): Image handling error.
> Failed to draw layer named 'MyLayer'.
>
>
>
> I checked the error is caused by decimal separators being commas instead
> of dots.
>
> As far as I understand the correct query would be (in *red* the changes):
>
> select "my_column"::text,ST_AsBinary(("the_geom"),'NDR') as
> geom,"gid"::text from (SELECT * FROM classi_comuni WHERE tipo_area = 2
> ORDER BY tipo_area DESC) AS confini where "the_geom" && ST_GeomFromText('*POLYGON((774076.75
> 4875124.5,774076.75 5115124.5,1014076.75 5115124.5,1014076.75
> 4875124.5,774076.75 4875124.5*
> ))',find_srid('','classi_comuni','the_geom'))
>
>
>
>
>
> I think I should set something during the compilation of java mapserver
> library.
>
> Please can someone drive me on how to solve it?
>
>
>
>
>
> Thank you,
>
> Francesco
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20220127/5b0e77fe/attachment.html>


More information about the MapServer-users mailing list