/**
* @class
* A location strategy that returns the centre of the target object.
* For polygons and polylines, the centre is computed as the centre of the bounding box and therefore
* may not lie on or in the shape.
*
* @constructor
* @param {lucid.maps.limbs.location.CentreLocationStrategyOptions} options The options controlling the location calculation.
*/
lucid.maps.limbs.location.CentreLocationStrategy = function( options )
{
lucid.maps.limbs.location.LocationStrategy.apply( this, [ options ] );
this.computeMarkerLocation = function( target )
{
return target.getPosition();
};
this.computePolylineLocation = function( target )
{
// TODO Cache the result of computeBounds to improve performance.
// Provide an option in the CentreLocationStrategyOptions to set the cache class.
// The cache class should provide a function to clear a value out of the cache.
return lucid.maps.geometry.computeBounds( target ).getCenter();
};
this.computePolygonLocation = function( target )
{
return lucid.maps.geometry.computeBounds( target ).getCenter();
};
this.computeRectangleLocation = function( target )
{
return target.getBounds().getCenter();
};
this.computeCircleLocation = function( target )
{
return target.getCenter();
};
};
/**
* @type {object}
* @augments lucid.maps.limbs.location.LocationStrategyOptions
*/
lucid.maps.limbs.location.CentreLocationStrategyOptions = {};