Renaming method to getInteriorPoint
as suggested by @tschaub. Also giving credit to JTS.
This commit is contained in:
@@ -136,10 +136,11 @@ ol.geom.Polygon.prototype.containsCoordinate = function(coordinate) {
|
||||
|
||||
|
||||
/**
|
||||
* Calculates a label point that is guaranteed to be inside the polygon.
|
||||
* @return {ol.Coordinate} The label point.
|
||||
* Calculates a point that is guaranteed to lie in the interior of the polygon.
|
||||
* Inspired by JTS's com.vividsolutions.jts.geom.Geometry#getInteriorPoint.
|
||||
* @return {ol.Coordinate} A point which is in the interior of the polygon.
|
||||
*/
|
||||
ol.geom.Polygon.prototype.getLabelPoint = function() {
|
||||
ol.geom.Polygon.prototype.getInteriorPoint = function() {
|
||||
if (goog.isNull(this.labelPoint_)) {
|
||||
var center = ol.extent.getCenter(this.getBounds()),
|
||||
resultY = center[1],
|
||||
|
||||
@@ -445,7 +445,7 @@ ol.renderer.canvas.VectorRenderer.getLabelVectors = function(geometry) {
|
||||
return [[geometry.get(0), geometry.get(1), 0]];
|
||||
}
|
||||
if (type == ol.geom.GeometryType.POLYGON) {
|
||||
var coordinates = geometry.getLabelPoint();
|
||||
var coordinates = geometry.getInteriorPoint();
|
||||
return [[coordinates[0], coordinates[1], 0]];
|
||||
}
|
||||
throw new Error('Label rendering not implemented for geometry type: ' +
|
||||
|
||||
Reference in New Issue
Block a user