Bug report #18247

qgis-server - Problem with id field for WFS request

Added by Roberto Marzocchi about 6 years ago. Updated over 5 years ago.

Status:Closed
Priority:High
Assignee:Marco Hugentobler
Category:QGIS Server
Affected QGIS version:2.18.17 Regression?:No
Operating System:Ubuntu 16.04 Easy fix?:No
Pull Request or Patch supplied:Yes Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:26138

Description

Using PostGIS data (PostgreSQL 9.5 and PostGIS 2.4.2) the WFS are not correctly managed. I see two problems:

1) problem with layer id . See the following GEOJSON which is the answer of a WFS request on my server:

"type": "FeatureCollection",
 "bbox": [ 8.66328335, 44.37787282, 9.0979391, 44.52055853],
 "features": [
  {
   "type":"Feature",
*   "id":"municipo.",
*   "bbox":[8.911015, 44.394807, 8.948944, 44.441498],
   "geometry":
   {"type": "Polygon", "coordinates": [[ [8.911086, 44.394807], [8.948944, 44.394831], [8.948903, 44.441498], [8.911015, 44.441475], [8.911086, 44.394807]]] },
   "properties":{
      "nome_munic":"Centro est" 
   }
}
 ,{
   "type":"Feature",
   *"id":"municipo.",*
   "bbox":[8.875491, 44.388001, 8.94037, 44.430367],
   "geometry":
   {"type": "Polygon", "coordinates": [[ [8.875581, 44.388001], [8.94037, 44.388053], [8.940326, 44.430367], [8.875491, 44.430314], [8.875581, 44.388001]]] },
   "properties":{
      "nome_munic":"Centro Ovest" 
   }
}
 ,{
   "type":"Feature",
   "id":"municipo.",
   "bbox":[8.946167, 44.404599, 8.999985, 44.437809],
   "geometry":
   {"type": "Polygon", "coordinates": [[ [8.946198, 44.404599], [8.999985, 44.404612], [8.999985, 44.437809], [8.946167, 44.437796], [8.946198, 44.404599]]] },
   "properties":{
      "nome_munic":"Bassa Val Bisagno" 
   }
}
 ,{
   "type":"Feature",
   "id":"municipo.",
   "bbox":[8.930862, 44.414459, 9.057417, 44.485182],
   "geometry":
   {"type": "Polygon", "coordinates": [[ [8.930946, 44.414459], [9.057348, 44.414466], [9.057417, 44.485182], [8.930862, 44.485176], [8.930946, 44.414459]]] },
   "properties":{
      "nome_munic":"Media Val Bisagno" 
   }
}
 ,{
   "type":"Feature",
   "id":"municipo.",
   "bbox":[8.856775, 44.424035, 8.939742, 44.519878],
   "geometry":
   {"type": "Polygon", "coordinates": [[ [8.857009, 44.424035], [8.939742, 44.424109], [8.939643, 44.519878], [8.856775, 44.519804], [8.857009, 44.424035]]] },
   "properties":{
      "nome_munic":"Val Polcevera" 
   }
}
 ,{
   "type":"Feature",
   "id":"municipo.",
   "bbox":[8.816747, 44.399442, 8.890092, 44.476811],
   "geometry":
   {"type": "Polygon", "coordinates": [[ [8.816989, 44.399442], [8.890092, 44.399536], [8.889946, 44.476811], [8.816747, 44.476717], [8.816989, 44.399442]]] },
   "properties":{
      "nome_munic":"Medio Ponente" 
   }
}
 ,{
   "type":"Feature",
   "id":"municipo.",
   "bbox":[8.665559, 44.411659, 8.857853, 44.499071],
   "geometry":
   {"type": "Polygon", "coordinates": [[ [8.666055, 44.411659], [8.857853, 44.412059], [8.857641, 44.499071], [8.665559, 44.498669], [8.666055, 44.411659]]] },
   "properties":{
      "nome_munic":"Ponente" 
   }
}
 ,{
   "type":"Feature",
   "id":"municipo.",
   "bbox":[8.933302, 44.389217, 8.991497, 44.421298],
   "geometry":
   {"type": "Polygon", "coordinates": [[ [8.933339, 44.389217], [8.991497, 44.389237], [8.991492, 44.421298], [8.933302, 44.421278], [8.933339, 44.389217]]] },
   "properties":{
      "nome_munic":"Medio Levante" 
   }
}
 ,{
   "type":"Feature",
   "id":"municipo.",
   "bbox":[8.976466, 44.379032, 9.095649, 44.4365],
   "geometry":
   {"type": "Polygon", "coordinates": [[ [8.97649, 44.37907], [9.095556, 44.379032], [9.095649, 44.436462], [8.976466, 44.4365], [8.97649, 44.37907]]] },
   "properties":{
      "nome_munic":"Levante" 
   }
}
 ]
}

2) for big PostgreSQL data the server crash

History

#1 Updated by Giovanni Manghi about 6 years ago

  • Status changed from Open to Feedback

Hi, can you please edit the subject and change it something more meaningful (regarding to the issue reported), thanks!

Also 2) must be reported in a separate ticket, will all the details of the case (like what do you mean for "big").

#2 Updated by Roberto Marzocchi about 6 years ago

Giovanni Manghi wrote:

Hi, can you please edit the subject and change it something more meaningful (regarding to the issue reported), thanks!

I try to edit but I cannot change the subject of the ticket

Also 2) must be reported in a separate ticket, will all the details of the case (like what do you mean for "big").

OK

#3 Updated by Giovanni Manghi about 6 years ago

Roberto Marzocchi wrote:

Giovanni Manghi wrote:

Hi, can you please edit the subject and change it something more meaningful (regarding to the issue reported), thanks!

I try to edit but I cannot change the subject of the ticket

write it down here, I'll change it.

#4 Updated by Roberto Marzocchi about 6 years ago

Giovanni Manghi wrote:

Roberto Marzocchi wrote:

Giovanni Manghi wrote:

Hi, can you please edit the subject and change it something more meaningful (regarding to the issue reported), thanks!

I try to edit but I cannot change the subject of the ticket

write it down here, I'll change it.

qgis-server - Problem with id field for WFS request

#5 Updated by Roberto Marzocchi about 6 years ago

This problem affect PostGIS and Spatialite layer, while using a Shapefile the request works

POSTGIS REQUEST
https://www.gishosting.gter.it/lizmap-web-client/lizmap/www/index.php/lizmap/service/?repository=dorota&project=mappa_incidenti&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=municipo&OUTPUTFORMAT=GeoJSON&GEOMETRYNAME=extent&PROPERTYNAME=geometry%2Cnome_munic

{"type": "FeatureCollection",
"bbox": [ 8.66328335, 44.37787282, 9.0979391, 44.52055853],
"features": [ {
"type":"Feature",
"id":"municipo.",
"bbox":[8.911015, 44.394807, 8.948944, 44.441498],
"geometry": {"type": "Polygon", "coordinates": [[ [8.911086, 44.394807], [8.948944, 44.394831], [8.948903, 44.441498], [8.911015, 44.441475], [8.911086, 44.394807]]] },
"properties":{
"nome_munic":"Centro est"
}
}
[...]

SPATIALITE REQUEST
https://www.gishosting.gter.it/lizmap-web-client/lizmap/www/index.php/lizmap/service/?repository=dorota&project=mappa_incidenti&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=municipi&OUTPUTFORMAT=GeoJSON&GEOMETRYNAME=extent&PROPERTYNAME=geometry%2CNOME_MUNIC

{"type": "FeatureCollection",
"bbox": [ 8.66543983, 44.3785835, 9.09578466, 44.51985394],
"features": [ {
"type":"Feature",
"id":"municipi.",
"bbox":[8.911015, 44.394807, 8.948944, 44.441498],
"geometry": {"type": "Polygon", "coordinates": [[ [8.911086, 44.394807], [8.948944, 44.394831], [8.948903, 44.441498], [8.911015, 44.441475], [8.911086, 44.394807]]] },
"properties":{
"NOME_MUNIC":"Centro est"
}
}
[...]

SHAPEFILE REQUEST
https://www.gishosting.gter.it/lizmap-web-client/lizmap/www/index.php/lizmap/service/?repository=dorota&project=mappa_incidenti&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=municipi_shape&OUTPUTFORMAT=GeoJSON&GEOMETRYNAME=extent&PROPERTYNAME=geometry%2CNOME_MUNIC

{"type": "FeatureCollection",
"bbox": [ 8.66543983, 44.3785835, 9.09578466, 44.51985394],
"features": [ {
"type":"Feature",
"id":"municipi_shape.0",
"bbox":[8.911015, 44.394807, 8.948944, 44.441498],
"geometry": {"type": "Polygon", "coordinates": [[ [8.911086, 44.394807], [8.948944, 44.394831], [8.948903, 44.441498], [8.911015, 44.441475], [8.911086, 44.394807]]] },
"properties":{
"NOME_MUNIC":"Centro est"
}
}
[...]

#6 Updated by Giovanni Manghi about 6 years ago

  • Subject changed from QGIS Server to qgis-server - Problem with id field for WFS request

Roberto Marzocchi wrote:

This problem affect PostGIS and Spatialite layer, while using a Shapefile the request works

could you try the requests by taking Lizmap out of the equation (probably won't change a thing, but anyway...)? thanks.

#8 Updated by Giovanni Manghi about 6 years ago

Roberto Marzocchi wrote:

Yes. Same behaviour. I think it is a problem of application server, not of client. Perhaps a misconfiguration of php-pgsql or php-sqlite3?

if is the server then PHP is not involved at all.

#9 Updated by Giovanni Manghi about 6 years ago

  • Priority changed from High to Normal

I cannot confirm. Example here (from a project/getfeature that uses postgis):

...
...
...
"features": [ {
"type":"Feature",
"id":"clc_nivel5_evora.1",
"bbox":[-8.269889, 38.479035, -8.266458, 38.480962],
"geometry": {"type": "MultiPolygon", "coordinates": [[[ [-8.269531, 38.479035], [-8.269803, 38.479233], [-8.269889, 38.479303], [-8.269886, 38.479334], [-8.269763, 38.479457], [-8.269161, 38.479881], [-8.268837, 38.480065], [-8.268685, 38.480154], [-8.268639, 38.480177], [-8.268345, 38.480282], [-8.268223, 38.480319], [-8.268089, 38.480381], [-8.267994, 38.480431], [-8.267912, 38.48048], [-8.267692, 38.480632], [-8.267501, 38.480751], [-8.267419, 38.480796], [-8.267309, 38.480847], [-8.267261, 38.480864], [-8.267164, 38.480891], [-8.267009, 38.480928], [-8.266835, 38.480955], [-8.26677, 38.480962], [-8.266624, 38.480955], [-8.266573, 38.480947], [-8.266543, 38.480939], [-8.266497, 38.480919], [-8.26647, 38.480875], [-8.266458, 38.480827], [-8.266458, 38.480787], [-8.266462, 38.480741], [-8.266476, 38.480711], [-8.26649, 38.480672], [-8.266528, 38.480596], [-8.266561, 38.48055], [-8.26662, 38.480483], [-8.266681, 38.480426], [-8.266718, 38.480397], [-8.26676, 38.480367], [-8.266838, 38.480325], [-8.26688, 38.48029], [-8.266905, 38.480254], [-8.266935, 38.480197], [-8.266953, 38.480105], [-8.266982, 38.480027], [-8.267004, 38.479981], [-8.267009, 38.479972], [-8.26704, 38.47992], [-8.267066, 38.479884], [-8.267096, 38.479855], [-8.267141, 38.479836], [-8.26716, 38.479831], [-8.267211, 38.479824], [-8.267247, 38.479823], [-8.267357, 38.479832], [-8.267562, 38.479858], [-8.267643, 38.479861], [-8.267695, 38.47986], [-8.26773, 38.479857], [-8.268019, 38.479709], [-8.268207, 38.479552], [-8.26846, 38.479403], [-8.26881, 38.479297], [-8.269084, 38.479149], [-8.269272, 38.479077], [-8.269531, 38.479035]]]] },
"properties":{
"id":1,
"descri":"Albufeiras de barragem",
"clc51":"5.1.2.2",
"densidade":null,
"shape_leng":780.276304269,
"shape_area":2.39300404127
}
}
,
...
...
...

#10 Updated by René-Luc ReLuc about 6 years ago

  • Assignee set to Marco Hugentobler
  • Priority changed from Normal to High

This issue is due to an enhancement for multi primary keys. It this PR https://github.com/qgis/QGIS/pull/6279

Did you set the fields used as primary keys ?

#11 Updated by Marco Hugentobler about 6 years ago

Is it possible to attach a small postgres sql-dump with the problematic dataset (can be a small subset of the data). Like this, it is easier for us to check if the primary key is correctly detected by QGIS and why the problem happens.

#12 Updated by Jürgen Fischer about 6 years ago

  • Description updated (diff)

#13 Updated by Roberto Marzocchi about 6 years ago

using this spatialite file [[https://www.gter.it/nextcloud/index.php/s/zZPqoFPA0UY1PfX]] I have the problem

#14 Updated by Marco Hugentobler about 6 years ago

Thanks.
I've tested here with the latest 2.18 branch, simple project with municipi spatialite layer. The output here looks ok (see below). Maybe you could check if it happens for you also with such a simple project. If yes, please attach the project to this ticket (just in case something project specific is triggering the issue).

{"type": "FeatureCollection",
"bbox": [ 8.66543983, 44.3785835, 9.09578466, 44.51985394],
"features": [ {
"type":"Feature",
"id":"municipi.1",
"bbox":[8.911035, 44.394823, 8.948928, 44.441489],
"geometry": {"type": "MultiPolygon", "coordinates": [[[ [8.911233, 44.428853], [8.911237, 44.429023], [8.911268, 44.429102], [8.911351, 44.429162], [8.911404, 44.429228], [8.911465, 44.429326], [8.911531, 44.429408], [8.911545, 44.429471], [8.911618, 44.429637], [8.911723, 44.42974], [8.912019,

#15 Updated by Roberto Marzocchi about 6 years ago

I do the test using two different server and two different project, but I have the same problem. I use qgis-server package (v 2.18.17) and my OS is Ubuntu server 16.04 in both the server
here [[https://www.gter.it/nextcloud/index.php/s/6lCQi5MBq7Ynvdz]] my project, but it is a test project with only two spatalite layers..

#16 Updated by René-Luc ReLuc about 6 years ago

mhugent, the issue comes from the parameter PROPERTYNAME in which the web client does not request the primary key fields. So the primary key fields are not requested by QGIS Server, and it cannot use it in Fetaure ID.

#17 Updated by Marco Hugentobler about 6 years ago

Ah, too bad.
https://github.com/qgis/QGIS/pull/6522 provides a fallback to the feature id for such cases.

#18 Updated by Giovanni Manghi about 6 years ago

  • Pull Request or Patch supplied changed from No to Yes

#20 Updated by Roberto Marzocchi about 6 years ago

Alessandro Pasotti wrote:

Can we close this after https://github.com/qgis/QGIS/pull/6522 ?

I agree with you. We can close this ticket

#21 Updated by Giovanni Manghi over 5 years ago

  • Status changed from Feedback to Closed
  • Resolution set to fixed/implemented

Also available in: Atom PDF