Example #1
0
 public void Combine(MapExtent extent)
 {
     if (extent == MapExtent.None)
     {
         return;
     }
     if (this == MapExtent.None)
     {
         this.left   = extent.left;
         this.right  = extent.right;
         this.top    = extent.top;
         this.bottom = extent.bottom;
     }
     else
     {
         if (this.left > extent.left)
         {
             this.left = extent.left;
         }
         if (this.right < extent.right)
         {
             this.right = extent.right;
         }
         if (this.top < extent.top)
         {
             this.top = extent.top;
         }
         if (this.bottom > extent.bottom)
         {
             this.bottom = extent.bottom;
         }
     }
 }
Example #2
0
        internal bool DoParserIdAndExtent(XmlNode dataNode, out int id, out List <MapPoint> points)
        {
            string strextent;

            points = new List <MapPoint>();
            if (DoParserIdAndExtent(dataNode, out id, out strextent))
            {
                string[] strs = strextent.Split(';');
                foreach (string item in strs)
                {
                    if (String.IsNullOrWhiteSpace(item))
                    {
                        continue;
                    }
                    MapExtent?me = MapExtent.FromString(item);
                    if (me == null)
                    {
                        continue;
                    }
                    MapPoint mp = ((MapExtent)me).LeftTop;
                    points.Add(mp);
                }
            }
            return(points.Count != 0);
        }
Example #3
0
        public override bool Equals(object obj)
        {
            if (!(obj is MapExtent))
            {
                return(false);
            }
            MapExtent extent = (MapExtent)obj;

            return(extent == this);
        }
Example #4
0
 public bool IsIntersectWith(MapExtent extent)
 {
     if (Math.Abs(this.Center.x - extent.Center.x) <= this.Width / 2 + extent.Width / 2 && Math.Abs(this.Center.y - extent.Center.y) <= this.Height / 2 + extent.Height / 2)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Example #5
0
        public override List <Datarow> Query(string tableName, MapExtent extent)
        {
            string      lsdtfile = System.IO.Path.Combine(_datasourcePath, tableName + ".lsdt");
            XmlDocument document = new XmlDocument();

            document.Load(lsdtfile);
            XmlNodeList nodelist = document.SelectNodes("datas/data");

            if (nodelist != null && nodelist.Count > 0)
            {
                return(DoQueryFileTableData(nodelist, tableName, extent));
            }
            return(new List <Datarow>());
        }
Example #6
0
        public static MapExtent?FromPoints(List <MapPoint> points)
        {
            if (points == null || points.Count == 0)
            {
                return(null);
            }
            MapExtent me = FromPoint(points[0]);

            for (int i = 1; i < points.Count; i++)
            {
                me.Combine(points[i]);
            }
            return(me);
        }
Example #7
0
        public override MapExtent QueryExtent(string tableName)
        {
            List <Datarow> rows = Query(tableName, MapExtent.Max);

            if (rows.Count > 0)
            {
                MapExtent extent = rows[0].Extent;
                for (int i = 1; i < rows.Count; i++)
                {
                    extent.Combine(rows[i].Extent);
                }
                return(extent);
            }
            return(MapExtent.None);
        }
Example #8
0
        internal bool DoParserIdAndExtent(XmlNode dataNode, out int id, out MapExtent extent)
        {
            string strextent;

            extent = MapExtent.Empty;
            if (DoParserIdAndExtent(dataNode, out id, out strextent))
            {
                MapExtent?me = MapExtent.FromString(strextent);
                if (me == null)
                {
                    return(false);
                }
                extent = (MapExtent)me;
                return(true);
            }
            return(false);
        }
Example #9
0
        internal List <Datarow> DoParserLineData(XmlNodeList nodelist, string tableName, MapExtent extent)
        {
            List <Datarow> rows = new List <Datarow>();

            foreach (XmlNode node in nodelist)
            {
                int             id;
                List <MapPoint> points;
                if (!DoParserIdAndExtent(node, out id, out points))
                {
                    continue;
                }
                MapLine mapLine = new MapLine();
                mapLine.Points = points;
                if (mapLine.Extent.IsIntersectWith(extent))
                {
                    Datarow datarow = new Datarow(mapLine, mapLine.Extent);
                    rows.Add(datarow);
                }
            }
            return(rows);
        }
Example #10
0
        internal List <Datarow> DoParserRasterData(XmlNodeList nodelist, string tableName, MapExtent extent)
        {
            List <Datarow> rows   = new List <Datarow>();
            string         ddPath = System.IO.Path.Combine(_datasourcePath, tableName + ".lsdd");

            foreach (XmlNode node in nodelist)
            {
                int       id;
                MapExtent textent;
                if (!DoParserIdAndExtent(node, out id, out textent))
                {
                    continue;
                }
                if (textent.IsIntersectWith(extent))
                {
                    string  fileddPath = ddPath + id;
                    Datarow datarow    = new Datarow(fileddPath, textent);
                    rows.Add(datarow);
                }
            }
            return(rows);
        }
Example #11
0
        internal List <Datarow> DoParserPointData(XmlNodeList nodelist, string tableName, MapExtent extent)
        {
            List <Datarow> rows = new List <Datarow>();

            foreach (XmlNode node in nodelist)
            {
                int       id;
                MapExtent textent;
                if (!DoParserIdAndExtent(node, out id, out textent))
                {
                    continue;
                }
                if (textent.IsIntersectWith(extent))
                {
                    Datarow datarow = new Datarow(textent.LeftTop, textent);
                    rows.Add(datarow);
                }
            }
            return(rows);
        }
Example #12
0
 public Datarow(object data, MapExtent extent)
 {
     _data   = data;
     _extent = extent;
 }
Example #13
0
 static MapExtent()
 {
     Empty = new MapExtent(0, 0, 0, 0);
     Max   = new MapExtent(double.MinValue, double.MaxValue, double.MaxValue, double.MinValue);
     None  = new MapExtent(double.MinValue, double.MinValue, double.MinValue, double.MinValue);
 }
Example #14
0
        public void Combine(MapPoint point)
        {
            MapExtent ex = MapExtent.FromPoint(point);

            Combine(ex);
        }
Example #15
0
        internal List <Datarow> DoQueryFileTableData(XmlNodeList nodelist, string tableName, MapExtent extent)
        {
            Datatable table = GetDatatable(tableName);

            if (table != null)
            {
                switch (table.TableType)
                {
                case DatatableType.Null:
                    break;

                case DatatableType.Point:
                    return(DoParserPointData(nodelist, tableName, extent));

                case DatatableType.Raster:
                    return(DoParserRasterData(nodelist, tableName, extent));

                case DatatableType.Line:
                    return(DoParserLineData(nodelist, tableName, extent));

                case DatatableType.Polygon:
                    return(DoParserPolygonData(nodelist, tableName, extent));

                default:
                    break;
                }
            }
            return(new List <Datarow>());
        }
Example #16
0
 public abstract List <Datarow> Query(string tableName, MapExtent extent);
Example #17
0
 public List <Datarow> Query(MapExtent extent)
 {
     return(_datasource.Query(_tableName, extent));
 }