èªç±ã倧奜ããªOpenStreetMapãããžã§ã¯ãã§ã¯ãå°çãªããžã§ã¯ãã®ååãç°ãªãèšèªã§ä¿åã§ããããšãç¥ãããŠããŸãã ãã®ããã«ã nameïŒru ã nameïŒenãŸãã¯nameïŒesãªã©ã®ç¹å¥ãªã¿ã°ã䜿çšãããŸããæãéèŠãªã®ã¯ã OpenStreetMapåå è ã«ãã£ãŠåããããŸãã ãã¡ãããæã詳现ãªç¢æã¯ããŠãŒã¶ãŒã話ãèšèªã§äœæãããŸãïŒãã·ã¢èª-ãã·ã¢èªãäžåœ-äžåœèªãã¢ããªã«è«žåœ-çŸå°èªã ãã€ãžã§ãªã¢ã®äžéšã®éè·¯ã§ãã·ã¢èªã®ç¿»èš³ãè¡ãããå¯èœæ§ã¯ã»ãšãã©ãããŸããããããã§ãäž»èŠãªå°çãªããžã§ã¯ãïŒåœãéœåžãæ²³å·ãªã©ïŒã«ã¯ç¿»èš³ããããŸãã ãã®å°ããªå°å³æ å ±ã¯ããã·ã¢èªã話ããŠãŒã¶ãŒããããšãã°äžåœã®å°å³ãéããŠããã®äžã®äž»èŠãªååãèŠã€ããã®ã«ååã§ãã ãããã£ãŠããªãœãŒã¹ã¯ããå°ããŠãŒã¶ãŒãã¬ã³ããªãŒã«ãªããŸãã
ç¬èªã®Webã«ãŒãã§ãããã®ç¿»èš³ã¿ã°ã䜿çšããæ¹æ³ã«é¢ããè³¢æãªæ瀺ãèŠã€ããããšãç®æããŠããå ŽåãRunetã®ã¹ããŒã¹å šäœãŸãã¯ã€ã³ã¿ãŒãããã§ããã OpenStreetMap Webãããã®ããŒã«ãªãŒãŒã·ã§ã³ã®ããŸããŸãªåŽé¢ã«é¢ããæ å ±ã®ã¿ãæ£åšããŠããŸããããç®±å ¥ããã®æ瀺ã¯ã»ãšãã©èŠã€ãããŸããã äžæ¹ã§ããã®åé¡ã¯æãé£ããã¢ãŒããã¯ãã£äžã®åé¡ã§ã¯ãããŸããããªããªãã ãã®ãã¯ãããžãŒã¯ã OpenStreetMapãããžã§ã¯ãèªäœã®äžéšãšããŠéçºãããŸããã ãããäžæ¹ã§ãæåãªRostelecom Satelliteãªã©ã®ããŒã«ã©ã€ãºãããWebãããã®å®æãããããžã§ã¯ãã§ã¯ãããŒã«ãªãŒãŒã·ã§ã³ã®åé¡ã¯è§£æ±ºãããéçºè ãçŽé¢ããåé¡ãšãããã®è§£æ±ºæ¹æ³ã¯ITã³ãã¥ããã£ã«ãã£ãŠè©±ãããŠããŸããã
å€èšèªãµããŒããåããWebãããã®ãã¶ã€ã³ããããŸããããããã¯è«ççã§äœ¿ãããããã®ã§ã¯ãããŸããã
ãã®èšäºã®ç®çã¯ããã®ç°çš®ã®æ å ±ãã OpenStreetMapããããããŒã«ã©ã€ãºããããã®å®å šãªæ瀺ã®åœ¢ã§ãŸãšããããšã§ãã ãã®èšäºã§ã¯ã OpenStreetMapããŒã¿ã«åºã¥ããŠåã«ã¿ã€ã«ãå±éããããšã«é¢ããæå°éã®æ å ±ãã Habré ã Gis-Lab'e ãããã³ä»ã®ç¹å¥ãªãããžã§ã¯ãã®ä»ã®åºçç©ã¯ããã®ãããã¯ã詳现ã«æããã«ããŠããŸãã ãã®èšäºã®ãã¬ãŒã ã¯ãŒã¯ã§ã¯ã ããç¥ãããŠããæ瀺ã«åŸã£ãŠãã¿ã€ã«ã®ãªããžããªïŒWebãããã€ã¡ãŒãžããã¹ãããããããã€ã¡ãŒãžã¿ã€ã«ïŒããããã€ããŸããã詳现ãªèª¬æã¯è¡ããŸããã ã¿ã€ã«ã¹ãã¬ãŒãžã®å±éã«é¢ãã質åãããå Žåã¯ãæåã«èšèŒãããŠããæé ãã芧ãã ããã
ãããã£ãŠãããã±ãŒãžãå¿ èŠã§ãïŒå¿ èŠãªãã¹ãŠã®äŸåé¢ä¿ãå«ãïŒïŒ
- PostgreSQL> = 8.4
- PostGIS> = 1.5 <2
- Python 2.x
- Mapnik> = 2
- osm2pgsql
- 転èŠ
ãã®èšäºã®ç®çã®ããã«ãæ¬æ Œçãªã¿ã€ã«ãµãŒããŒïŒApache httpdãmod_tileãããã³ã¬ã³ããªã³ã°æžã¿ïŒããããã€ããå¿ èŠã¯ãããŸããã ãã ããã¿ã€ã«ãµãŒããŒã®å±éã®æ¹åãã¯ãã«ã¯ä»¥äžã®ãšããã§ãã詳现ãªæé ã«ã€ããŠã¯ãäžèšã®ãªã³ã¯ãåç §ããŠãã ããã
1. OpenStreetMapãããã¯ã¿ãŒããŒã¿ãååŸãã
ãã®ããŒã¿ãïŒosm2pgsqlãŠãŒãã£ãªãã£ã䜿çšããŠïŒPostgresqlããŒã¿ããŒã¹ã«ã€ã³ããŒããããšãMapnikã¬ã³ããªã³ã°ããã±ãŒãžãã©ã¹ã¿ãŒã¿ã€ã«ãçæããŸãã
ãã®ããã OpenStreetMapãã©ãŒã®1ã€ãããXML圢åŒïŒOSMãã¡ã€ã«ïŒãŸãã¯å§çž®ãã€ããªPBF圢åŒã§æå®ãããé åã®ããããããŠã³ããŒãããŸãã
planetãã¡ã€ã«ã¯ã次ã®ã³ãã³ãã§ããŠã³ããŒãã§ããŸãã
wget http://download.bbbike.org/osm/planet/planet-latest.osm.pbf.md5 wget http://download.bbbike.org/osm/planet/planet-latest.osm.pbf md5sum planet-latest.osm.pbf
ãã®ããŒã¿ã¯éèŠã§ããããšã«æ³šæããŠãã ããã ããšãã°ãææPlanet.osmå šäœã®éå§çž®OSM XML圢åŒã®ãã¯ã¿ãŒããŒã¿ãå«ããã¡ã€ã«ã¯1TB以äžãXML圢åŒã§ã¯å§çž®bz2ã41.8GBããã€ããªPBF圢åŒ18.1GBã䜿çšããŸãã ãããã®åœ¢åŒã¯ãã¹ãŠåãããŒã¿ãä¿åããŸãã åœç¶ãææå šäœã§ã¯ãªãç¹å®ã®å°åã®ã¿ãå¿ èŠãªå Žåããããã®æ°å€ã¯ã¯ããã«å°ãããªããŸããããã©ãŒããããOSM XMLãOSM XMLãå§çž®bz2ãããã³PBFãã©ãŒãããã®ããŒã¿ããªã¥ãŒã ã®å²åã¯å€ãããŸããã Postgresqlã«ã€ã³ããŒãããåã«ãBZ2ããã³ãã€ããªåœ¢åŒPBFã§å§çž®ãããOSM XML圢åŒã®ãã¯ã¿ãŒããŒã¿ãååŠçïŒã¢ã³ããã¯ã解æïŒããããããããŠã³ããŒããããã¡ã€ã«ãPostgresqlããŒã¿ããŒã¹ã«ã€ã³ããŒãããæéãé·ããªãããšã«æ³šæããŠãã ããã ãã®ããã16GBã®RAMã2TBã®HDDïŒUbuntu 14.04 64xïŒãæèŒããã¯ã¢ããã³ã¢Core i5ãã·ã³ã§ã¯ã Planet.osm.pbfã®ã€ã³ããŒãã«2é±éããããŸããã åæ§ã®Planet.osm.bz2ãã¡ã€ã«ã®ã€ã³ããŒãã«ã¯ã1æ¡ã®æéãããããŸããã§ããã ç§ã®èãã§ã¯ãosm2pgsqlãŠãŒãã£ãªãã£ã¯RAMã®éãèŠæ±ããŠããŸãïŒæé©ãªã¡ã¢ãªç®¡çã®ãããosm2pgsqlãŠãŒãã£ãªãã£ã®--cacheããã³--cache-strategyããŒã®æ©èœã«ã€ããŠèªãã§ãã ããïŒãããã»ããµã³ã¢ã®é »åºŠãšæ°ïŒãã¡ã€ã«ã®è§£ææãããã»ããµã³ã¢ã®ããŒããå¶åŸ¡ããããã«åç §ããŠãã ããïŒ ïŒosm2pgsqlãŠãŒãã£ãªãã£ã®--number-processesããŒïŒãããã³ããŒããã©ã€ãã®é床ïŒPostgresqlã§ã®ããŒã¿ã®æ¿å ¥æããã³ã€ã³ããã¯ã¹ã®äœææãæé©åã«ã€ããŠã¯ãosm2pgsqlãŠãŒãã£ãªãã£ã®--disable-parallel-indexingããŒãåç §ããŠãã ããïŒã SSDãããå ŽåãPostgresqlããŒã¿ããŒã¹ãžã®ããŒã¿ã®ã€ã³ããŒãã¯ã¯ããã«é«éã«ãªããŸãã
ãã®èšäºã§ã¯ãäžåœã®å°åã次ã®ããã«äœ¿çšããŸãã ããã©ã«ãã§ã¯Russifiedã§ã¯ãªãããµã€ãºãæ¯èŒçå°ããã®ã§ããããã°æè¡ã®æ®µéã§äŸ¿å©ã§ãã äžåœã®ãã¯ã¿ãŒããŒã¿ãã¡ã€ã«ã¯ã geofabrik.deãããžã§ã¯ãã®Webãµã€ããã次ã®ã³ãã³ãã䜿çšããŠããŠã³ããŒãã§ããŸãã
wget http://download.geofabrik.de/asia/china-latest.osm.pbf
2.åä¿¡ãããã¯ã¿ãŒããŒã¿OpenStreetMapãæŽæ°ããŸã
å®éãããŒã¿ãã¡ã€ã«ãããã±ãŒãžåãããŠãããã·ã³ã«å±éããããŸã§ã®éã«ãOpenStreetMapã§ããã€ãã®å€æŽãè¡ãããå¯èœæ§ããããŸãã ãããã£ãŠãã€ã³ããŒãããåã«ãosmcutilsããã±ãŒãžã®osmupdateã³ãã³ãã§ããŒã¿ãã¡ã€ã«ãæŽæ°ããŸãã
osmupdate china-latest.osm.pbf new-china-latest.osm.pbf
OSMãã¡ã€ã«ã«ã¿ã€ã ã¹ã¿ã³ããå«ãŸããŠããªãå ŽåãosmupdateãŠãŒãã£ãªãã£ã¯ãšã©ãŒãè¿ããŸãã ãã®å ŽåïŒãã¡ã€ã«ã®ã¿ã€ã ã¹ã¿ã³ããããã£ãŠããå Žå-ãã¡ã€ã«ã®ããŠã³ããŒãããŒãžã§å ¬éãããå ŽåããããŸãïŒã次ã®åœ¢åŒã§ã³ãã³ããå®è¡ããå¿ èŠããããŸãã
osmupdate china-latest.osm.pbf 2015-05-13T14:48:07Z new-china-latest.osm.pbf
osmupdateãŠãŒãã£ãªãã£ã¯ãdiffãã¡ã€ã«ãåå¥ã«ããŠã³ããŒãããcallã³ãã³ãã®æåã®åŒæ°ã§æå®ããããã¡ã€ã«ã«é©çšããŸãã OSM XML圢åŒã®å€§ããªãã¡ã€ã«ïŒplanet-latest.osm.bz2ãªã©ïŒã§osmupdateãŠãŒãã£ãªãã£ãå®è¡ããããšã¯ãå§ãããŸããã åãosmcutilsããã±ãŒãžã®osmconvertãŠãŒãã£ãªãã£ã«ãããã¡ã€ã«ã®äºååŠçãå¿ èŠã§ããosmupdateãŠãŒãã£ãªãã£ã¯ãå€æåŸã®ãã¡ã€ã«ã§æ°æ¥éæ©èœããŸãã 倧ããªãã¡ã€ã«ã®å Žåã¯ãPBF圢åŒã䜿çšããããšããå§ãããŸãã ãã ãããã®ãããªãã¡ã€ã«ãPostgresqlã«ã€ã³ããŒãããå Žåã¯ãOSM XMLãã¡ã€ã«ãã€ã³ããŒããããããæéããããããšã«æ³šæããŠãã ããã ããã°ãäž¡åã®å£ã å人çã«ãç§ã¯åžžã«PBF圢åŒãéžæããŸãã
3. osm2pgsqlãŠãŒãã£ãªãã£ã®èšå®ã§å¿ èŠãªèšèªã®ãµããŒããæ§æããŸã
ããã©ã«ãã§ã¯ããã¹ãŠã®èšèªã®ãµããŒãã¯/usr/share/osm2pgsql/osm2pgsql/default.styleã¹ã¿ã€ã«ã·ãŒãã«ã€ã³ã¹ããŒã«ãããŠããŸããã ãããäžã®ç¢æã«ã¯ã次ã®è¡ã§/usr/share/osm2pgsql/osm2pgsql/default.styleãã¡ã€ã«ã«èšå®ãããŠããååã¿ã°ã䜿çšãããŸãã
node,way name text linear
ããšãã°ããã·ã¢èªãè±èªãã¹ãã€ã³èªããµããŒãåŸã«è¿œå ããŸãã
node,way name:ru text linear node,way name:en text linear node,way name:es text linear
ãããã®3è¡ã¯ãosm2pgsqlãŠãŒãã£ãªãã£ã«ãPBFãã¡ã€ã«ããã¿ã°å€nameïŒru ã nameïŒen ã nameïŒseãã€ã³ããŒãããããã«æ瀺ããŸãã ä»ã®ããŒã«ã©ã€ãºãããååã¯ç¡èŠãããŸãã
4. OpenStreetMapãã¯ã¿ãŒããŒã¿ãä¿åããPostgresqlããŒã¿ããŒã¹ãäœæããŸã
æåã«ãä¿¡é ŒèªèšŒãæ§æãïŒãã¹ã¯ãŒããå ¥åããªãããããã®èšäºã®ãã¬ãŒã ã¯ãŒã¯å ã§ããã¯å¿ èŠãããŸããïŒãå¿ èŠãªããŒã¿ããŒã¹ãŠãŒã¶ãŒãäœæããå¿ èŠããããŸãïŒ æé ãåç §ïŒã ãã®èšäºã®äžéšãšããŠãèªèšŒãšæšæºã®postgresãŠãŒã¶ãŒãä¿¡é Œããããã«å¶éããŠããŸãã ãã®ãããããšãã°chinaãªã©ã®ããŒã¿ããŒã¹ãäœæããå¿ èŠãªæ¡åŒµæ©èœãæ¥ç¶ããŸãã
createdb -U postgres china psql -U postgres -d china -c 'CREATE EXTENSION hstore; CREATE EXTENSION postgis;'
5.ãã¯ã¿ãŒããŒã¿ãPostgresqlããŒã¿ããŒã¹ã«ã€ã³ããŒããã
ã€ã³ããŒãã¯osm2pgsqlãŠãŒãã£ãªãã£ã«ãã£ãŠå®è¡ãããŸãã ãŠãŒãã£ãªãã£ããŒã®èª¬æã¯ããŠãŒãã£ãªãã£ã®ãã«ãã«èšèŒãããŠããŸãã ããã€ãã®èª¬ææ å ±ãè±èªã®ãªãœãŒã¹ã§æäŸãããŠããŸãã
osm2pgsql -s -m -d china -U postgres --drop new-china-latest.osm.pbf
--dropã¹ã€ããã䜿çšãããšãããŒã¿ããŒã¹ãå æãããã£ã¹ã¯å®¹éãæžããããšãã§ãããããæ°ããPBFãŸãã¯OSM XMLãã¡ã€ã«ããããŒã¿ããŒã¹å ã®ããŒã¿ãåŸã§æŽæ°ããæ©èœãç ç²ã«ãªããŸãã äžåœã®å ŽåãããŒã¿ããŒã¹ã®ãµã€ãºã¯çŽ500MBãã92MBã«æžå°ããŸããã ããŒã¿ããŒã¹ãå ãããµã€ãºã確èªããã«ã¯ãæ¢åã®ããŒã¿ããŒã¹ã«æ¥ç¶ãããpsqlã³ã³ãœãŒã«ã§æ¬¡ã®ã³ãã³ããå ¥åããŸãã
SELECT pg_size_pretty( pg_database_size( 'china' ) );
6.翻蚳ãããå°çåã衚瀺ããããã«ãDBã«è¡šçŸãäœæããŸãã
åœä»€ã䜿çšããŠãSQLã®ããã€ãã®è¡šçŸãäœæããŸãã ããã·ã¢èªãã¿ã€ã«ïŒãã·ã¢ã®çœ²åãå«ãã¿ã€ã«ïŒãçæããã«ã¯ãæ¥é èŸchina_ruã䜿çšããŠããè±èªãã¿ã€ã«-china_enãçæãããã¹ãã€ã³èªãã¿ã€ã«-china_esãçæããŸãã 以äžã¯ãããã·ã¢èªãã¿ã€ã«ã®ã¿ãçæããããã®SQLè¡šçŸãäœæããããã®SQLã¹ã¯ãªããã§ãã 芪æãªãèªè ã¯ã "ãã·ã¢èª" VIEWãåºç€ãšããŠã "è±èª"ããã³ "ã¹ãã€ã³èª"ã¿ã€ã«ã®çæã«é¢ããSQLãã¥ãŒãç解ããŠãããšæããŸãã
CREATE VIEW china_ru_point AS SELECT data.osm_id, data.access, data."addr:housename", data."addr:housenumber", data."addr:interpolation", data.admin_level, data.aerialway, data.aeroway, data.amenity, data.area, data.barrier, data.bicycle, data.brand, data.bridge, data.boundary, data.building, data.capital, data.construction, data.covered, data.culvert, data.cutting, data.denomination, data.disused, data.ele, data.embankment, data.foot, data."generator:source", data.harbour, data.highway, data.historic, data.horse, data.intermittent, data.junction, data.landuse, data.layer, data.leisure, data.lock, data.man_made, data.military, data.motorcar, CASE data."name:ru" IS NULL WHEN true THEN '' ELSE data."name:ru" || CASE data.name IS NULL WHEN true THEN '' ELSE E'\n' END END || CASE data.name IS NULL WHEN true THEN '' ELSE data.name END AS name, data."natural", data.office, data.oneway, data.operator, data.place, data.poi, data.population, data.power, data.power_source, data.public_transport, data.railway, data.ref, data.religion, data.route, data.service, data.shop, data.sport, data.surface, data.toll, data.tourism, data."tower:type", data.tunnel, data.water, data.waterway, data.wetland, data.width, data.wood, data.z_order, data.way FROM planet_osm_point AS data; CREATE VIEW china_ru_line AS SELECT data.osm_id, data.access, data."addr:housename", data."addr:housenumber", data."addr:interpolation", data.admin_level, data.aerialway, data.aeroway, data.amenity, data.area, data.barrier, data.bicycle, data.brand, data.bridge, data.boundary, data.building, data.construction, data.covered, data.culvert, data.cutting, data.denomination, data.disused, data.embankment, data.foot, data."generator:source", data.harbour, data.highway, data.historic, data.horse, data.intermittent, data.junction, data.landuse, data.layer, data.leisure, data.lock, data.man_made, data.military, data.motorcar, CASE data."name:ru" IS NULL WHEN true THEN '' ELSE data."name:ru" || CASE data.name IS NULL WHEN true THEN '' ELSE E'\n' END END || CASE data.name IS NULL WHEN true THEN '' ELSE data.name END AS name, data."natural", data.office, data.oneway, data.operator, data.place, data.population, data.power, data.power_source, data.public_transport, data.railway, data.ref, data.religion, data.route, data.service, data.shop, data.sport, data.surface, data.toll, data.tourism, data."tower:type", data.tracktype, data.tunnel, data.water, data.waterway, data.wetland, data.width, data.wood, data.z_order, data.way FROM planet_osm_line AS data; CREATE VIEW china_ru_polygon AS SELECT data.osm_id, data.access, data."addr:housename", data."addr:housenumber", data."addr:interpolation", data.admin_level, data.aerialway, data.aeroway, data.amenity, data.area, data.barrier, data.bicycle, data.brand, data.bridge, data.boundary, data.building, data.construction, data.covered, data.culvert, data.cutting, data.denomination, data.disused, data.embankment, data.foot, data."generator:source", data.harbour, data.highway, data.historic, data.horse, data.intermittent, data.junction, data.landuse, data.layer, data.leisure, data.lock, data.man_made, data.military, data.motorcar, CASE data."name:ru" IS NULL WHEN true THEN '' ELSE data."name:ru" || CASE data.name IS NULL WHEN true THEN '' ELSE E'\n' END END || CASE data.name IS NULL WHEN true THEN '' ELSE data.name END AS name, data."natural", data.office, data.oneway, data.operator, data.place, data.population, data.power, data.power_source, data.public_transport, data.railway, data.ref, data.religion, data.route, data.service, data.shop, data.sport, data.surface, data.toll, data.tourism, data."tower:type", data.tunnel, data.water, data.waterway, data.wetland, data.width, data.wood, data.z_order, data.way, data.way_area FROM planet_osm_polygon AS data; CREATE VIEW china_ru_roads AS SELECT data.osm_id, data.access, data."addr:housename", data."addr:housenumber", data."addr:interpolation", data.admin_level, data.aerialway, data.aeroway, data.amenity, data.area, data.barrier, data.bicycle, data.brand, data.bridge, data.boundary, data.building, data.construction, data.covered, data.culvert, data.cutting, data.denomination, data.disused, data.embankment, data.foot, data."generator:source", data.harbour, data.highway, data.historic, data.horse, data.intermittent, data.junction, data.landuse, data.layer, data.leisure, data.lock, data.man_made, data.military, data.motorcar, CASE data."name:ru" IS NULL WHEN true THEN '' ELSE data."name:ru" || CASE data.name IS NULL WHEN true THEN '' ELSE E'\n' END END || CASE data.name IS NULL WHEN true THEN '' ELSE data.name END AS name, data."natural", data.office, data.oneway, data.operator, data.place, data.population, data.power, data.power_source, data.public_transport, data.railway, data.ref, data.religion, data.route, data.service, data.shop, data.sport, data.surface, data.toll, data.tourism, data."tower:type", data.tunnel, data.water, data.waterway, data.wetland, data.width, data.wood, data.z_order, data.way FROM planet_osm_roads AS data; INSERT INTO geometry_columns VALUES ('', 'public', 'china_ru_point', 'way', 2, 900913, 'POINT'); INSERT INTO geometry_columns VALUES ('', 'public', 'china_ru_line', 'way', 2, 900913, 'LINESTRING'); INSERT INTO geometry_columns VALUES ('', 'public', 'china_ru_polygon', 'way', 2, 900913, 'POLYGON'); INSERT INTO geometry_columns VALUES ('', 'public', 'china_ru_roads', 'way', 2, 900913, 'LINESTRING');
ãã®å ŽåããnameïŒru \ nnameããšãã圢åŒã§çœ²åãã«ãŒãã«äœæããŸããE '\ n'ã¯ããåãã®ããã«ããã£ãªããžãæ°ããè¡ã«ç§»åããããã®èšå·ã§ãã ãããäžã®çœ²åã®ããæŽç·Žãããé 眮ã«ã€ããŠã¯ã TextSymbolizer Mapnikã®ããã¥ã¡ã³ããåç §ããŠãã ããã ãã®å Žåã次ã®æ®µèœã®ãã®æ瀺ã«åŸã£ãŠçæãããããããäžã®çœ²åã®è¡šç€ºã¹ã¿ã€ã«ãå€æŽããå¿ èŠããããŸãã
7. OpenStreetMapããã¹ã¯ãªãããã€ã³ã¹ããŒã«ããŠã¿ã€ã«ãçæããŸã
ãã£ã¬ã¯ããª/ home / osm / mapnikãéžæããŠãå¿ èŠãªMapnikã¹ã¯ãªããããã¹ãŠä¿åããŸãããã OpenStreetMapããã¹ã¯ãªããããã³ãããŠã¿ã€ã«ãçæããå°ããªã¹ã±ãŒã«ã§ã®ã¿ã€ã«ã®çæãç°¡çŽ åããããã«äœ¿çšãããäžçã®åœ¢ç¶ïŒã·ã§ã€ããã¡ã€ã«ïŒãæœåºããMapnikã¹ã¿ã€ã«ã®XMLãã¡ã€ã«ãäœæããŠããŒã¿ããŒã¹ã«ã¢ã¿ããããŸãã
svn co http://svn.openstreetmap.org/applications/rendering/mapnik /home/osm/mapnik /home/osm/mapnik/get-coastlines.sh
次ã«ãå°çãªããžã§ã¯ãã®ãã·ã¢èªãè±èªãã¹ãã€ã³èªã®çœ²åçšã«ãããããã¿ã€ã«ãã¬ã³ããªã³ã°ããããã®3ã€ã®ãã¡ã€ã«ã¹ã¿ã€ã«ãäœæããå¿ èŠããããŸãã ãããè¡ãã«ã¯ãç¹å¥ãªç°å¢å€æ°MAPNIK_PREFIXãèšå®ããŸããããã«ãããPostgresããŒã¿ããŒã¹å ã®ãã¯ã¿ãŒããŒã¿ããŒãã«ã®ãã¬ãã£ãã¯ã¹ãèšå®ã§ããã¹ã¯ãªãã/home/osm/mapnik/generate_xml.pyãèªã¿åããããŒã¿ããŒã¹ãžã®æ¬äŒŒã¯ãšãªã«çœ®ãæããŸãã
export MAPNIK_PREFIX='china_ru' /home/osm/mapnik/generate_xml.py /home/osm/mapnik/osm.xml china_ru.xml --dbname china --user postgres --accept-none export MAPNIK_PREFIX='china_en' /home/osm/mapnik/generate_xml.py /home/osm/mapnik/osm.xml china_en.xml --dbname china --user postgres --accept-none export MAPNIK_PREFIX='china_es' /home/osm/mapnik/generate_xml.py /home/osm/mapnik/osm.xml china_es.xml --dbname china --user postgres --accept-none
ãããã®ã³ãã³ãã¯ãã¿ã€ã«ãã¬ã³ããªã³ã°ããããã®3ã€ã®ç¹å¥ãªã¹ã¿ã€ã«ãäœæãããã·ã¢èªãè±èªãã¹ãã€ã³èªã®å¿ èŠãªè¡šçŸããã¬ã³ããªã³ã°çšã®ããŒã¿ãèªã¿åãããšãã§ããŸãã
8.ã¿ã€ã«çæã¹ã¯ãªããã§ã¯ãã¿ã€ã«çæã®ããã®äžåœã®é åã瀺ããŸã
ã¹ã¯ãªãã/home/osm/mapnik/generate_tiles_multiprocess.pyã«ã¯æ¬¡ã®è¡ããããŸãã
bbox = (-180.0,-90.0, 180.0,90.0) # render_tiles(bbox, mapfile, tile_dir, 0, 5, "World") # 0- 5-
ãããã®è¡ã®åŸã次ã®ããã«èšè¿°ããŸãã
bbox = (85.0,19.7,132.5,40.8) # render_tiles(bbox, mapfile, tile_dir, 6, 15, "China") # 6- 15- exit()
ããã«ãããå¿ èŠãªèšèªã®çœ²åãå«ã6ã15ã¹ã±ãŒã«ã®äžåœã®ã¿ã€ã«ãçæãããŸãã exitïŒïŒåœä»€ã䜿çšãããšãã¹ã¯ãªãã/home/osm/mapnik/generate_tiles_multiprocess.pyïŒMuenchenãMuenchen +ãMuenchen ++ãNuernbergãKarlsruheãKarlsruhe +ãAugsburgãAugsburg +ãEurope +ïŒã§ããã©ã«ãã§æå®ãããé åã®ãããªãã¬ã³ããªã³ã°ãæåŠã§ããŸãã ãŸããåäžã®ã¹ã¬ããã§ã¬ã³ããªã³ã°ããã»ã¹ãéå§ããã¹ã¯ãªãã/home/osm/mapnik/generate_tiles.pyããããŸãã ãã ãã䜿çšããŸããã è€æ°ã®ããã»ããµã³ã¢ãããå Žåãã¹ã¯ãªãã/home/osm/mapnik/generate_tiles_multiprocess.pyã¯äžè¬ã«é«éã«åäœããŸãã
9.éžæããå Žæã®ã¿ã€ã«ãçæããŸã
Mapnikãçæãããã¿ã€ã«ãä¿åãããã£ã¬ã¯ããªãäœæããå¿ èŠããããŸãã
mkdir /home/osm/mapnik/tiles mkdir /home/osm/mapnik/tiles/ru mkdir /home/osm/mapnik/tiles/en mkdir /home/osm/mapnik/tiles/es
ã·ã¹ãã ç°å¢MAPNIK_MAP_FILEããã³MAPNIK_TILE_DIRã®å€æ°ã®å€ãå€æŽããŠãã¿ã€ã«ã®çæã3åéå§ããå¿ èŠããããŸãã ã¹ã¯ãªããã¯ãããã®å€æ°ãèªã¿åããMapnikã«æž¡ããŠã¿ã€ã«ã®ã¬ã³ããªã³ã°ãæ§æããŸãã
export MAPNIK_MAP_FILE=/home/osm/mapnik/china_ru.xml export MAPNIK_TILE_DIR=/home/osm/mapnik/tiles/ru/ exec python /home/osm/mapnik/generate_tiles_multiprocess.py export MAPNIK_MAP_FILE=/home/osm/mapnik/china_en.xml export MAPNIK_TILE_DIR=/home/osm/mapnik/tiles/en/ exec python /home/osm/mapnik/generate_tiles_multiprocess.py export MAPNIK_MAP_FILE=/home/osm/mapnik/china_es.xml export MAPNIK_TILE_DIR=/home/osm/mapnik/tiles/es/ exec python /home/osm/mapnik/generate_tiles_multiprocess.py
ã¿ã€ã«ãçæãããŸãã
10. Webãããã«ã¿ã€ã«ã衚瀺ãã
ãããè¡ãã«ã¯ãäœæããã¿ã€ã«ãªããžããªãæ¥ç¶ããæãåçŽãªhtmlããŒãžãäœæããŸãã ããŒãžãã¡ã€ã«ã¯ãçæãããã¿ã€ã«/ home / osm / mapnik / tilesã®ãã£ã¬ã¯ããªã®é£ã«é 眮ããå¿ èŠããããŸãã Webãããã衚瀺ããã«ã¯ã LeafletJS javascriptãã¬ãŒã ã¯ãŒã¯ã䜿çšããŸãã
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css" /> <script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script> </head> <body> <div id="map" style="height: calc(100vh - 15px)"></div> <script> var map = L.map('map', { center: [34.7, 111.7], zoom: 6 }); L.control.layers({ "ru" : L.tileLayer('tiles/ru/{z}/{x}/{y}.png').addTo(map), "en" : L.tileLayer('tiles/en/{z}/{x}/{y}.png'), "es" : L.tileLayer('tiles/es/{z}/{x}/{y}.png') }, null).addTo(map); </script> </body> </html>
ãã®ããŒãžã¯ããŒã«ã«ã§å®è¡ãããŸãã å³äžé ã«ãã¿ã€ã«ã®ãœãŒã¹ãéžæã§ããã³ã³ãããŒã«ã䜿çšå¯èœã«ãªã£ãŠããã¯ãã§ãã ãããã®ãã·ã¢èªçãè±èªçãã¹ãã€ã³èªçã¯æ¬¡ã®ããã«ãªããŸãã
11.ããªã³ã¶ãã©ã€ãã§ã®ã¿ã€ã«ã®ã¬ã³ããªã³ã°
Apache WebãµãŒããŒã®ããã€ãã®mod_tileã¢ãžã¥ãŒã«ãæ§æããå¿ èŠããããŸããåã¢ãžã¥ãŒã«ã¯ãç¬èªã®ãããã³ã°ãæ åœããŸã-/ ru-ãã·ã¢ã®ã¿ã€ã«ãã¬ã³ããªã³ã°ãã/ en-ãããããè±èªã®ã¿ã€ã«ãã¬ã³ããªã³ã°ãããªã© mod_tileãhttpdãããã³renderdã®æ§æã®è©³çŽ°ã«ã€ããŠã¯ã Gis-Labã®æé ãåç §ããŠãã ããã ãããã®ããŒã«ã©ã€ãºã®äŸã®ãã¢ã³ã¹ãã¬ãŒã·ã§ã³ã®äžç°ãšããŠãOpenStreetMapã¯æ¬æ Œçãªã¿ã€ã«ãµãŒããŒãå±éããå¿ èŠããããšã¯èããŠããŸããã
泚é
- èšäºã®å ã®ããŒãžã§ã³ã§ã¯ãèè ã¯äžåœã§ã¯ãªããããã¹ã®äŸã䜿çšããŠå°å³ã®ãã·ã¢å/ããŒã«ã©ã€ãºã®äŸã瀺ãããšãèšç»ããŸããã ãããã¹ã®å æé¢ç©ã¯äžåœãããããã«å°ãããããããŒã¿ã®ããŒã¿ããŒã¹ãžã®ã€ã³ããŒããéããªããã¿ã€ã«ã®çæãéããªããŸãã ããããå€æããããã«ããããŒã«ã«ãèšèªã«ã¯ã©ãã³ã¢ã«ãã¡ãããã«é¡äŒŒããæåãå«ãŸããŠããŸãã ãããã£ãŠãè±èªãžã®ç¿»èš³ã¯å®èšŒçã§ã¯ãããŸããã§ããã ã¡ãªã¿ã«ããããã¹ãšäžåœã®ããŒã¿ããŒã¹ã®ãµã€ãºïŒ--dropããŒã®æç¡ã«ãããããïŒã¯ããããã®åœãå ããé¢ç©ã«å€§ããªéããããã«ããããããããã©ã¹ãŸãã¯ãã€ãã¹æ°ã¡ã¬ãã€ãã§ããã
- ãã®èšäºã®èè ã¯ãèšäºã®äžéšãšããŠãã·ã¢èªãè±èªããã€ãèªã®ãµããŒããå®è£ ããäºå®ã§ããã ããããè±èªãšãã€ãèªã®ç¿»èš³ã¯ã»ãšãã©ã®å Žååãæ¹æ³ã§æžãããŠããã®ã§ãèšäºã®æçµçã§ã¯ããã€ãèªãããããããããããããã«ã¹ãã€ã³èªã«çœ®ãæããŸããã
- Planet.osmã®èªã¿èŸŒã¿ã«é¢ããèè ã®å®éšã¯å®äºããŠããŸããïŒãããã¹ãšäžåœã®å°å³ã®å Žåã®ããã«ïŒã äºå®ããã¡ã€ã«ãPostgresããŒã¿ããŒã¹ã«ã€ã³ããŒãããã®ã«ããªãã®æéïŒ2é±é以äžïŒããã£ãŠãããããosm2pgsqlãŠãŒãã£ãªãã£ïŒããã³ãã®ã¹ã¿ã€ã«ãã¡ã€ã«/usr/share/osm2pgsql/osm2pgsql/default.styleïŒã®ãããã®èšå®ãŸãã¯ãã®ä»ã®èšå®ããåçãã§ããŸããã§ããèè ã®æéã ãã®ããããã®èšäºã«ã¯ãã®ãããªå€§éã®ããŒã¿ã®åŠçã«é¢ããç¹å®ã®çµ±èšæ å ±ããããŸããã
- china_ru_pointãchina_ru_roadsãªã©ã®ããŒã¿ããŒã¹ãã¥ãŒãäœæããã·ã¹ãã ç°å¢å€æ°MAPNIK_PREFIXã«å¿ èŠãªç¿»èš³ãããŒãã«ã®ãã¬ãã£ãã¯ã¹ã«åŒ·å¶ããããšã¯ãå¿ èŠãªç¿»èš³ãååŸããå¯äžã®æ¹æ³ã§ã¯ãããŸããã generate_xml.pyã¹ã¯ãªããã«ãã£ãŠçæãããMapnikã¹ã¿ã€ã«ãã¡ã€ã«ã§ã¯ãTextSymbolizerã¿ã°ã§ãããäžã®çœ²åãè¡šãããã®åœ¢åŒãæ§æã§ããŸãã ç¹ã«ã éå»æå[name]ã®çæãããååãã£ãŒã«ãã[nameïŒru]ã«çœ®ãæãããšãMapnikã¯ååããåãããéå»æåãå ¥ããŸãïŒruãã£ãŒã«ãã®planet_osm_point ã planet_osm_line ã planet_osm_polygon ã planet_osm_roads tables ã ããããå®è·µã瀺ãããã«ãå°ççãªããžã§ã¯ãã®ååã®ç¿»èš³ã¯ããããã®ååèªäœãããå€§å¹ ã«å°ãªãã§ãã ãããããããã å€èšèªãããã®ãããžã§ã¯ãããããå°çãªããžã§ã¯ãã®çœ²åãªãã§ã裞ãã§ããçç±ã§ãã ãã®ç¹ã§ãchina_ru_ *ã®ãã¥ãŒã§äœæããåå\ ruã®é£çµã¯ãããæ®éçã§ãã
- è€æ°ã®èšèªããµããŒãããäºå®ããªããå®æçã«ããŒã¿ãæŽæ°ããäºå®ããªãå ŽåïŒã€ãŸããosm2pgsqlãŠãŒãã£ãªãã£ã®--dropããŒã䜿çšããå ŽåïŒãããŒã¿ããŒã¹ãã¥ãŒã®é¢åãªèšèšã1ã€ã®UPDATEã¯ãšãªã«çœ®ãæããŠã ååãã£ãŒã«ãã®æ¢åã®å€ã眮ãæããŸãååãé£çµããã«ã¯ãè¡šplanet_osm_point ã planet_osm_line ã planet_osm_polygonããã³planet_osm_roadsã® ru \ nnameã䜿çšããŸãã ãã®å Žåãã·ã¹ãã ç°å¢å€æ°MAPNIK_PREFIXã匷å¶çã«èšå®ããå¿ èŠã¯ãããŸããã ãããŠãäºæ³ã©ãããMapnikã¯éžæããèšèªã®ã¿ã€ã«ã®ã¿ãçæããŸãã
çµè«
OpenStreetMapãããã®ããŒã«ã©ã€ãºã®åé¡ã¯ããã»ã©é£ãããããŸããã ãã®åé¡ã解決ããã«ã¯ãããã€ãã®ã¢ãããŒãããããŸãã ãã®èšäºã§ã¯ãéåžžã«å ·äœçãªäœæ¥ãªãã·ã§ã³ãææ¡ããŸãã 芪æãªãèªè ã¯ããã®èšäºã®å 容ã«ã€ããŠå€ãã®è³ªåãæã£ãŠãããšç¢ºä¿¡ããŠããŸããææ¡ãããã¢ã«ãŽãªãºã ãåå²ãããããã®åœŒèªèº«ã®ã¢ã€ãã¢ãããã§ãããã ãã®èšäºã®èè ã¯ãOpenStreetMapãããã®Russification / localizationã®åé¡ã解決ããå¯äžã®çã®æ¹æ³ã§ãããšã¯äž»åŒµããŠãããããã®åé¡ã解決ããéã®ãããªãã¯ãã«ã€ããŠåãã§ãèªã¿ãã ããã