当前位置: 首页>>代码示例>>C#>>正文


C# Rectangle.GetCrossesDateLine方法代码示例

本文整理汇总了C#中Rectangle.GetCrossesDateLine方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.GetCrossesDateLine方法的具体用法?C# Rectangle.GetCrossesDateLine怎么用?C# Rectangle.GetCrossesDateLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rectangle的用法示例。


在下文中一共展示了Rectangle.GetCrossesDateLine方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:81,代码来源:BBoxStrategy.cs

示例2: CreateIndexableFields

 public Field[] CreateIndexableFields(Rectangle bbox)
 {
     var fields = new Field[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 StringField(field_xdl, bbox.GetCrossesDateLine() ? "T" : "F", Field.Store.NO);
     return fields;
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:10,代码来源:BBoxStrategy.cs

示例3: 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);
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:67,代码来源:BBoxStrategy.cs

示例4: MakeDisjoint

        /// <summary>
        /// Constructs a query to retrieve documents that are disjoint to the input envelope.
        /// </summary>
        /// <param name="bbox"></param>
        /// <returns>the spatial query</returns>
        Query MakeDisjoint(Rectangle bbox)
        {
            // general case
            // docMinX > queryExtent.GetMaxX() OR docMaxX < queryExtent.GetMinX() OR docMinY > queryExtent.GetMaxY() OR docMaxY < queryExtent.GetMinY()

            // Y conditions
            // docMinY > queryExtent.GetMaxY() OR docMaxY < queryExtent.GetMinY()
            Query qMinY = NumericRangeQuery.NewDoubleRange(field_minY, precisionStep, bbox.GetMaxY(), null, false, false);
            Query qMaxY = NumericRangeQuery.NewDoubleRange(field_maxY, precisionStep, null, bbox.GetMinY(), false, false);
            Query yConditions = this.MakeQuery(new Query[] { qMinY, qMaxY }, Occur.SHOULD);

            // 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,
                // docMinX > queryExtent.GetMaxX() OR docMaxX < queryExtent.GetMinX()
                Query qMinX = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, bbox.GetMaxX(), null, false, false);
                Query qMaxX = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, null, bbox.GetMinX(), false, false);
                Query qMinMax = this.MakeQuery(new Query[] { qMinX, qMaxX }, Occur.SHOULD);
                Query qNonXDL = this.MakeXDL(false, qMinMax);

                // X Conditions for documents that cross the date line,
                // both the left and right portions of the document must be disjoint to the query
                // (docMinXLeft > queryExtent.GetMaxX() OR docMaxXLeft < queryExtent.GetMinX()) AND
                // (docMinXRight > queryExtent.GetMaxX() OR docMaxXRight < queryExtent.GetMinX())
                // where: docMaxXLeft = 180.0, docMinXRight = -180.0
                // (docMaxXLeft  < queryExtent.GetMinX()) equates to (180.0  < queryExtent.GetMinX()) and is ignored
                // (docMinXRight > queryExtent.GetMaxX()) equates to (-180.0 > queryExtent.GetMaxX()) and is ignored
                Query qMinXLeft = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, bbox.GetMaxX(), null, false, false);
                Query qMaxXRight = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, null, bbox.GetMinX(), false, false);
                Query qLeftRight = this.MakeQuery(new Query[] { qMinXLeft, qMaxXRight }, Occur.MUST);
                Query qXDL = this.MakeXDL(true, qLeftRight);

                // apply the non-XDL and XDL conditions
                xConditions = this.MakeQuery(new Query[] { qNonXDL, qXDL }, Occur.SHOULD);

                // queries that cross the date line
            }
            else
            {

                // X Conditions for documents that do not cross the date line,
                // the document must be disjoint to both the left and right query portions
                // (docMinX > queryExtent.GetMaxX()Left OR docMaxX < queryExtent.GetMinX()) AND (docMinX > queryExtent.GetMaxX() OR docMaxX < queryExtent.GetMinX()Left)
                // where: queryExtent.GetMaxX()Left = 180.0, queryExtent.GetMinX()Left = -180.0
                Query qMinXLeft = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, 180.0, null, false, false);
                Query qMaxXLeft = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, null, bbox.GetMinX(), false, false);
                Query qMinXRight = NumericRangeQuery.NewDoubleRange(field_minX, precisionStep, bbox.GetMaxX(), null, false, false);
                Query qMaxXRight = NumericRangeQuery.NewDoubleRange(field_maxX, precisionStep, null, -180.0, false, false);
                Query qLeft = this.MakeQuery(new Query[] { qMinXLeft, qMaxXLeft }, Occur.SHOULD);
                Query qRight = this.MakeQuery(new Query[] { qMinXRight, qMaxXRight }, Occur.SHOULD);
                Query qLeftRight = this.MakeQuery(new Query[] { qLeft, qRight }, Occur.MUST);

                // No need to search for documents that do not cross the date line

                xConditions = this.MakeXDL(false, qLeftRight);
            }

            // either X or Y conditions should occur
            return this.MakeQuery(new Query[] { xConditions, yConditions }, Occur.SHOULD);
        }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:70,代码来源:BBoxStrategy.cs

示例5: 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);
//.........这里部分代码省略.........
开发者ID:raol,项目名称:lucene.net,代码行数:101,代码来源:AreaSimilarity.cs

示例6: MakeWithin

 /// <summary>
 /// Constructs a query to retrieve documents that fully contain the input envelope.
 /// </summary>
 /// <param name="bbox"></param>
 private Query MakeWithin(Rectangle bbox)
 {
     var bq = new BooleanQuery();
     const Occur MUST = Occur.MUST;
     if (bbox.GetCrossesDateLine())
     {
         //use null as performance trick since no data will be beyond the world bounds
         bq.Add(RangeQuery(fieldNameX, null /*-180*/, bbox.GetMaxX()), Occur.SHOULD);
         bq.Add(RangeQuery(fieldNameX, bbox.GetMinX(), null /*+180*/), Occur.SHOULD);
         bq.MinimumNumberShouldMatch = 1; //must match at least one of the SHOULD
     }
     else
     {
         bq.Add(RangeQuery(fieldNameX, bbox.GetMinX(), bbox.GetMaxX()), MUST);
     }
     bq.Add(RangeQuery(fieldNameY, bbox.GetMinY(), bbox.GetMaxY()), MUST);
     return bq;
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:22,代码来源:PointVectorStrategy.cs

示例7: 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;
 }
开发者ID:Cefa68000,项目名称:lucenenet,代码行数:13,代码来源:PointVectorStrategy.cs

示例8: 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;
 }
开发者ID:raol,项目名称:lucene.net,代码行数:11,代码来源:BBoxStrategy.cs

示例9: RelateRectanglePhase2

        /// <summary>
        /// Called after bounding box is intersected.
        /// </summary>
        /// <param name="r"></param>
        /// <param name="bboxSect">INTERSECTS or CONTAINS from enclosingBox's intersection</param>
        /// <returns>DISJOINT, CONTAINS, or INTERSECTS (not WITHIN)</returns>
        protected override SpatialRelation RelateRectanglePhase2(Rectangle r, SpatialRelation bboxSect)
        {
            //Rectangle wraps around the world longitudinally creating a solid band; there are no corners to test intersection
            if (r.GetWidth() == 360)
            {
                return SpatialRelation.INTERSECTS;
            }

            if (inverseCircle != null)
            {
                return inverseCircle.Relate(r).Inverse();
            }

            //if a pole is wrapped, we have a separate algorithm
            if (enclosingBox.GetWidth() == 360)
            {
                return RelateRectangleCircleWrapsPole(r, ctx);
            }

            //This is an optimization path for when there are no dateline or pole issues.
            if (!enclosingBox.GetCrossesDateLine() && !r.GetCrossesDateLine())
            {
                return base.RelateRectanglePhase2(r, bboxSect);
            }

            //do quick check to see if all corners are within this circle for CONTAINS
            int cornersIntersect = NumCornersIntersect(r);
            if (cornersIntersect == 4)
            {
                //ensure r's x axis is within c's.  If it doesn't, r sneaks around the globe to touch the other side (intersect).
                SpatialRelation xIntersect = r.RelateXRange(enclosingBox.GetMinX(), enclosingBox.GetMaxX());
                if (xIntersect == SpatialRelation.WITHIN)
                    return SpatialRelation.CONTAINS;
                return SpatialRelation.INTERSECTS;
            }

            //INTERSECT or DISJOINT ?
            if (cornersIntersect > 0)
                return SpatialRelation.INTERSECTS;

            //Now we check if one of the axis of the circle intersect with r.  If so we have
            // intersection.

            /* x axis intersects  */
            if (r.RelateYRange(GetYAxis(), GetYAxis()).Intersects() // at y vertical
                  && r.RelateXRange(enclosingBox.GetMinX(), enclosingBox.GetMaxX()).Intersects())
                return SpatialRelation.INTERSECTS;

            /* y axis intersects */
            if (r.RelateXRange(GetXAxis(), GetXAxis()).Intersects())
            { // at x horizontal
                double yTop = GetCenter().GetY() + radiusDEG;
                Debug.Assert(yTop <= 90);
                double yBot = GetCenter().GetY() - radiusDEG;
                Debug.Assert(yBot >= -90);
                if (r.RelateYRange(yBot, yTop).Intersects())//back bottom
                    return SpatialRelation.INTERSECTS;
            }

            return SpatialRelation.DISJOINT;
        }
开发者ID:h0st1le,项目名称:Spatial4n,代码行数:67,代码来源:GeoCircle.cs


注:本文中的Rectangle.GetCrossesDateLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。