本文整理汇总了C#中Rectangle.GetMaxY方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.GetMaxY方法的具体用法?C# Rectangle.GetMaxY怎么用?C# Rectangle.GetMaxY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle.GetMaxY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RectangleImpl
public RectangleImpl(Rectangle r)
{
minX = r.GetMinX();
maxX = r.GetMaxX();
minY = r.GetMinY();
maxY = r.GetMaxY();
}
示例2: Init
protected void Init(SpatialContext ctx, Rectangle bounds, int maxLevels)
{
this.xmin = bounds.GetMinX();
this.xmax = bounds.GetMaxX();
this.ymin = bounds.GetMinY();
this.ymax = bounds.GetMaxY();
levelW = new double[maxLevels];
levelH = new double[maxLevels];
levelS = new int[maxLevels];
levelN = new int[maxLevels];
gridW = xmax - xmin;
gridH = ymax - ymin;
xmid = xmin + gridW / 2.0;
ymid = ymin + gridH / 2.0;
levelW[0] = gridW / 2.0;
levelH[0] = gridH / 2.0;
levelS[0] = 2;
levelN[0] = 4;
for (int i = 1; i < levelW.Length; i++)
{
levelW[i] = levelW[i - 1] / 2.0;
levelH[i] = levelH[i - 1] / 2.0;
levelS[i] = levelS[i - 1] * 2;
levelN[i] = levelN[i - 1] * 4;
}
}
示例3: QuadPrefixTree
public QuadPrefixTree(SpatialContext ctx, Rectangle bounds, int maxLevels)
: base(ctx, maxLevels)
{
//not really sure how big this should be
// side
// number
xmin = bounds.GetMinX();
xmax = bounds.GetMaxX();
ymin = bounds.GetMinY();
ymax = bounds.GetMaxY();
levelW = new double[maxLevels];
levelH = new double[maxLevels];
levelS = new int[maxLevels];
levelN = new int[maxLevels];
gridW = xmax - xmin;
gridH = ymax - ymin;
xmid = xmin + gridW / 2.0;
ymid = ymin + gridH / 2.0;
levelW[0] = gridW / 2.0;
levelH[0] = gridH / 2.0;
levelS[0] = 2;
levelN[0] = 4;
for (int i = 1; i < levelW.Length; i++)
{
levelW[i] = levelW[i - 1] / 2.0;
levelH[i] = levelH[i - 1] / 2.0;
levelS[i] = levelS[i - 1] * 2;
levelN[i] = levelN[i - 1] * 4;
}
}
示例4: Area
public override double Area(Rectangle rect)
{
//From http://mathforum.org/library/drmath/view/63767.html
double lat1 = DistanceUtils.ToRadians(rect.GetMinY());
double lat2 = DistanceUtils.ToRadians(rect.GetMaxY());
return Math.PI / 180 * radius * radius *
Math.Abs(Math.Sin(lat1) - Math.Sin(lat2)) *
rect.GetWidth();
}
示例5: Equals
/// <summary>
/// All {@link Rectangle} implementations should use this definition of {@link Object#equals(Object)}.
/// </summary>
/// <param name="thiz"></param>
/// <param name="o"></param>
/// <returns></returns>
public static bool Equals(Rectangle thiz, Object o)
{
if (thiz == null)
throw new ArgumentNullException("thiz");
if (thiz == o) return true;
var rectangle = o as Rectangle;
if (rectangle == null) return false;
return thiz.GetMaxX().Equals(rectangle.GetMaxX()) && thiz.GetMinX().Equals(rectangle.GetMinX()) &&
thiz.GetMaxY().Equals(rectangle.GetMaxY()) && thiz.GetMinY().Equals(rectangle.GetMinY());
}
示例6: Relate
public SpatialRelation Relate(Rectangle rect, SpatialContext ctx)
{
SpatialRelation yIntersect = RelateYRange(rect.GetMinY(), rect.GetMaxY(), ctx);
if (yIntersect == SpatialRelation.DISJOINT)
return SpatialRelation.DISJOINT;
SpatialRelation xIntersect = RelateXRange(rect.GetMinX(), rect.GetMaxX(), ctx);
if (xIntersect == SpatialRelation.DISJOINT)
return SpatialRelation.DISJOINT;
if (xIntersect == yIntersect)//in agreement
return xIntersect;
//if one side is equal, return the other
if (GetMinX() == rect.GetMinX() && GetMaxX() == rect.GetMaxX())
return yIntersect;
if (GetMinY() == rect.GetMinY() && GetMaxY() == rect.GetMaxY())
return xIntersect;
return SpatialRelation.INTERSECTS;
}
示例7: Score
public double Score(Rectangle target, Explanation exp)
{
if (target == null || queryArea <= 0)
{
return 0;
}
double targetArea = target.GetArea(null);
if (targetArea <= 0)
{
return 0;
}
double score = 0;
double top = Math.Min(queryExtent.GetMaxY(), target.GetMaxY());
double bottom = Math.Max(queryExtent.GetMinY(), target.GetMinY());
double height = top - bottom;
double width = 0;
// queries that cross the date line
if (queryExtent.GetCrossesDateLine())
{
// documents that cross the date line
if (target.GetCrossesDateLine())
{
double left = Math.Max(queryExtent.GetMinX(), target.GetMinX());
double right = Math.Min(queryExtent.GetMaxX(), target.GetMaxX());
width = right + 360.0 - left;
}
else
{
double qryWestLeft = Math.Max(queryExtent.GetMinX(), target.GetMaxX());
double qryWestRight = Math.Min(target.GetMaxX(), 180.0);
double qryWestWidth = qryWestRight - qryWestLeft;
if (qryWestWidth > 0)
{
width = qryWestWidth;
}
else
{
double qryEastLeft = Math.Max(target.GetMaxX(), -180.0);
double qryEastRight = Math.Min(queryExtent.GetMaxX(), target.GetMaxX());
double qryEastWidth = qryEastRight - qryEastLeft;
if (qryEastWidth > 0)
{
width = qryEastWidth;
}
}
}
}
else
{ // queries that do not cross the date line
if (target.GetCrossesDateLine())
{
double tgtWestLeft = Math.Max(queryExtent.GetMinX(), target.GetMinX());
double tgtWestRight = Math.Min(queryExtent.GetMaxX(), 180.0);
double tgtWestWidth = tgtWestRight - tgtWestLeft;
if (tgtWestWidth > 0)
{
width = tgtWestWidth;
}
else
{
double tgtEastLeft = Math.Max(queryExtent.GetMinX(), -180.0);
double tgtEastRight = Math.Min(queryExtent.GetMaxX(), target.GetMaxX());
double tgtEastWidth = tgtEastRight - tgtEastLeft;
if (tgtEastWidth > 0)
{
width = tgtEastWidth;
}
}
}
else
{
double left = Math.Max(queryExtent.GetMinX(), target.GetMinX());
double right = Math.Min(queryExtent.GetMaxX(), target.GetMaxX());
width = right - left;
}
}
// calculate the score
if ((width > 0) && (height > 0))
{
double intersectionArea = width * height;
double queryRatio = intersectionArea / queryArea;
double targetRatio = intersectionArea / targetArea;
double queryFactor = Math.Pow(queryRatio, queryPower);
double targetFactor = Math.Pow(targetRatio, targetPower);
score = queryFactor * targetFactor * 10000.0;
if (exp != null)
{
// StringBuilder sb = new StringBuilder();
// sb.append("\nscore=").append(score);
// sb.append("\n query=").append();
// sb.append("\n target=").append(target.toString());
// sb.append("\n intersectionArea=").append(intersectionArea);
//
// sb.append(" queryArea=").append(queryArea).append(" targetArea=").append(targetArea);
//.........这里部分代码省略.........
示例8: RelateRectangleCircleWrapsPole
private SpatialRelation RelateRectangleCircleWrapsPole(Rectangle r, SpatialContext ctx)
{
//This method handles the case where the circle wraps ONE pole, but not both. For both,
// there is the inverseCircle case handled before now. The only exception is for the case where
// the circle covers the entire globe, and we'll check that first.
if (radiusDEG == 180)//whole globe
return SpatialRelation.CONTAINS;
//Check if r is within the pole wrap region:
double yTop = GetCenter().GetY() + radiusDEG;
if (yTop > 90)
{
double yTopOverlap = yTop - 90;
Debug.Assert(yTopOverlap <= 90, "yTopOverlap: " + yTopOverlap);
if (r.GetMinY() >= 90 - yTopOverlap)
return SpatialRelation.CONTAINS;
}
else
{
double yBot = point.GetY() - radiusDEG;
if (yBot < -90)
{
double yBotOverlap = -90 - yBot;
Debug.Assert(yBotOverlap <= 90);
if (r.GetMaxY() <= -90 + yBotOverlap)
return SpatialRelation.CONTAINS;
}
else
{
//This point is probably not reachable ??
Debug.Assert(yTop == 90 || yBot == -90);//we simply touch a pole
//continue
}
}
//If there are no corners to check intersection because r wraps completely...
if (r.GetWidth() == 360)
return SpatialRelation.INTERSECTS;
//Check corners:
int cornersIntersect = NumCornersIntersect(r);
// (It might be possible to reduce contains() calls within nCI() to exactly two, but this intersection
// code is complicated enough as it is.)
double frontX = GetCenter().GetX();
if (cornersIntersect == 4)
{//all
double backX = frontX <= 0 ? frontX + 180 : frontX - 180;
if (r.RelateXRange(backX, backX).Intersects())
return SpatialRelation.INTERSECTS;
else
return SpatialRelation.CONTAINS;
}
else if (cornersIntersect == 0)
{//none
if (r.RelateXRange(frontX, frontX).Intersects())
return SpatialRelation.INTERSECTS;
else
return SpatialRelation.DISJOINT;
}
else//partial
return SpatialRelation.INTERSECTS;
}
示例9: MakeWithin
/*
* Constructs a query to retrieve documents are fully within the input envelope.
*
* @return the spatial query
*/
Query MakeWithin(Rectangle bbox)
{
// general case
// docMinX >= queryExtent.GetMinX() AND docMinY >= queryExtent.GetMinY() AND docMaxX <= queryExtent.GetMaxX() AND docMaxY <= queryExtent.GetMaxY()
// Y conditions
// docMinY >= queryExtent.GetMinY() AND docMaxY <= queryExtent.GetMaxY()
Query qMinY = NumericRangeQuery.NewDoubleRange(field_minY, precisionStep, bbox.GetMinY(), null, true, false);
Query qMaxY = NumericRangeQuery.NewDoubleRange(field_maxY, precisionStep, null, bbox.GetMaxY(), false, true);
Query yConditions = this.MakeQuery(new Query[] { qMinY, qMaxY }, Occur.MUST);
// X conditions
Query xConditions = null;
// X Conditions for documents that cross the date line,
// the left portion of the document must be within the left portion of the query,
// AND the right portion of the document must be within the right portion of the query
// docMinXLeft >= queryExtent.GetMinX() AND docMaxXLeft <= 180.0
// AND docMinXRight >= -180.0 AND docMaxXRight <= queryExtent.GetMaxX()
Query qXDLLeft = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, bbox.GetMinX(), null, true, false);
Query qXDLRight = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, null, bbox.GetMaxX(), false, true);
Query qXDLLeftRight = this.MakeQuery(new Query[] { qXDLLeft, qXDLRight }, Occur.MUST);
Query qXDL = this.MakeXDL(true, qXDLLeftRight);
// queries that do not cross the date line
if (!bbox.GetCrossesDateLine())
{
// X Conditions for documents that do not cross the date line,
// docMinX >= queryExtent.GetMinX() AND docMaxX <= queryExtent.GetMaxX()
Query qMinX = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, bbox.GetMinX(), null, true, false);
Query qMaxX = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, null, bbox.GetMaxX(), false, true);
Query qMinMax = this.MakeQuery(new Query[] { qMinX, qMaxX }, Occur.MUST);
Query qNonXDL = this.MakeXDL(false, qMinMax);
// apply the non-XDL or XDL X conditions
if ((bbox.GetMinX() <= -180.0) && bbox.GetMaxX() >= 180.0)
{
xConditions = this.MakeQuery(new Query[] { qNonXDL, qXDL }, Occur.SHOULD);
}
else
{
xConditions = qNonXDL;
}
// queries that cross the date line
}
else
{
// X Conditions for documents that do not cross the date line
// the document should be within the left portion of the query
// docMinX >= queryExtent.GetMinX() AND docMaxX <= 180.0
Query qMinXLeft = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, bbox.GetMinX(), null, true, false);
Query qMaxXLeft = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, null, 180.0, false, true);
Query qLeft = this.MakeQuery(new Query[] { qMinXLeft, qMaxXLeft }, Occur.MUST);
// the document should be within the right portion of the query
// docMinX >= -180.0 AND docMaxX <= queryExtent.GetMaxX()
Query qMinXRight = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, -180.0, null, true, false);
Query qMaxXRight = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, null, bbox.GetMaxX(), false, true);
Query qRight = this.MakeQuery(new Query[] { qMinXRight, qMaxXRight }, Occur.MUST);
// either left or right conditions should occur,
// apply the left and right conditions to documents that do not cross the date line
Query qLeftRight = this.MakeQuery(new Query[] { qLeft, qRight }, Occur.SHOULD);
Query qNonXDL = this.MakeXDL(false, qLeftRight);
// apply the non-XDL and XDL conditions
xConditions = this.MakeQuery(new Query[] { qNonXDL, qXDL }, Occur.SHOULD);
}
// both X and Y conditions must occur
return this.MakeQuery(new Query[] { xConditions, yConditions }, Occur.MUST);
}
示例10: MakeContains
//-------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------
/// <summary>
/// Constructs a query to retrieve documents that fully contain the input envelope.
/// </summary>
/// <param name="bbox"></param>
/// <returns>The spatial query</returns>
protected Query MakeContains(Rectangle bbox)
{
// general case
// docMinX <= queryExtent.GetMinX() AND docMinY <= queryExtent.GetMinY() AND docMaxX >= queryExtent.GetMaxX() AND docMaxY >= queryExtent.GetMaxY()
// Y conditions
// docMinY <= queryExtent.GetMinY() AND docMaxY >= queryExtent.GetMaxY()
Query qMinY = NumericRangeQuery.NewDoubleRange(field_minY, precisionStep, null, bbox.GetMinY(), false, true);
Query qMaxY = NumericRangeQuery.NewDoubleRange(field_maxY, precisionStep, bbox.GetMaxY(), null, true, false);
Query yConditions = this.MakeQuery(new Query[] { qMinY, qMaxY }, Occur.MUST);
// X conditions
Query xConditions = null;
// queries that do not cross the date line
if (!bbox.GetCrossesDateLine())
{
// X Conditions for documents that do not cross the date line,
// documents that contain the min X and max X of the query envelope,
// docMinX <= queryExtent.GetMinX() AND docMaxX >= queryExtent.GetMaxX()
Query qMinX = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, null, bbox.GetMinX(), false, true);
Query qMaxX = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, bbox.GetMaxX(), null, true, false);
Query qMinMax = this.MakeQuery(new Query[] { qMinX, qMaxX }, Occur.MUST);
Query qNonXDL = this.MakeXDL(false, qMinMax);
// X Conditions for documents that cross the date line,
// the left portion of the document contains the min X of the query
// OR the right portion of the document contains the max X of the query,
// docMinXLeft <= queryExtent.GetMinX() OR docMaxXRight >= queryExtent.GetMaxX()
Query qXDLLeft = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, null, bbox.GetMinX(), false, true);
Query qXDLRight = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, bbox.GetMaxX(), null, true, false);
Query qXDLLeftRight = this.MakeQuery(new Query[] { qXDLLeft, qXDLRight }, Occur.SHOULD);
Query qXDL = this.MakeXDL(true, qXDLLeftRight);
// apply the non-XDL and XDL conditions
xConditions = this.MakeQuery(new Query[] { qNonXDL, qXDL }, Occur.SHOULD);
// queries that cross the date line
}
else
{
// No need to search for documents that do not cross the date line
// X Conditions for documents that cross the date line,
// the left portion of the document contains the min X of the query
// AND the right portion of the document contains the max X of the query,
// docMinXLeft <= queryExtent.GetMinX() AND docMaxXRight >= queryExtent.GetMaxX()
Query qXDLLeft = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, null, bbox.GetMinX(), false, true);
Query qXDLRight = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, bbox.GetMaxX(), null, true, false);
Query qXDLLeftRight = this.MakeQuery(new Query[] { qXDLLeft, qXDLRight }, Occur.MUST);
xConditions = this.MakeXDL(true, qXDLLeftRight);
}
// both X and Y conditions must occur
return this.MakeQuery(new Query[] { xConditions, yConditions }, Occur.MUST);
}
示例11: MakeDisjoint
/// <summary>
/// Constructs a query to retrieve documents that fully contain the input envelope.
/// </summary>
/// <param name="bbox"></param>
private Query MakeDisjoint(Rectangle bbox)
{
if (bbox.GetCrossesDateLine())
throw new InvalidOperationException("MakeDisjoint doesn't handle dateline cross");
Query qX = RangeQuery(fieldNameX, bbox.GetMinX(), bbox.GetMaxX());
Query qY = RangeQuery(fieldNameY, bbox.GetMinY(), bbox.GetMaxY());
var bq = new BooleanQuery { { qX, Occur.MUST_NOT }, { qY, Occur.MUST_NOT } };
return bq;
}
示例12: CreateIndexableFields
public AbstractField[] CreateIndexableFields(Rectangle bbox)
{
var fields = new AbstractField[5];
fields[0] = DoubleField(field_minX, bbox.GetMinX());
fields[1] = DoubleField(field_maxX, bbox.GetMaxX());
fields[2] = DoubleField(field_minY, bbox.GetMinY());
fields[3] = DoubleField(field_maxY, bbox.GetMaxY());
fields[4] = new Field(field_xdl, bbox.GetCrossesDateLine() ? "T" : "F", Field.Store.NO,
Field.Index.NOT_ANALYZED_NO_NORMS) {OmitNorms = true, OmitTermFreqAndPositions = true};
return fields;
}
示例13: RectangleImpl
public RectangleImpl(Rectangle r, SpatialContext ctx)
: this(r.GetMinX(), r.GetMaxX(), r.GetMinY(), r.GetMaxY(), ctx)
{
}
示例14: RelateRectanglePhase2
protected virtual SpatialRelation RelateRectanglePhase2(Rectangle r, SpatialRelation bboxSect, SpatialContext ctx)
{
/*
!! DOES NOT WORK WITH GEO CROSSING DATELINE OR WORLD-WRAP.
TODO upgrade to handle crossing dateline, but not world-wrap; use some x-shifting code from RectangleImpl.
*/
//At this point, the only thing we are certain of is that circle is *NOT* WITHIN r, since the bounding box of a
// circle MUST be within r for the circle to be within r.
//--Quickly determine if they are DISJOINT or not.
//see http://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection/1879223#1879223
double closestX;
double ctr_x = GetXAxis();
if (ctr_x < r.GetMinX())
closestX = r.GetMinX();
else if (ctr_x > r.GetMaxX())
closestX = r.GetMaxX();
else
closestX = ctr_x;
double closestY;
double ctr_y = GetYAxis();
if (ctr_y < r.GetMinY())
closestY = r.GetMinY();
else if (ctr_y > r.GetMaxY())
closestY = r.GetMaxY();
else
closestY = ctr_y;
//Check if there is an intersection from this circle to closestXY
bool didContainOnClosestXY = false;
if (ctr_x == closestX)
{
double deltaY = Math.Abs(ctr_y - closestY);
double distYCirc = (ctr_y < closestY ? enclosingBox.GetMaxY() - ctr_y : ctr_y - enclosingBox.GetMinY());
if (deltaY > distYCirc)
return SpatialRelation.DISJOINT;
}
else if (ctr_y == closestY)
{
double deltaX = Math.Abs(ctr_x - closestX);
double distXCirc = (ctr_x < closestX ? enclosingBox.GetMaxX() - ctr_x : ctr_x - enclosingBox.GetMinX());
if (deltaX > distXCirc)
return SpatialRelation.DISJOINT;
}
else
{
//fallback on more expensive calculation
didContainOnClosestXY = true;
if (!Contains(closestX, closestY))
return SpatialRelation.DISJOINT;
}
//At this point we know that it's *NOT* DISJOINT, so there is some level of intersection. It's *NOT* WITHIN either.
// The only question left is whether circle CONTAINS r or simply intersects it.
//If circle contains r, then its bbox MUST also CONTAIN r.
if (bboxSect != SpatialRelation.CONTAINS)
return SpatialRelation.INTERSECTS;
//Find the farthest point of r away from the center of the circle. If that point is contained, then all of r is
// contained.
double farthestX = r.GetMaxX() - ctr_x > ctr_x - r.GetMinX() ? r.GetMaxX() : r.GetMinX();
double farthestY = r.GetMaxY() - ctr_y > ctr_y - r.GetMinY() ? r.GetMaxY() : r.GetMinY();
if (Contains(farthestX, farthestY))
return SpatialRelation.CONTAINS;
return SpatialRelation.INTERSECTS;
}
示例15: GetHashCode
public static int GetHashCode(Rectangle thiz)
{
if (thiz == null)
throw new ArgumentNullException("thiz");
long temp = thiz.GetMinX() != +0.0d ? BitConverter.DoubleToInt64Bits(thiz.GetMinX()) : 0L;
int result = (int)(temp ^ ((uint)temp >> 32));
temp = thiz.GetMaxX() != +0.0d ? BitConverter.DoubleToInt64Bits(thiz.GetMaxX()) : 0L;
result = 31 * result + (int)(temp ^ ((uint)temp >> 32));
temp = thiz.GetMinY() != +0.0d ? BitConverter.DoubleToInt64Bits(thiz.GetMinY()) : 0L;
result = 31 * result + (int)(temp ^ ((uint)temp >> 32));
temp = thiz.GetMaxY() != +0.0d ? BitConverter.DoubleToInt64Bits(thiz.GetMaxY()) : 0L;
result = 31*result + (int) (temp ^ ((uint)temp >> 32));
return result;
}