Skip to content

Seperate linestrings are being combined into one multi-linestring. #117

@junyi2022

Description

@junyi2022

When I try to use the package and export the shapefile of multiple linestrings, it automatically combines the linestrings into one single multi-linestring.

const data = {
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {"id": 1},
      "geometry": {
        "coordinates": [
          [ 15.732725333712267, 18.51499012275039 ], [ 29.796471779359706, 18.19539060475546 ]
        ],
        "type": "LineString"
      }
    },
    {
      "type": "Feature",
      "properties": {"id": 2},
      "geometry": {
        "coordinates": [
          [ 16.008079368924513, 13.843031299450175 ], [ 29.25915144646919, 9.310680918508353 ]
        ],
        "type": "LineString"
      }
    }
  ]
}
const shpOptions = { outputType: 'blob'};
const blob = await shpwrite.zip( data, shpOptions);

The blob above will contain one multi-linestring. However, I expect to have two linestrings.

In the library, I changed the following line

geometries: shpType === 'POLYLINE' ? [oftype.map(justCoords)] : oftype.map(justCoords),

to

      geometries: shpType === 'POLYLINE' ? oftype.map(l => [justCoords(l)]) : oftype.map(justCoords),

This solved the issue to me, but not sure how it will do to actual multi-linestrings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions