Add ol.geom.MultiLineString#appendLineString
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
@exportSymbol ol.geom.MultiLineString
|
@exportSymbol ol.geom.MultiLineString
|
||||||
|
@exportProperty ol.geom.MultiLineString.prototype.appendLineString
|
||||||
@exportProperty ol.geom.MultiLineString.prototype.clone
|
@exportProperty ol.geom.MultiLineString.prototype.clone
|
||||||
@exportProperty ol.geom.MultiLineString.prototype.getCoordinateAtM
|
@exportProperty ol.geom.MultiLineString.prototype.getCoordinateAtM
|
||||||
@exportProperty ol.geom.MultiLineString.prototype.getCoordinates
|
@exportProperty ol.geom.MultiLineString.prototype.getCoordinates
|
||||||
|
|||||||
@@ -47,6 +47,22 @@ ol.geom.MultiLineString = function(coordinates, opt_layout) {
|
|||||||
goog.inherits(ol.geom.MultiLineString, ol.geom.SimpleGeometry);
|
goog.inherits(ol.geom.MultiLineString, ol.geom.SimpleGeometry);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ol.geom.LineString} lineString LineString.
|
||||||
|
*/
|
||||||
|
ol.geom.MultiLineString.prototype.appendLineString = function(lineString) {
|
||||||
|
goog.asserts.assert(lineString.getLayout() == this.layout);
|
||||||
|
if (goog.isNull(this.flatCoordinates)) {
|
||||||
|
this.flatCoordinates = lineString.getFlatCoordinates().slice();
|
||||||
|
} else {
|
||||||
|
goog.array.extend(
|
||||||
|
this.flatCoordinates, lineString.getFlatCoordinates().slice());
|
||||||
|
}
|
||||||
|
this.ends_.push(this.flatCoordinates.length);
|
||||||
|
this.dispatchChangeEvent();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -37,6 +37,17 @@ describe('ol.geom.MultiLineString', function() {
|
|||||||
expect(multiLineString.getStride()).to.be(2);
|
expect(multiLineString.getStride()).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can append line strings', function() {
|
||||||
|
multiLineString.appendLineString(
|
||||||
|
new ol.geom.LineString([[1, 2], [3, 4]]));
|
||||||
|
expect(multiLineString.getCoordinates()).to.eql(
|
||||||
|
[[[1, 2], [3, 4]]]);
|
||||||
|
multiLineString.appendLineString(
|
||||||
|
new ol.geom.LineString([[5, 6], [7, 8]]));
|
||||||
|
expect(multiLineString.getCoordinates()).to.eql(
|
||||||
|
[[[1, 2], [3, 4]], [[5, 6], [7, 8]]]);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('construct with 2D coordinates', function() {
|
describe('construct with 2D coordinates', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user