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

Example pbf.html is Broken #29

Closed
aemkei opened this issue Sep 24, 2014 · 6 comments
Closed

Example pbf.html is Broken #29

aemkei opened this issue Sep 24, 2014 · 6 comments

Comments

@aemkei
Copy link

aemkei commented Sep 24, 2014

It is not possible to run the example/pbf.html.

I followed the instructions and run npm run browserify to create the file osm-read-pbf.js. When opening the example HTML it will throw the following errors:

Uncaught Error: Cannot find module 'bytebuffer' osm-read-pbf.js:1
Uncaught ReferenceError: pbfParser is not defined pbf.html:18
GET http://localhost:8080/inflate.min.js.map 404 (Not Found)
@aemkei
Copy link
Author

aemkei commented Sep 24, 2014

Looks like browserify can't include bytebuffer correctly. I see this in the final osm-read-pbf.js:

{"bytebuffer":"bytebuffer","fs":undefined,"path":undefined}]}

@nrenner
Copy link
Collaborator

nrenner commented Sep 24, 2014

Seems like my hack to include the minified files is no longer working with the latest browserify:

browserify ./lib/pbfParser.js --bare -x bytebuffer -x long -r ./node_modules/protobufjs/node_modules/bytebuffer/ByteBuffer.min.js:bytebuffer -r ./node_modules/protobufjs/node_modules/bytebuffer/node_modules/long/dist/Long.min.js:long -s=pbfParser -o osm-read-pbf.js

As a workaround you can use:

browserify ./lib/pbfParser.js --bare -s=pbfParser -o osm-read-pbf.js

Need to see what I can do about this.

@aemkei
Copy link
Author

aemkei commented Sep 25, 2014

Thanks! The workaround works for now.
BTW: This is an amazing project and I'm looking forward to see OSM data in Node and the browser…

@nrenner
Copy link
Collaborator

nrenner commented Feb 18, 2015

The reason for wanting to require the already minified files is that ByteBuffer.min.js and Long.min.js are built with Google Closure Compiler in advanced mode, which supposedly might also improve runtime performance e.g. by function inlining.

But now I have done some quick manual testing and could not observe a significant performance improvement. I also wanted to look into compiling across all modules instead of using the individual builds, but don't know if that would be worth the effort. So for now I'm simply using minifyify on the sources.

Here is the build workaround used for testing:

  browserify -r ./node_modules/protobufjs/node_modules/bytebuffer/dist/ByteBufferAB.min.js:bytebuffer -x long -o bytebuffer.js
  browserify -r ./node_modules/protobufjs/node_modules/bytebuffer/node_modules/long/dist/Long.min.js:long -o long.js
  browserify ./lib/pbfParser.js --bare -x bytebuffer -x long -s=pbfParser -o osm-read-pbf.js

  <script src="long.js"></script>
  <script src="bytebuffer.js"></script>
  <script src="osm-read-pbf.js"></script>

@wolfgangvonludwigsburg
Copy link

I did follow your workaround so far,
but I end up with:

Uncaught TypeError: Cannot read property 'decode' of undefined (in osm-read-pbf.js):

function readBlobHeaderContent(fd, position, size, callback) {
=> return reader.readPBFElement(fd, position, size, fileFormat.BlobHeader.decode, callback);
}

Looks like:

var fileFormat = require('./proto/fileformat.js');

does'nt instantiate correctly ... (i.e. missing Member '.BlobHeader')

Would you please upload (e.g. to './dist') any working files from your functional workaround:
long.js, bytebuffer.js, osm-read-pbf.js
so I can check against my configuration ...

PLEASE ... ;-)
Thank you.

@nrenner
Copy link
Collaborator

nrenner commented May 21, 2015

Sorry about this. Moving forward, I now have merged the pending PR #31. This fixes the build, so npm run browserify now works again.

I also have committed the osm-read-pbf.js to the repo. It contains all that is needed, so you should be ready to go.

@nrenner nrenner closed this as completed May 21, 2015
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

3 participants