Change getInteriorPoint type to XYM with intersection length as M

This commit is contained in:
Andreas Hocevar
2017-09-27 18:06:05 +02:00
parent c75040e7d8
commit 7a3e11b9e4
5 changed files with 37 additions and 8 deletions

View File

@@ -14,7 +14,8 @@ goog.require('ol.geom.flat.contains');
* @param {Array.<number>} flatCenters Flat centers.
* @param {number} flatCentersOffset Flat center offset.
* @param {Array.<number>=} opt_dest Destination.
* @return {Array.<number>} Destination.
* @return {Array.<number>} Destination point as XYM coordinate, where M is the
* length of the horizontal intersection that the point belongs to.
*/
ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset,
ends, stride, flatCenters, flatCentersOffset, opt_dest) {
@@ -61,10 +62,10 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset,
pointX = flatCenters[flatCentersOffset];
}
if (opt_dest) {
opt_dest.push(pointX, y);
opt_dest.push(pointX, y, maxSegmentLength);
return opt_dest;
} else {
return [pointX, y];
return [pointX, y, maxSegmentLength];
}
};
@@ -75,7 +76,8 @@ ol.geom.flat.interiorpoint.linearRings = function(flatCoordinates, offset,
* @param {Array.<Array.<number>>} endss Endss.
* @param {number} stride Stride.
* @param {Array.<number>} flatCenters Flat centers.
* @return {Array.<number>} Interior points.
* @return {Array.<number>} Interior points as XYM coordinates, where M is the
* length of the horizontal intersection that the point belongs to.
*/
ol.geom.flat.interiorpoint.linearRingss = function(flatCoordinates, offset, endss, stride, flatCenters) {
var interiorPoints = [];

View File

@@ -223,12 +223,13 @@ ol.geom.MultiPolygon.prototype.getFlatInteriorPoints = function() {
/**
* Return the interior points as {@link ol.geom.MultiPoint multipoint}.
* @return {ol.geom.MultiPoint} Interior points.
* @return {ol.geom.MultiPoint} Interior points as XYM coordinates, where M is
* the length of the horizontal intersection that the point belongs to.
* @api
*/
ol.geom.MultiPolygon.prototype.getInteriorPoints = function() {
var interiorPoints = new ol.geom.MultiPoint(null);
interiorPoints.setFlatCoordinates(ol.geom.GeometryLayout.XY,
interiorPoints.setFlatCoordinates(ol.geom.GeometryLayout.XYM,
this.getFlatInteriorPoints().slice());
return interiorPoints;
};

View File

@@ -210,11 +210,12 @@ ol.geom.Polygon.prototype.getFlatInteriorPoint = function() {
/**
* Return an interior point of the polygon.
* @return {ol.geom.Point} Interior point.
* @return {ol.geom.Point} Interior point as XYM coordinate, where M is the
* length of the horizontal intersection that the point belongs to.
* @api
*/
ol.geom.Polygon.prototype.getInteriorPoint = function() {
return new ol.geom.Point(this.getFlatInteriorPoint());
return new ol.geom.Point(this.getFlatInteriorPoint(), ol.geom.GeometryLayout.XYM);
};