zoukankan      html  css  js  c++  java
  • 基于Skyline的TerraExplorer6.1.1如何通过二次开发实现矢量图层的空间查询和属性查询

    说明:先准备好一个FLY工程文件,其中要加载一个相对标准的SHP文件,自己参考其他部分实现绘制几何对象的方法;

    <!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" language="javascript">
            
    //遍历整个图层 
            //zhaohe.2012.09.25.
            function GetFeatureAll() {
                
    var strResult = "<table>";
                
    var SGWorld = CreateSGObj();
                
    var ItemID = SGWorld.ProjectTree.FindItem("Fairfax_zones");
                
    var obj = SGWorld.ProjectTree.GetLayer(ItemID);
                
    // 遍历当前图层中已经在地图上加载的全部对象及其属性
                var pIFeatureGroup = obj.FeatureGroups(0);
                
    for (var i = 0; i < pIFeatureGroup.Count; i++) {
                    strResult 
    = strResult + "<tr>";
                    
    var pIFeature = pIFeatureGroup.Item(i);
                    
    for (var j = 0; j < pIFeature.FeatureAttributes.Count; j++) {
                        
    var pIFeatureAttribute = pIFeature.FeatureAttributes.Item(j);
                        strResult 
    = strResult + "<td>" + pIFeatureAttribute.Name + "*" + pIFeatureAttribute.Value + "</td>";
                    }
                    strResult 
    = strResult + "</tr>";
                }
                strResult 
    = strResult + "</table>";
                window.document.getElementById(
    "result").innerHTML = strResult;
            }

            
    //多边形查询
            //zhaohe.2012.09.25.
            function GetFeatureWithPoly() {
                
    var strResult = "<table>";
                
    var SGWorld = CreateSGObj();
                
    var ItemID = SGWorld.ProjectTree.FindItem("Fairfax_zones");
                
    var obj = SGWorld.ProjectTree.GetLayer(ItemID);
                
    // 遍历多边形内选中的对象及其属性
                var qItemID = SGWorld.ProjectTree.GetNextItem(010);
                
    var qobj = SGWorld.ProjectTree.GetObject(qItemID);
                
    var queryGeometry = qobj.Geometry;
                
    var resFeatures = obj.ExecuteSpatialQuery(queryGeometry, 1);
                
    for (var i = 0; i < resFeatures.Count; i++) {
                    strResult 
    = strResult + "<tr>";
                    
    var pIFeature = resFeatures.Item(i);
                    
    for (var j = 0; j < pIFeature.FeatureAttributes.Count; j++) {
                        
    var pIFeatureAttribute = pIFeature.FeatureAttributes.Item(j);
                        strResult 
    = strResult + "<td>" + pIFeatureAttribute.Name + "*" + pIFeatureAttribute.Value + "</td>";
                    }
                    strResult 
    = strResult + "</tr>";
                }
                strResult 
    = strResult + "</table>";
                window.document.getElementById(
    "result").innerHTML = strResult;
            }

            
    //属性查询
            //zhaohe.2012.09.25.
            function GetFeatureWithPro() {
                
    var SGWorld = CreateSGObj();
                
    var ItemID = SGWorld.ProjectTree.FindItem("Fairfax_zones");
                
    var obj = SGWorld.ProjectTree.GetLayer(ItemID);
                
    var clause = window.document.getElementById("Text1").value;
                
    if (clause == "") {
                    obj.Filter 
    = clause;
                    obj.Streaming 
    = 1;
                    obj.Refresh();
                }
                
    else {
                    obj.Filter 
    = clause;
                    obj.Streaming 
    = 0;
                    obj.Refresh();
                }
                GetFeatureAll();
            }

            
    /*  
            功能:   创建sgworld对象
            备注:   赵贺 2011.04.01.
            
    */
            
    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:3a4f91b0-65a8-11d5-85c1-0001023952c1";
                }
                
    return obj;
            }
            
    function $(id) {
                
    return window.document.getElementById(id);
            }
        
    </script>
    </head>
    <body>
        <table>
            <tr>
                <td colspan="4">
                    <input id="Button1" type="button" value="全部Feature" onclick="GetFeatureAll()" />
                    <input id="Button2" type="button" value="空间查询" onclick="GetFeatureWithPoly()" />
                </td>
            </tr>
            <tr>
                <td colspan="4">
                    <input id="Text1" type="text" value="Class=3" />
                    <input id="Button6" type="button" value="属性查询" onclick="GetFeatureWithPro()" />
                </td>
            </tr>
            <tr>
                <td>
                    <div id="result">
                    </div>
                </td>
            </tr>
        </table>
    </body>
    </html>
  • 相关阅读:
    《Node.js 包教不包会》
    (转)Java并发编程:线程池的使用方法
    (原创)定时线程池中scheduleWithFixedDelay和scheduleAtFixedRate的区别
    JAVA线程本地变量ThreadLocal和私有变量的区别
    (原创)确保JAVA线程安全的4种常用方法
    (转)ReentrantLock可重入锁的使用场景
    (原创)JAVA阻塞队列LinkedBlockingQueue 以及非阻塞队列ConcurrentLinkedQueue 的区别
    读/写锁的实现和应用(高并发状态下的map实现)
    Jira API传字符串的换行问题 (文本编辑器使用)
    使用泛型SwingWorker与EDT事件分发线程保持通讯
  • 原文地址:https://www.cnblogs.com/yitianhe/p/2701743.html
Copyright © 2011-2022 走看看