protected int InsertExtent(string layername, MG_MapExtent mapExt)
        {// INSERT INTO ext(layername, minx, miny, maxx, maxy) VALUES('links', 1.1, 1.1, 2.2, 2.2);
            string strSQL = "INSERT INTO ext(layername, minx, miny, maxx, maxy) VALUES('{0}', {1}, {2}, {3}, {4});";

            strSQL = String.Format(strSQL, layername.ToLower(), mapExt.MinX, mapExt.MinY, mapExt.MaxX, mapExt.MaxY);
            return(this.Run(strSQL));
        }
        protected MG_MapExtent GetExtent(string layername)
        {// SELECT minx, miny, maxx, maxy FROM ext WHERE layername = 'links';
            string strSQL = "SELECT minx, miny, maxx, maxy FROM ext WHERE layername = '{0}';";

            strSQL = String.Format(strSQL, layername.ToLower());
            NpgsqlDataReader reader = this.Select(strSQL);

            if (reader != null)
            {
                if (reader.HasRows)
                {
                    MG_MapExtent mapExt = new MG_MapExtent();
                    int          fc     = reader.FieldCount; // 4
                    while (reader.Read())
                    {                                        // xmin ymin xmax ymax
                        double xmin = Double.Parse(reader["minx"].ToString());
                        double ymin = Double.Parse(reader["miny"].ToString());
                        double xmax = Double.Parse(reader["maxx"].ToString());
                        double ymax = Double.Parse(reader["maxy"].ToString());
                        mapExt.SetExtent(xmin, ymin, xmax, ymax);
                    }
                    reader.Close();
                    reader.Dispose();
                    return(mapExt);
                }
            }
            return(null);
        }
Exemple #3
0
 public MG_MapView(Rectangle rect, MG_MapExtent me)
 {
     this.Scale = 1.0;
     this.CurrentWindow = rect;
     this.CurrentExtent = me;
     this.Calculate();
 }
Exemple #4
0
        private string LayerPath; // null or not

        #endregion Fields

        #region Constructors

        public MG_Layer()
        {
            layerCount++;
            this.LayerName = "Layer_" + layerCount.ToString();
            this.LayerPath = null;
            this.IsVisible = true;
            this.FeatureSet = new MG_FeatureSet();
            this.FieldSet = new MG_FieldSet(this.LayerName);
            this.Extent = new MG_MapExtent();
            this.Type = MG_GeometryType.NONE;
        }
Exemple #5
0
 public MG_Map()
 {
     mapCount++;
     this.MapName = "Map_" + mapCount.ToString();
     this.MapPath = null;
     this.MapExtent = new MG_MapExtent();
     this.LayerSet = new MG_LayerSet();
     this.ZoomHistory = new MG_ZoomHistory();
     this.CurrentZoomIndex = -1;
     this.MapView = null;
 }
Exemple #6
0
        public void AddLayer(MG_Layer layer)
        {
            this.LayerSet.Add(layer);

            // calculate extent dynamic
            if (this.MapExtent.Empty())
            {
                this.MapExtent = layer.Extent;
            }
            else
            {
                this.MapExtent = calculateExtent(this.MapExtent, layer.Extent);
            }
        }
Exemple #7
0
 private MG_MapExtent calculateExtent(MG_MapExtent e1, MG_MapExtent e2)
 {
     MG_MapExtent ext = new MG_MapExtent();
     ext.MinX = min(e1.MinX, e2.MinX);
     ext.MinY = min(e1.MinY, e2.MinY);
     ext.MaxX = max(e1.MaxX, e2.MaxX);
     ext.MaxY = max(e1.MaxY, e2.MaxY);
     return ext;
 }
Exemple #8
0
 public void SetMapExtent(MG_MapExtent mapExtent)
 {
     // zoom to layer : mapextent = layerextent
     this.MapExtent = mapExtent;
 }
Exemple #9
0
        public void RemoveLayer(int i)
        {
            if (i < 0 || i >= this.GetLayerCount())
                return;
            this.LayerSet.RemoveAt(i);

            // calculate extent dynamic(except i layer)
            this.MapExtent = new MG_MapExtent();// Empty extent
            for (int j = 0; j < this.GetLayerCount(); j++)
            {
                if (j != i)
                {
                    if (this.MapExtent.Empty())
                    {
                        this.MapExtent = this.LayerSet.GetAt(j).Extent;
                    }
                    else
                    {
                        this.MapExtent = calculateExtent(this.MapExtent, this.LayerSet.GetAt(j).Extent);
                    }
                }
            }
        }
Exemple #10
0
 public void InitMapView(Rectangle rect, MG_MapExtent me)
 {
     // layerCount>0 => MapExtent!=Empty => MapView!=null
     if (!this.MapExtent.Empty())
     {
         this.MapView = new MG_MapView(rect, me);
     }
 }
        protected MG_MapExtent GetExtent(string layername)
        {
            // SELECT minx, miny, maxx, maxy FROM ext WHERE layername = 'links';
            string strSQL = "SELECT minx, miny, maxx, maxy FROM ext WHERE layername = '{0}';";
            strSQL = String.Format(strSQL, layername.ToLower());
            NpgsqlDataReader reader = this.Select(strSQL);
            if (reader != null)
            {
                if (reader.HasRows)
                {
                    MG_MapExtent mapExt = new MG_MapExtent();
                    int fc = reader.FieldCount; // 4
                    while (reader.Read())
                    {// xmin ymin xmax ymax

                            double xmin = Double.Parse(reader["minx"].ToString());
                            double ymin = Double.Parse(reader["miny"].ToString());
                            double xmax = Double.Parse(reader["maxx"].ToString());
                            double ymax = Double.Parse(reader["maxy"].ToString());
                            mapExt.SetExtent(xmin, ymin, xmax, ymax);

                    }
                    reader.Close();
                    reader.Dispose();
                    return mapExt;
                }
            }
            return null;
        }
 protected int InsertExtent(string layername, MG_MapExtent mapExt)
 {
     // INSERT INTO ext(layername, minx, miny, maxx, maxy) VALUES('links', 1.1, 1.1, 2.2, 2.2);
     string strSQL = "INSERT INTO ext(layername, minx, miny, maxx, maxy) VALUES('{0}', {1}, {2}, {3}, {4});";
     strSQL = String.Format(strSQL, layername.ToLower(), mapExt.MinX, mapExt.MinY, mapExt.MaxX, mapExt.MaxY);
     return this.Run(strSQL);
 }
Exemple #13
0
 public void Update(Rectangle rect, MG_MapExtent me)
 {
     // FullExtent  ZoomToLayer
     this.CurrentWindow = rect;
     this.CurrentExtent = me;
     this.Calculate();
 }