Skip to content

Spatial output: MultiLineString gets mangled into a LineString #5352

Closed

Description

@fredrik-stock

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

MultiLineStrings should be represented as [LineString, LineString, ...].
As of HC 12.12 / 13 it seems all the contained LinesStrings get concatenated into one single array of coordinates, which gets really wonky if the LineStrings aren't actually contigous:

BrokenMultiLineString

Manually serializing the same string with NTS.IO and sending it as a raw string gives the expected result:
CorrectMultiLineString

Steps to reproduce

  1. Create a MultiLineString consisting of 2 or more LineStrings.
  2. Request the MLS from your gql client.
  3. Observe that the returned output is 2-dimensional, not 3-dimensional.

Relevant log output

No response

Additional Context?

From existing issues and PRs it seems a similiar problem was fixed for MultiPolygon already.

Product

Hot Chocolate

Version

12.12.1

Activity

  1. fredrik-stock commented on Aug 30, 2022

    @fredrik-stock
    Author

    This might actually be an easy fix, since @PascalSenn already implemented the needed functionality in #4394.

    MultiPolygons were updated to be correctly handled as a GeometryCollection, reading out the contained coordinate arrays through indexed access:
    https://github.com/ChilliCream/hotchocolate/blob/ef1b268c7e624808862f18c43a190fba6303677a/src/HotChocolate/Spatial/src/Types/GeoJsonMultiPolygonType.cs#L19-L23

    MultiLineStrings meanwhile still access MultiLineString.Coordinates for their Coordinates field. This property "Collects all coordinates of all subgeometries into an Array", thus we get the flat structure observed:
    https://github.com/ChilliCream/hotchocolate/blob/ef1b268c7e624808862f18c43a190fba6303677a/src/HotChocolate/Spatial/src/Types/GeoJsonMultiLineStringType.cs#L18-L20

    Worth noting is that in NTS there are three classes that extend GeometryCollection. MultiPolygon, MultiLineString and MultiPoint. MultiPoint probably wouldn't need this change since it's basically a LineString, dimension-wise.

  2. PascalSenn commented on Aug 30, 2022

    @PascalSenn
    Member

    @fredrik-stock Thanks for reporting! yes this could indeed be the same problem

  3. added
    ⌛ stale
    on Dec 29, 2022
  4. deleted a comment from stale on Jan 14, 2024
  5. added
    Area: Spatial
    and removed
    ⌛ stale
    on Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: Spatial🌶️ hot chocolate

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions