Socket
Socket
Sign inDemoInstall

mapbox

Package Overview
Dependencies
Maintainers
44
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mapbox - npm Package Compare versions

Comparing version 1.0.0-beta2 to 1.0.0-beta3

test/fixtures/tilestats.json

57

API.md

@@ -448,16 +448,17 @@ # bulkFeatureUpdate

// {
// "account": {account},
// "tilesetid": "tileset-id",
// "layerCount": {layer count},
// "layers": [
// {
// "account": {account},
// "tilesetid": "tileset-id",
// "layer": {layername},
// "count": 10,
// "layer": {layer name},
// "geometry": {dominant geometry},
// "count": {feature count},
// "attributeCount": {attribute count}
// "attributes": [
// {
// "attribute": {attributename},
// "min": 0,
// "max": 10,
// "values": [0, 10]
// "attribute": {attribute name},
// "type": {attribute type},
// "count": {unique value count},
// "min": {minimum value if type is number},
// "max": {maximum value if type is number},
// "values": [{...unique values}]
// }

@@ -473,38 +474,2 @@ // ]

# getTilestatsAttribute
To retrieve statistics about the attribute values of a particular attribute
within a tileset layer.
**Parameters**
- `tileset` **String** the id for the tileset
- `layer` **String** the name of the layer in the tileset
- `attribute` **String** the name of the attribute in the layer
- `callback` **Function** called with (err)
**Examples**
```javascript
var client = new MapboxClient('ACCESSTOKEN');
client.getTilestatsAttribute('tileset-id', 'layer-name', 'attr-name', function(err, info) {
console.log(info);
// {
// "account": {account},
// "tilesetid": "tileset-id",
// "layer": "layer-name",
// "attribute": "attr-name",
// "type": "Number",
// "min": 0,
// "max": 10,
// "values": [
// 0,
// 10
// ]
// }
});
```
Returns **undefined** nothing, calls callback
# createUpload

@@ -511,0 +476,0 @@

@@ -0,1 +1,5 @@

## 1.0.0-beta3
- Update tilestat service for new API.
## 1.0.0-beta1

@@ -2,0 +6,0 @@

@@ -10,58 +10,2 @@ 'use strict';

/**
* To create an empty set of tileset statistics.
*
* @private
* @param {String} tileset - the id for the tileset
* @param {Array<string>} layers - an array of layer names in the tileset
* @param {Function} callback called with (err, tilestats)
* @returns {undefined} nothing, calls callback
*/
Tilestats.prototype.createTilestats = function(tileset, layers, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
invariant(Array.isArray(layers), 'layers must be an array');
invariant(layers.every(function(layer) {
return typeof layer === 'string';
}), 'layers must be an array of strings');
var owner = tileset.split('.')[0];
if (owner === tileset) owner = this.owner;
return this.client({
path: constants.API_TILESTATS_STATISTICS,
params: {
owner: owner,
tileset: tileset
},
entity: { layers: layers },
method: 'post',
callback: callback
}).entity();
};
/**
* To delete a set of tileset statistics.
*
* @private
* @param {String} tileset - the id for the tileset
* @param {Function} callback called with (err)
* @returns {undefined} nothing, calls callback
*/
Tilestats.prototype.deleteTilestats = function(tileset, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
var owner = tileset.split('.')[0];
if (owner === tileset) owner = this.owner;
return this.client({
path: constants.API_TILESTATS_STATISTICS,
params: {
owner: owner,
tileset: tileset
},
method: 'delete',
callback: callback
}).entity();
};
/**
* To retrieve statistics about a specific tileset.

@@ -77,16 +21,17 @@ *

* // {
* // "account": {account},
* // "tilesetid": "tileset-id",
* // "layerCount": {layer count},
* // "layers": [
* // {
* // "account": {account},
* // "tilesetid": "tileset-id",
* // "layer": {layername},
* // "count": 10,
* // "layer": {layer name},
* // "geometry": {dominant geometry},
* // "count": {feature count},
* // "attributeCount": {attribute count}
* // "attributes": [
* // {
* // "attribute": {attributename},
* // "min": 0,
* // "max": 10,
* // "values": [0, 10]
* // "attribute": {attribute name},
* // "type": {attribute type},
* // "count": {unique value count},
* // "min": {minimum value if type is number},
* // "max": {maximum value if type is number},
* // "values": [{...unique values}]
* // }

@@ -115,114 +60,22 @@ * // ]

/**
* Add or update information about geometry types present in a tileset layer.
* This request may be made multiple times against a single layer, in order to
* update the total geometry counts across a set of parallel tileset reads.
*
* @private
* @param {String} tileset - the id for the tileset
* @param {String} layer - the name of the layer in the tileset
* @param {Object} geometries - an object indicating the number of features present
* in the layer of various geometry types.
* @param {Number} [geometries.point] - number of Point features
* @param {Number} [geometries.multipoint] - number of MultiPoint features
* @param {Number} [geometries.linestring] - number of LineString features
* @param {Number} [geometries.multilinestring] - number of MultiLineString features
* @param {Number} [geometries.polygon] - number of Polygon features
* @param {Number} [geometries.multipolygon] - number of MultiPolygon features
* @param {Number} [geometries.geometrycollection] - number of GeometryCollection features
* @param {Function} callback called with (err)
* @returns {undefined} nothing, calls callback
*/
Tilestats.prototype.updateTilestatsLayer = function(tileset, layer, geometries, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
invariant(typeof layer === 'string', 'layer must be a string');
invariant(typeof geometries === 'object', 'geometries must be an object');
var owner = tileset.split('.')[0];
if (owner === tileset) owner = this.owner;
return this.client({
path: constants.API_TILESTATS_LAYER,
params: {
owner: owner,
tileset: tileset,
layer: layer
},
entity: geometries,
method: 'post',
callback: callback
}).entity();
};
/**
* To add or update statistics about the values of a particular attribute in
* a layer. This request may be made multiple times against a single attribute,
* in order to update the statistics across a set of parallel tileset reads.
* To create or update statistics about a specific tileset.
*
* @private
* @param {String} tileset - the id for the tileset
* @param {String} layer - the name of the layer in the tileset
* @param {String} attribute - the name of the attribute in the layer
* @param {Object} stats - statistics about attribute values in the layer
* @param {Number|String} stats.min - the minimum attribute value
* @param {Number|String} stats.max - the maximum attribute value
* @param {Array<Number|String>} stats.values - an array of unique values for the attribute
* @param {Function} callback called with (err)
* @param {object} statistics - the statistics to upload
* @param {Function} callback called with (err, tilestats)
* @returns {undefined} nothing, calls callback
*/
Tilestats.prototype.updateTilestatsAttribute = function(tileset, layer, attribute, stats, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
invariant(typeof layer === 'string', 'layer must be a string');
invariant(typeof attribute === 'string', 'attribute must be a string');
invariant(typeof stats === 'object', 'stats must be an object');
var owner = tileset.split('.')[0];
if (owner === tileset) owner = this.owner;
return this.client({
path: constants.API_TILESTATS_ATTRIBUTE,
params: {
owner: owner,
tileset: tileset,
layer: layer,
attribute: attribute
},
entity: stats,
method: 'post',
callback: callback
}).entity();
};
/**
* To retrieve statistics about the attribute values of a particular attribute
* within a tileset layer.
*
* @param {String} tileset - the id for the tileset
* @param {String} layer - the name of the layer in the tileset
* @param {String} attribute - the name of the attribute in the layer
* @param {Function} callback called with (err)
* @returns {undefined} nothing, calls callback
* @example
* var client = new MapboxClient('ACCESSTOKEN');
* client.getTilestatsAttribute('tileset-id', 'layer-name', 'attr-name', function(err, info) {
* console.log(info);
* client.getTilestats('tileset-id', function(err, stats) {
* console.log(stats);
* // {
* // "account": {account},
* // "tilesetid": "tileset-id",
* // "layer": "layer-name",
* // "attribute": "attr-name",
* // "type": "Number",
* // "min": 0,
* // "max": 10,
* // "values": [
* // 0,
* // 10
* // ]
* // "account": {account}
* // ... see stats example above (for Tilestats#getTilestats)
* // }
* });
*/
Tilestats.prototype.getTilestatsAttribute = function(tileset, layer, attribute, callback) {
Tilestats.prototype.putTilestats = function(tileset, statistics, callback) {
invariant(typeof tileset === 'string', 'tileset must be a string');
invariant(typeof layer === 'string', 'layer must be a string');
invariant(typeof attribute === 'string', 'attribute must be a string');

@@ -233,11 +86,11 @@ var owner = tileset.split('.')[0];

return this.client({
path: constants.API_TILESTATS_ATTRIBUTE,
path: constants.API_TILESTATS_STATISTICS,
params: {
owner: owner,
tileset: tileset,
layer: layer,
attribute: attribute
tileset: tileset
},
entity: statistics,
method: 'put',
callback: callback
}).entity();
};
{
"name": "mapbox",
"version": "1.0.0-beta2",
"version": "1.0.0-beta3",
"description": "interface to mapbox services",

@@ -46,2 +46,3 @@ "main": "lib/mapbox.js",

"geojson-random": "^0.2.2",
"geojsonhint": "^1.1.0",
"smokestack": "^3.3.0",

@@ -51,3 +52,2 @@ "tap": "^1.3.1",

"tape": "^4.2.0",
"geojsonhint": "^1.1.0",
"uglifyjs": "^2.4.10"

@@ -54,0 +54,0 @@ },

@@ -7,40 +7,25 @@ /* eslint no-shadow: 0 */

var hat = require('../vendor/hat');
var xtend = require('../vendor/xtend').extend;
var sampleStats = require('./fixtures/tilestats');
var modifiedStats = xtend(sampleStats, { layerCount: 12 });
test('TilestatsClient', function(tilestatsClient) {
var tilesetid = hat().slice(0, 6);
tilestatsClient.test('#createTilestats', function(createTilestats) {
createTilestats.test('typecheck', function(assert) {
tilestatsClient.test('#putTilestats', function(putTilestats) {
putTilestats.test('typecheck', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
assert.ok(client, 'created dataset client');
assert.ok(client, 'created tilestats client');
assert.throws(function() {
client.createTilestats(null, ['ham'], function() {});
client.putTilestats(null, {}, function() {});
}, 'tileset must be a string');
assert.throws(function() {
client.createTilestats('yes', 'ham', function() {});
}, 'layers must be an array');
assert.throws(function() {
client.createTilestats('yes', [{}], function() {});
}, 'layers must be an array of strings');
assert.end();
});
createTilestats.test('creates', function(assert) {
putTilestats.test('creates with simple tilesetid', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
client.createTilestats(tilesetid, ['layer'], function(err, result) {
client.putTilestats(tilesetid, sampleStats, function(err, result) {
assert.ifError(err, 'success');
assert.deepEqual(result, {
account: client.owner,
tilesetid: tilesetid,
layers: [
{
account: client.owner,
tilesetid: tilesetid,
layer: 'layer',
geometry: 'UNKNOWN',
count: 0,
attributes: []
}
]
}, 'expected result');
assert.deepEqual(result, sampleStats, 'expected result');
assert.end();

@@ -50,42 +35,7 @@ });

createTilestats.test('creates - promise style', function(assert) {
putTilestats.test('creates with tilesetid containing owner', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
client.createTilestats(tilesetid, ['layer']).then(function(result) {
assert.deepEqual(result, {
account: client.owner,
tilesetid: tilesetid,
layers: [
{
account: client.owner,
tilesetid: tilesetid,
layer: 'layer',
geometry: 'UNKNOWN',
count: 0,
attributes: []
}
]
}, 'expected result');
assert.end();
});
});
createTilestats.test('creates when user specified by tilesetid', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var id = client.owner + '.' + tilesetid;
client.createTilestats(id, ['layer'], function(err, result) {
client.putTilestats(client.owner + '.' + tilesetid, sampleStats, function(err, result) {
assert.ifError(err, 'success');
assert.deepEqual(result, {
account: client.owner,
tilesetid: id,
layers: [
{
account: client.owner,
tilesetid: id,
layer: 'layer',
geometry: 'UNKNOWN',
count: 0,
attributes: []
}
]
}, 'expected result');
assert.deepEqual(result, sampleStats, 'expected result');
assert.end();

@@ -95,34 +45,7 @@ });

createTilestats.end();
});
tilestatsClient.test('#updateTilestatsLayer', function(updateTilestatsLayer) {
updateTilestatsLayer.test('typecheck', function(assert) {
putTilestats.test('updates', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
assert.ok(client, 'created dataset client');
assert.throws(function() {
client.updateTilestatsLayer(null, 'ham', {}, function() {});
}, 'tileset must be a string');
assert.throws(function() {
client.updateTilestatsLayer('yes', null, {}, function() {});
}, 'layer must be a string');
assert.throws(function() {
client.updateTilestatsLayer('yes', 'ham', 'geom', function() {});
}, 'geometries must be an object');
assert.end();
});
updateTilestatsLayer.test('updates layer', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var geoms = { 'point': 10, 'linestring': 100 };
client.updateTilestatsLayer(tilesetid, 'layer', geoms, function(err, result) {
client.putTilestats(tilesetid, modifiedStats, function(err, result) {
assert.ifError(err, 'success');
assert.deepEqual(result, {
account: client.owner,
tilesetid: tilesetid,
layer: 'layer',
geometry: 'LineString',
count: 110,
attributes: []
}, 'expected result');
assert.deepEqual(result, modifiedStats, 'expected result');
assert.end();

@@ -132,140 +55,5 @@ });

updateTilestatsLayer.test('updates layer when user specified by tilesetid', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var geoms = { 'point': 10, 'linestring': 100 };
var id = client.owner + '.' + tilesetid;
client.updateTilestatsLayer(id, 'layer', geoms, function(err, result) {
assert.ifError(err, 'success');
assert.deepEqual(result, {
account: client.owner,
tilesetid: id,
layer: 'layer',
geometry: 'LineString',
count: 110,
attributes: []
}, 'expected result');
assert.end();
});
});
updateTilestatsLayer.end();
putTilestats.end();
});
tilestatsClient.test('#updateTilestatsAttribute', function(updateTilestatsAttribute) {
updateTilestatsAttribute.test('typecheck', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
assert.ok(client, 'created dataset client');
assert.throws(function() {
client.updateTilestatsAttribute(null, 'ham', 'eggs', {}, function() {});
}, 'tileset must be a string');
assert.throws(function() {
client.updateTilestatsAttribute('yes', null, 'eggs', {}, function() {});
}, 'layer must be a string');
assert.throws(function() {
client.updateTilestatsAttribute('yes', 'ham', null, {}, function() {});
}, 'attribute must be a string');
assert.throws(function() {
client.updateTilestatsAttribute('yes', 'ham', 'eggs', 'stats', function() {});
}, 'stats must be an object');
assert.end();
});
updateTilestatsAttribute.test('update attribute', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var stats = { min: 2, max: 2, values: [2] };
client.updateTilestatsAttribute(tilesetid, 'layer', 'attr', stats, function(err, result) {
assert.ifError(err, 'success');
assert.deepEqual(result, {
account: client.owner,
tilesetid: tilesetid,
layer: 'layer',
attribute: 'attr',
type: 'number',
min: 2,
max: 2,
values: [2]
}, 'expected result');
assert.end();
});
});
updateTilestatsAttribute.test('update attribute when user specified by tilesetid', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var stats = { min: 2, max: 2, values: [2] };
var id = client.owner + '.' + tilesetid;
client.updateTilestatsAttribute(id, 'layer', 'attr', stats, function(err, result) {
assert.ifError(err, 'success');
assert.deepEqual(result, {
account: client.owner,
tilesetid: id,
layer: 'layer',
attribute: 'attr',
type: 'number',
min: 2,
max: 2,
values: [2]
}, 'expected result');
assert.end();
});
});
updateTilestatsAttribute.end();
});
tilestatsClient.test('#getTilestatsAttribute', function(getTilestatsAttribute) {
getTilestatsAttribute.test('typecheck', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
assert.ok(client, 'created dataset client');
assert.throws(function() {
client.getTilestatsAttribute(null, 'ham', 'eggs', function() {});
}, 'tileset must be a string');
assert.throws(function() {
client.getTilestatsAttribute('yes', null, 'eggs', function() {});
}, 'layer must be a string');
assert.throws(function() {
client.getTilestatsAttribute('yes', 'ham', null, function() {});
}, 'attribute must be a string');
assert.end();
});
getTilestatsAttribute.test('get attribute', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
client.getTilestatsAttribute(tilesetid, 'layer', 'attr', function(err, result) {
assert.ifError(err, 'success');
assert.deepEqual(result, {
account: client.owner,
tilesetid: tilesetid,
layer: 'layer',
attribute: 'attr',
type: 'number',
min: 2,
max: 2,
values: [2]
}, 'expected result');
assert.end();
});
});
getTilestatsAttribute.test('get attribute when user specified by tilesetid', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var id = client.owner + '.' + tilesetid;
client.getTilestatsAttribute(id, 'layer', 'attr', function(err, result) {
assert.ifError(err, 'success');
assert.deepEqual(result, {
account: client.owner,
tilesetid: id,
layer: 'layer',
attribute: 'attr',
type: 'number',
min: 2,
max: 2,
values: [2]
}, 'expected result');
assert.end();
});
});
getTilestatsAttribute.end();
});
tilestatsClient.test('#getTilestats', function(getTilestats) {

@@ -285,23 +73,3 @@ getTilestats.test('typecheck', function(assert) {

assert.ifError(err, 'success');
assert.deepEqual(result, {
account: client.owner,
tilesetid: tilesetid,
layers: [
{
account: client.owner,
tilesetid: tilesetid,
layer: 'layer',
geometry: 'LineString',
count: 110,
attributes: [
{
attribute: 'attr',
min: 2,
max: 2,
values: [2]
}
]
}
]
}, 'expected result');
assert.deepEqual(result, modifiedStats, 'expected result');
assert.end();

@@ -316,23 +84,3 @@ });

assert.ifError(err, 'success');
assert.deepEqual(result, {
account: client.owner,
tilesetid: id,
layers: [
{
account: client.owner,
tilesetid: id,
layer: 'layer',
geometry: 'LineString',
count: 110,
attributes: [
{
attribute: 'attr',
min: 2,
max: 2,
values: [2]
}
]
}
]
}, 'expected result');
assert.deepEqual(result, sampleStats, 'expected result');
assert.end();

@@ -345,35 +93,3 @@ });

tilestatsClient.test('#deleteTilestats', function(deleteTilestats) {
deleteTilestats.test('typecheck', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
assert.ok(client, 'created dataset client');
assert.throws(function() {
client.deleteTilestats(null, function() {});
}, 'tileset must be a string');
assert.end();
});
deleteTilestats.test('deletes', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
client.deleteTilestats(tilesetid, function(err, result) {
assert.ifError(err, 'success');
assert.notOk(result, 'no result');
assert.end();
});
});
deleteTilestats.test('deletes when user specified by tilesetid', function(assert) {
var client = new MapboxClient(process.env.MapboxAccessToken);
var id = client.owner + '.' + tilesetid;
client.deleteTilestats(id, function(err, result) {
assert.ifError(err, 'success');
assert.notOk(result, 'no result');
assert.end();
});
});
deleteTilestats.end();
});
tilestatsClient.end();
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc