Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #11 from nrenner/utf8

also use ByteBuffer.readUTF8StringBytes for Node.js
  • Loading branch information...
commit f70ebaca5e50827ed4f52fbe87badfd66de35a0a 2 parents 257f621 + 7657428
@marook authored
View
BIN  example/test.pbf
Binary file not shown
View
5 lib/browser/buffer.js
@@ -2,16 +2,11 @@ function readPBFElementFromBuffer(buffer, pbfDecode, callback){
return callback(null, pbfDecode(buffer));
}
-function pbfBufferToBuffer(src, srcOffset, len){
- return src.readUTF8StringBytes(len, srcOffset).string;
-}
-
function blobDataToBuffer(blob){
return new Uint8Array(blob.toArrayBuffer());
}
module.exports = {
readPBFElementFromBuffer: readPBFElementFromBuffer,
- pbfBufferToBuffer: pbfBufferToBuffer,
blobDataToBuffer: blobDataToBuffer
};
View
1  lib/nodejs/buffer.js
@@ -48,6 +48,5 @@ function blobDataToBuffer(blob){
module.exports = {
readPBFElementFromBuffer: readPBFElementFromBuffer,
- pbfBufferToBuffer: pbfBufferToBuffer,
blobDataToBuffer: blobDataToBuffer
};
View
5 lib/pbfParser.js
@@ -88,11 +88,10 @@ function getStringTableEntry(i){
s = this.s[i];
- // TODO specify toString encoding
-
// obviously someone is missinterpreting the meanding of 'offset'
// and 'length'. they should be named 'start' and 'end' instead.
- return buf.pbfBufferToBuffer(s, s.offset, s.length - s.offset).toString();
+ return s.readUTF8StringBytes(s.length - s.offset, s.offset).string;
+
}
function extendStringTable(st){
View
4 test/pbfTest.js
@@ -180,6 +180,10 @@ describe('pbf read', function(){
way.tags.highway.should.be.equal('service');
});
+ it('then way has tag name=üßé€', function(){
+ way.tags.name.should.be.equal('üßé€');
+ });
+
it('then first way node ref has id 304994979', function(){
way.nodeRefs[0].should.be.equal('304994979');
});
View
BIN  test/test.pbf
Binary file not shown
View
1  test/test.xml
@@ -20,5 +20,6 @@
<nd ref="304994981"/>
<tag k="access" v="private"/>
<tag k="highway" v="service"/>
+ <tag k="name" v="üßé€"/>
</way>
</osm>
Please sign in to comment.
Something went wrong with that request. Please try again.