Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arches throws error when updating geojson-feature-collection node when zero-length LineString or MultiLineString is present #11666

Open
tris-ots opened this issue Dec 3, 2024 · 4 comments

Comments

@tris-ots
Copy link

tris-ots commented Dec 3, 2024

In our work with Arches, we sometimes receive geojson files from clients which include zero-length LineString or MultiLineString features. QGIS and geojson.io handle this type of feature gracefully, but Arches returns an error ("Unable to serialize some geometry features") and refuses to save the geojson data. This is surprising and opaque to users who have experience with standard GIS software.

So far I have only encountered this issue while using Arches 7.6.0, and haven't tried reproducing it in any other versions.

The error message is this:

TileValidationError: geojson-feature-collection error, {'type': 'FeatureCollection', 'features': [{'id': 'fa1f218f-e694-44e8-a43e-2c007bfc97e1', 'type': 'Feature', 'properties': {'Name': None, 'nodeId': '1fb1a9be-b05c-11ef-a8fd-52540067bf29'}, 'geometry': {'coordinates': [[1.4805, 51.895167, 0], [1.4805, 51.895167, 0]], 'type': 'LineString'}}, {'id': '7b9add596dc34dadf325de2ef357a939', 'type': 'Feature', 'properties': {'nodeId': '1fb1a9be-b05c-11ef-a8fd-52540067bf29'}, 'geometry': {'coordinates': [[[1.480771916663599, 51.89549137934347], [1.47982430885628, 51.89464670840576], [1.4808640452009172, 51.8945248795564], [1.4816142347153516, 51.89534518743264], [1.480771916663599, 51.89549137934347]]], 'type': 'Polygon'}}, {'id': '1ff5f9d4-c36d-4fab-86ff-ff39b64cf864', 'type': 'Feature', 'properties': {'Name': None, 'nodeId': '1fb1a9be-b05c-11ef-a8fd-52540067bf29'}, 'geometry': {'coordinates': [[1.4805, 51.895167, 0], [1.4805, 51.895167, 0]], 'type': 'LineString'}}, {'id': '1696c9a4-752b-422f-b57e-ce6a33676d06', 'type': 'Feature', 'properties': {'nodeId': '1fb1a9be-b05c-11ef-a8fd-52540067bf29', 'name': 'Sealand 2: Oceanic Boogaloo'}, 'geometry': {'coordinates': [[[1.480771916663599, 51.89549137934347], [1.47982430885628, 51.89464670840576], [1.4808640452009172, 51.8945248795564], [1.4816142347153516, 51.89534518743264], [1.480771916663599, 51.89549137934347]]], 'type': 'Polygon'}}]} - Unable to serialize some geometry features.. Unable to save.
Unable to save. Please verify your input is valid

Attached is a sample geojson which produces the error, and screenshots of the file being loaded successfully (as a polygon layer and a line layer) in QGIS and in geojson.io, as well as a screenshot of the error shown by Arches.

Steps to reproduce:

  1. Edit the geojson data of a geojson-feature-collection node.
  2. Paste the sample geojson.
  3. Click the Update Features button.
  4. Click the Add button.

Expected behavior:
Arches stores the geojson data on the node successfully.

Observed behavior:
Arches throws an error and the data is not saved on the node.

zero-length-line-issue-arches
zero-length-line-issue-geojson-io
zero-length-line-issue-qgis

JSON file for reproducing error on Arches: (file contains both a valid polygon and a zero-length LineString) zero-length-issue.json

@chiatt chiatt added this to pipeline Dec 3, 2024
@kfogel
Copy link
Contributor

kfogel commented Dec 3, 2024

@tris-ots I'm no GeoJSON expert, but in your sample file (zero-length-issue.json) there are actually two zero-length LineStrings, both at the exact same location. (They have different "id" values, so there's no actual entity collision here.)

Also, they both have null for their "Name" field, in their corresponding "properties" dicts -- I don't know if that matters? Maybe null is perfectly fine? But it's worth seeing if this bug still reproduces with a non-null name, maybe?

Also: in the cases of those two LineStrings, that "Name" field is capitalized. But the only other occurrence of a name field in the input file is uncapitalized "name" (for the Polygon "name": "A Polygon Near Sealand"), and furthermore all other fieldnames throughout the file start with a lower-case letter -- which makes me wonder if capitalized "Name" for those two LineStrings is correct.

So I guess I have three semi-related questions:

  1. Could the null values for the names of the LineStrings be the problem?
  2. Could the fact that the two LineStrings have the same name (well, null, but null is indeed equal to null) be the problem?
  3. Could the capitalization of the "Name" field be the problem?

I assume that the fact that there are two LineStrings whose location and shape are exactly the same is not, in itself, a problem, since obviously geographic features can overlap in real life.

@tris-ots
Copy link
Author

tris-ots commented Dec 3, 2024

hi Karl - good questions, thanks.
I should note that the geojson file i posted above was somewhat transformed by the attempt to import it into Arches, hence all the id fields containing UUIDs. i edited the file, addressing all the issues you mentioned - making the "name" field consistently non-capitalized, and assigning a different name to each linestring - and Arches still threw the same error about being unable to serialize geometry.

I'll also admit at this point that my hypothesis about what's causing the issue came from examining the Arches log in journalctl, and coming across these messages:

GEOS_NOTICE: Too few points in geometry component at or near point 1.4804999999999999 51.895167000000001 0
GEOS_NOTICE: Too few points in geometry component at or near point 1.4804999999999999 51.895167000000001 0

This error message led me to an old stackexchange post which I'll admit I don't fully understand, but it suggests that the GEOS library used by PostGIS (and in turn used by Arches) doesn't like zero-length LineStrings.

Here's the sample geojson that I imported into Arches (before it adds UUIDs or does any other editing) :

{
  "type": "FeatureCollection",
  "features": [
    {
        "type": "Feature",
        "properties": {
          "name": "Line0"
        },
        "geometry": {
          "coordinates": [
            [1.4805, 51.895167, 0],
            [1.4805, 51.895167, 0]
          ],
          "type": "LineString"
        }
      },
    {
      "type": "Feature",
      "properties": {
        "name": "Line1"
      },
      "geometry": {
        "coordinates": [
          [1.4805, 51.895167, 0],
          [1.4805, 51.895167, 0]
        ],
        "type": "LineString"
      }
    },
    {
      "type": "Feature",
      "properties": {
        "name": "A Polygon Near Sealand"
      },
      "geometry": {
        "coordinates": [
          [
            [1.480771916663599, 51.89549137934347],
            [1.47982430885628, 51.89464670840576],
            [1.4808640452009172, 51.8945248795564],
            [1.4816142347153516, 51.89534518743264],
            [1.480771916663599, 51.89549137934347]
          ]
        ],
        "type": "Polygon"
      }
    }
  ]
}

@robgaston
Copy link
Member

I’m noting that there is one other interesting case here: these linestrings are 3-dimensional (note the third value in coordinate pairs), though the elevation value appears unused (0). I don’t think that Arches supports 3d geometries at the moment, so this may alone be the issue. i would need to consider how best to proceed on that question (support 3d geometries? aggressively convert to 2d?), but converting to 2d geometries may provide a workaround in the short term if you don’t truly need 3-dimensional geometries.

@tris-ots
Copy link
Author

tris-ots commented Dec 3, 2024

Good spot, Rob. Just to reduce the number of variables, i deleted the third coordinate in the linestring feature and tried to update the geojson-feature-collection node. Same error - Unable to serialize some geometry features.. Unable to save.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

3 participants