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

shp2geobuf TypeError: stream.on is not a function #105

Open
andrewharvey opened this issue Feb 17, 2019 · 4 comments
Open

shp2geobuf TypeError: stream.on is not a function #105

andrewharvey opened this issue Feb 17, 2019 · 4 comments
Labels

Comments

@andrewharvey
Copy link

/tmp/geobuf/node_modules/stream-source/index.node.js:8
  that._stream = stream.on("readable", read).on("end", end).on("close", end).on("error", error);
                        ^

TypeError: stream.on is not a function
    at new StreamSource (/tmp/geobuf/node_modules/stream-source/index.node.js:8:25)
    at module.exports (/tmp/geobuf/node_modules/stream-source/index.node.js:2:10)
    at open (/tmp/geobuf/node_modules/shapefile/dist/shapefile.node.js:310:14)
    at Object.read (/tmp/geobuf/node_modules/shapefile/dist/shapefile.node.js:358:10)
    at Object.<anonymous> (/tmp/geobuf/bin/shp2geobuf:7:11)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

@metacollin
Copy link

Hi @andrewharvey, I was having this issue as well, so I went ahead and fixed shp2geobuf by, uh, completely rewriting it. Use at your own risk, but it is working fine for me and in a production environment. I also added the ability to locate and include associated .dbf files automatically, or specify the path to one explicitly. A .dbf file is still optional of course.

Checkout the changes in my fork, metacollin/geobuf. If you are ok with risking it in your project (I make zero guarantees, I am not liable if it breaks your code, burns down your house, or murders your cat), you can install my fork:

npm install -g metacollin/geobuf

@mourner mourner added the bug label Feb 19, 2020
@bwcastillo
Copy link

@mourner that the issue is tagged as bug, does mean that this problem persist?
If I use the lines:
npm -install geobuf I get the same problem that @mourner (" stream.on is not a function), but if i use the @metacollin version I get "SyntaxError: missing ) after argument list.

I keep attent for any conclusion.

Regards!

@bwcastillo
Copy link

bwcastillo commented Mar 9, 2020

Now I have modified the Syntax in the last if (line 48) of @metacollin version:
if(dbf_exists === true) { shapefile.read(shp_path, dbf_path).then(function(geojson){ var geobuf = encode(geojson, new Pbf()); var output_buffer = Buffer.allocUnsafe ? Buffer.from(geobuf) : new Buffer(geobuf); process.stdout.write(output_buffer); }); } else { shapefile.read(shp_path).then(function(geojson){ var geobuf = encode(geojson, new Pbf()); var output_buffer = Buffer.allocUnsafe ? Buffer.from(geobuf) : new Buffer(geobuf); process.stdout.write(output_buffer); })};

I get an output but when I try to open in QGIS this dont recognize the source. I opened the file in a text editor, and i found only weird characters. i.e:

ROUTE_NAME �bbox"Êú¯� ’� ƒ����þ�˜§‘ÏÜ�Äó‚üÞí�­»Ë�˜Ã¸�Û¼Ð�¦ýŠ�ë‚��¤ÛØ)ÛØè Ö‚Œ�©²Š�²² �±É¥9¬™ðvµý¦�ÖäÇ ÃîêAú¨¢‹�Ý»Î@–鵆�ÏÅ©�ºÖä1¹—“�¤Ý‘7ÿîÞ�’íü�¿Æß�¤Ùà�»Ø­�г˜�áÝÈ�ÆÎÝ�»¯iÄ˹�«ø�üî©

I just recognize the first line "ROUTE_NAME"

@kevinstadler
Copy link

Got shp2geobuf to work by:

  1. installing metacollin's fork using npm install -g metacollin/geobuf and then
  2. (manually) applying the following patch: thomas-maschler@d46c390

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

No branches or pull requests

5 participants