Renaming method to getInteriorPoint

as suggested by @tschaub. Also giving credit to JTS.
This commit is contained in:
ahocevar
2013-07-30 09:25:24 +02:00
parent 11ef2cb7d1
commit b2e25c8f6b
2 changed files with 5 additions and 4 deletions

View File

@@ -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],

View File

@@ -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: ' +