Open andrewharvey opened 5 years ago
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 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!
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"
Got shp2geobuf
to work by:
npm install -g metacollin/geobuf
and then