mapbox / shp-write

create and write to shapefiles in pure javascript
BSD 3-Clause "New" or "Revised" License
300 stars 187 forks source link

Issue with naming of Poly Line #109

Open devanshubisht opened 1 year ago

devanshubisht commented 1 year ago
  [
    geojson.point(gj),
    geojson.line(gj),
    geojson.polygon(gj),
    geojson.multipolygon(gj),
    geojson.multiline(gj),
  ].forEach(function (l) {
    if (l.geometries.length && l.geometries[0].length) {
      write(
        // field definitions
        l.properties,
        // geometry type
        l.type,
        // geometries
        l.geometries,
        function (err, files) {
          var fileName =
            options && options.types && options.types[l.type.toLowerCase()]
              ? options.types[l.type.toLowerCase()]
              : l.type;
          zipTarget.file(fileName + ".shp", files.shp.buffer, { binary: true });
          zipTarget.file(fileName + ".shx", files.shx.buffer, { binary: true });
          zipTarget.file(fileName + ".dbf", files.dbf.buffer, { binary: true });
          zipTarget.file(fileName + ".prj", prj);
        }
      );
    }
  });

When a geojson with linestring is being added, the shp type returned is polyline. But there is no option to edit the polyline name under shpwritedownloadoptions/zip optiosn

  export interface DownloadOptions {
    folder?: string;
    filename?: string;
    prj?: string;
    types?: {
      point?: string;
      polygon?: string;
      line?: string;
      multipolygon?: string;
      multiline?: string;
    };
  }
devanshubisht commented 1 year ago
  export interface DownloadOptions {
    folder?: string;
    filename?: string;
    prj?: string;
    types?: {
      point?: string;
      polygon?: string;
      polyline?: string;
      multipolygon?: string;
      multiline?: string;
    };
  }

Changing this would work, isit possible to add such changes?