This project is read-only.

Problem with Layer Propierties Dialog

Jan 14, 2011 at 9:03 PM

Hi all,

I have the folowing data :

IDE XY
11000001 690662.56595 1159700.02556 690635.35054 1159701.60201
11000003 690812.74134 1159605.52326 690802.66049 1159590.21049
11000004 690856.99466 1159662.623 690839.42907 1159639.8017

 when I create a layer of LineString and use the Layer Propierties Dialog, DotSpatial don't Drawing  the map after you change the symbol, but if  featureset is save as xxx.shp and reload the Layer Propierties Dialog work fine, any help.

Thanks,

HEAH

 

Jan 14, 2011 at 9:12 PM

Without the underlying code it is hard to say.  Most likely, however, after you generate new features in a featureset from scratch, rather than loading from a file, you need to call myFeatureSet.InitializeVertices() which will take your features and use them to update the actual vertex values that are rendered by the layer.

Ted

 

Jan 14, 2011 at 9:34 PM

 

When create the featureset the map is rendering but when change the layer symbol map don´t drawing,

i show my code for any suggestions

 

 public void LoadNet(string IDE)
        {

            #region validate 
            if (_Map == null) { return; }
                       
            _Acces.ConexionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"D:\\data.mdb\"";
            List<LoadEntities> layers=new List<LoadEntities>(); 
           
            if (IDE == "*") 
           {
               //layers.Add(new LoadEntities("LIN", "Select IDE,XY,INS FROM LIN"));
            }
            else
           {
               //layers.Add(new LoadEntities("TRM", "Select IDE,XY,INS FROM GAUSS"));
               layers.Add(new LoadEntities("TRM", "Select IDE,XY,INS FROM LIN WHERE INS=" + IDE));
               //layers.Add(new LoadEntities("INT","Select IDE,XY,INS FROM APA_INT WHERE INS=" + IDE));
               //layers.Add(new LoadEntities("FUS", "Select IDE,XY,INS FROM APA_FUS WHERE INS=" + IDE));
               //layers.Add(new LoadEntities("PUE", "Select IDE,XY,INS FROM APA_PUE WHERE INS=" + IDE));
           }
            #endregion




            IMapGroup group = new DotSpatial.Controls.MapGroup(_Map.MapFrame.Layers, _Map.MapFrame, null);
            group.LegendText = "NetWork"; 
          
           try
           {
               _Acces.Open();
               foreach (LoadEntities  msql in layers )
               {
                   Logger.SendInfo("Load " + msql.NameLayer +"....");                   
                   _Acces.OpenTabla(msql.MySql);
                   IFeatureSet f = LoadLineEntities(_Acces.Datareader, msql.NameLayer);
                  

                   if (f != null)
                   {
                       group.Layers.Add(f);                       
                       _Map.ViewExtents = _Map.Layers.MapFrame.Extent;                                               
                       //f.SaveAs("D:\\DataSamples\\gol.shp",true);
                   }
                   _Acces.Datareader.Close();
               }
               _Acces.Close();

               _Map.Legend.RefreshNodes();
               _Map.Invalidate();
               _Map.MapFrame.ResetBuffer();   
               
           }
           catch (Exception e)
           {
               _Acces.Datareader.Close();
               _Acces.Close();
               _Logger.SendError(e.Message);   
           }
        }

private  IFeatureSet LoadLineEntities(OleDbDataReader lin, string NameLayer)
        {
            string[] cordenadas;
            string cord;
            string ide="";
            string ins;
            int num = 0;

            _Map.MapFrame.SuspendEvents();
  
            FeatureSet feature = new FeatureSet();             
            feature.DataTable.Columns.Add("IDE", typeof(int));
            feature.DataTable.Columns.Add("XY", typeof(string));
            feature.DataTable.Columns.Add("INS", typeof(int));
            feature.DataTable.Columns.Add("ELEVATION", typeof(double));           
            feature.Name = NameLayer;
            feature.FillAttributes();
           
            
             
            double lastx=0;
            double lasty=0;
            try
            {
                while (lin.Read())
                {
                    ide = GetValue(lin, "IDE");
                    cord = GetValue(lin, "XY");
                    ins = GetValue(lin, "INS");
                    cordenadas = NormCoordenate(cord.Split(' '));
                    num++;

                    List<Coordinate> points = new List<Coordinate>();

                    bool validcoordenate = false;
                    for (int i = 0; i < cordenadas.Length; i += 2)
                    {
                        if (cordenadas[i] != "")
                        {
                            double x = Convert.ToDouble(cordenadas[i]);
                            double y = Convert.ToSingle(cordenadas[i + 1]);

                            if ((x < 2000000) && (y < 2000000))
                            {
                                points.Add(new Coordinate(x, y));
                                lastx = x;
                                lasty = y;
                                validcoordenate = true;
                            }

                        }
                    }

                    if (validcoordenate)
                    {
                        
                        Feature f;
                        //f = new Feature(FeatureType.Line, points.ToList());
                        if (points.Count > 1)
                        {
                            f = new Feature(FeatureType.Line, points.ToList());
                        }
                        else
                        {
                            f = new Feature(FeatureType.Point, points.ToList());
                        }
                        
                        feature.Features.Add(f);
                        f.DataRow["IDE"] = Convert.ToInt32(ide);
                        f.DataRow["XY"] = cord;
                        f.DataRow["INS"] = Convert.ToInt32(ins);
                        f.DataRow["ELEVATION"] = 0;
                    }
                    else
                    {
                        Logger.SendInfo("Check las coordenates");
                    }
                }
                Logger.SendInfo("Load " + num.ToString() + " Feature");
            }
            catch (ArgumentException arg)
            {
                Logger.SendError(arg.Message);   
            }
            catch (Exception e)
            {
                Logger.SendError("Error load " + ide + " Entity");
            }
            
            _Map.MapFrame.ResumeEvents();
            feature.InitializeVertices();  //add according comment 
            return feature; 
        }