<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body>
Another idea might be to add a couple of columns to the data called GetMap and GetFeatureInfo and store the appropriate values to get you the order you want in them.<br>
<br>
Then you can use runtime substitution in the DATA attribute to set the sort column based on the request type. E.g.<br>
<br>
  DATA “... ORDER BY %request% ...”<br>
<br>
You set validation on the the request accordingly. Might be some other SQL options to capitalize on.
<br>
<br>
—Steve<br>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> mapserver-users <mapserver-users-bounces@lists.osgeo.org> on behalf of Rahkonen Jukka (MML) <jukka.rahkonen@maanmittauslaitos.fi><br>
<b>Sent:</b> Tuesday, August 28, 2018 4:33:54 AM<br>
<b>To:</b> Jörg Thomsen (WhereGroup); mapserver-users@lists.osgeo.org<br>
<b>Subject:</b> Re: [mapserver-users] GetMap vs GetFeatureinfo sort</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hi,<br>
<br>
>From <a href="https://mapserver.org/mapfile/layer.html">https://mapserver.org/mapfile/layer.html</a><br>
"Inside a layer, only a single class will be used for the rendering of a feature. Each feature is tested against each class in the order in which they are defined in the mapfile. The first class that matches the its min/max scale constraints and its EXPRESSION
 check for the current feature will be used for rendering."<br>
<br>
So in your example first geometry is rendered first with color 53 68 150 and the second one above it with color 188 34 115.<br>
<br>
You wrote "I expect that the topmost feature returned in getfeatureinfo response <br>
correspond to the topmost feature drawn on map". If you think of the rendering process, of yourself painting with brushes, the topmost feature on the map is the one that is painted last. If I understand it ight you would like to get a reversed order for GetFeatureInfo.<br>
<br>
A workaround could be to make a copy of the layer you show on the map but with reversed sorting order. This layer would be used only for GetFeatureInfo requests. According to WMS specification QUERY_LAYERS must be a subset of LAYERS but if I remember right
 Mapserver is not strict with that and you could capture the GFT request on server side and change the name of the QUERY_LAYER on-the-fly. If Mapserver is strict, or you use some other server that follows the standard, you must also manipulate the request a
 bit more and add this extra layer into &LAYERS=.  Of course if you can control the client side you can make it to alter the GetFeatureInfo instead.<br>
<br>
Another option could be to read the feature info with WFS GetFeature instead of WMS GetFeatureInfo. I also guess that heavy users of Mapserver will recommend you to use some MapScript dialect.<br>
<br>
Be aware that Mapserver does not offer a real WYSIWYG experience with GetFeatureInfo. You can get also something what you do not see because Mapserver does not filter the GFI result by rendering rules like min/maxscaledenominators. I also believe that even
 if you have classes only for expression values 1 and 4 in your mapfile the GetFeatureInfo finds everything that appears in the data. I am not sure about this, though.<br>
<br>
-Jukka Rahkonen-<br>
<br>
<br>
<br>
<br>
-----Alkuperäinen viesti-----<br>
Lähettäjä: mapserver-users [<a href="mailto:mapserver-users-bounces@lists.osgeo.org">mailto:mapserver-users-bounces@lists.osgeo.org</a>] Puolesta Jörg Thomsen (WhereGroup)<br>
Lähetetty: 28. elokuuta 2018 10:13<br>
Vastaanottaja: mapserver-users@lists.osgeo.org<br>
Aihe: Re: [mapserver-users] GetMap vs GetFeatureinfo sort<br>
<br>
Hi,<br>
<br>
hm, I would have expected the classes to be drawn in the same order as in the mapfile.<br>
<br>
You could try to use the label-section with geomtransform 'labelpoint'<br>
[1], perhaps mapserver there takes care of the mapfile order...<br>
<br>
Another option would be to use grouped layers, I guess you found this<br>
already:<br>
<a href="https://gis.stackexchange.com/questions/71152/mapserver-layer-classes-display-order">https://gis.stackexchange.com/questions/71152/mapserver-layer-classes-display-order</a><br>
-> 2nd answer<br>
<br>
Jörg<br>
<br>
<br>
[1] <a href="https://mapserver.org/mapfile/label.html">https://mapserver.org/mapfile/label.html</a><br>
[2] <a href="https://mapserver.org/mapfile/geomtransform.html">https://mapserver.org/mapfile/geomtransform.html</a><br>
<br>
Am 27.08.2018 um 20:37 schrieb pe_lord:<br>
> Thanks. <br>
> <br>
> Here more informations.<br>
> <br>
> I have 2 overlapping geometries. <br>
> <br>
> My class are based on a field ==> CLASSITEM "code_type" and appear in <br>
> my mapfile in this order.<br>
> <br>
> CLASS<br>
>     NAME "Blue CLASS"<br>
>     EXPRESSION '1'<br>
>     STYLE<br>
>     SYMBOL "square"<br>
>         SIZE 8<br>
>        COLOR 53 68 150<br>
>     END<br>
> END<br>
> ...<br>
> CLASS<br>
>     NAME "Red Class"<br>
>     EXPRESSION '4'<br>
>     STYLE<br>
>     SYMBOL "square"<br>
>         SIZE 8<br>
>        COLOR 188 34 115<br>
>     END<br>
> END<br>
> <br>
> My data is stored in this order into PG, with this structure (id,<br>
> code_type,geom):<br>
> id1,4,geom<br>
> id2,1,geom<br>
> <br>
> If I understand properly, my last geometrie (id2) is plotted on top of <br>
> other classes. This is making sense.<br>
> <br>
> Otherwise, in the getfeatureinfo, the same order is kept, this a <br>
> non-sense according to my classes's order.<br>
> <br>
> I would like to to present this data in a flipped order like, <br>
> according to my classes's logic:<br>
> id2,1<br>
> id1,4<br>
> <br>
> <br>
> I expect that the topmost feature returned in getfeatureinfo response <br>
> correspond to the topmost feature drawn on map. I would like to have a <br>
> constant response, independently from my template format (gml, html,<br>
> json...)<br>
> <br>
> You will find an<br>
> <<a href="http://osgeo-org.1560.x6.nabble.com/file/t378858/sl.png">http://osgeo-org.1560.x6.nabble.com/file/t378858/sl.png</a>><br>
> <br>
> <br>
> Here what I tried without succes:<br>
> - flip my mapfile's classes<br>
> - sort my data based on my field (code_type). In this case, either I <br>
> have the getmap sorted in the right order, or the getfeatureinfo. Both <br>
> behaviors are impossible at the same time.<br>
> <br>
> <br>
> <br>
> <br>
> <br>
> --<br>
> Sent from: <br>
> <a href="http://osgeo-org.1560.x6.nabble.com/Mapserver-User-f4226646.html">http://osgeo-org.1560.x6.nabble.com/Mapserver-User-f4226646.html</a><br>
> _______________________________________________<br>
> mapserver-users mailing list<br>
> mapserver-users@lists.osgeo.org<br>
> <a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
> <br>
<br>
<br>
Viele Grüße,<br>
Jörg Thomsen<br>
<br>
-- <br>
<br>
******************************************************************<br>
 FOSS Academy Sommerschule 2018<br>
 Alles Wichtige zur Erstellung einer GDI in nur 5 Tagen erlernen!<br>
 <a href="https://www.foss-academy.com/kompaktkurse">https://www.foss-academy.com/kompaktkurse</a><br>
 *****************************************************************<br>
<br>
<br>
Jörg Thomsen<br>
WhereGroup GmbH & Co. KG<br>
Gillweg 3<br>
14193 Berlin<br>
Germany<br>
<br>
Fon: +49 (0)30 / 5130 278 74<br>
Fax: +49 (0)30 / 89 09 53 21<br>
<br>
joerg.thomsen@wheregroup.com<br>
<a href="http://www.wheregroup.com">www.wheregroup.com</a><br>
Amtsgericht Bonn, HRA 6788<br>
-------------------------------<br>
Komplementärin:<br>
WhereGroup Verwaltungs GmbH<br>
vertreten durch:<br>
Olaf Knopp, Peter Stamm<br>
-------------------------------<br>
Folgen Sie der WhereGroup auf twitter: <a href="http://twitter.com/WhereGroup_com">
http://twitter.com/WhereGroup_com</a> _______________________________________________<br>
mapserver-users mailing list<br>
mapserver-users@lists.osgeo.org<br>
<a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a><br>
_______________________________________________<br>
mapserver-users mailing list<br>
mapserver-users@lists.osgeo.org<br>
<a href="https://lists.osgeo.org/mailman/listinfo/mapserver-users">https://lists.osgeo.org/mailman/listinfo/mapserver-users</a></div>
</span></font></div>
</body>
</html>