From b87db0e3de15ad3976568889d13365f56c1bea95 Mon Sep 17 00:00:00 2001 From: pharret31 Date: Thu, 30 Apr 2026 18:19:52 +0200 Subject: [PATCH] Fix --- .../js/__internal/viz/vector_map/map_layer.ts | 33 +++++--- .../mapLayer.strategies.tests.js | 31 ++++--- .../mapLayer_new.tests.js | 82 ++++++++++++++++++- 3 files changed, 120 insertions(+), 26 deletions(-) diff --git a/packages/devextreme/js/__internal/viz/vector_map/map_layer.ts b/packages/devextreme/js/__internal/viz/vector_map/map_layer.ts index 49c11f377064..fadc174a8208 100644 --- a/packages/devextreme/js/__internal/viz/vector_map/map_layer.ts +++ b/packages/devextreme/js/__internal/viz/vector_map/map_layer.ts @@ -415,20 +415,29 @@ strategiesByType[TYPE_MARKER] = { }, }; -strategiesByGeometry[TYPE_AREA] = function (sample) { - return { - project(projection, coordinates) { - return coordinates[0] - && coordinates[0][0] - && coordinates[0][0][0] - && typeof coordinates[0][0][0][0] === 'number' ? projectMultiPolygon(projection, coordinates) : projectPolygon(projection, coordinates); - }, - }; +function projectAreaByGeometry(projection, coordinates) { + return coordinates[0] + && coordinates[0][0] + && coordinates[0][0][0] + && typeof coordinates[0][0][0][0] === 'number' + ? projectMultiPolygon(projection, coordinates) + : projectPolygon(projection, coordinates); +} + +strategiesByGeometry[TYPE_AREA] = function () { + return { project: projectAreaByGeometry }; }; -strategiesByGeometry[TYPE_LINE] = function (sample) { - const coordinates = sample.coordinates; - return { project: coordinates[0] && coordinates[0][0] && typeof coordinates[0][0][0] === 'number' ? projectPolygon : projectLineString }; +function projectLineByGeometry(projection, coordinates) { + return coordinates[0] + && coordinates[0][0] + && typeof coordinates[0][0][0] === 'number' + ? projectPolygon(projection, coordinates) + : projectLineString(projection, coordinates); +} + +strategiesByGeometry[TYPE_LINE] = function () { + return { project: projectLineByGeometry }; }; strategiesByElementType[TYPE_MARKER] = { diff --git a/packages/devextreme/testing/tests/DevExpress.viz.vectorMap/mapLayer.strategies.tests.js b/packages/devextreme/testing/tests/DevExpress.viz.vectorMap/mapLayer.strategies.tests.js index d0467b384ba0..bd7378da4296 100644 --- a/packages/devextreme/testing/tests/DevExpress.viz.vectorMap/mapLayer.strategies.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.viz.vectorMap/mapLayer.strategies.tests.js @@ -101,25 +101,30 @@ QUnit.test('Select project strategy by type (polygon/multipolygon)', function(as QUnit.test('Project', function(assert) { const projection = { project: function(coordinates) { - return coordinates + '-proj'; + return coordinates * 2; + } + }; + const multilineProjection = { + project: function(coordinates) { + return coordinates.map(item => item * 2); } }; assert.deepEqual(lineStrategyLineString.project(projection, [ - 'p1', 'p2', 'p3' + 1, 2, 3 ]), [ - ['p1-proj', 'p2-proj', 'p3-proj'] + [2, 4, 6] ], 'line linestring'); - assert.deepEqual(lineStrategyMultiLineString.project(projection, [ - ['p1', 'p2'], - ['p3', 'p4', 'p5'], - ['p6'] - ]), [ - ['p1-proj', 'p2-proj'], - ['p3-proj', 'p4-proj', 'p5-proj'], - ['p6-proj'] - ], 'line multilinestring'); - assert.deepEqual(pointDotStrategy.project(projection, ['p']), 'p-proj', 'point'); + assert.deepEqual(lineStrategyMultiLineString.project(multilineProjection, [[ + [1, 2], + [3, 4, 5], + [6] + ]]), [[ + [2, 4], + [6, 8, 10], + [12] + ]], 'line multilinestring'); + assert.deepEqual(pointDotStrategy.project(projection, [1]), 2, 'point'); }); QUnit.test('Project area label', function(assert) { diff --git a/packages/devextreme/testing/tests/DevExpress.viz.vectorMap/mapLayer_new.tests.js b/packages/devextreme/testing/tests/DevExpress.viz.vectorMap/mapLayer_new.tests.js index f4b9970af3fb..ee960f4526c4 100644 --- a/packages/devextreme/testing/tests/DevExpress.viz.vectorMap/mapLayer_new.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.viz.vectorMap/mapLayer_new.tests.js @@ -263,10 +263,90 @@ QUnit.test('Lines (MultiLineString)', function(assert) { ] }], 'line 2 (complex)'); assert.deepEqual(this.getLine(2).attr.getCall(0).args, [{ - points: [] + points: [[]] }], 'line 3 (degenerate)'); }); +QUnit.test('Lines (mixed LineString and MultiLineString, MultiLineString first) (T1327745)', function(assert) { + this.createLayer({ + dataSource: { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + geometry: { + type: 'MultiLineString', + coordinates: [ + [[200, 100], [400, 0], [400, 300]], + [[0, 0], [0, 300], [400, 300], [400, 0]] + ] + }, + properties: {} + }, + { + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: [[100, 200], [300, 300], [400, 0]] + }, + properties: {} + } + ] + } + }); + + assert.strictEqual(this.getLine(0).attr.getCall(1).args[0]['class'], 'dxm-line', 'type'); + assert.deepEqual(this.getLine(0).attr.getCall(0).args, [{ + points: [ + [600, 400, 1000, 600, 1000, 0], + [200, 600, 200, 0, 1000, 0, 1000, 600] + ] + }], 'line 1 - MultiLineString'); + assert.deepEqual(this.getLine(1).attr.getCall(0).args, [{ + points: [[400, 200, 800, 0, 1000, 600]] + }], 'line 2 - LineString (no NaN)'); +}); + +QUnit.test('Lines (mixed LineString and MultiLineString, LineString first) (T1327745)', function(assert) { + this.createLayer({ + dataSource: { + type: 'FeatureCollection', + features: [ + { + type: 'Feature', + geometry: { + type: 'LineString', + coordinates: [[100, 200], [300, 300], [400, 0]] + }, + properties: {} + }, + { + type: 'Feature', + geometry: { + type: 'MultiLineString', + coordinates: [ + [[200, 100], [400, 0], [400, 300]], + [[0, 0], [0, 300], [400, 300], [400, 0]] + ] + }, + properties: {} + } + ] + } + }); + + assert.strictEqual(this.getLine(0).attr.getCall(1).args[0]['class'], 'dxm-line', 'type'); + assert.deepEqual(this.getLine(0).attr.getCall(0).args, [{ + points: [[400, 200, 800, 0, 1000, 600]] + }], 'line 1 - LineString'); + assert.deepEqual(this.getLine(1).attr.getCall(0).args, [{ + points: [ + [600, 400, 1000, 600, 1000, 0], + [200, 600, 200, 0, 1000, 0, 1000, 600] + ] + }], 'line 2 - MultiLineString (no NaN)'); +}); + QUnit.test('Lines (simple data source)', function(assert) { this.createLayer({ dataSource: [