That is interesting, I wonder if sorting is respected when staging data for
vector tiles.

The source code will not contain an actual SQL query (as it is written to
work against and data format supported by the GeoTools library). There
should be a "query" object and we can check if it includes sort
information.

Looking at VectorMapRenderUtils
<https://github.com/geoserver/geoserver/blob/master/src/extension/vectortiles/src/main/java/org/geotools/renderer/lite/VectorMapRenderUtils.java#L69>
it is using VectorMapRenderUtils.getStyleQuery to access query defined by
the style. If you have access to a debugger you could put a breakpoint in
here and see if sorting is included.
--
Jody Garnett


On Mon, 2 Sep 2019 at 08:53, Moritz Schoenegg <schoen...@w3-data.de> wrote:

> hello geoserver users,
>
> I have problems sorting features with the vectortiles plugin. It works
> well in geoserver's layer preview, but sorting while requesting tiles from
> gwc service doesn't work. Has anybody successfully managed this?
>
> Here is what I've tried:
>
> + create a PostGIS table with some polygons:
>
> CREATE TABLE public.mvtexample
> (
>     shape geometry,
>     integer2sort integer,
>     string2sort text COLLATE pg_catalog."default",
>     CONSTRAINT mvtexample_pkey PRIMARY KEY (integer2sort)
> );
>
> INSERT INTO public.mvtexample(
>     shape, integer2sort, string2sort)
> VALUES
>
> ('0106000020E6100000010000000103000000010000003A000000AE484C50C3AF2A40228C9FC6BDD14A40158F8B6A11A12A40ECDCB419A7D14A40FEB8FDF2C9A22A404016A243E0D44A407F1475E61E9A2A40F7ADD689CBD54A40BA11161571B22A40CCB4FD2B2BD74A401DE8A1B60DC32A40983446EBA8D84A40ABEB504D49CE2A408597E0D407DA4A4028EE7893DFC22A40FBCDC47421DC4A40CB11329067B72A40AEF4DA6CACDC4A4047020D3675BE2A40384C3448C1DF4A4011E50B5A48C02A406F7F2E1A32E24A40F3E49A0299B52A404C5299620EE44A404CDD955D30B02A406B459BE3DCE64A40C72C7B12D8BC2A401AFD683865E64A4053B131AF23C62A40365A0EF450E74A401CD2A8C0C9CE2A4085285FD042E44A4095EEAEB321DF2A408351499D80E24A40ADFA5C6DC5E62A40D02A33A5F5E34A40B8ACC26680EB2A40D0B69A75C6E74A4026A77686A9F52A40533D997FF4E74A4066A19DD32C002B40164CFC51D4E54A40BE6C3B6D8D102B40C30FCEA78EE54A4054ABAFAE0A142B40DCF126BF45E54A40D9B5BDDD921C2B408C6665FB90E34A4091F12895F0342B407EE5417A8AE24A4035272F32013F2B40503750E09DE44A4046D1031F834D2B4094861A8524E34A40A14CA3C9C5582B4048DC63E943E34A404F78094E7D582B406364C91CCBDF4A403FC4060B27512B40B9C5FCDCD0DE4A401286014BAE6A2B40315EF3AACEDA4A40BE4D7FF6236D2B409755D80C70D94A40B0C6D97404782B40C0EAC891CED84A40D7C1C1DEC4882B40111B2C9CA4D74A407DCF488446982B400D0055DCB8D74A402C0E677E358F2B406A2E3718EAD64A40069D103AE8722B407A185A9D9CD54A40A4DFBE0E9C632B40070ABC934FD34A40FD4AE7C3B3742B40FE0C6FD6E0D14A40A5677A89B1842B40BD5296218ECF4A40810871E5EC652B40D1EAE40CC5CB4A403FC7478B33562B404FE8F527F1CB4A40B7B585E7A5522B405401F73C7FCC4A40E7C41EDAC7322B40ED612F14B0CB4A40C5909C4CDC1A2B40B83EAC376ACD4A40B6679604A8092B40FA7E6ABC74C94A4006651A4D2EEE2A40D57B2AA73DC74A402368CC24EAE52A40E947C32973C94A40F641960513D72A408DF161F6B2C94A40BF9CD9AED0CF2A4078094E7D20CB4A402F17F19D98AD2A405AF10D85CFC84A40CDCB61F71DA32A4092CCEA1D6EC94A400A14B188619F2A4054724EECA1CB4A40B9E00CFE7EA12A400C73823639CC4A40C24B70EA03B12A400569C6A2E9CC4A40348463963DC12A40F015DD7A4DCF4A40AE484C50C3AF2A40228C9FC6BDD14A40AE484C50C3AF2A40228C9FC6BDD14A40'::geometry,1,'1'),
>
> ('0106000020E6100000010000000103000000010000003D0000007FDAA84E07822A4016FC36C478BF4A4058AEB7CD54702A402B4CDF6B08C04A40DE03745FCE7C2A403E78EDD286C14A401538D906EE982A4072C284D1ACC24A40785E2A36E6A52A40CCECF318E5C34A40F0FD0DDAABAF2A406CED7DAA0AC54A402F17F19D98AD2A405AF10D85CFC84A40BF9CD9AED0CF2A4078094E7D20CB4A404B033FAA61D72A40BA84436FF1CC4A406840BD1935D72A4069C36169E0CD4A4065A71FD445DA2A40A86F99D365D14A40A4FD0FB056E52A402D431CEBE2D44A40C9FFE4EFDEE92A40F9F884ECBCD74A40459E245D33F92A40427A8A1C22DA4A401E87C1FC15EA2A40A9674128EFDB4A4027124C35B3DE2A403BFC3559A3DA4A40999B6F44F7D42A408255F5F23BDB4A4072361D01DCDC2A4016855D143DE04A4003E962D34A012B40EBE40CC51DDF4A40F33D23111A092B40A10F96B1A1DD4A40A8363811FD122B40A6D24F38BBD94A40B20DDC813A1D2B404792205C01D94A4040683D7C99482B40F9484A7A18DA4A402D228AC91B502B40E1D1C6116BD94A4047ACC5A700402B40E94317D4B7D84A4036751E15FF272B4099F04BFDBCD14A409599D2FA5B3A2B404A438D4292CF4A4067F3380CE63F2B40377007EA94CD4A40B7B585E7A5522B405401F73C7FCC4A403FC7478B33562B404FE8F527F1CB4A400667F0F78B512B4002D8800871C94A40B9E00CFE7E412B40F5DBD78173C84A40529E7939EC562B4012143FC6DCC54A40492C29779F5B2B400934D8D479C44A40997FF44D9A562B4001A4367172C14A40D2510E6613402B40E15D2EE23BC14A40037D224F923E2B40DE04DF347DC24A406AF7AB00DF1D2B401F813FFCFCC14A40AF415F7AFB132B4007EFAB72A1C24A4075C7629B540C2B40A2D3F36E2CC24A40799274CDE40B2B40A46C91B41BBF4A40FC3905F9D9182B406ADE718A8EBC4A4071AAB5300B0D2B4091D26C1E87BB4A406F83DA6FEDFC2A40063065E080BC4A40AE7FD767CEF22A407A8F334DD8BA4A40F513CE6E2DD32A408813984EEBB84A40331AF9BCE2C92A4015731074B4B64A40AE8218E8DAD72A40554FE61F7DB34A40C710001C7BBE2A40C4060B2769B24A40A56950340FB82A40293C6876DDAF4A40725298F738AB2A40D93EE42D57AF4A4075CC79C6BEA42A40348639419BB04A402429E96168AD2A4009C6C1A563B24A4035B742588D9D2A400F7EE200FAB34A404EED0C535B922A40B2BAD573D2B34A40B1F84D61A5922A40F6B2EDB435B64A4073D53C47E48B2A40A568E55E60B84A40B115342DB1822A405664744012B84A40E0F60489ED762A4076C3B64599B94A407FDAA84E07822A4016FC36C478BF4A407FDAA84E07822A4016FC36C478BF4A40'::geometry,2,'2');
>
> In geoserver panel:
> + create a PostGIS store
> + create a layer, serve it as application/vnd.mapbox-vector-tile
> + create a Style for sorting  by feature (following the "Enabling
> z-ordering in a single FeatureTypeStyle" tutorial):
>
>       <VendorOption name="sortBy">integer2sort A</VendorOption>
>
> + attach style to layer
>
> In geoserver's layer preview, the features are sorted by default the same
> way I inserted them into the table.
> When I attach the style, the features are correctly sorted in the layer
> preview, and they change their order when I change integer2sort A to 
> integer2sort
> D.
>
> However when I fetch them via mapbox-gl, the order is always descending
> and doesn't change no matter what I do.
>
> Here's a minimal example of my javascript:
>
>   map.on("load", function() {
>     map.addLayer(
>       {
>         "id": "layer",
>         "source-layer": "mvtexample", // this has to fit settings in
> geoserver (name of layer)
>         "type": "fill",
>         "source": {
>           "type": "vector",
>           "tiles":
> ["<geoserver.baseurl>/geoserver/gwc/service/wmts?bbox={bbox-epsg-3857}&REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=warnings:mvtexample&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}"]
>         },
>         "layout": {
>           "visibility": "visible",
>         },
>         "paint": {
>           "fill-color": {
>             "type": "categorical",
>             "property": "integer2sort",
>             "stops": [
>               [
>                 1,
>                 "rgba(251,140,0,1)"
>               ],
>               [
>                 2,
>                 "rgba(255,235,59,1)"
>               ]
>             ],
>             "default": "rgba(0,0,0,0)"
>           },
>           "fill-outline-color": "rgba(0,0,0,0)",
>         }
>       });
>
>     map.on("click", function (e) {
>       let features = map.queryRenderedFeatures(e.point, {layers:
> ["layer"]});
>       let sort = [];
>
>       for (var i = 0; i < features.length; i++) {
>         sort.push(features[i].properties.integer2sort);
>       }
>       console.log(sort)
>     });
>
> I can see that the style is attached to the layer in geoserver logs.
>
> I am new to geoserver, and wasn't able to find the actual PostGIS query in
> the source code, perhaps that would be a start.
>
> I am using geoserver 2.15.2 and the corresponding vectortiles-plugin, java
> (openjdk 11.0.4) on Ubuntu 18.04.
>
>
> Thank you for your help
>
> Moritz
>
>
>
> _______________________________________________
> Geoserver-users mailing list
>
> Please make sure you read the following two resources before posting to
> this list:
> - Earning your support instead of buying it, but Ian Turton:
> http://www.ianturton.com/talks/foss4g.html#/
> - The GeoServer user list posting guidelines:
> http://geoserver.org/comm/userlist-guidelines.html
>
> If you want to request a feature or an improvement, also see this:
> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer
>
>
> Geoserver-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to