diff --git a/src/commands/mapshaper-union.js b/src/commands/mapshaper-union.js index 886ec8b37..1b999a69c 100644 --- a/src/commands/mapshaper-union.js +++ b/src/commands/mapshaper-union.js @@ -49,11 +49,11 @@ api.union = function(targetLayers, targetDataset, opts) { }); var unionLyr = { + name: 'union', geometry_type: 'polygon', shapes: mosaicShapes, data: new DataTable(mosaicRecords) }; - // if ('name' in targetLyr) unionLyr.name = targetLyr.name; return [unionLyr]; }; diff --git a/test/union-test.js b/test/union-test.js index 91e09b505..83df9f0a7 100644 --- a/test/union-test.js +++ b/test/union-test.js @@ -71,15 +71,15 @@ describe('mapshaper-union.js', function () { }); }); - it('union with a no-data layer works', function(done) { + it('union with a no-data layer works; default layer name is "union"', function(done) { var fileA = 'test/test_data/issues/union/polygonA.json'; var geomB = { type: 'Polygon', coordinates: [[[1, 1], [2, 2], [3, 1], [2, 0], [1, 1]]] } - var cmd = `-i polygonB.json -i ${fileA} -union target=polygonA,polygonB name=merged -o`; + var cmd = `-i polygonB.json -i ${fileA} -union target=polygonA,polygonB -o`; api.applyCommands(cmd, {'polygonB.json': geomB}, function(err, out) { - var features = JSON.parse(out['merged.json']).features; + var features = JSON.parse(out['union.json']).features; var records = _.pluck(features, 'properties'); assert.deepEqual(records, [ { name: 'A', value: 4 },