第四章 實驗結果與分析
4.4 資料傳輸檢查與效能評估實驗結果
國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
53
續型,或座標差異度較小,對於以上各壓縮方法會較佳的成果。
表14:兩種類型之座標資料壓縮結果
GeoJSON 壓縮 HTTP 壓縮 HTTP 壓縮+
GeoJSON 壓縮
非連續型座標資料 33.2% 70.8% 74.9%
連續型座標資料 40.6% 75.6% 85.3%
4.4 資料傳輸檢查與效能評估實驗結果
本節進行實驗為,實際操作本研究設計的Web GIS 資料檢索介面,並查詢北台 灣提款機座標分佈資料共計7,925 個,以及選用 GeoJSON 與 HTTP 兩種壓縮技術後,
資料的傳輸效能觀察與分析。
依據第三章資料檢查機制的流程,首先設定每一個檔案是以多少個座標為單位來 切割,本研究假設1,000 個座標為單位,因此 7,925 個座標會分成 8 個檔案(不足 1000 當成一個檔案);第二將每一個檔案內容皆附加 MD5 雜湊碼;第三送交至用戶端時,
用戶端也會產生一個MD5 雜湊碼進行比對;第四為比對無誤後,主動要求伺服器端 傳遞下一筆檔案,直到檔案傳輸作業結束,若比對發現錯誤,則要求伺服器重新傳遞 該筆檔案。
實驗的結果如圖4.15 所示,為 OpenLayers 平台介面,由於本系統使用的地理資 料來源均為台灣地區,因此當資料標示座標即顯示台灣區域的地圖影像,介面下方為 各批次資料傳遞的流程以及回應的時間。
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
54
圖4.15:檔案分批呈現結果
圖4.16 為驗證資料畫面,當資料傳遞完成後,便由系統比對與確認伺服器端與 用戶端的MD5 雜湊碼後,主動要求傳遞下一筆檔案 (在實驗設計上,為了完整呈現 比對雜湊碼的流程,故以跳出訊息框的方式顯示) 。
圖4.16:資料檢查碼呈現結果
‧
1 1,000 13,783 1d03eb74db503a8541b1f492f34ebe3c 2 1,000 13,701 049b683918cdeaa63d7066625f2b424d 3 1,000 13,670 e50e64dbcb8d11d975a3cd053e6dc52b 4 1,000 13,650 9f6ce0a5c878e9ecd85778d127468c54 5 1,000 13,466 977f04f8e0238cecf73b82d364c027b9 6 1,000 13,393 4eb7092ca291ab5a8482a276da9e5e6e 7 1,000 13,404 092ba6e7618e7142da7a14d9dd52075a 8 925 12,544 181d63016e8957d16214c560497bcade 總資料傳輸時間: 約 23,060 毫秒
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
56
5.1 結論
在本研究中,我們提出了一套GeoJSON 壓縮技術增進網路的資料傳輸效能,且壓 縮後的GeoJSON 格式,符合開放地理資料交換標準(Open Geospatial Consortium,OGC) 及JSON 輕量級結構基礎。從 GeoJSON 壓縮技術中,本研究提出的浮點數編碼,改善 了差分編碼前置零問題,讓僅有差分編碼的資料壓縮率,從11%提高至 40.6%~53.5%,
另外透過HTTP 壓縮技術的輔助,可以達到最佳平均為 85.3%的壓縮率。此外,將壓縮 方法實際套入本研究模疑Web GIS 的環境中,GeoJSON 壓縮節省約原始資料 30%的資 料量與傳輸時間,加上HTTP 壓縮的補助,則可讓傳輸時間縮短約原始時間的 80%,因 此本方法應用在資料傳遞,在時間效能上也有明顯的提昇。在資料的品質控管,「資料 傳輸驗證機制」的設立,能確保用戶端與伺服器端的資料一致性,以及避免資料編解碼 錯誤的情形發生。
經由第四章實驗結果與過程,本研究整理以下幾點發現:
1. GeoJSON 壓縮若沒有 HTTP 壓縮的輔助,雖達到座標壓縮的目的,但壓縮的成果 並沒有HTTP 壓縮(GZIP)來的好,由於 GeoJSON 壓縮後仍為十進制的字串的格式,
而HTTP 壓縮後格式為二進制,但是若要符合地理資料格式的規範而言,則壓縮與 可讀性兼具的情況使用GeoJSON 壓縮結果較佳;若在網路上傳輸以 HTTP 壓縮雖 然有不錯的效能,但在結合GeoJSON 壓縮仍能減少資料量與時間約 20%,在結果 上,GeoJSON 壓縮仍達到增進的目的。
2. 由於差分編碼對於座標數值相近且連續的情況下,可以達到不錯的壓縮成果,但假 設座標在地理範圍的距離加大,所產生的差分值也就愈大,因此本方法若套用在非 同一個地理範圍的座標集,雖能壓縮但成果有限。
3. 建立單向雜湊函數可確保資料傳遞過程的一致性,但其代價是需要額外付出較長的
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
57
資料傳輸時間,經實驗結果顯示,加入檢查機制後,傳遞空間資料所需的傳輸時間,
將遠大於未經檢查所需的傳輸時間。
近年來GeoJSON 開始被許多計畫與地理資訊系統軟體公司熱切注意與研究,因此 透過有系統的資料整理以及實驗,呈現完整的數據提供大眾參考,並對GeoJSON 有更 進一步的了解與肯定,並且滿足未來廣大的市場需求,以增加本研究壓縮技術的應用價 值。
5.2 未來研究方向
本研究嘗試對GeoJSON 格式進行壓縮以增進網路資料傳輸效能,並利用 HTTP 壓 縮方法的輔助,達到更佳的壓縮成果與傳輸效能;唯本研究在計算平均傳輸時間的變異 係數略高,若能改善實驗環境應可以獲得更精確的成果數據,茲將如何提昇實驗的精確 度與效能的建議作為未來研究方向:
1. 加入座標尾數壓縮規則
GeoJSON 壓縮原則是以簡單且容易應用為基礎,若僅參考座標中整數重複的特性 下,雖達到壓縮目的,但成果不夠顯著,若未來加入座標尾數的壓縮規則,應能發 揮更大的壓縮成果。
2. 改善非同地理範圍座標資料壓縮
本研究基於座標的特性,在壓縮實驗中使用差分編碼來儲存差異值,差異值愈小則 壓縮成果較佳,但對於非連續型的資料而言,差異值較大且壓縮成果略差,因此若 能針對差距較大的座標集合,調整差分編碼的計算方法以改善壓縮成果。
3. 改善資料檢查流程
在執行壓縮GeoJSON 座標時與資料傳輸檢查時,因檔案切割的流程,雖可以避免 網路傳輸錯誤率發生,但額外增加執行次數與時間,因此在資料檢查部份,若能 減少檢查所執行的時間,可以提昇更多的網路資料傳輸效能。
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
58
[1] 徐百輝,”地理資訊標準格式之簡介(電子版) ”,
國土資訊系統通訊,第 71 期
,pp.14-34,2009。
[2] 林昂賢,”一個高效率的 XML 資料壓縮演算法”,
國立臺灣大學資訊工程學研究所 碩士論文
,1999。[3] 廖泫銘、林農堯、廖宜真,”地理資訊開放服務的規範與應用軟體架構”,
國土資訊 系統通訊,
第71 期,pp. 53-64,2008。[4] 鍾國亮,”
資料壓縮的原理與應用
”,台北:全華科技圖書
,2004。[5] 陳仁德,”一個針對GPRS 之資料壓縮演算法”,
國立交通大學資訊管理研究所碩士 論文
,2005。[6] 賴溪松、韓亮、張真誠,”近代密碼學及其應用”,
台北:松崗
,1998。[7] 楊佑寧,”有限信任讀卡機下安全服務機制”,
國立暨南國際大學資訊管理學系碩士 論文
,2006。[8] 孫志堅,”地理空間資料與座標系統間關係之研析”,2010 年 6 月 20 日,取自 http://163.29.126.136/share/地理空間資料與座標系統間關係之研析,2010
[9] 微軟技術及技術論壇(2002),”效能比較:安全性設計選擇”,MSDN Library,2010 年6 月 20 日,取自
http://www.microsoft.com/taiwan/msdn/library/2002/Nov-2002/bdadotnetarch15.htm。
[10] PCNET 網路研究所,”TCP 與UDP”, 2010 年 9 月 20 日,取自 http://www.pcnet.idv.tw/pcnet/network/network_ip_tcp.htm。
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
59
[11] Bassiouni, M.A.,” Data compression in Scientific and Statistical Databases”,IEEE
Transactions on Software Engineering., vol.11, pp.1047-1058, 1985.
[12] Bakhtiari, S. and Safavi-Naini, R. and Pieprzyk J.,”Cryptographic Hash Functions: A Survey.” Technical Report, Department of Computer Science, University of Wollongong, pp.
95-09, 1995.
[13] Do-Hyun, “K., and K. Min-Soo,”Web GIS service component based on open environment”, In Geoscience and Remote Sensing Symposium,. IEEE International, pp.
3346-3348, 2002.
[14] D.A. Huffman, “A method for the construction of minimum-redundancy codes”,
Proceedings of the I.R.E., pp.1098-1102, 1952.
[15] James J. Hunt and Kiem-Phong Vo and Walter F. Tichy, “Delta Algorithms: An Empirical Analysis”, ACM Transactions on Software Engineering and Methodology, vol.7, pp.
192-214, 1998.
[16] Jens Müller, “Data Compression-LZ77”, Universität Stuttgart, 2008.
[17] Jihong Guan, Shuigeng Zhou, “GPress: Towards Effective GML Documents Compresssion”, IEEE 23rd International Conference on Data Engineering, pp.
1473-1474, 2007.
[18] J. Rissanen and G. G. Langdon, “An Introduction to Arithmetic Coding”, IBM Journal of
Research and Development, vol. 28, pp. 135, 1979.
[19] Jeffery N. Ladino, “Data Compression Algorithms”, College of Computer Science at
Northeastern University, Honors Project, 1996.
[20] J. Ziv and A. Lemple, “A universal algorithm for data compression”, IEEE Transactions
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
60
n Information Theory, vol. 23, pp. 337-343, 1997.
[21] Torsten Suel and Nasir Memon, “Algorithms for Delta Compression and Remote File Synchronization”, In Khalid Sayood, editor, Lossless Compression Handbook, 2002.
[22] Timothy J. McLaughlin,” The Benefits and Drawbacks of HTTP Compression” , Lehigh
CSC 2002 Technical Reports,vol. 2, pp. 104, 2002.
[23] OGC(2007), OpenGIS® Web Processing Service Implementation Specification Version:
1.0.0.
[24] Peng, Z. R. A., and C. A. Zhang, “The roles of geography markup language (GML), scalable vector graphics (SVG), and Web feature service (WFS) specifications in the development of Internet geographic information systems (GIS)” , Journal of
Geographical Systems, vol.6, pp.95-116, 2006.
[25] R. Rivest(1992),”The MD5 Message-Digest Algorithm”, MIT Laboratory for Computer
Science and RSA Data Security, Inc.,1992.
[26] Yuzhen Li, Takashi Imaizumi, Jihong Guan, “Spatial Data Compression Techniques for GML”, Japan-China Joint Workshop on Frontier of Computer Science and Technology, pp.79-84, 2008.
[27] 3 Top Data Formats for Map Mashups: KML, GeoRSS and GeoJSON, Retrieved Aug 11, 2009, from
http://blog.programmableweb.com/2008/08/27/3-top-data-formats-for-map-mashups-kml -georss-and-geojson/.
[28] Behram Mistree and Dmitry Kashlev , “, GZIP Encoding”, Retrieved Jun 20, 2009, from http://csg.csail.mit.edu/6.375/6_375_2007_www/projects/group6_final_report.pdf .
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
61
[29] ArcDeveloper Project, Retrieved Aug 11, 2009, from http://groups.google.com/group/arcdeveloper-dev.
[30] Automation for the people: Deployment-automation patterns, Retrieved Aug 11, 2009, from http://www.ibm.com/developerworks/java/library/j-ap02109/index.html.
[31] Douglas Crockford, Retrieved Aug 11, 2009, from http://www.crockford.com/.
[32] Data compression tutorial: Part 2, Retrieved Aug 11, 2009, from
http://www.eetimes.com/design/automotive-design/4017499/Data-compression-tutorial-Part-2.
[33] Ekrem seren’s weblog, Retrieved May 20, 2009, from
http://www.ekremseren.com/2009/05/compression-tools-lzma-bzip2-gzip/.
[34] GeoJSON WIKI, Retrieved May 20, 2009, from http://wiki.geojson.org/Main_Page. [35] GeoJSON Python Library, Retrieved May 20, 2009, from
http://pypi.python.org/pypi/geojson/1.0.
[36] Google maps, Retrieved May 20, 2009, from
http://maps.google.com/support/bin/static.py?hl=b5&page=guide.cs&guide=21670, [37] Introducing JSON, Retrieved May 20, 2009, from http://json.org.
[38] J. Stolfi. Hash function , Retrieved Aug 11, 2009, from http://en.wikipedia.org/wiki/Hash_function.
[39] LZ77 and LZ78, Retrieved Aug 11, 2009, from http://en.wikipedia.org/wiki/LZ77_and_LZ78.
[40] MapFish, Retrieved May 20, 2009, from http://mapfish.org/.
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
62
[41] MD5-Wiki, Retrieved May 20, 2009, from http://en.wikipedia.org/wiki/MD5.
[42] Open Source Geospatial Foundation, Retrieved May 20, 2009, from http://www.osgeo.org/.
[43] OpenLayers, Retrieved May 20, 2009, from http://openlayers.org/.
[44] OSGEO, Retrieved May 20, 2009, from http://www.osgeo.org/.
[45] OpenLayers Vector Formats Example, Retrieved Aug 11, 2009, from http://openlayers.org/dev/examples/vector-formats.html.
[46] pgRouting On Ubuntu Netbook Remix 9.10, Retrieved May 20, 2009, from http://www.mkgeomatics.com/wordpress/?p=312.
[47] Speed Web delivery with HTTP compression, Retrieved Apr 20, 2009, from http://www.ibm.com/developerworks/web/library/wa-httpcomp/.
[48] The GeoJSON Format Specification, Retrieved July 25, 2009, from http://geojson.org/geojson-spec.html.
[49] Unzipping the GZIP compression protocol, Retrieved Apr 20, 2009, from http://www.chipestimate.com/techtalk.php?d=2010-03-23.)
[50] Web Services, Output Formats and GZIP Compression, Retrieved Feb 11, 2010, from http://www.sendung.de/archives/2007/04/09/web-services-output-formats-and-gzip-com pression/.
[51] Yahoo Developer Network, Retrieved Apr 20, 2010, from http://developer.yahoo.com/common/json.html#xml.
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
63
附錄
附錄1. 浮點式編碼函式的編碼
function float_encode($delta_coor) {
if ($delta_coor<0) { //取得座標的”sign”,並定義為$sign,分別與0 $sign = 1; 與1代表正號與負號
$nosign_coor = substr($delta_coor,1); //過濾負號 }
else {
$sign = 0;
$nosign_coor = $delta_coor; //過濾尾巴的0,並定義為$ nozero_coor找出小 } 數點的位置,從前面算起
$nozero_coor = rtrim($nosign_coor, '0');
$decops=strops($nozero_coor, '.'); //用小數點的位置,決定exponent,把浮點數 $exp = strlen($nozero_coor)-$decpos-1; 變成整數
$str_before_dot = substr($nozero_coor, 0, $decpos);
$str_after_dot = substr($nozero_coor, intval($decpos+1), $exp);
$magnitude = $str_before_dot.$str_after_dot;
$magnitude1 = ltrim($magnitude, '0'); //取得magnitude,並去掉開頭的"0"
$result1 = dec2base( ((int)($sign*$base*0.5)+$exp));
} }
‧
function my_decode(base, cor_s) {
var sign_exp = base2dec(cor_s.charAt(0), base); //查表找出 sign_exp 對應的值
magnitude = base2dec(org_magnitude, base); //將 magnitude 從 base 進制還原成 10 進制 var m_s = magnitude + "";
var magnitude_len = m_s.length;
if (magnitude_len > exponent) { //利用 Exponent 的資訊將小數點加回去原來的座標值 var str_before_dot = m_s.substring(0, magnitude_len - exponent);
var str_after_dot = m_s.substring(magnitude_len - exponent, magnitude_len);
var result_s = sign_s + str_before_dot + "." + str_after_dot;
‧ 國
立 政 治 大 學
‧
N a tio na
l C h engchi U ni ve rs it y
65
附錄3. 差分編碼函式
$coor = [[x1, y1], [x2, y2], ….[xn, yn]] //範例座標陣列 function delta_encode($coor)
{
$coorsize=sizeof($coor); //$coorsize為座標矩陣的大小,即n遞迴呼 for($i=0; $i<$coorsize; $i++) 叫座標矩陣內物件
{
$delta_x = ($coor[$i][0]-$coor[$i-1][0])); // 座標進行差分編碼 (
Δp
i p
i 1 p
i) $delta_y = ($coor[$i][1]-$coor[$i-1][1]);}
Return $delta_x.”,”.$delta_y;