Skip to content

Commit

Permalink
Merge pull request #71 from mapbox/pbf3
Browse files Browse the repository at this point in the history
Update for compatibility with pbf 3
  • Loading branch information
mourner committed Sep 20, 2016
2 parents 155dacd + 392a7af commit 651a351
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
@@ -1,7 +1,7 @@
sudo: false
language: node_js
node_js:
- "0.12"
- "4"
- "stable"
script:
- npm test
- npm run coveralls
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -48,7 +48,8 @@ var buffer = geobuf.encode(geojson, new Pbf());
```

Given a GeoJSON object and a [Pbf](https://github.com/mapbox/pbf) object to write to,
returns a Geobuf as a `Buffer` object in Node or `UInt8Array` object in browsers.
returns a Geobuf as `UInt8Array` arrya of bytes.
In Node, you can use `Buffer.from` to convert back to a buffer.

### decode

Expand Down
2 changes: 1 addition & 1 deletion bin/geobuf2json
Expand Up @@ -20,5 +20,5 @@ input.pipe(concat(function(buf) {
// JSON.parse(data);
// console.timeEnd('JSON.parse');

process.stdout.write(data);
process.stdout.write(Buffer.from(data));
}));
2 changes: 1 addition & 1 deletion bin/json2geobuf
Expand Up @@ -17,7 +17,7 @@ input.pipe(concat(function(buf) {
// console.timeEnd('JSON.stringify');

// console.time('encode');
var buffer = encode(geojson, new Pbf());
var buffer = Buffer.from(encode(geojson, new Pbf()));
// console.timeEnd('encode');

process.stdout.write(buffer);
Expand Down
18 changes: 9 additions & 9 deletions package.json
Expand Up @@ -37,22 +37,22 @@
},
"homepage": "https://github.com/mapbox/geobuf",
"devDependencies": {
"benchmark": "~2.1.0",
"browserify": "^13.0.0",
"coveralls": "~2.11.6",
"eslint": "^2.11.1",
"benchmark": "~2.1.1",
"browserify": "^13.1.0",
"coveralls": "~2.11.14",
"eslint": "^3.5.0",
"eslint-config-mourner": "^2.0.1",
"geojson-fixtures": "1.0.0",
"in-publish": "^2.0.0",
"istanbul": "~0.4.2",
"istanbul": "~0.4.5",
"mkdirp": "^0.5.1",
"tap": "~5.7.2",
"tap": "~7.1.2",
"uglifyjs": "^2.4.10"
},
"dependencies": {
"concat-stream": "^1.5.1",
"pbf": "^2.0.1",
"shapefile": "~0.3.1"
"concat-stream": "^1.5.2",
"pbf": "^3.0.1",
"shapefile": "~0.5.7"
},
"eslintConfig": {
"extends": "mourner",
Expand Down
4 changes: 3 additions & 1 deletion test/validate.test.js
Expand Up @@ -75,7 +75,9 @@ test('roundtrip a circle with potential accumulating error', function (t) {

function roundtripTest(geojson) {
return function (t) {
t.same(geobuf.decode(new Pbf(geobuf.encode(geojson, new Pbf()))), geojson);
var buf = geobuf.encode(geojson, new Pbf());
var geojson2 = geobuf.decode(new Pbf(buf));
t.same(geojson2, geojson);
t.end();
};
}
Expand Down

0 comments on commit 651a351

Please sign in to comment.