本文整理汇总了C#中Shape.GetCenter方法的典型用法代码示例。如果您正苦于以下问题:C# Shape.GetCenter方法的具体用法?C# Shape.GetCenter怎么用?C# Shape.GetCenter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shape
的用法示例。
在下文中一共展示了Shape.GetCenter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateIndexableFields
public AbstractField[] CreateIndexableFields(Shape shape, double distErr)
{
int detailLevel = grid.GetLevelForDistance(distErr);
var cells = grid.GetNodes(shape, detailLevel, true);//true=intermediates cells
//If shape isn't a point, add a full-resolution center-point so that
// PointPrefixTreeFieldCacheProvider has the center-points.
// TODO index each center of a multi-point? Yes/no?
if (!(shape is Point))
{
Point ctr = shape.GetCenter();
//TODO should be smarter; don't index 2 tokens for this in CellTokenStream. Harmless though.
cells.Add(grid.GetNodes(ctr, grid.GetMaxLevels(), false)[0]);
}
//TODO is CellTokenStream supposed to be re-used somehow? see Uwe's comments:
// http://code.google.com/p/lucene-spatial-playground/issues/detail?id=4
return new AbstractField[]
{
new Field(GetFieldName(), new CellTokenStream(cells.GetEnumerator()))
{OmitNorms = true, OmitTermFreqAndPositions = true}
};
}
示例2: MakeRecipDistanceValueSource
/// <summary>
/// Returns a ValueSource with values ranging from 1 to 0, depending inversely
/// on the distance from {@link #makeDistanceValueSource(com.spatial4j.core.shape.Point)}.
/// The formula is <c>c/(d + c)</c> where 'd' is the distance and 'c' is
/// one tenth the distance to the farthest edge from the center. Thus the
/// scores will be 1 for indexed points at the center of the query shape and as
/// low as ~0.1 at its furthest edges.
/// </summary>
/// <param name="queryShape"></param>
/// <returns></returns>
public ValueSource MakeRecipDistanceValueSource(Shape queryShape)
{
Rectangle bbox = queryShape.GetBoundingBox();
double diagonalDist = ctx.GetDistCalc().Distance(
ctx.MakePoint(bbox.GetMinX(), bbox.GetMinY()), bbox.GetMaxX(), bbox.GetMaxY());
double distToEdge = diagonalDist*0.5;
float c = (float) distToEdge*0.1f; //one tenth
return new ReciprocalFloatFunction(MakeDistanceValueSource(queryShape.GetCenter()), 1f, c, c);
}
示例3: newDoc
protected override Document newDoc(String id, Shape shape)
{
//called by adoc(). Make compatible with BBoxStrategy.
if (shape != null && strategy is BBoxStrategy)
shape = ctx.MakeRectangle(shape.GetCenter(), shape.GetCenter());
return base.newDoc(id, shape);
}