Closed mofoyoda closed 9 years ago
You probably need to add xmlhttp.responseType = 'arraybuffer';
and use xmlhttp.response
rather than xmlhttp.responseText
.
Yep, sounds like what John said.
Oh, true, thanks a lot! I guess d3.xhr()
doesn't work either, because it wraps responseText
rather than response
.
FYI decoding runs quite fast: 1.5mln point features (87.5MB pbf) decoded in
Chrome: decoding: 3612.231ms
Firefox: decoding: 6859.14ms
Safari: decoding: 49256.836ms
(this one is strange)
Strange indeed. Can you profile and see what causes such a big difference?
Profiled on Chrome and FF: everything went smooth. Added code and profiling info to the gist (https://gist.github.com/mofoyoda/da963a75a3bb8c9437a6).
When I tried to profile on Safari, decoding script freezed like forever with 100% CPU load and swap file kept increasing over the edge. Tried several times with hard reset machine, unloaded all heavy services (postgres, tilemill, etc), but couldn't get it to finish. So I made a smaller test pbf (100k points instead of 1.5mln), and finished the profiling. It seems like pow
in readDataField()
function of decode.js
file is nasty on Safari. readFeatureCollection()
is the second most time-consuming function, but I guess that's normal.
I've added my test data to the gist (caution - big data may take a while to clone).
I'll investigate further on this and let you know if there'll be any more details.
That sound super-weird since pow
should only be called once for a file... Thanks for looking into this!
So, how do you effectively AJAX a .pbf file into the browser? Anyone have a guide on this? Thanks!
@aboutaaron xhr.responseType = 'arraybuffer';
-- see the mapbox-gl-js implementation for example.
That did it! Thank you!
Sent from Outlook
On Tue, Oct 20, 2015 at 3:47 PM -0700, "John Firebaugh" notifications@github.com wrote:
@aboutaaron xhr.responseType = 'arraybuffer'; -- see the mapbox-gl-js implementation for example.
— Reply to this email directly or view it on GitHub.
Under IIS, it was necessary to add the MIME type to Web.config:
`
</system.webServer>`
I've made a simple gist that gets test pbf with XHR and then decodes it with geobuf.decode(). Unfortunately, it returns an empty Object. http://bl.ocks.org/mofoyoda/da963a75a3bb8c9437a6 I've tested decoding with node, and it works ok.