示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CadastralFile"/> class.
        /// </summary>
        /// <param name="name">The name of the xml file</param>
        /// <param name="data">The data that was deserialized</param>
        internal CadastralFile(string name, GeoSurveyPacketData data)
        {
            m_Name   = Path.GetFileName(name);
            m_Data   = data;
            m_Extent = new Window(m_Data.points);
            m_Points = new Dictionary <int, IPoint>(m_Data.points.Length);

            IEditSpatialIndex index = new SpatialIndex();

            foreach (Point p in m_Data.points)
            {
                index.Add(p);
                m_Points.Add(p.pointNo, p);
            }

            foreach (Plan plan in m_Data.plans)
            {
                foreach (Parcel parcel in plan.parcels)
                {
                    // Relate the parcel to it's plan
                    parcel.Plan = plan;

                    foreach (Line line in parcel.lines)
                    {
                        Debug.Assert(line.From == null && line.To == null);

                        // Relate the line to the parcel that it is part of
                        line.Parcel = parcel;

                        line.From = m_Points[line.fromPoint];
                        line.To   = m_Points[line.toPoint];

                        if (line.centerPointSpecified)
                        {
                            line.Center = m_Points[line.centerPoint];
                        }

                        index.Add(line);
                    }

                    /*
                     * foreach (LinePoint lp in parcel.linePoints)
                     * {
                     *  // Relate to the parcel it's referenced by
                     *
                     *  // Relate the associated point
                     * }
                     */
                }
            }

            m_Index = index;
        }
示例#2
0
        public ShapeFile(string fileName)
        {
            if (String.IsNullOrEmpty(fileName))
            {
                throw new ArgumentNullException();
            }

            m_MapName = fileName;
            IEditSpatialIndex index = new SpatialIndex();

            ShapefileDataReader sfdr = Shapefile.CreateDataReader(fileName, new GeometryFactory());
            ShapefileHeader     hdr  = sfdr.ShapeHeader;
            Envelope            ex   = hdr.Bounds;

            m_Extent = new Window(ex.MinX, ex.MinY, ex.MaxX, ex.MaxY);

            foreach (object o in sfdr)
            {
                // You get back an instance of GisSharpBlog.NetTopologySuite.IO.RowStructure, but
                // that's internal, so cast to the interface it implements (we'll attach this to
                // the geometry we wrap).
                //ICustomTypeDescriptor row = (ICustomTypeDescriptor)o;
                AdhocPropertyList row  = CreatePropertyList(sfdr);
                NTS.Geometry      geom = sfdr.Geometry;
                geom.UserData = row;

                List <NTS.Geometry> geoms = GetBasicGeometries(geom);
                foreach (NTS.Geometry g in geoms)
                {
                    g.UserData = row;
                    if (g is NTS.Point)
                    {
                        index.Add(new PointWrapper((NTS.Point)g));
                    }
                    else
                    {
                        index.Add(new GeometryWrapper(g));
                    }
                }
            }

            // Don't permit any further additions
            m_Index = index;
        }
示例#3
0
        internal override Feature[] LoadFeatures(string fileName, Operation creator)
        {
            // First load all point features
            Trace.Write("Loading points");
            List <PointFeature> points = LoadPoints(fileName, creator);

            m_Result.AddRange(points.ToArray());

            // Create a spatial index for the points
            foreach (PointFeature p in points)
            {
                m_Index.Add(p);
            }

            // Load circular arcs
            Trace.Write("Loading circular arcs");
            List <ArcFeature> arcs = LoadArcs(fileName, creator);

            m_Result.AddRange(arcs.ToArray());

            // Now load everything except points
            Trace.Write("Loading data");
            Ntx.File file = new Ntx.File();

            try
            {
                file.Open(fileName);

                // Define line end point tolerance
                ILength tol = GetPointMatchTolerance(file);

                while (file.GetMore())
                {
                    Feature f = null;

                    if (file.DataType == (int)Ntx.DataType.Line && !file.Line.IsCurve)
                    {
                        f = ImportLine(tol, file.Line, creator);
                    }
                    else if (file.DataType == (int)Ntx.DataType.Name)
                    {
                        f = ImportName(file.Name, creator);
                    }

                    if (f != null)
                    {
                        m_Result.Add(f);
                    }
                }

                // Mark all features as moved, so they will be intersected against the map model
                //SetMoved(m_Result);

                return(m_Result.ToArray());
            }

            finally
            {
                file.Close();
            }
        }
示例#4
0
 /// <summary>
 /// Includes a circle in this index.
 /// </summary>
 /// <param name="c">The circle to add to the index</param>
 internal void AddCircle(Circle c)
 {
     Debug.Assert(c.SpatialType == SpatialType.Line);
     m_ExtraData.Add(c);
 }
示例#5
0
文件: Scene.cs 项目: git-thinh/limada
 public virtual void AddBounds(IVisual visual)
 {
     SpatialIndex.Add(visual);
 }