├── README.md
├── images
├── 0.7和1.0在栅格图层的差异.png
├── 0.7和1.0在矢量图层的差异.png
├── Class_Map.png
├── OpenLayers_3_API_Reference_Index.png
├── leaflet-pip-v2.png
├── leaflet-pip.png
├── map1.png
├── map_structure.png
├── ol3.jpg
├── osm-wiki.png
├── osm1.1.png
├── osm1.2.png
├── osm_arch.png
├── schema6_2014p.pdf
├── schema6_2014p.png
├── tilemail.png
├── tsmap1.jpg
├── tsmap2.jpg
├── tsmap3.jpg
├── tsmap4.jpg
├── world.png
└── zhanlijun.png
└── openlayer
├── README.md
├── images
└── logo.jpg
├── index.html
├── v3.19.1-dist.zip
└── v3.19.1-dist
├── ol-debug.js
├── ol.css
└── ol.js
/README.md:
--------------------------------------------------------------------------------
1 | ## GIS基础知识
2 |
3 | ### GIS基本组件
4 |
5 | * **地图数据库**:提供地图数据,例如OSM的planet.osm可以导入PostgreSQL作为地图数据库
6 |
7 | * **瓦片服务器**:负责生成一系列的瓦片(tiles),这些瓦片通常为256像素的方块,瓦片组在一起形成地图。对于Google Map,瓦片服务器是Google提供的,用户不能接触其地图数据库;对于OSM,地图数据库是开放的,可以随意下载,需要自己搭建瓦片服务器
8 |
9 | * **前端API**:用于浏览器的JavaScript API,或者用于移动客户端的同功API。例如OpenLayers、Leaflet。
10 |
11 |
12 |
13 | ### 坐标参考系统(Coordinate Reference Systems)
14 |
15 | 又称空间参考系统(spatial reference system,SRS),是基于二维坐标的,用于定位局部、区域或者全球地理信息资源的体系。CRS定义了一种地图映射规则、与其它CRS之间进行转化的算法。CRS是GIS系统的基础。
16 |
17 | 最常用的两种CRS为:
18 |
19 |
20 |
21 | | CRS |
22 | 说明 |
23 |
24 |
25 |
26 | | EPSG:4326 |
27 |
28 | 以经纬度直接作为X(经度)、Y(维度)坐标,南纬、西经采用负数表示
29 | 投影范围: -180.0000, -85.0600, 180.0000, 85.0600
30 | |
31 |
32 |
33 | | EPSG:3857 |
34 |
35 | 主要用于Web地图等应用程序,最初由Google地图提出,故经常称为900913,基于椭圆形墨卡托(ellipsoidal Mercator )投影
36 | 投影范围: -180.0000, -90.0000, 180.0000, 90.0000
37 | |
38 |
39 |
40 |
41 |
42 |
43 | ## OpenStreetMap基础知识
44 |
45 | ### OpenStreetMap的优势
46 |
47 | * 地图数据开源,人人可以编辑,并且可以完整的下载,部署私有的地图服务器
48 | * 内容丰富,比起ESRI Shapefiles的点、面、线,支持更多复杂的元素
49 | * 生态圈活跃,从地图数据、数据库、地图渲染、瓦片服务器、前端API,到桌面、Web地图设计工具,具有大量优秀的开源组件
50 |
51 | ### OpenStreetMap生态圈
52 |
53 | 
54 |
55 |
56 | ## 搭建地图服务器
57 |
58 | ### Windows下搭建OSM服务器的详细步骤
59 |
60 | 目前网络上的例子,大多是在Linux下搭建OSM服务器。实际项目中由于客户现场环境的限制,可能必须使用Windows Server,故本文详细记录Windows下的搭建步骤,供各位参考。
61 |
62 | * **系统架构**
63 |
64 |
65 | 上图中红色部分为本文主要使用的组件,我们把这些组件全部安装到一个目录%OSM_STACK%下
66 |
67 | * **下载地图**
68 |
69 | 区域地图,可从这里下载:[http://download.geofabrik.de/](http://download.geofabrik.de/)
70 | 全球地图,可从这里下载:[http://ftp.heanet.ie/mirrors/openstreetmap.org/planet/2015/planet-150105.osm.bz2](http://ftp.heanet.ie/mirrors/openstreetmap.org/planet/2015/planet-150105.osm.bz2)
71 |
72 | * **安装Python**
73 |
74 | 安装Python 2.7.x到%OSM_STACK%\python,并加入PATH环境变量,下载地址:[https://www.python.org/ftp/python/2.7.9/python-2.7.9.msi](https://www.python.org/ftp/python/2.7.9/python-2.7.9.msi)
75 | 为避免后续需要下载依赖的模块,可以安装便携版的Python,集成了很多常用模块,安装后把App目录里面的所有文件拷贝到%OSM_STACK%\python即可,下载地址:[http://ftp.osuosl.org/pub/portablepython/v2.7/PortablePython_2.7.6.1.exe](http://ftp.osuosl.org/pub/portablepython/v2.7/PortablePython_2.7.6.1.exe)
76 |
77 | * **安装PostgreSQL和PostGIS**
78 |
79 | 最好下载PostgreSQL 9.0以上或者 8.3版,8.4存在性能问题。
80 | 9.4的下载地址:[http://get.enterprisedb.com/postgresql/postgresql-9.4.0-1-windows-binaries.zip](http://get.enterprisedb.com/postgresql/postgresql-9.4.0-1-windows-binaries.zip)
81 | 解压到%OSM_STACK%\psql
82 | 下载PostGIS:[http://download.osgeo.org/postgis/windows/pg94/](http://download.osgeo.org/postgis/windows/pg94/)
83 | 解压覆盖到%OSM_STACK%\psql
84 | 注意:上述的PostgreSQL是绿色版的,对MSVC12有C运行时库、C++标准库有依赖,如果你的机器缺少msvcp120.dll、msvcr120.dll这两个DLL,可以下载:Visual C++ Redistributable Packages for Visual Studio 2013并安装,亦可直接拷贝这两个文件到%OSM_STACK%\psql\bin下
85 |
86 | 下面的脚本说明如何初始化PostgreSQL、创建用户gisuser、数据库gis、激活PostGIS:
87 | ```
88 | @echo off
89 |
90 | pushd "%~dp0"
91 |
92 | SET "PGDATA=%PSQL_HOME%\data"
93 | SET "PGDATABASE=postgres"
94 | SET "PGUSER=postgres"
95 | SET "PGPORT=5439"
96 | SET "PGLOCALEDIR=%PSQL_HOME%\share\locale"
97 | rem GIS databse name and owner
98 | SET "GISDATABASE=gis"
99 | SET "GISUSER=gisuser"
100 |
101 | echo ****** Prepare to initializing PostgreSQL ******
102 | rem 初始化数据库,这将生成data目录,并且根据机器硬件环境生成配置文件
103 | initdb -U %PGUSER% -A trust
104 |
105 | echo ****** Prepare to start PostgreSQL ******
106 | rem 启动数据库,日志记录到pgsql.log,等待启动完成
107 | pg_ctl -w -l %PSQL_HOME%\pgsql.log start
108 |
109 | echo ****** Creating user %GISUSER% ******
110 | rem 创建GIS专门用户
111 | createuser -U %PGUSER% %GISUSER%
112 | echo ****** Creating database %GISDATABASE% ******
113 | rem 创建GIS专用数据库
114 | createdb -U %PGUSER% -E UTF8 -O %GISUSER% %GISDATABASE%
115 | echo ****** Installing procedural language into %GISDATABASE% ******
116 | rem 添加扩展
117 | createlang -U %PGUSER% plpgsql %GISDATABASE%
118 | echo ****** Activating PostGIS for %GISDATABASE% ******
119 | rem 为GIS数据库激活PostGIS支持
120 | psql -U %PGUSER% -d %GISDATABASE% -f "%PSQL_HOME%\share\contrib\postgis-2.1\postgis.sql"
121 | psql -U %PGUSER% -d %GISDATABASE% -f "%PSQL_HOME%\share\contrib\postgis-2.1\spatial_ref_sys.sql"
122 | rem After the activation, the following command should list the tables geometry_columns and spatial_ref_sys:
123 | rem 下面这一句不能在UTF-8代码页下运行,会报内存不足的错误
124 | psql --username=%GISUSER% --dbname=%GISDATABASE% --command="\d"
125 | rem 停止数据库
126 | pg_ctl -w stop
127 | ```
128 |
129 | 打开%OSM_STACK%\psql\data\postgresql.conf,修改以下参数,以提高性能(根据硬件配置调整):
130 |
131 | ```
132 | shared_buffers = 512MB
133 | checkpoint_segments = 20
134 | maintenance_work_mem = 256MB
135 | autovacuum = off
136 |
137 | kernel.shmmax=536870912
138 | ```
139 |
140 | * **导入地图到数据库**
141 |
142 | 使用命令行工具osm2pgsql 可以把OpenStreetMap地图数据导入到启用了postGIS的PostgreSQL数据库中。尽管mapnik可以直接渲染OSM XML原始数据,但是导入PostGIS可以使用更多的高级特性。
143 | 从这里下载此工具:[http://customdebug.com/osm/osm2pgsql.zip](http://customdebug.com/osm/osm2pgsql.zip)
144 | 使用示例:
145 | ```
146 | osm2pgsql -c -d gis -U postgres -H localhost -P 5439 -S default.style -C 600 beijing.osm.bz2
147 | ```
148 | default.style是 导入时需要的样式定义文件,内容如下:
149 | ```
150 | # OsmType Tag DataType Flags
151 | node,way access text linear
152 | node,way addr:housename text linear
153 | node,way addr:housenumber text linear
154 | node,way addr:interpolation text linear
155 | node,way admin_level text linear
156 | node,way aerialway text linear
157 | node,way aeroway text polygon
158 | node,way amenity text polygon
159 | node,way area text
160 | node,way barrier text linear
161 | node,way bicycle text
162 | node,way brand text linear
163 | node,way bridge text linear
164 | node,way boundary text linear
165 | node,way building text polygon
166 | node capital text linear
167 | node,way construction text linear
168 | node,way covered text linear
169 | node,way culvert text linear
170 | node,way cutting text linear
171 | node,way denomination text linear
172 | node,way disused text linear
173 | node ele text linear
174 | node,way embankment text linear
175 | node,way foot text linear
176 | node,way generator:source text linear
177 | node,way harbour text polygon
178 | node,way highway text linear
179 | node,way historic text polygon
180 | node,way horse text linear
181 | node,way intermittent text linear
182 | node,way junction text linear
183 | node,way landuse text polygon
184 | node,way layer text linear
185 | node,way leisure text polygon
186 | node,way lock text linear
187 | node,way man_made text polygon
188 | node,way military text polygon
189 | node,way motorcar text linear
190 | node,way name text linear
191 | node,way natural text polygon
192 | node,way office text polygon
193 | node,way oneway text linear
194 | node,way operator text linear
195 | node,way place text polygon
196 | node poi text
197 | node,way population text linear
198 | node,way power text polygon
199 | node,way power_source text linear
200 | node,way public_transport text polygon
201 | node,way railway text linear
202 | node,way ref text linear
203 | node,way religion text nocache
204 | node,way route text linear
205 | node,way service text linear
206 | node,way shop text polygon
207 | node,way sport text polygon
208 | node,way surface text linear
209 | node,way toll text linear
210 | node,way tourism text polygon
211 | node,way tower:type text linear
212 | way tracktype text linear
213 | node,way tunnel text linear
214 | node,way water text polygon
215 | node,way waterway text polygon
216 | node,way wetland text polygon
217 | node,way width text linear
218 | node,way wood text linear
219 | node,way z_order int4 linear
220 | way way_area real
221 | ```
222 |
223 | * **安装mapnik**
224 |
225 | 从[http://mapnik.org/download/](http://mapnik.org/download/)下载mapnik,解压到%OSM_STACK%\mapnik,将其bin、lib目录加入PATH环境变量,python\2.7\site-packages加入PYTHONPATH环境变量。
226 | 在mapnik中,一个Map可以包含若干个图层(Layer),每个层可以独立着色,即可为每个层定制样式(Style),每个样式由若干个规则组成(Rule),每个规则由是由若干个符号定制。
227 |
228 | * **生成mapnik的样式文件**
229 |
230 | 从[https://www.mapbox.com/tilemill/](https://www.mapbox.com/tilemill/)下载并安装TileMill,该工具用于编辑地图元素的样式,我们主要用它导出mapnik的样式文件。
231 | OpenStreetMap官方使用的样式托管在GitHub上:[https://github.com/gravitystorm/openstreetmap-carto](https://github.com/gravitystorm/openstreetmap-carto)。下载后解压到C:\Users\用户名\Documents\MapBox\project
232 | 打开Cygwin,或者在Linux下执行get-shapefiles.sh,下载并处理openstreetmap-cart中缺少的data目录:
233 | ```
234 | #以Cygwin为例
235 |
236 | apt-cyg install curl
237 | apt-cyg install unzip
238 |
239 | #编译gdal,在Ubuntu下只需要sudo apt-get install gdal-bin即可
240 | #你也可以到http://download.gisinternals.com/下载编译好的二进制文件供Cygwin使用
241 | wget http://download.osgeo.org/gdal/1.11.1/gdal-1.11.1.tar.gz
242 | tar vzxf gdal-1.11.1.tar.gz
243 | rm gdal-1.11.1.tar.gz
244 | cd gdal-1.11.1/
245 | ./autogen.sh
246 | ./configure --host=mingw32 --without-libtool --without-python
247 | make
248 | make install
249 |
250 | cd /cygdrive/c/Users/Suigintou/Documents/MapBox/project/openstreetmap-carto-master
251 | ./get-shapefiles.sh
252 | #需要下载的数据较多,耐心等待
253 | #如果出现Failed to connect to planet.openstreetmap.org port 80: Network is unreachable,则添加下一行到host文件
254 | #193.63.75.107 planet.openstreetmap.org
255 | ```
256 | 下载、处理完成后,打开TileMill,可以看到OpenStreetMap Carto这个项目,点击打开,然后点击右上角按钮,导出mapnik样式文件,如下图:
257 |
258 |
259 |
260 | 导出成功后,打开XML文件,搜寻里面的类似:“C:\Users\用户名\Documents\MapBox\project\osm-carto\……”绝对路径,将其删除,并把路径中剩余部分的反斜杠改为正斜杠,修改完毕后,路径类似:“data/simplified-land-polygons-complete-3857/simplified_land_polygons.shp”,把文件移动到%OSM_STACK%\osm-carto目录下。
261 | 把整个openstreetmap-carto-master目录(就是TileMill编辑的工程)覆盖到%OSM_STACK%\osm-carto。
262 |
263 | * **安装和配置TileStache**
264 |
265 | 安装便携版Python后,只需要执行下面的脚本:
266 | ```
267 | easy_install tilestache
268 |
269 | rem 可能需要检查以下依赖模块是否安装
270 | easy_install PIL
271 | easy_install ModestMaps
272 | easy_install SimpleJSON
273 | ```
274 | 在Windows上,如果使用的是Python 2.7.6,需要修改一下__init__.py的源码,否则运行时会报错:
275 | UnicodeDecodeError: utf8 codec can't decode byte 0xb0 in position 1: invalid start byte,这是Python的一个BUG。
276 | ```
277 | import sys
278 | reload(sys)
279 | sys.setdefaultencoding('gb18030') #添加上面三行即可
280 | config_dict = json_load(urlopen(configpath))
281 | ```
282 | 安装完毕后,通过下面的脚本即可启动TileStache的Web服务(基于 Werkzeug,一个WSGI工具库):
283 | ```
284 | echo ****** Prepare to start TileStache ******
285 | SET "TILE_STACHE_SCR=%PYTHON_HOME%\Scripts\tilestache-server.py"
286 |
287 | python "%TILE_STACHE_SCR:\=/%" -p 5539 -c tilestache.cfg
288 | ```
289 | 其中tilestache.cfg是TileStache使用的配置文件,我们先使用下面这个做测试:
290 | ```
291 | {
292 | "_comment": "tilestache.cfg包含两个顶级元素,分别实现缓存、图层的配置"
293 | "cache":
294 | {
295 | "name": "Disk",
296 | "path": "F:/Temp/tiles-cache"
297 | },
298 | "layers":
299 | {
300 | "osm":
301 | {
302 | "provider": {"name": "proxy", "provider": "OPENSTREETMAP"}
303 | }
304 | }
305 | }
306 | ```
307 | 启动TileStache后,可以通过以下几个URL来测试:
308 |
309 |
310 | | URL |
311 | 说明 |
312 |
313 |
314 |
315 | | http://127.0.0.1:5539/osm/preview.html |
316 | 交互式的地图预览 |
317 |
318 |
319 | | http://127.0.0.1:5539/osm/0/0/0.png |
320 |
321 | 显示一个静态瓦片,TileStache的URL风格类似于Google地图:
322 | http://host:port/{layer name}/{zoom}/{column}/{row}.{extension}
323 | |
324 |
325 |
326 |
327 |
328 | * **集成TileStache与mapnik**
329 |
330 | 


331 |
332 | tilestache.cfg可以配置为这样:
333 | ```
334 | {
335 | "cache":
336 | {
337 | "name": "Disk",
338 | "path": "D:/Programs/OsmStack/tilestache/cache"
339 | },
340 | "layers":
341 | {
342 | "osm":
343 | {
344 | "provider": {
345 | "name": "mapnik",
346 | "mapfile": "file://D:/Programs/OsmStack/osm-carto/mapnik-style.xml",
347 | "fonts" : "D:/Programs/OsmStack/mapnik/fonts"
348 | },
349 | "metatile" : {
350 | "rows" : "4",
351 | "columns" : "4",
352 | "buffer" : "64"
353 | },
354 | "preview" : {
355 | "lat" : "39.9396",
356 | "lon" : "116.3488",
357 | "zoom" : "12",
358 | "ext" : "png"
359 | }
360 | }
361 | }
362 | }
363 | ```
364 | 注意其中的mapfile对应的路径,必须从Windows路径格式改为URI形式,例如:D:\Programs\Osmstack 改为 file://D:/Programs/Osmstack
365 | tilestache.cfg改好后,启动TileStache Web服务,浏览器打开http://127.0.0.1:5539/osm/preview.html进行测试。
366 |
367 | * **绿化批处理脚本示意**
368 |
369 | 在Windows下,可以参考下面三个脚本,分别完成地图服务器的初始化、启动、停止:
370 |
371 | init.bat
372 | ```
373 | @echo off
374 | chcp 437
375 | pushd "%~dp0"
376 |
377 | set "OSMSTACK_HOME=%CD%"
378 | set "OSM_DIR=%OSMSTACK_HOME%\osm"
379 | set "MAPNIK_HOME=%OSMSTACK_HOME%\mapnik"
380 | set "PYTHON_HOME=%OSMSTACK_HOME%\python"
381 | set "PSQL_HOME=%OSMSTACK_HOME%\psql"
382 | set "OSM2PQSQL_HOME=%OSMSTACK_HOME%\osm2pgsql"
383 | set "PATH=%OSM2PQSQL_HOME%;%MAPNIK_HOME%\lib;%MAPNIK_HOME%\bin;%PSQL_HOME%\bin;%PYTHON_HOME%;%PYTHON_HOME%\Scripts;%PATH%"
384 | set "PYTHONPATH=%MAPNIK_HOME%\python\2.7\site-packages;%PYTHONPATH%"
385 |
386 | SET "PGDATA=%PSQL_HOME%\data"
387 | SET "PGDATABASE=postgres"
388 | SET "PGUSER=postgres"
389 | SET "PGPORT=5432"
390 | SET "PGLOCALEDIR=%PSQL_HOME%\share\locale"
391 | rem GIS databse name and owner
392 | SET "GISDATABASE=gis"
393 | SET "GISUSER=gisuser"
394 |
395 | echo ****** Prepare to initializing PostgreSQL ******
396 | initdb -U %PGUSER% --auth=trust --auth-host=trust --auth-local=trust --pwprompt -E UTF8
397 | copy %PSQL_HOME%\postgresql.conf %PSQL_HOME%\data\postgresql.conf /y
398 |
399 | echo ****** Prepare to start PostgreSQL ******
400 | pg_ctl -w -l %PSQL_HOME%\pgsql.log start
401 |
402 | echo ****** Creating user %GISUSER% ******
403 | createuser -U %PGUSER% -P %GISUSER%
404 | echo ****** Creating database %GISDATABASE% ******
405 | createdb -U %PGUSER% -E UTF8 -O %GISUSER% %GISDATABASE%
406 | echo ****** Installing procedural language into %GISDATABASE% ******
407 | createlang -U %PGUSER% plpgsql %GISDATABASE%
408 | echo ****** Activating PostGIS for %GISDATABASE% ******
409 |
410 | psql -U %PGUSER% -d %GISDATABASE% -f "%PSQL_HOME%\share\contrib\postgis-2.1\postgis.sql"
411 | psql -U %PGUSER% -d %GISDATABASE% -f "%PSQL_HOME%\share\contrib\postgis-2.1\spatial_ref_sys.sql"
412 | rem After the activation, the following command should list the tables geometry_columns and spatial_ref_sys:
413 | psql --username=%GISUSER% --dbname=%GISDATABASE% --command="\d"
414 |
415 | echo ****** Installing extension hstore for %GISDATABASE% ******
416 | echo create extension hstore; | psql -U %PGUSER% -d %GISDATABASE%
417 |
418 |
419 | echo ****** Import OSM data into %GISDATABASE% ******
420 | echo Please input osm package name ( without suffix '.osm.bz2' ), Press Enter to skip :
421 | set /p OSM_NAME=
422 | if defined OSM_NAME (
423 | osm2pgsql -c -d gis -U %PGUSER% -H localhost -P %PGPORT% --hstore -S %OSM2PQSQL_HOME%\openstreetmap-carto.style -C 600 %OSM_DIR%\%OSM_NAME%.osm.bz2
424 | )
425 |
426 | echo ****** Processing TilesTache config file ******
427 | set __OSM_PATH=%~p0
428 | set __OSM_PATH=%__OSM_PATH:\=/%
429 | python "tilestache/generate-cfg.py" %__OSM_PATH%
430 |
431 | echo ****** Prepare to stop PostgreSQL ******
432 | pg_ctl -w stop
433 |
434 | :end
435 | ```
436 |
437 | startup.bat
438 | ```
439 | @echo off
440 | chcp 437
441 | pushd "%~dp0"
442 |
443 | set "OSMSTACK_HOME=%CD%"
444 | set "OSM_DIR=%OSMSTACK_HOME%\osm"
445 | set "MAPNIK_HOME=%OSMSTACK_HOME%\mapnik"
446 | set "PYTHON_HOME=%OSMSTACK_HOME%\python"
447 | set "PSQL_HOME=%OSMSTACK_HOME%\psql"
448 | set "OSM2PQSQL_HOME=%OSMSTACK_HOME%\osm2pgsql"
449 | set "PATH=%OSM2PQSQL_HOME%;%MAPNIK_HOME%\lib;%MAPNIK_HOME%\bin;%PSQL_HOME%\bin;%PYTHON_HOME%;%PYTHON_HOME%\Scripts;%PATH%"
450 | set "PYTHONPATH=%MAPNIK_HOME%\python\2.7\site-packages;%PYTHONPATH%"
451 |
452 |
453 | SET "PGDATA=%PSQL_HOME%\data"
454 | SET "PGDATABASE=postgres"
455 | SET "PGUSER=postgres"
456 | SET "PGPORT=5432"
457 | SET "PGLOCALEDIR=%PSQL_HOME%\share\locale"
458 |
459 | echo ****** Prepare to start PostgreSQL ******
460 | pg_ctl -w -l%PSQL_HOME%\pgsql.log start
461 |
462 | echo ****** Prepare to start TileStache ******
463 | SET "TILE_STACHE_SCR=%PYTHON_HOME%\Scripts\tilestache-server.py"
464 |
465 | python "%TILE_STACHE_SCR:\=/%" -i 0.0.0.0 -p 5539 -c tilestache/osm.cfg
466 | ```
467 |
468 | shutdown.bat
469 | ```
470 | @echo off
471 | chcp 437
472 | pushd "%~dp0"
473 |
474 | set "OSMSTACK_HOME=%CD%"
475 | set "MAPNIK_HOME=%OSMSTACK_HOME%\mapnik"
476 | set "PYTHON_HOME=%OSMSTACK_HOME%\python"
477 | set "PSQL_HOME=%OSMSTACK_HOME%\psql"
478 | set "PATH=%MAPNIK_HOME%\lib;%MAPNIK_HOME%\bin;%PSQL_HOME%\bin;%PYTHON_HOME%;%PATH%"
479 |
480 | SET "PGDATA=%PSQL_HOME%\data"
481 | SET "PGDATABASE=postgres"
482 | SET "PGUSER=postgres"
483 | SET "PGPORT=5432"
484 | SET "PGLOCALEDIR=%PSQL_HOME%\share\locale"
485 |
486 | echo ****** Prepare to stop PostgreSQL ******
487 | pg_ctl -w stop
488 | ```
489 |
490 |
491 | > 以下是着重要学习的!!!
492 |
493 | ## 通过前端API使用OSM瓦片
494 |
495 | ### 使用OpenLayers
496 |
497 | OpenLayers很久以来一直是在网页中嵌入OSM地图的标准选择,它是一个成熟、综合的JS库,学习曲线较为平缓,提供大量的特性,包括完整的投影支持(full projection support)、矢量绘图、预览地图(overview maps)等等。
498 |
499 | 下面是一个简单的例子:
500 | ```
501 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
502 |
503 |
504 |
505 |
506 |
510 |
511 | OpenLayers3 Example
512 |
513 |
514 |
515 |
516 |
610 |
611 |
612 | ```
613 |
614 | ### 使用Leaflet
615 |
616 | Leaflet是一个近来迅速流行的JavaScript库,比起OpenLayers它更小小巧、简单,对于简单寻常的需求,Leaflet是个好的选择。
617 |
618 | 下面是一个简单的例子:
619 | ```
620 | <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
621 |
622 |
623 |
624 | Leaflet Example
625 |
626 |
627 |
669 |
670 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 | ```
683 |
684 | 原文:https://blog.gmem.cc/setup-openstreetmap-server
685 |
--------------------------------------------------------------------------------
/images/0.7和1.0在栅格图层的差异.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/0.7和1.0在栅格图层的差异.png
--------------------------------------------------------------------------------
/images/0.7和1.0在矢量图层的差异.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/0.7和1.0在矢量图层的差异.png
--------------------------------------------------------------------------------
/images/Class_Map.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/Class_Map.png
--------------------------------------------------------------------------------
/images/OpenLayers_3_API_Reference_Index.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/OpenLayers_3_API_Reference_Index.png
--------------------------------------------------------------------------------
/images/leaflet-pip-v2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/leaflet-pip-v2.png
--------------------------------------------------------------------------------
/images/leaflet-pip.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/leaflet-pip.png
--------------------------------------------------------------------------------
/images/map1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/map1.png
--------------------------------------------------------------------------------
/images/map_structure.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/map_structure.png
--------------------------------------------------------------------------------
/images/ol3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/ol3.jpg
--------------------------------------------------------------------------------
/images/osm-wiki.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/osm-wiki.png
--------------------------------------------------------------------------------
/images/osm1.1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/osm1.1.png
--------------------------------------------------------------------------------
/images/osm1.2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/osm1.2.png
--------------------------------------------------------------------------------
/images/osm_arch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/osm_arch.png
--------------------------------------------------------------------------------
/images/schema6_2014p.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/schema6_2014p.pdf
--------------------------------------------------------------------------------
/images/schema6_2014p.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/schema6_2014p.png
--------------------------------------------------------------------------------
/images/tilemail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/tilemail.png
--------------------------------------------------------------------------------
/images/tsmap1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/tsmap1.jpg
--------------------------------------------------------------------------------
/images/tsmap2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/tsmap2.jpg
--------------------------------------------------------------------------------
/images/tsmap3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/tsmap3.jpg
--------------------------------------------------------------------------------
/images/tsmap4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/tsmap4.jpg
--------------------------------------------------------------------------------
/images/world.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/world.png
--------------------------------------------------------------------------------
/images/zhanlijun.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/images/zhanlijun.png
--------------------------------------------------------------------------------
/openlayer/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/openlayer/images/logo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/openlayer/images/logo.jpg
--------------------------------------------------------------------------------
/openlayer/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | OpenLayers 3地图示例
8 |
9 |
10 |
11 |
12 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |

122 |
123 |
197 |
198 |
199 |
--------------------------------------------------------------------------------
/openlayer/v3.19.1-dist.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/RLwu/GIS/aa4497d4ae3549925e51ddd06220884df8bdb533/openlayer/v3.19.1-dist.zip
--------------------------------------------------------------------------------
/openlayer/v3.19.1-dist/ol.css:
--------------------------------------------------------------------------------
1 | .ol-control,.ol-scale-line{position:absolute;padding:2px}.ol-box{box-sizing:border-box;border-radius:2px;border:2px solid #00f}.ol-mouse-position{top:8px;right:8px;position:absolute}.ol-scale-line{background:rgba(0,60,136,.3);border-radius:4px;bottom:8px;left:8px}.ol-scale-line-inner{border:1px solid #eee;border-top:none;color:#eee;font-size:10px;text-align:center;margin:1px;will-change:contents,width}.ol-overlay-container{will-change:left,right,top,bottom}.ol-unsupported{display:none}.ol-viewport .ol-unselectable{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-tap-highlight-color:transparent}.ol-control{background-color:rgba(255,255,255,.4);border-radius:4px}.ol-control:hover{background-color:rgba(255,255,255,.6)}.ol-zoom{top:.5em;left:.5em}.ol-rotate{top:.5em;right:.5em;transition:opacity .25s linear,visibility 0s linear}.ol-rotate.ol-hidden{opacity:0;visibility:hidden;transition:opacity .25s linear,visibility 0s linear .25s}.ol-zoom-extent{top:4.643em;left:.5em}.ol-full-screen{right:.5em;top:.5em}@media print{.ol-control{display:none}}.ol-control button{display:block;margin:1px;padding:0;color:#fff;font-size:1.14em;font-weight:700;text-decoration:none;text-align:center;height:1.375em;width:1.375em;line-height:.4em;background-color:rgba(0,60,136,.5);border:none;border-radius:2px}.ol-control button::-moz-focus-inner{border:none;padding:0}.ol-zoom-extent button{line-height:1.4em}.ol-compass{display:block;font-weight:400;font-size:1.2em;will-change:transform}.ol-touch .ol-control button{font-size:1.5em}.ol-touch .ol-zoom-extent{top:5.5em}.ol-control button:focus,.ol-control button:hover{text-decoration:none;background-color:rgba(0,60,136,.7)}.ol-zoom .ol-zoom-in{border-radius:2px 2px 0 0}.ol-zoom .ol-zoom-out{border-radius:0 0 2px 2px}.ol-attribution{text-align:right;bottom:.5em;right:.5em;max-width:calc(100% - 1.3em)}.ol-attribution ul{margin:0;padding:0 .5em;font-size:.7rem;line-height:1.375em;color:#000;text-shadow:0 0 2px #fff}.ol-attribution li{display:inline;list-style:none;line-height:inherit}.ol-attribution li:not(:last-child):after{content:" "}.ol-attribution img{max-height:2em;max-width:inherit;vertical-align:middle}.ol-attribution button,.ol-attribution ul{display:inline-block}.ol-attribution.ol-collapsed ul{display:none}.ol-attribution.ol-logo-only ul{display:block}.ol-attribution:not(.ol-collapsed){background:rgba(255,255,255,.8)}.ol-attribution.ol-uncollapsible{bottom:0;right:0;border-radius:4px 0 0;height:1.1em;line-height:1em}.ol-attribution.ol-logo-only{background:0 0;bottom:.4em;height:1.1em;line-height:1em}.ol-attribution.ol-uncollapsible img{margin-top:-.2em;max-height:1.6em}.ol-attribution.ol-logo-only button,.ol-attribution.ol-uncollapsible button{display:none}.ol-zoomslider{top:4.5em;left:.5em;height:200px}.ol-zoomslider button{position:relative;height:10px}.ol-touch .ol-zoomslider{top:5.5em}.ol-overviewmap{left:.5em;bottom:.5em}.ol-overviewmap.ol-uncollapsible{bottom:0;left:0;border-radius:0 4px 0 0}.ol-overviewmap .ol-overviewmap-map,.ol-overviewmap button{display:inline-block}.ol-overviewmap .ol-overviewmap-map{border:1px solid #7b98bc;height:150px;margin:2px;width:150px}.ol-overviewmap:not(.ol-collapsed) button{bottom:1px;left:2px;position:absolute}.ol-overviewmap.ol-collapsed .ol-overviewmap-map,.ol-overviewmap.ol-uncollapsible button{display:none}.ol-overviewmap:not(.ol-collapsed){background:rgba(255,255,255,.8)}.ol-overviewmap-box{border:2px dotted rgba(0,60,136,.7)}
--------------------------------------------------------------------------------