首页 / 浏览问题 / 桌面GIS / 问题详情
KML里模型实现替换
5EXP 2019年09月16日
现有一个需求是基于KML图层的。客户针对一个对象提供了动静两个模型,希望实现KML图层运动时加载动的模型,停下以后加载静的模型。请问有办法替换吗?我尝试了替换kml里的feature3D里的geomodel的name。也进行了kml图层的编辑和UpdateData。还是无法替换模型。  请问有什么办法替换KML里的模型

1个回答

您好,可以通过KML获得Feature3Ds,再通过Remove(Feature3D)和Add(Geomodle3D)去进行更换模型
2,432EXP 2019年09月17日
那原来geomodel的nodeanimal怎么取出来给新的geomodel。nodeanimal是只读的。

 private void changeStaticModel(Feature3Ds feature3ds, Feature3D m_feature,GeoModel m_geomodel, string modelpath)
        {
            try
            {
                Point3D n_point = m_feature.Geometry.InnerPoint3D;
                Geometry3D m_line = m_geomodel.NodeAnimation.GetTrack();
                string modelname = Path.GetFileName(m_geomodel.Name);
                    string n_modelname = modelname.Replace("pao", "zhan");
                    string n_path = modelpath + "\\" + n_modelname;
                if(System.IO.File.Exists(n_path))
                {
                feature3ds.Remove(m_feature);

                GeoModel n_geomodel = new GeoModel();
                n_geomodel.FromFile(n_path, n_point);
                NodeAnimation ani = n_geomodel.NodeAnimation;
                ani.SetTrack(m_line);
                ani.PlayMode = PlayMode.Once;
                feature3ds.Add(n_geomodel);
                }
            }
            catch (Exception x)
            { }
        }

我现在这样来替换。会导致图层管理器崩溃

您好,我看你提问里面描述的是“停了”过后,那么不需要nodeanimation这个动画轨迹了呀。如果还需要继续前行,那就需要通过获取你动的模型最后停留的点,结合已有的轨迹重新设定路线,设置新的Geomodel的nodeanimation
您好,添加完了刷新kml图层试试UpdateData刷新一下,还不行的话就用Feature3Ds.ToKMLFile保存一下,再刷新
...