Hi list,

I am parsing a larger (about 200k characters) GeoJSON FeatureCollection string via QgsJsonUtils.stringToFields().
It contains polygon features, each with many coordinate pairs.
Despite the string being valid GeoJSON, no fields are returned.

However, if I save the string to a .geojson file and open it as vector layer, it opens with the attribute fields.

I am working with both QGIS 3.10.8 and 3.14.1 on Ubuntu.
Here is a simplified example of the GeoJSON structure:

{
    "features": [
        {
            "geometry": {
                "coordinates": [
                    [
                        [
                            0.0,
                            1.0
                        ],
                     .
                     .
                     .
                        [
                            0.0,
                            1.0
                        ]
                    ]
                ],
                "type": "Polygon"
            },
            "id": "abcd",
            "type": "Feature",
            "properties": {
                "attrib_a": "a text",
                "attrib_b": 1
            }
        }
    ],
"type": "FeatureCollection"
}


I found that if I do either of the below steps before calling QgsJsonUtils.stringToFields(), it does return the fields:

 *   significantly reduce the number of coordinate pairs
 *   Change the order of objects so that "type"  is ahead of "geometry"
   in the features.

I looked at the unit tests of QgsJsonUtils but only short geojson strings are tested there..

So it looks like large geometry objects in the GeoJSON feature would prevent reading its fields... unless "type" is parsed before them?

Is this buggy behavior? Or am I missing something?

Should I open an issue on GitHub?



Best regards,
Aron

<<attachment: aron_gergely.vcf>>

_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to