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

Projected small demo doesn't work: Invalid URL #180

Open
Richard-Walter opened this issue Apr 13, 2022 · 3 comments
Open

Projected small demo doesn't work: Invalid URL #180

Richard-Walter opened this issue Apr 13, 2022 · 3 comments

Comments

@Richard-Walter
Copy link

Clicking on your Projected small demo I get an error in the chrome/edge browser console:

TypeError: Failed to construct 'URL': Invalid URL
at checkSuffix (shp.js:14498:15)
at Function.shp.getShapefile (shp.js:14505:7)
at shp (shp.js:14399:14)
at proj-small.html:38:3

Same isse happens with some of your other demos. Any idea what is causing this?

@benderlidze
Copy link

try something like this

   fetch("shp.zip")
                .then(text => text.arrayBuffer())
                .then((myshape) => shp(myshape))
                .then((data) => {
                   
//your data 
                   
                }).catch(e => console.log('error', e));

@rgoggins
Copy link

rgoggins commented Jul 5, 2024

This doesn't work for me. I still get

Error in readShapefile: TypeError: Cannot read properties of undefined (reading 'map')
    at readShapefile (webpack-internal:///(rsc)/./components/readshapefile.ts:30:43)
    at Multipart.eval (webpack-internal:///(rsc)/./app/api/uploadShapefile/route.ts:91:112)
    at Multipart.emit (node:events:520:28)
    at WriteStream.eval (webpack-internal:///(rsc)/./app/api/uploadShapefile/route.ts:68:28)
    at WriteStream.emit (node:events:532:35)
    at finish (node:internal/streams/writable:946:10)
    at node:internal/streams/writable:927:13
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
nah still errors TypeError: Failed to parse URL from uploads/counties/counties.zip
    at node:internal/deps/undici/undici:12502:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  [cause]: TypeError: Invalid URL

If I switch to an absolute path, I get a slightly different error:

Error in readShapefile: TypeError: Cannot read properties of undefined (reading 'map')
    at readShapefile (webpack-internal:///(rsc)/./components/readshapefile.ts:30:43)
    at Multipart.eval (webpack-internal:///(rsc)/./app/api/uploadShapefile/route.ts:91:112)
    at Multipart.emit (node:events:520:28)
    at WriteStream.eval (webpack-internal:///(rsc)/./app/api/uploadShapefile/route.ts:68:28)
    at WriteStream.emit (node:events:532:35)
    at finish (node:internal/streams/writable:946:10)
    at node:internal/streams/writable:927:13
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
nah still errors TypeError: Failed to parse URL from /Users/ryangoggins/mining_work/mineflow_website_v4/uploads/counties/counties.zip

I even get this issue when I just create a node shell and import shpjs and pass it literally any file. Or any directory with a prefix of a file with no extension.

Has anyone encountered this issue before?

I've tried my own shapefiles, I've tried zip files, of shapefiles. I've tried changing the directory where the files are written to/read from. Any suggestions?

@calvinmetcalf
Copy link
Owner

@Richard-Walter v5.0.2 should fix this, there was previously a bug with reletive urls

@rgoggins it's hard to tell what exactly is going on because the error is in your file readshapefile not one in the libarary, can you post some of the code from readshapefile.ts?

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

4 participants