Skip to content

zbycz/php_wms2tile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 

Repository files navigation

php_wms2tile - easily convert wms service to tiles for slippy map

LIVE DEMO:

Address for custom background of iD OSM editor:

http://osm.zby.cz/tiles_cuzk.php/{z}/{x}/{y}.png
http://osm.zby.cz/tiles_uhul.php/{z}/{x}/{y}.jpg

Config

First lines of the PHP script itself

// we log the execution time
$time_start = microtime(true);

// url of WMS image query ending with bbox=
$wmsurl = "http://wms.cuzk.cz/wms.asp?...&BBOX=";

// filetype of WMS - png or jpg --> this one is saved and conversion to .jpg/.png is possible
$filetype = 'png';

// sql table name
$table = "tiles_cuzk";

// page called without parameters
$attribution = "<hr>
	<a href='http://www.cuzk.cz/'>&copy; CUZK.cz</a>
	<br>
	<a href='http://github.com/zbycz/php_wms2tile'>php_wms2tile</a> script by <a href='http://zby.cz/'>zbycz</a> 2011
";

// db login
mysql_connect("localhost", "root", "") or die("Could not connect to db");
mysql_select_db("test") or die("Could not select db");

You are supposed to create the MySQL table:

CREATE TABLE `$table` (
  `z` tinyint(2) unsigned NOT NULL,
  `x` int(10) unsigned NOT NULL,
  `y` int(10) unsigned NOT NULL,
  `hits` int(10) unsigned NOT NULL,
  `hits_month` int(10) unsigned NOT NULL,
  `hits_last_month` int(10) unsigned NOT NULL,
  `downloaded` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `calculated` tinyint(4) NOT NULL,
  `image` blob NOT NULL,
  PRIMARY KEY  (`z`,`x`,`y`)
)

Example sizes for ortophoto map:

z16 = 870 000
-> jpg 12 GB
-> png 43 GB

z15 = 200 000
-> jpg 2.8 GB
-> png 10.0 GB

z14 = 50 000
-> jpg 0.7 GB
-> png 2.5 GB 

z13 = 13 000
-> jpg 182 MB
-> png 650 MB

License and author

(c) Pavel Zbytovský 2011

Licensed under MIT.

About

convert wms service to XYZ tiles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages