terraformer-js / terraformer

A geographic toolkit for dealing with geometry, geography, formats, and building geodatabases
MIT License
182 stars 28 forks source link

applyConverter missing? #68

Closed allmondjoy87 closed 2 years ago

allmondjoy87 commented 2 years ago

How do I use the applyConverter tool with the latest release?

jgravois commented 2 years ago
import { applyConverter } from '@terraformer/spatial'
// Runs the passed function against every Coordinate in the geojson object. 
// Your function will be passed a Coordinate and will be expected to return a Coordinate.
applyConverter(geojson, yourFunction);

if someone is interested in adding JSDoc for the method to ensure it shows up in the documentation, that'd be welcome.

allmondjoy87 commented 2 years ago

aha!! I was getting "TypeError: Object(...) is not a function" errors and assumed it was an issue with my converter function.

After digging a little deeper applyConverter is missing in the exports section in the t-spatial.esm.js and t-spatial.umd.js files. I added it in my source code and everything's gravy.

jgravois commented 2 years ago

if someone wants to export the utility function in the file below and add JSDoc, i'd be more than happy to publish the change.

https://github.com/terraformer-js/terraformer/blob/master/packages/spatial/src/index.js

allmondjoy87 commented 2 years ago

looks like this hasn't been updated yet, any chance someone can make the fix? is this something i can do? i've never contributed to a project before, unsure what the rules are.

jgravois commented 2 years ago

is this something i can do? i've never contributed to a project before, unsure what the rules are.

absolutely. to do this you'd just need to:

  1. clone the repo
  2. run npm install && npm test locally to ensure all is well
  3. add the relevant export in packages/spatial/src/index.js
  4. supplement that export with the JSDoc below
  5. run npm run doc to update the README for the spatial package to mention the new method
  6. run npm test again to confirm all is still well
  7. commit the result in your own branch and open up a PR
/**
 * Runs the passed function against every Coordinate in the geojson object.
 * @function
 * @param {object} GeoJSON - The input [GeoJSON](https://tools.ietf.org/html/rfc7946) Geometry, Feature, GeometryCollection or FeatureCollection.
 * @param {function} function - Your function will be passed a Coordinate and will be expected to return a Coordinate.
 * @return {object} GeoJSON - [GeoJSON](https://tools.ietf.org/html/rfc7946) with altered coordinates.
 * ```js
 * import { applyConverter } from "@terraformer/spatial"
 *
 * applyConverter({
 *   type: "Point",
 *   coordinates: [ 45, 60 ]
 * }, (coord) => [coord[0] + 1, coord[1] - 1])
 *
 * >> { type: "Point", coordinates: [ 46, 59 ] }
 * ```
 */
allmondjoy87 commented 2 years ago

Well I'm having issues with npm-install. Getting tarball and ultimately EINTEGRITY errors when it tries to install jison@git+ssh.

lerna ERR! npm install exited 1 in '@terraformer/wkt'
lerna ERR! npm install stderr:
npm WARN deprecated nomnom@1.5.2: Package no longer supported. Contact support@npmjs.com for more info.
npm WARN tarball tarball data for jison@git+ssh://git@github.com/GabrielRatener/jison.git#2668d7efbb628c763dc7cce41ab24a4632528942 (sha512-NHThbqidF4gPr4YwTd6MUFqGiUdWbYqcBAFH1gPYWaLmoHWafH/kCGjDmJkFKEV2XkeWAyODEBT95mzZVa67sA==) seems to be corrupted. Trying again.
npm WARN tarball tarball data for jison@git+ssh://git@github.com/GabrielRatener/jison.git#2668d7efbb628c763dc7cce41ab24a4632528942 (sha512-NHThbqidF4gPr4YwTd6MUFqGiUdWbYqcBAFH1gPYWaLmoHWafH/kCGjDmJkFKEV2XkeWAyODEBT95mzZVa67sA==) seems to be corrupted. Trying again.
npm ERR! code EINTEGRITY
npm ERR! sha512-NHThbqidF4gPr4YwTd6MUFqGiUdWbYqcBAFH1gPYWaLmoHWafH/kCGjDmJkFKEV2XkeWAyODEBT95mzZVa67sA== integrity checksum failed when using sha512: wanted sha512-NHThbqidF4gPr4YwTd6MUFqGiUdWbYqcBAFH1gPYWaLmoHWafH/kCGjDmJkFKEV2XkeWAyODEBT95mzZVa67sA== but got sha512-ZBsVuTEO3DrliKB3f8FABrVAz6p2fazutqBn3inowySvzbUEfvJc9tF+fwvBX1WJm58FeU2rVRg6i3USFrNYeg==. (33143 bytes)

However I saw you very recently made a branch "patch-68" that looks like it handles the fix! Whats up with that?

jgravois commented 2 years ago

if you use Node.js 16x or 17x, the install should succeed.

patch-68 can't be merged as is. it has a bunch of unrelated whitespace changes.

allmondjoy87 commented 2 years ago
node --version
v16.14.0

Failing w/ 16x. npm cache verify and npm cache clean --force didn't help either.

I'll update to 17x and give it a shot.

jgravois commented 2 years ago

Failing w/ 16x

hmmm, that's a surprise.

https://github.com/terraformer-js/terraformer/blob/0d8379a9ca5dc1fafd4c272b242144fcb3d53a04/.travis.yml#L5-L6

https://app.travis-ci.com/github/terraformer-js/terraformer/builds/251360143

jgravois commented 2 years ago

Well I'm having issues with npm install

i think what i did in #87 will fix your issue.

https://github.com/terraformer-js/terraformer/pull/87/files#diff-a2fe61aa17681ca122cfdd06603e7462426b0672cea3517deefdd96b6d4e3523R13

jgravois commented 2 years ago

released in v2.1.2.