視域分析

<< Click to Display Table of Contents >>

Navigation:  3D API 應用範例 >

視域分析

 

 

檢視範例

範例下載

 

 

<說明>

在本範例中,我們將示範如何使用域分析模組,說明如下:

 

 

<範例>

 var earth_ = null;

 

         function documentLoad()

       {

             SuperGIS.Initialize("/ServerGate/", function () {

                 SuperGIS.ServerEarth.Initialize(InitEarth);

             });

         }

 

     function InitEarth()

     {

         var pBody = new SuperGIS.Windows.HTMLContainer(document.getElementById("example"));

 

         var sHost = location.href;

         var idx = sHost.indexOf("/", 8);

         if (idx >= 0) sHost = sHost.substring(0, idx);

         CreateHTML5Earth(pBody, function (pEarth) { EarthLoaded(pEarth); });

 

         function EarthLoaded(pEarth)

         {

             earth_ = pEarth;

             pEarth.Scene.BackgroundColor = pEarth.CreateColor(0, 0, 0, 1);

             pEarth.SetupSystem(true, s_WGS84);

             pEarth.SetupSkin(pEarth.CreateEnvelope(-180, 180, -90, 90, s_WGS84), sHost + "/ServerGate/Skin1.jpg");

             pEarth.MajorGraticule.Visible = false;

             pEarth.MinorGraticule.Visible = false;

 

             // 指定向量磚服務的 WMTS 網址, 欲加入的圖層名稱, 及 callback function 名稱

             //VLayer = new SuperGIS.VectorLayer(getDataServicePath() + 'project_block/SimpleWMTS.aspx',

               //                                pEarth, { layer: '土地使用分區' }, LanduseFinish);

             VLayer = new SuperGIS.VectorLayer(getDataServicePath() + 'project_build/SimpleWMTS.aspx',

                                             pEarth, { layer: '建物' }, BuildingFinish);

             VLayer.setPickable(true);

 

             pEarth.SetViewpoint(120.65545, 24.16204, 39, 30, 50, true);

 

             var sHref = location.href;

             idx = sHref.lastIndexOf("/");

             if (idx >= 0) sHref = sHref.substring(0, idx);

             var iconurl = sHref + "/Point.png";

 

             var loc = SuperGIS.DDDEarth.LatLonAlt.NewLatLonAlt(24.16204, 120.65545, 39);

             var marker = new SuperGIS.Marker(pEarth, loc, "Eye", iconurl, { });

         }

 

         function BuildingFinish(array) {

 

             var rv = 128, gv = 128, bv = 128;

             for (var i = 0; i < array.length; i++) {

                 var mark = array[i];

                 var floor = mark.GetFieldValue("建物樓層數");

                 var z = 0;

                 if (floor != null) {

                     z = parseInt(floor) * 3.2;

                     if (floor < 3)

                     { rv = 192; gv = 255; bv = 192; }

                     else if (floor >= 3 && floor < 10)

                     { rv = 255; gv = 192; bv = 64; }

                     else

                     { rv = 192; gv = 128; bv = 64; }

                 }

 

                 var fc = earth_.CreateColor(rv / 255.0, gv / 255.0, bv / 255.0, 228 / 255.0);

                 mark.ReplaceZ = z;

                 mark.DDDSymbol = earth_.CreateSimpleDDDFillSymbol(earth_.CreateModelMaterial(0, fc), null);

                 mark.ExtrudeSymbol = earth_.CreateSimpleDDDFillSymbol(earth_.CreateModelMaterial(0, fc), null);

             }

         }

 

         // 在 callback 中設定每個 feature 的符號樣式

         function LanduseFinish(array) {

             var rv = 108, gv = 108, bv = 108;

             for (var i = 0; i < array.length; i++) {

                 var mark = array[i];

                 var fc = earth_.CreateColor(rv / 255.0, gv / 255.0, bv / 255.0, 187 / 255.0);

                 mark.ReplaceZ = (i % 10) * 10; // 設定高程 (公尺)

                 mark.DDDSymbol = earth_.CreateSimpleDDDFillSymbol(earth_.CreateModelMaterial(0, fc), null);

 

                 // ExtrudeSymbol 是拔高面的 Symbol 樣式, 只要有設定, 就會畫出拔高面

                 mark.ExtrudeSymbol = earth_.CreateSimpleDDDFillSymbol(earth_.CreateModelMaterial(0, fc), null);

             }

         }

       }

 

     function OnViewshed()

     {

         var pos = SuperGIS.DDDEarth.LatLonAlt.NewLatLonAlt(24.16204, 120.65545, 39);

         earth_.ViewshedAnalysis(pos, 30, 50, 20, 10, false, earth_.CreateColor(0, 1, 0, 1));

     }

 

 

 

 


© 2017 Supergeo Technologies Inc.