Skip to content
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
33 changes: 21 additions & 12 deletions packages/devextreme/js/__internal/viz/vector_map/map_layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
Loading