<div dir="auto">PS: QGIS server adds the id when creating the GeoJSON for a GetFeature request [1].<div dir="auto"><br></div><div dir="auto">giovanni<br><div dir="auto"><br></div><div dir="auto">[1] <a href="https://github.com/qgis/QGIS/blob/master/src/server/services/wfs/qgswfsgetfeature.cpp#L994">https://github.com/qgis/QGIS/blob/master/src/server/services/wfs/qgswfsgetfeature.cpp#L994</a></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">Il 9 ott 2017 18:13, "G. Allegri" <<a href="mailto:giohappy@gmail.com">giohappy@gmail.com</a>> ha scritto:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>HI all,<br></div>GeoJSON RFC7946 states that "If a Feature has a commonly used identifier, that identifier SHOULD be included as a member of the Feature object with the name "id", and the value of this member is either a JSON string or number". For example OpenLayers tries to parse the id field to uniquely identify the features inside a GeoJSON feature collection.<br></div>I've digged how OGR GeoJSON driver treats FIDs during serialization and it seems that it will write it if the OGrFeature has the FID field set [2], but AFAICS QIGS OGR provider doesn't set it unless "<span class="m_-6317282209978234536gmail-pl-c">the first attribute is the FID and the user has set it</span>". Well, this condition depends on [4], and now I odn't understand how this applies to a QGIS layer being exported to GeoJSON. <br><br></div>Questions:<br></div> - is there a way to force the OGR provider setting the FID?<br></div> - could the OGR provider have an option to force it from the export window, like Mapserver does with the USE_FEATUREID option for its output format<span style="font-weight:normal"><strong>?<br><br></strong></span></div>giovanni<span style="font-weight:normal"><strong><br></strong></span><div><div><div><div><div><br>[1] <a href="https://tools.ietf.org/html/rfc7946#page-11" target="_blank">https://tools.ietf.org/html/<wbr>rfc7946#page-11</a><br>[2] <a href="https://github.com/OSGeo/gdal/blob/trunk/gdal/ogr/ogrsf_frmts/geojson/ogrgeojsonwriter.cpp#L601" target="_blank">https://github.com/OSGeo/gdal/<wbr>blob/trunk/gdal/ogr/ogrsf_<wbr>frmts/geojson/<wbr>ogrgeojsonwriter.cpp#L601</a><br>[3] <a href="https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L1269" target="_blank">https://github.com/qgis/QGIS/<wbr>blob/master/src/providers/ogr/<wbr>qgsogrprovider.cpp#L1269</a><br>[4] <a href="https://github.com/qgis/QGIS/blob/master/src/providers/ogr/qgsogrprovider.cpp#L894" target="_blank">https://github.com/qgis/QGIS/<wbr>blob/master/src/providers/ogr/<wbr>qgsogrprovider.cpp#L894</a><br>[5] <a href="http://mapserver.org/output/ogr_output.html#table-of-contents" target="_blank">http://mapserver.org/output/<wbr>ogr_output.html#table-of-<wbr>contents</a><br></div></div></div></div></div></div>
</blockquote></div></div>