[本文著作權由xiaotie@vip.sina.com所有,轉載需得到作者同意。]
在國家基礎地理資訊中心下載到的資料格式是Shape file資料。Shape file資料由3個檔案構成,*.shp,*.dbf和*.shx,分別儲存空間資料、屬性資料和兩者間的關係。*.shp得專門的軟體瀏覽。*.dbf採用一般文本瀏覽器就可以瀏覽,Excel可以直接編輯dbf檔案。
開源GIS軟體支援的資料集一般還有WKT和GML。WKT是文本形式的GIS資料,PostGIS中空間資料的儲存便是以WKT形式儲存的。GML是XML格式的GIS資料。
PostGIS提供了shp2pgsql.exe工具,能夠將shp檔案轉化為sql語句,執行這些sql命令就可以將相關內容匯入PostgreSQL資料庫中。匯入後的表如下:
前面幾列都是屬性資料,最後一列是空間資料。第一行最後一列的內容如下:
SRID=-1;MULTILINESTRING((121.48827 53.332596,121.48844 53.332649,121.49954 53.336006,121.51841 53.339191,121.53907 53.341721,121.57375 53.348175,121.58404 53.349644,121.59367 53.353237,121.60381 53.357811,121.61327 53.363365,121.62292 53.366798,121.635 53.371044,121.64644 53.373333,121.66065 53.377907,121.66735 53.382805,121.67487 53.385582,121.68401 53.389175,121.69724 53.389996,121.70394 53.390156,121.71096 53.388359,121.71848 53.386398,121.72583 53.385582,121.73253 53.385746,121.73727 53.386726,121.74249 53.387871,121.7536 53.3913,121.7652 53.394894,121.77647 53.397671,121.7848 53.399796,121.79182 53.402573,121.80359 53.407475,121.80996 53.410088,121.81829 53.413353,121.82303 53.414333,121.82874 53.414333,121.83773 53.415314,121.84541 53.416294,121.85259 53.420052,121.85978 53.422993,121.86632 53.424953,121.87318 53.425442,121.8784 53.424789,121.88968 53.422829,121.89866 53.421032,121.90503 53.420216,121.90977 53.420868,121.91386 53.421848,121.91924 53.422993,121.92382 53.423809,121.9297 53.424625,121.9426 53.426258,121.95355 53.428055,121.96482 53.428711,121.97299 53.429363,121.98164 53.429199,121.99308 53.428711,122.00533 53.428055,122.01791 53.426422,122.02951 53.424953,122.03963 53.422993,122.05009 53.420868,122.06202 53.419071,122.07313 53.418583,122.08946 53.42038,122.10302 53.423481,122.11527 53.429527,122.12458 53.438839,122.13504 53.448475,122.14239 53.456806,122.14729 53.462036,122.15203 53.46579,122.15791 53.468407,122.16183 53.469875,122.16656 53.470367,122.17588 53.470692,122.18453 53.469387,122.21181 53.462688,122.22129 53.460075,122.22619 53.459583,122.22995 53.460075,122.23828 53.460728,122.24596 53.462688,122.26475 53.470528,122.29145 53.479515,122.30191 53.487682,122.30877 53.493561,122.31824 53.49781,122.32968 53.500095,122.33948 53.500751,122.34765 53.499115,122.35124 53.495522,122.35451 53.491276,122.35712 53.486374,122.36105 53.483109,122.3666 53.476246,122.37019 53.47298,122.38849 53.461544,122.40548 53.451416,122.41659 53.44619,122.43129 53.442921,122.44599 53.442921,122.45644 53.44521,122.47082 53.453049,122.48258 53.454685,122.49369 53.454685,122.50676 53.452396,122.52048 53.451088,122.53649 53.451088,122.54596 53.453377,122.55805 53.45599,122.57308 53.457623,122.58647 53.461216,122.6002 53.462524,122.62372 53.461544,122.6394 53.460892,122.65018 53.460239,122.65836 53.459259,122.67273 53.457951,122.69495 53.458279,122.7188 53.458279,122.7384 53.460239,122.75343 53.460892,122.76878 53.459583,122.78152 53.458279,122.79852 53.45599,122.81158 53.455009,122.83412 53.455662,122.85144 53.455338,122.8668 53.457951,122.88607 53.460892,122.89522 53.463177,122.90502 53.464485,122.91221 53.467751,122.92168 53.473961,122.93704 53.481476,122.95338 53.48605,122.972 53.488007,122.98148 53.489967,122.99911 53.493561,123.01643 53.49683,123.02917 53.498463,123.03832 53.499115,123.04322 53.499443,123.0491 53.501732,123.05727 53.504669,123.06642 53.505325,123.07524 53.504997,123.10072 53.503036,123.11869 53.499443,123.13339 53.49585,123.14058 53.496502,123.16476 53.504017,123.17848 53.512184,123.19024 53.522312,123.20789 53.537342,123.22422 53.547142,123.24121 53.553352,123.2582 53.556618,123.27225 53.557926,123.28629 53.556618,123.30099 53.554657,123.31145 53.553677,123.32125 53.551392,123.32877 53.549431,123.33759 53.546818,123.34805 53.542568,123.36111 53.539955,123.38007 53.535381,123.39869 53.534077,123.41404 53.534401,123.42841 53.534077,123.43887 53.533096,123.44704 53.529827,123.45063 53.524601,123.45422 53.520679,123.45978 53.512184,123.46566 53.50761,123.47089 53.501732,123.47742 53.49781,123.48232 53.496178,123.4869 53.495522,123.49442 53.497158,123.49572 53.501076,123.49638 53.503689,123.49605 53.507286,123.49409 53.511204,123.49049 53.515778,123.48265 53.522968,123.47906 53.531136,123.47971 53.537994,123.48853 53.546162,123.49801 53.550735,123.50945 53.554333,123.51794 53.554657,123.52676 53.552044,123.53493 53.54845,123.5444 53.543549,123.54897 53.538651,123.54963 53.532768,123.54701 53.527866,123.53819 53.520027,123.5297 53.514473,123.52708 53.508919,123.52839 53.502384,123.53231 53.496178,123.53689 53.494541,123.5444 53.49585,123.55714 53.501732,123.564 53.508263,123.5676 53.516434,123.57119 53.529175,123.57446 53.53767,123.5774 53.542568,123.58197 53.54649,123.59047 53.54747,123.60484 53.546818,123.61269 53.544857,123.62314 53.542896,123.63261 53.540283,123.64176 53.535053,123.65483 53.527214,123.66757 53.516434,123.67247 53.51088,123.6777 53.504997,123.68456 53.499443,123.6875 53.49585,123.69044 53.493561,123.69501 53.491928,123.70187 53.490948,123.71135 53.490948,123.72376 53.49258,123.73063 53.493561,123.73912 53.494541,123.75382 53.493561,123.76395 53.492908,123.77375 53.490623,123.79532 53.487682,123.81067 53.486374,123.82505 53.487354,123.84367 53.48703,123.85838 53.485069,123.86556 53.483761,123.87275 53.48082,123.8868 53.474941,123.9028 53.467098,123.91849 53.458931,123.93025 53.454685,123.94201 53.448803,123.95247 53.443901,123.9603 53.438675,123.97076 53.432793,123.97828 53.427567,123.98351 53.421032,123.99102 53.412537,124.0018 53.404041,124.01225 53.398163,124.02402 53.394569,124.03186 53.392933,124.03905 53.392281,124.04688 53.390648,124.05538 53.388035,124.0629 53.385422,124.06878 53.379211,124.07237 53.369411,124.0776 53.363205,124.08348 53.360588,124.08871 53.358303,124.09328 53.354382,124.0985 53.35144,124.10439 53.348827,124.11517 53.345886,124.12366 53.344906,124.13445 53.345886,124.15241 53.353729,124.16451 53.358303,124.17496 53.363857,124.18378 53.368431,124.19228 53.371044,124.20469 53.374638,124.21416 53.374966,124.22266 53.373985,124.23376 53.372025,124.24357 53.368759,124.25565 53.361568,124.26643 53.355362,124.2829 53.350151,124.28312 53.349983))
資料入庫後,就可以開始應用開發了。:P
一切是這麼的簡單!
後續內容包括應用開發和索引、緩衝機制的實現
過段時間再寫