Пример #1
0
        /// <summary>
        /// Creates a new <c>FindOverlapsQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="closedShape">The closed shape defining the search area.</param>
        /// <param name="spatialType">The type of objects to look for.</param>
        internal FindOverlapsQuery(ISpatialIndex index, IPosition[] closedShape, SpatialType spatialType)
        {
            m_ClosedShape = new ClosedShape(closedShape);
            m_Points      = new List <PointFeature>(100);
            m_Result      = new List <ISpatialObject>(100);

            // If we are looking for points or lines, locate points that overlap. Note that
            // if the user does not actually want points in the result, we still do a point
            // search, since it helps with the selection of lines.
            if ((spatialType & SpatialType.Point) != 0 || (spatialType & SpatialType.Line) != 0)
            {
                index.QueryWindow(m_ClosedShape.Extent, SpatialType.Point, OnPointFound);

                // Remember the points in the result if the caller wants them
                if ((spatialType & SpatialType.Point) != 0)
                {
                    m_Result.AddRange(m_Points.ToArray());
                }
            }

            // Find lines (this automatically includes lines connected to the points we just found)
            if ((spatialType & SpatialType.Line) != 0)
            {
                index.QueryWindow(m_ClosedShape.Extent, SpatialType.Line, OnLineFound);
            }

            // Find any overlapping text
            if ((spatialType & SpatialType.Text) != 0)
            {
                index.QueryWindow(m_ClosedShape.Extent, SpatialType.Text, OnTextFound);
            }

            m_Result.TrimExcess();
            m_Points = null;
        }
Пример #2
0
        /// <summary>
        /// Creates a new <c>FindOverlapsQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="closedShape">The closed shape defining the search area.</param>
        /// <param name="spatialType">The type of objects to look for.</param>
        internal FindOverlapsQuery(ISpatialIndex index, IPosition[] closedShape, SpatialType spatialType)
        {
            m_ClosedShape = new ClosedShape(closedShape);
            m_Points = new List<PointFeature>(100);
            m_Result = new List<ISpatialObject>(100);

            // If we are looking for points or lines, locate points that overlap. Note that
            // if the user does not actually want points in the result, we still do a point
            // search, since it helps with the selection of lines.
            if ((spatialType & SpatialType.Point)!=0 || (spatialType & SpatialType.Line)!=0)
            {
                index.QueryWindow(m_ClosedShape.Extent, SpatialType.Point, OnPointFound);

                // Remember the points in the result if the caller wants them
                if ((spatialType & SpatialType.Point)!=0)
                    m_Result.AddRange(m_Points.ToArray());
            }

            // Find lines (this automatically includes lines connected to the points we just found)
            if ((spatialType & SpatialType.Line)!=0)
                index.QueryWindow(m_ClosedShape.Extent, SpatialType.Line, OnLineFound);

            // Find any overlapping text
            if ((spatialType & SpatialType.Text)!=0)
                index.QueryWindow(m_ClosedShape.Extent, SpatialType.Text, OnTextFound);

            m_Result.TrimExcess();
            m_Points = null;
        }
        /// <summary>
        /// Creates a new <c>FindPointContainerQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="point">The position you want the container for</param>
        internal FindPointContainerQuery(ISpatialIndex index, IPointGeometry p)
        {
            m_Point = p;
            m_Result = null;
            IWindow w = new Window(p, p);
            index.QueryWindow(w, SpatialType.Polygon, OnQueryHit);

            // If we didn't get a result, but we skipped some candidates, check them now.
            if (m_Result==null && m_Candidates!=null)
            {
                // If NONE of the polygon's islands enclose the search position, that's
                // the result we want.

                foreach (Polygon cand in m_Candidates)
                {
                    Debug.Assert(cand.HasAnyIslands);

                    if (!cand.HasIslandEnclosing(m_Point))
                    {
                        m_Result = cand;
                        return;
                    }
                }
            }
        }
Пример #4
0
 /// <summary>
 /// Creates a new <c>FindPointQuery</c> (and executes it). The result of the query
 /// can then be obtained through the <c>Result</c> property.
 /// </summary>
 /// <param name="index">The spatial index to search</param>
 /// <param name="point">The position of interest</param>
 internal FindPointQuery(ISpatialIndex index, IPointGeometry p)
 {
     m_Point = p;
     m_Result = null;
     IWindow w = new Window(p, p);
     index.QueryWindow(w, SpatialType.Point, OnQueryHit);
 }
Пример #5
0
        /// <summary>
        /// Creates a new <c>FindPointContainerQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="point">The position you want the container for</param>
        internal FindPointContainerQuery(ISpatialIndex index, IPointGeometry p)
        {
            m_Point  = p;
            m_Result = null;
            IWindow w = new Window(p, p);

            index.QueryWindow(w, SpatialType.Polygon, OnQueryHit);

            // If we didn't get a result, but we skipped some candidates, check them now.
            if (m_Result == null && m_Candidates != null)
            {
                // If NONE of the polygon's islands enclose the search position, that's
                // the result we want.

                foreach (Polygon cand in m_Candidates)
                {
                    Debug.Assert(cand.HasAnyIslands);

                    if (!cand.HasIslandEnclosing(m_Point))
                    {
                        m_Result = cand;
                        return;
                    }
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Creates a new <c>FindClosestQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="p">The search position.</param>
        /// <param name="radius">The search tolerance (expected to be greater than zero).</param>
        /// <param name="types">The type of objects to look for.</param>
        internal FindClosestQuery(ISpatialIndex index, IPosition p, ILength radius, SpatialType types)
        {
            if (types == 0)
            {
                throw new ArgumentNullException("Spatial type(s) not specified");
            }

            // If the user hasn't been specific, ensure we don't search for polygons!
            SpatialType useTypes = (types == SpatialType.All ? SpatialType.Feature : types);

            Debug.Assert((useTypes & SpatialType.Polygon) == 0);

            // It's important to round off to the nearest micron. Otherwise you might not
            // get the desired results in situations where the search radius is zero.
            m_Position = PositionGeometry.Create(p);

            m_Radius   = radius;
            m_Types    = types;
            m_Result   = null;
            m_Distance = m_Radius.Meters;

            // The query will actually involve a square window, not a circle.
            IWindow x = new Window(m_Position, radius.Meters * 2.0);

            index.QueryWindow(x, useTypes, OnQueryHit);
        }
Пример #7
0
        /// <summary>
        /// Creates a new <c>FindPointQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="point">The position of interest</param>
        internal FindPointQuery(ISpatialIndex index, IPointGeometry p)
        {
            m_Point  = p;
            m_Result = null;
            IWindow w = new Window(p, p);

            index.QueryWindow(w, SpatialType.Point, OnQueryHit);
        }
        /// <summary>
        /// Creates a new <c>FindPolygonLabelQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="polygon">The polygon that needs to be associated with a label</param>
        internal FindPolygonLabelQuery(ISpatialIndex index, Polygon polygon)
        {
            m_Polygon = polygon;
            m_Result = null;

            if (!polygon.HasAnyIslands)
                index.QueryWindow(m_Polygon.Extent, SpatialType.Text, OnTextFound);
        }
        /// <summary>
        /// Creates a new <c>FindPointsOnLineQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="line">The line of interest.</param>
        /// <param name="wantEnds">Specify true if you want points coincident with the line ends.</param>
        /// <param name="tol">The search tolerance (expected to be greater than zero).</param>
        internal FindPointsOnLineQuery(ISpatialIndex index, LineGeometry line, bool wantEnds, ILength tol)
        {
            m_Line = line;
            m_Tolerance = tol.Meters;
            m_Result = new List<PointFeature>();

            IWindow w = m_Line.Extent;
            index.QueryWindow(w, SpatialType.Point, OnQueryHit);
        }
Пример #10
0
        /// <summary>
        /// Creates a new <c>FindPolygonLabelQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="polygon">The polygon that needs to be associated with a label</param>
        internal FindPolygonLabelQuery(ISpatialIndex index, Polygon polygon)
        {
            m_Polygon = polygon;
            m_Result  = null;

            if (!polygon.HasAnyIslands)
            {
                index.QueryWindow(m_Polygon.Extent, SpatialType.Text, OnTextFound);
            }
        }
Пример #11
0
        /// <summary>
        /// Creates a new <c>FindPointsOnLineQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="line">The line of interest.</param>
        /// <param name="wantEnds">Specify true if you want points coincident with the line ends.</param>
        /// <param name="tol">The search tolerance (expected to be greater than zero).</param>
        internal FindPointsOnLineQuery(ISpatialIndex index, LineGeometry line, bool wantEnds, ILength tol)
        {
            m_Line      = line;
            m_Tolerance = tol.Meters;
            m_Result    = new List <PointFeature>();

            IWindow w = m_Line.Extent;

            index.QueryWindow(w, SpatialType.Point, OnQueryHit);
        }
Пример #12
0
 /// <summary>
 /// Creates a new <c>DrawQuery</c> that refers to the specified feature type(s),
 /// drawing the results of the spatial query to the specified display.
 /// </summary>
 /// <param name="index">The index to query</param>
 /// <param name="display">The display to draw to</param>
 /// <param name="style">The drawing style</param>
 /// <param name="types">The type(s) of spatial feature to draw</param>
 public DrawQuery(ISpatialIndex index, ISpatialDisplay display, IDrawStyle style, SpatialType types)
 {
     m_Display = display;
     m_Style = style;
     m_DoPaint = false;
     Timer t = new Timer(500);
     t.Elapsed += new ElapsedEventHandler(Timer_Elapsed);
     t.Start();
     index.QueryWindow(m_Display.Extent, types, OnQueryHit);
     t.Close();
     display.PaintNow();
 }
Пример #13
0
        /// <summary>
        /// Detects intersections
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        private void FindIntersections(ISpatialIndex index)
        {
            // Get the window of the candidate object and add on a 2mm buffer (on the ground). This is
            // intended to help cover the fact that some circular arcs may be inaccurate by that much.
            Window  searchwin = new Window(m_Geom.Extent);
            ILength dim       = new Length(0.002);

            searchwin.Expand(dim);

            index.QueryWindow(searchwin, SpatialType.Line, OnQueryHit);
            m_Result.TrimExcess();
        }
Пример #14
0
        /// <summary>
        /// Creates a new <c>DrawQuery</c> that refers to the specified feature type(s),
        /// drawing the results of the spatial query to the specified display.
        /// </summary>
        /// <param name="index">The index to query</param>
        /// <param name="display">The display to draw to</param>
        /// <param name="style">The drawing style</param>
        /// <param name="types">The type(s) of spatial feature to draw</param>
        public DrawQuery(ISpatialIndex index, ISpatialDisplay display, IDrawStyle style, SpatialType types)
        {
            m_Display = display;
            m_Style   = style;
            m_DoPaint = false;
            Timer t = new Timer(500);

            t.Elapsed += new ElapsedEventHandler(Timer_Elapsed);
            t.Start();
            index.QueryWindow(m_Display.Extent, types, OnQueryHit);
            t.Close();
            display.PaintNow();
        }
Пример #15
0
        /// <summary>
        /// Creates a new <c>FileCheckQuery</c> and executes it.
        /// </summary>
        /// <param name="model">The model to check</param>
        /// <param name="checks">Flag bits indicating the checks of interest</param>
        /// <param name="onCheckItem">Delegate to call whenever a further item is checked (null if no
        /// callback is required)</param>
        internal FileCheckQuery(CadastralMapModel model, CheckType checks, OnCheckItem onCheckItem)
        {
            if (model == null)
            {
                throw new ArgumentNullException();
            }

            m_OnCheckItem = onCheckItem;
            m_Options     = checks;
            m_NumCheck    = 0;
            m_Result      = new List <CheckItem>(100);

            ISpatialIndex index = model.Index;

            index.QueryWindow(null, SpatialType.Line, CheckLine);
            index.QueryWindow(null, SpatialType.Text, CheckText);
            index.QueryWindow(null, SpatialType.Polygon, CheckPolygon);

            // Do any post-processing.
            PostCheck(m_Result, true);

            m_Result.TrimExcess();
        }
Пример #16
0
        /// <summary>
        /// Creates a new <c>FindIslandContainerQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="island">The island you want the container for</param>
        internal FindIslandContainerQuery(ISpatialIndex index, Island island)
        {
            m_Island = island;
            m_Result = null;

            // Get the most easterly point in the island.
            IPosition ep = m_Island.GetEastPoint();

            // Shift the east point ONE MICRON further to the east, to ensure
            // we don't pick up the interior of the island!
            PointGeometry eg = PointGeometry.Create(ep);

            m_EastPoint = new PointGeometry(eg.Easting.Microns + 1, eg.Northing.Microns);
            IWindow w = new Window(m_EastPoint, m_EastPoint);

            index.QueryWindow(w, SpatialType.Polygon, OnQueryHit);
        }
        /// <summary>
        /// Detects intersections
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        private void FindIntersections(ISpatialIndex index)
        {
            // Get the window of the candidate object and add on a 2mm buffer (on the ground). This is
            // intended to help cover the fact that some circular arcs may be inaccurate by that much.
            Window searchwin = new Window(m_Geom.Extent);
            ILength dim = new Length(0.002);
            searchwin.Expand(dim);

            index.QueryWindow(searchwin, SpatialType.Line, OnQueryHit);
            m_Result.TrimExcess();
        }
Пример #18
0
 /// <summary>
 /// Creates a new <c>FindPointByIdQuery</c> (and executes it). The result of the query
 /// can then be obtained through the <c>Result</c> property.
 /// </summary>
 /// <param name="index">The spatial index to search</param>
 /// <param name="key">The ID of interest.</param>
 internal FindPointByIdQuery(ISpatialIndex index, string key)
 {
     m_Key = key;
     m_Result = null;
     index.QueryWindow(null, SpatialType.Point, OnQueryHit);
 }
Пример #19
0
        /// <summary>
        /// Creates a new <c>FindClosestQuery</c> (and executes it). The result of the query
        /// can then be obtained through the <c>Result</c> property.
        /// </summary>
        /// <param name="index">The spatial index to search</param>
        /// <param name="p">The search position.</param>
        /// <param name="radius">The search tolerance (expected to be greater than zero).</param>
        /// <param name="types">The type of objects to look for.</param>
        internal FindClosestQuery(ISpatialIndex index, IPosition p, ILength radius, SpatialType types)
        {
            if (types==0)
                throw new ArgumentNullException("Spatial type(s) not specified");

            // If the user hasn't been specific, ensure we don't search for polygons!
            SpatialType useTypes = (types==SpatialType.All ? SpatialType.Feature : types);
            Debug.Assert((useTypes & SpatialType.Polygon)==0);

            // It's important to round off to the nearest micron. Otherwise you might not
            // get the desired results in situations where the search radius is zero.
            m_Position = PositionGeometry.Create(p);

            m_Radius = radius;
            m_Types = types;
            m_Result = null;
            m_Distance = m_Radius.Meters;

            // The query will actually involve a square window, not a circle.
            IWindow x = new Window(m_Position, radius.Meters * 2.0);
            index.QueryWindow(x, useTypes, OnQueryHit);
        }
Пример #20
0
 /// <summary>
 /// Creates a new <c>FindPointByIdQuery</c> (and executes it). The result of the query
 /// can then be obtained through the <c>Result</c> property.
 /// </summary>
 /// <param name="index">The spatial index to search</param>
 /// <param name="key">The ID of interest.</param>
 internal FindPointByIdQuery(ISpatialIndex index, string key)
 {
     m_Key    = key;
     m_Result = null;
     index.QueryWindow(null, SpatialType.Point, OnQueryHit);
 }