Beispiel #1
0
        public Rectangle GetEnvelope()
        {
            MPoint p1 = new MPoint(0, minX, minY);
            MPoint p2 = new MPoint(0, maxX, maxY);

            return(new Rectangle(p1, p2));
        }
Beispiel #2
0
        /// <summary>
        /// 读点要素
        /// </summary>
        /// <param name="points"></param>
        /// <param name="br"></param>
        public static void readPoint(List <MPoint> points, BinaryReader br)
        {
            uint   recordnumber;
            uint   contentlength;
            int    shapetype;
            MPoint Cmpoint;
            int    i = 0;

            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                recordnumber  = EndianConvert(br.ReadUInt32());
                contentlength = EndianConvert(br.ReadUInt32());
                shapetype     = br.ReadInt32();
                Cmpoint       = new MPoint((int)recordnumber, 0, 0);
                Cmpoint.X     = br.ReadDouble();
                Cmpoint.Y     = br.ReadDouble();
                points.Add(Cmpoint);
                if (shapetype == 18)
                {
                    br.ReadDouble();
                    br.ReadDouble();
                }
                else if (shapetype == 28)
                {
                    br.ReadDouble();
                }
                i++;
            }
        }
Beispiel #3
0
        public override List <int> QueryByLocat(Rectangle rect)
        {
            List <int> ids = new List <int>();

            for (int i = 0; i < ElementCount; i++)
            {
                for (int j = 0; j < elements[i].PolygonCount; j++)
                {
                    for (int k = 0; k < elements[i].List[j].PointCount; k++)
                    {
                        MPoint p = elements[i].List[j].List[k];
                        if (p.X >= rect.p1.X && p.X <= rect.p2.X && p.Y <= rect.p1.Y && p.Y >= rect.p2.Y)
                        {
                            ids.Add(elements[i].Id);
                            break;
                        }
                    }
                    if (ids.Count != 0 && ids.Last() == elements[i].Id)
                    {
                        break;
                    }
                }
            }
            return(ids);
        }
Beispiel #4
0
        public Point ToScrPoint(MPoint mapPoint)
        {
            double x = mapPoint.X / ratio - offsetX;
            double y = this.height - (mapPoint.Y / ratio + offsetY);

            return(new Point(x, y));
        }
Beispiel #5
0
 /// <summary>
 /// 在n之后插入点
 /// </summary>
 /// <param name="n"></param>
 /// <param name="point"></param>
 public void AddPoint(int n, MPoint point)
 {
     if (n < pointCount)
     {
         _list.Insert(n, point);
     }
 }
Beispiel #6
0
        public override void Add(object element)
        {
            MPoint point = (MPoint)element;

            point.Id = GenerateUniqueID();
            elements.Add(point);
            ElementCount++;
        }
Beispiel #7
0
        /// <summary>
        /// 读取多边形要素
        /// </summary>
        /// <param name="br"></param>
        public static void readPolygon(List <Polygon> polygonlayer, BinaryReader br)
        {
            uint recordnumber;
            uint contentlength;
            int  shapetype;
            int  pointcount;
            int  numparts;

            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                MPoint        Cpoint;                           //点
                List <MPoint> mpointlist = new List <MPoint>(); //点列
                PList         pointlist  = new PList(0, mpointlist);
                List <int>    parts      = new List <int>();
                recordnumber  = EndianConvert(br.ReadUInt32());
                contentlength = EndianConvert(br.ReadUInt32());
                shapetype     = br.ReadInt32();
                //for (int box = 0; box < 4; box++)
                //{
                //    br.ReadDouble();
                //}
                double minx = br.ReadDouble();
                double miny = br.ReadDouble();
                double maxx = br.ReadDouble();
                double maxy = br.ReadDouble();
                numparts   = br.ReadInt32();
                pointcount = br.ReadInt32();
                for (int i = 0; i < numparts; i++)
                {
                    parts.Add(br.ReadInt32());
                }
                parts.Add(pointcount);
                Polygon polygons = new Polygon((int)recordnumber);
                for (int i = 0; i < parts.Count - 1; i++)
                {
                    mpointlist = new List <MPoint>();
                    pointlist  = new PList(0, mpointlist);
                    for (int j = 0; j < parts[i + 1] - parts[i]; j++)
                    {
                        Cpoint   = new MPoint(0, 0, 0);
                        Cpoint.X = br.ReadDouble();
                        Cpoint.Y = br.ReadDouble();
                        pointlist.AddPoint(Cpoint);
                    }
                    List <PList> listplist = new List <PList>();
                    listplist.Add(pointlist);
                    polygons.AddPolygon(pointlist);
                }

                polygons.PointCount   = pointcount;
                polygons.PolygonCount = numparts;
                polygons.MinX         = minx;
                polygons.MinY         = miny;
                polygons.MaxX         = maxx;
                polygons.MaxY         = maxy;
                polygonlayer.Add(polygons);
            }
        }
Beispiel #8
0
 public void AddPoint(int i, int n, MPoint input)
 {
     if (i < lineCount)
     {
         if (n < _list[i].PointCount)
         {
             _list[i].AddPoint(n, input);
         }
     }
 }
Beispiel #9
0
 public void EditPoint(int i, int n, MPoint input)
 {
     if (i < lineCount)
     {
         if (n < _list[i].PointCount)
         {
             _list[i].EditPList(n, input);
         }
     }
 }
Beispiel #10
0
        /// <summary>
        /// 读取多点要素
        /// </summary>
        /// <param name="mpoint"></param>
        public static void readMPoint(List <MultiPoint> multipoints, BinaryReader br)
        {
            uint recordnumber;
            uint contentlength;
            int  shapetype;

            while (br.BaseStream.Position < br.BaseStream.Length)
            {
                int           pointcount;
                MPoint        Cpoint;
                List <MPoint> pointlist  = new List <MPoint>();
                MultiPoint    multipoint = new MultiPoint(0, pointlist);
                multipoint.Id = multipoints.Count + 1;
                recordnumber  = EndianConvert(br.ReadUInt32());
                contentlength = EndianConvert(br.ReadUInt32());
                shapetype     = br.ReadInt32();
                for (int box = 0; box < 4; box++)
                {
                    br.ReadDouble();
                }
                pointcount = br.ReadInt32();
                for (int i = 0; i < pointcount; i++)
                {
                    Cpoint   = new MPoint(0, 0, 0);
                    Cpoint.X = br.ReadDouble();
                    Cpoint.Y = br.ReadDouble();
                    pointlist.Add(Cpoint);
                    if (shapetype == 18)
                    {
                        br.ReadDouble();
                        br.ReadDouble();
                    }
                    else if (shapetype == 28)
                    {
                        br.ReadDouble();
                    }
                    multipoint.AddPoint(Cpoint);
                }
                multipoints.Add(multipoint);
            }
        }
Beispiel #11
0
 public void AddPoint(MPoint point)
 {
     _list.Add(point);
     if (point.X > maxX)
     {
         maxX = point.X;
     }
     if (point.X < minX)
     {
         minX = point.X;
     }
     if (point.Y > maxY)
     {
         maxY = point.Y;
     }
     if (point.Y < minY)
     {
         minY = point.Y;
     }
     pointCount++;
 }
Beispiel #12
0
 public void EditPoint(int n, MPoint point)
 {
     if (n < pointCount)
     {
         _list[n].X = point.X;
         _list[n].Y = point.Y;
     }
     if (point.X > maxX)
     {
         maxX = point.X;
     }
     if (point.X < minX)
     {
         minX = point.X;
     }
     if (point.Y > maxY)
     {
         maxY = point.Y;
     }
     if (point.Y < minY)
     {
         minY = point.Y;
     }
 }
Beispiel #13
0
 public void CopyPoint(MPoint inputPoint)
 {
     this.id = inputPoint.Id;
     this.x  = inputPoint.X;
     this.y  = inputPoint.Y;
 }
Beispiel #14
0
 public Rectangle(MPoint point1, MPoint point2)
 {
     p1 = point1;
     p2 = point2;
 }