其实,在Skyline中TerrainModify对象就是一个特殊类型Polygon对象,他们的Geometry是可以直接交换使用的;

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">
        function SelectShp() {
            try {
                var sg = CreateSGObj();
                var iid = sg.ProjectTree.GetNextItem(sg.ProjectTree.RootID, 10);
                if (sg.ProjectTree.IsLayer(iid)) {
                    var ilyr = sg.ProjectTree.GetLayer(iid);
                    var gid = CreateGroup("地形修整");
                    for (var i = 0; i < ilyr.FeatureGroups.Polygon.Features.Count; i++) {
                        var iGeometry = ilyr.FeatureGroups.Polygon.Features(i).Geometry;
                        sg.Creator.CreateTerrainModifier(iGeometry, 0, 0, 1, gid);
                    }
                }
            }
            catch (e) {
                alert(e);
            }
        }
        function CreateGroup(gname) {
            var sg = CreateSGObj();
            var gid = sg.ProjectTree.FindItem(gname);
            if (gid != "" && gid != 0) {

            }
            else {
                gid = sg.ProjectTree.CreateGroup(gname, sg.ProjectTree.RootID);
            }
            return gid;
        }
        //------------------------------------------------------------
        // 创建sgworld对象  赵贺 2013.09.11.
        //------------------------------------------------------------
        function CreateSGObj() {
            var obj = $("sgworld");
            if (obj == null) {
                obj = document.createElement(\'object\');
                document.body.appendChild(obj);
                obj.name = "sgworld";
                obj.id = "sgworld";
                obj.classid = "clsid:3a4f9197-65a8-11d5-85c1-0001023952c1";
            }
            return obj;
        }
        function $(id) {
            return window.document.getElementById(id);
        }
    </script>
</head>
<body>
    <input id="Button1" type="button" value="选择SHP" onclick="SelectShp()" />    
</body>
</html>

 

版权声明:本文为yitianhe原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/yitianhe/p/3318715.html