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

Regenerating fixtures #16

Merged
merged 10 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions FIXTURES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
id|description|valid v1|valid v2
---|---|---|---
001|A vector tile without any layers, which essentially results in a completely empty buffer. - [link](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L75)|true|true
002|A single layer with a single point feature that has no id field. According to the specification, "A feature MAY contain an id field. If a feature has an id field, the value of the id SHOULD be unique among the features of the parent layer." - [link](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/README.md#42-features)|true|true
003|A single point feature with a missing geometry type. From the spec, "A feature MUST contain a type field as described in the Geometry Types section." - [link](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L41) - recommended error handling `recoverable`|false|false
001|A vector tile without any layers, which essentially results in a completely empty buffer. - [spec source](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L75)|:white_check_mark:|:white_check_mark:
002|A single layer with a single point feature that has no id field. According to the specification, "A feature MAY contain an id field. If a feature has an id field, the value of the id SHOULD be unique among the features of the parent layer." - [spec source](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/README.md#42-features)|:white_check_mark:|:white_check_mark:
003|A single point feature with a missing geometry type. From the spec, "A feature MUST contain a type field as described in the Geometry Types section." - [spec source](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L41) - recommended error handling `recoverable`|:x:|:x:
004|[feature:geometry] A single point feature without a geometry field. The spec says, "A feature MUST contain a geometry field." - [spec source](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L46) - recommended error handling `recoverable`|:x:|:x:
005|[feature:tags] the tags array has only a single tag, where multiples of two are required. - [spec source](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L38) - recommended error handling `recoverable`|:x:|:x:
006|[feature:geometry] A single point feature with an invalid GeomType enum in the "type" field. Spec says, "" - [spec source](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L8-L13) - recommended error handling `recoverable`|:x:|:x:
007|[layer:keys] has a key value encoded as an integer instead of a string - [spec source](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L63) - recommended error handling `fatal`|:x:|:x:
008|[layer:extent] the layer extent field is encoded as a string instead of a uint32 - [spec source](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L70) - recommended error handling `fatal`|:x:|:x:
009|[layer:extent] the layer extent field is completely missing. The spec says, "A layer MUST contain an extent that describes the width and height of the tile in integer coordinates." - [spec source](https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L70) - recommended error handling `fatal`|:x:|:x:
4 changes: 2 additions & 2 deletions fixtures/002/tile.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
]
}
],
"keys": {},
"values": {},
"keys": [],
"values": [],
"extent": 4096
}
]
Expand Down
4 changes: 2 additions & 2 deletions fixtures/003/tile.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
]
}
],
"keys": {},
"values": {},
"keys": [],
"values": [],
"extent": 4096
}
]
Expand Down
9 changes: 9 additions & 0 deletions fixtures/004/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"description": "[feature:geometry] A single point feature without a geometry field. The spec says, \"A feature MUST contain a geometry field.\"",
"specification_reference": "https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L46",
"validity": {
"v1": false,
"v2": false,
"error": "recoverable"
}
}
18 changes: 18 additions & 0 deletions fixtures/004/tile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"layers": [
{
"version": 2,
"name": "hello",
"features": [
{
"id": 1,
"tags": [],
"type": 1
}
],
"keys": [],
"values": [],
"extent": 4096
}
]
}
Binary file added fixtures/004/tile.mvt
Binary file not shown.
9 changes: 9 additions & 0 deletions fixtures/005/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"description": "[feature:tags] the tags array has only a single tag, where multiples of two are required.",
"specification_reference": "https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L38",
"validity": {
"v1": false,
"v2": false,
"error": "recoverable"
}
}
31 changes: 31 additions & 0 deletions fixtures/005/tile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"layers": [
{
"version": 2,
"name": "hello",
"features": [
{
"id": 1,
"tags": [
0
],
"type": 1,
"geometry": [
9,
50,
34
]
}
],
"keys": [
"hello"
],
"values": [
{
"string_value": "world"
}
],
"extent": 4096
}
]
}
Binary file added fixtures/005/tile.mvt
Binary file not shown.
9 changes: 9 additions & 0 deletions fixtures/006/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"description": "[feature:geometry] A single point feature with an invalid GeomType enum in the \"type\" field. Spec says, \"\"",
"specification_reference": "https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L8-L13",
"validity": {
"v1": false,
"v2": false,
"error": "recoverable"
}
}
23 changes: 23 additions & 0 deletions fixtures/006/tile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"layers": [
{
"version": 2,
"name": "hello",
"features": [
{
"id": 1,
"tags": [],
"type": 8,
"geometry": [
9,
50,
34
]
}
],
"keys": [],
"values": [],
"extent": 4096
}
]
}
Binary file added fixtures/006/tile.mvt
Binary file not shown.
9 changes: 9 additions & 0 deletions fixtures/007/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"description": "[layer:keys] has a key value encoded as an integer instead of a string",
"specification_reference": "https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L63",
"validity": {
"v1": false,
"v2": false,
"error": "fatal"
}
}
32 changes: 32 additions & 0 deletions fixtures/007/tile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"layers": [
{
"version": 2,
"name": "hello",
"features": [
{
"id": 1,
"tags": [
0,
0
],
"type": 1,
"geometry": [
9,
50,
34
]
}
],
"keys": [
1
],
"values": [
{
"string_value": "two"
}
],
"extent": 4096
}
]
}
Binary file added fixtures/007/tile.mvt
Binary file not shown.
9 changes: 9 additions & 0 deletions fixtures/008/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"description": "[layer:extent] the layer extent field is encoded as a string instead of a uint32",
"specification_reference": "https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L70",
"validity": {
"v1": false,
"v2": false,
"error": "fatal"
}
}
23 changes: 23 additions & 0 deletions fixtures/008/tile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"layers": [
{
"version": 2,
"name": "hello",
"features": [
{
"id": 1,
"tags": [],
"type": 1,
"geometry": [
9,
50,
34
]
}
],
"keys": [],
"values": [],
"extent": "fourzeroninesix"
}
]
}
Binary file added fixtures/008/tile.mvt
Binary file not shown.
9 changes: 9 additions & 0 deletions fixtures/009/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"description": "[layer:extent] the layer extent field is completely missing. The spec says, \"A layer MUST contain an extent that describes the width and height of the tile in integer coordinates.\"",
"specification_reference": "https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L70",
"validity": {
"v1": false,
"v2": false,
"error": "fatal"
}
}
23 changes: 23 additions & 0 deletions fixtures/009/tile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"layers": [
{
"version": 2,
"name": "hello",
"features": [
{
"id": 1,
"tags": [],
"type": 1,
"geometry": [
9,
50,
34
]
}
],
"keys": [],
"values": [],
"extent": 4096
}
]
}
Binary file added fixtures/009/tile.mvt
Binary file not shown.
3 changes: 3 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ mvtf.each(function(fixture) {
let mvt = dir + '/tile.mvt';
let json = dir + '/tile.json';
let info = dir + '/info.json';
if (fs.existsSync(mvt) && fs.readFileSync(mvt).length != fixture.buffer.length) {
console.log('updating',dir);
}
fs.writeFileSync(mvt, fixture.buffer);
fs.writeFileSync(json, JSON.stringify(fixture.json, null, 2));
fs.writeFileSync(info, JSON.stringify({
Expand Down
6 changes: 4 additions & 2 deletions scripts/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ let docs = `id|description|valid v1|valid v2
`;

mvtf.each(function(fixture) {
let description = `${fixture.description} - [link](${fixture.specification_reference})`;
let description = `${fixture.description} - [spec source](${fixture.specification_reference})`;
let emojiV1Validity = (!fixture.validity.v1) ? ':x:' : ':white_check_mark:';
let emojiV2Validity = (!fixture.validity.v2) ? ':x:' : ':white_check_mark:';
if (!fixture.validity.v1 || !fixture.validity.v2) {
description += ` - recommended error handling \`${fixture.validity.error}\``;
}
docs+=`${fixture.id}|${description}|${fixture.validity.v1}|${fixture.validity.v2}\n`;
docs+=`${fixture.id}|${description}|${emojiV1Validity}|${emojiV2Validity}\n`;
});

fs.writeFileSync('./FIXTURES.md', docs);
4 changes: 2 additions & 2 deletions scripts/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const template = `module.exports = function(schema) {
geometry: [ 9, 50, 34 ]
}
],
keys: {},
values: {},
keys: [],
values: [],
extent: 4096
}
]
Expand Down
4 changes: 2 additions & 2 deletions src/002.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ module.exports = function(schema) {
geometry: [ 9, 50, 34 ]
}
],
keys: {},
values: {},
keys: [],
values: [],
extent: 4096
}
]
Expand Down
4 changes: 2 additions & 2 deletions src/003.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ module.exports = function(schema) {
geometry: [ 9, 50, 34 ]
}
],
keys: {},
values: {},
keys: [],
values: [],
extent: 4096
}
]
Expand Down
30 changes: 30 additions & 0 deletions src/004.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
module.exports = function(schema) {
return {
description: '[feature:geometry] A single point feature without a geometry field. The spec says, "A feature MUST contain a geometry field."',
specification_reference: 'https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L46',
validity: {
v1: false,
v2: false,
error: 'recoverable'
},
json: {
layers: [
{
version: 2,
name: 'hello',
features: [
{
id: 1,
tags: [],
type: schema.Tile.GeomType.POINT.value,
// geometry: [ 9, 50, 34 ]
}
],
keys: [],
values: [],
extent: 4096
}
]
}
}
};
41 changes: 41 additions & 0 deletions src/005.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module.exports = function(schema) {
return {
description: '[feature:tags] the tags array has only a single tag, where multiples of two are required.',
specification_reference: 'https://github.com/mapbox/vector-tile-spec/blob/master/2.1/vector_tile.proto#L38',
validity: {
v1: false,
v2: false,
error: 'recoverable'
},
json: {
layers: [
{
version: 2,
name: 'hello',
features: [
{
id: 1,
tags: [
0,
// 0
],
type: schema.Tile.GeomType.POINT.value,
geometry: [ 9, 50, 34 ]
}
],
keys: [
'hello'
],
values: [
{ string_value: 'world' }
],
extent: 4096
}
]
},
manipulate: function(buffer) {
// stuff here
return buffer;
}
}
};
Loading