On Sun, Apr 19, 2020 at 3:13 PM Tom Palan <[email protected]> wrote: > > Hi, > > could somebody please explain why the fetching of a GetFeatureInfo > request in application/json format instead of text/xml does need to > query the layer again to get the feature values, again? > > I am talking about qgswmsrenderer.cpp, method convertFeatureInfoToJson, > around line 2167. The conversion to json is the only one that needs to > re-fetch the feature data instead of using the "result" (QDomDocument) > directly. > > Is this because we need to get the correct field types for json > conversion instead of returning just string values? Is this a real > necessity? > I noticed this because a postgis layer had problems with its id-column, > and the json request failed while the xml request worked just fine. Of > course the id-column will be fixed, but the re-fetching of every > feature are also means that in the best case the db-query count goes up > from 1 to 1+<feature-cnt>. > > Thanks for your input, > Tom >
AFAICS there is no good reason, the dom document is only used to get the layers list, if you are on it I would recommend you to skip the line QDomDocument result = featureInfoDocument( layers, mapSettings, outputImage.get(), version ); in case the format is json and pass in the list of layers to render instead of the doc to QgsRenderer::convertFeatureInfoToJson. To give you some more context, json export format was implemented recently, after the server refactoring that happened in 3.0, perhaps this is the reason why it was added as another "switch" in the format list. -- Alessandro Pasotti w3: www.itopen.it _______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
