Exemple #1
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="envelope"></param>
 /// <returns></returns>
 public static IEnvelope GetEnvelopeExternal(IEnvelope envelope)
 {
     // get envelose in external coordinates
     ICoordinate min = new Coordinate(envelope.MinX, envelope.MinY);
     ICoordinate max = new Coordinate(envelope.MaxX, envelope.MaxY);
     IEnvelope bounds = new Envelope(min.X, max.X, min.Y, max.Y);
     return bounds;
 }
Exemple #2
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="querySeg"></param>
        /// <returns></returns>
        public IList Query(LineSegment querySeg)
        {
            Envelope env = new Envelope(querySeg.P0, querySeg.P1);

            LineSegmentVisitor visitor = new LineSegmentVisitor(querySeg);
            index.Query(env, visitor);
            IList itemsFound = visitor.Items;

            return itemsFound;
        }
Exemple #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        /// <param name="addEnv"></param>
        /// <returns></returns>
        public static Node CreateExpanded(Node node, IEnvelope addEnv)
        {
            IEnvelope expandEnv = new Envelope(addEnv);
            if (node != null)
                expandEnv.ExpandToInclude(node.env);

            Node largerNode = CreateNode(expandEnv);
            if (node != null)
                largerNode.InsertNode(node);
            return largerNode;
        }
        /// <summary>
        /// Transforms a <see cref="Envelope"/>.
        /// </summary>
        /// <param name="box">BoundingBox to transform</param>
        /// <param name="transform">Math Transform</param>
        /// <returns>Transformed object</returns>
        public static IEnvelope TransformBox(IEnvelope box, IMathTransform transform)
        {
            if (box == null)
                return null;
            double[][] corners = new double[4][];
            corners[0] = transform.Transform(ToLightStruct(box.MinX, box.MinY)); //LL
            corners[1] = transform.Transform(ToLightStruct(box.MaxX, box.MaxY)); //UR
            corners[2] = transform.Transform(ToLightStruct(box.MinX, box.MaxY)); //UL
            corners[3] = transform.Transform(ToLightStruct(box.MaxX, box.MinY)); //LR

            IEnvelope result = new Envelope();
            foreach (double[] p in corners)
                result.ExpandToInclude(p[0], p[1]);
            return result;
        }
		public IEnumerable<IFeature> GetFeatures(IGeometry geom, string filter, double scale)
		{
			if (geom is IPoint)
			{
				IPoint p = (IPoint)geom;
				Envelope e = new Envelope(p.X, p.X, p.Y, p.Y);
				LinkedList<IFeature> ret = new LinkedList<IFeature>();
				m_tree.Query(e, new FeatureLinkedListVisitor(ret));
				return ret;
			}
			else
			{
				LinkedList<IFeature> ret = new LinkedList<IFeature>();
				foreach (Feature f in m_layer.Features)
				{
					//linear cull
					if (geom.Intersects(f.Geometry)) ret.AddLast(f);
				}
				return ret;
			}
		}
Exemple #6
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        public bool IsInside(ICoordinate pt)
        {
            crossings = 0;

            // test all segments intersected by ray from pt in positive x direction
            IEnvelope rayEnv = new Envelope(Double.NegativeInfinity, Double.PositiveInfinity, pt.Y, pt.Y);
            interval.Min = pt.Y;
            interval.Max = pt.Y;
            IList segs = tree.Query(interval);

            MCSelecter mcSelecter = new MCSelecter(this, pt);
            for (IEnumerator i = segs.GetEnumerator(); i.MoveNext(); )
            {
                MonotoneChain mc = (MonotoneChain) i.Current;
                TestMonotoneChain(rayEnv, mcSelecter, mc);
            }

            /*
            *  p is inside if number of crossings is odd.
            */
            if ((crossings % 2) == 1)
                return true;
            return false;
        }
Exemple #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 protected override object ComputeBounds()
 {
     IEnvelope bounds = null;
     for (IEnumerator i = ChildBoundables.GetEnumerator(); i.MoveNext(); )
     {
         IBoundable childBoundable = (IBoundable) i.Current;
         if (bounds == null)
              bounds =  new Envelope((IEnvelope) childBoundable.Bounds);
         else bounds.ExpandToInclude((IEnvelope) childBoundable.Bounds);
     }
     return bounds;
 }
Exemple #8
0
 /// <summary>
 /// Returns a "safe" envelope that is guaranteed to contain the hot pixel.
 /// </summary>
 /// <returns></returns>
 public IEnvelope GetSafeEnvelope()
 {
     if (safeEnv == null)
     {
         double safeTolerance = 0.75 / scaleFactor;
         safeEnv = new Envelope(originalPt.X - safeTolerance, originalPt.X + safeTolerance,
                                originalPt.Y - safeTolerance, originalPt.Y + safeTolerance);
     }
     return safeEnv;
 }
Exemple #9
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        private Node CreateSubnode(int index)
        {
            // create a new subquad in the appropriate quadrant
            double minx = 0.0;
            double maxx = 0.0;
            double miny = 0.0;
            double maxy = 0.0;

            switch (index)
            {
                case 0:
                    minx = env.MinX;
                    maxx = centre.X;
                    miny = env.MinY;
                    maxy = centre.Y;
                    break;

                case 1:
                    minx = centre.X;
                    maxx = env.MaxX;
                    miny = env.MinY;
                    maxy = centre.Y;
                    break;

                case 2:
                    minx = env.MinX;
                    maxx = centre.X;
                    miny = centre.Y;
                    maxy = env.MaxY;
                    break;

                case 3:
                    minx = centre.X;
                    maxx = env.MaxX;
                    miny = centre.Y;
                    maxy = env.MaxY;
                    break;

                default:
                    break;
            }
            IEnvelope sqEnv = new Envelope(minx, maxx, miny, maxy);
            Node node = new Node(sqEnv, level - 1);
            return node;
        }
 /// <summary> 
 /// Test whether a point lies in the envelopes of both input segments.
 /// A correctly computed intersection point should return <c>true</c>
 /// for this test.
 /// Since this test is for debugging purposes only, no attempt is
 /// made to optimize the envelope test.
 /// </summary>
 /// <param name="intPt"></param>
 /// <returns><c>true</c> if the input point lies within both input segment envelopes.</returns>
 private bool IsInSegmentEnvelopes(ICoordinate intPt)
 {
     IEnvelope env0 = new Envelope(inputLines[0, 0], inputLines[0, 1]);
     IEnvelope env1 = new Envelope(inputLines[1, 0], inputLines[1, 1]);
     return env0.Contains(intPt) && env1.Contains(intPt);
 }
 /// <summary>
 /// 
 /// </summary>
 /// <returns></returns>
 protected override IEnvelope ComputeEnvelopeInternal()
 {
     IEnvelope envelope = new Envelope();
     for (int i = 0; i < geometries.Length; i++)
         envelope.ExpandToInclude(geometries[i].EnvelopeInternal);
     return envelope;
 }