基于Skyline的TEP5.1.3实现对矢量SHP文件的加载和渲染

我们知道在Skyline的TEP软件中可以添加多种矢量图层,对于常见的SHP文件,我们如何通过接口来开发实现呢?

下面代码是基于C#开发的,供大家参考:

 

string XMLLayerInfo = "<PlugData><LayerName>" +
                        // 这里是要加载的shp文件所在的路径
                        Application.StartupPath + "//shp//DC_FF_Parks.shp" +
                        "</LayerName><PlugType>shape</PlugType><Annotation>0</Annotation><Feature>1</Feature>" +
                        "<AttributesToLoad>Name,County</AttributesToLoad>" + //这里是设置要加载的shp文件的属性字段
                        "<StreamedLayer>1</StreamedLayer></PlugData>";
                    iLyr = IInfoTree.CreateLayer("point", XMLLayerInfo, 0);
                    iLyr.Load();
                    iLyr.DisplayAs(ObjectTypeCode.OT_LABEL);
                    iLyr.SetFeature();
                    iLyr.SetValue("Text", PropertyValueType.PROPERTY_CLASSIFICATION, "<Classification FuncType='0'><Class><Value>[NAME]</Value></Class><DefaultValue>0</DefaultValue></Classification>");

                    //==Appearance
                    iLyr.SetProperty("Activation Action", 1);
                    iLyr.SetProperty("Line to Ground", 0);
                    iLyr.SetProperty("Line Length", 1000);
                    iLyr.SetProperty("Line Color", 300);
                    //==Text Options
                    iLyr.SetProperty("Text Color", 255);
                    iLyr.SetProperty("Text Size", 12);
                    iLyr.SetProperty("Font", "宋体");
                    iLyr.SetProperty("Bold", 1);
                    iLyr.SetProperty("Underline", 1);
                    iLyr.SetProperty("Italic", 1);
                    iLyr.SetProperty("Multiline Justification", 0);
                    iLyr.SetProperty("Background Color", 100);
                    iLyr.SetProperty("Background Opacity", 0);
                    iLyr.SetProperty("Lock Mode", 0);
                    //==Image Options           
                    iLyr.SetProperty("Image file", "C:\\Program Files\\Skyline\\TerraExplorer Pro\\Tools\\Data-Library\\Icons\\Letters\\Letter-a.gif");
                    //==Position
                    iLyr.SetProperty("Altitude Method", 1);
                    iLyr.SetProperty("Altitude", 1000);
                    iLyr.SetProperty("Yaw", 10);
                    iLyr.SetProperty("Pitch", 10);
                    iLyr.SetProperty("Roll", 10);
                    string[] myStrings = new string[9];
                    myStrings[0] = "0,0";
                    iLyr.SetProperty("Pivot Alignment", myStrings[0]);
                    //==Geometry
                    iLyr.SetProperty("Scale", 100);
                    iLyr.SetProperty("Limit Growth", 1);
                    iLyr.SetProperty("Min. Viewing Height", 100);
                    iLyr.SetProperty("Smallest Visible Size", 10);
                    //==Text&Image Alignment
                    iLyr.SetProperty("Text Relative to Image", 0);
                    iLyr.SetProperty("Text Alignment", myStrings[0]);
                    //==General
                    iLyr.SetProperty("Show In Basic", 0);
                    //---------------------------------------------------
                    ITerraExplorerMessage5 cMessage = null;
                    string tMessage = "Hello Skyline";
                    MsgType eMsgType = MsgType.TYPE_TEXT;
                    cMessage = IObjectManager.CreateMessage(MsgClient.CLIENT_POPUP, tMessage, eMsgType, _HTML_POPUP_FLAGS.HTML_POPUP_ALLOW_RESIZE, "属性信息", -1, 0, 0, 300, 300, 0);
                    iLyr.SetProperty("Message", cMessage.ID.Substring(cMessage.ID.IndexOf('_') + 1, (cMessage.ID.Length - cMessage.ID.IndexOf('_') - 1)));
                    //---------------------------------------------------
                    iLyr.SetProperty("Tool Tip", "公园");
                    iLyr.SetProperty("Default Viewing Distance", 1000);

 

说明:上面的代码实现了对点类型的SHP文件的加载和在三维场景中的渲染显示。

 

posted @ 2011-05-11 16:51  依尔根觉罗天赫  阅读(2663)  评论(0编辑  收藏  举报