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

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

Open
junyi2022 opened this issue Dec 11, 2023 · 1 comment
Open

Comments

@junyi2022
Copy link

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.

@berniesf
Copy link

@junyi2022 fix also helped me with an error I was getting when importing the shapefiles generated by shp-write into ArcGIS: "number of shapes doesn't not match the number of table records".
The error happened when multiple linestrings were present.

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

No branches or pull requests

2 participants