tileserver.php: serve tiles from a different webserver?

685 views
Skip to first unread message

Jim Lacy

unread,
Feb 2, 2016, 10:40:11 AM2/2/16
to MapTiler Community
Now that I have tileserver.php working, I'm very impressed with the combination of Tileserver and Maptiler.

I'm curious, is it possible to have tilserver.php sit on one http server ("Server A") with the actual image tiles residing elsewhere? ("Server B").  For example, this would allow tileserver.php to sit on an in-house server capable of running php, but the tiles could be served from an S3 bucket.  My main goal in such an arrangement is to allow WMTS connection requests to tileserver.php.

I do understand it's possible to use S3 buckets via some Javascript "magic" that is built into the HTML output by Maptiler.  However, that involves serving the WMTS through tileserver.com; I'm sure the service is reliable and so forth, but I'd prefer to keep that function in-house.

Thanks!

Petr Pridal

unread,
Feb 2, 2016, 11:35:43 AM2/2/16
to MapTiler Community
Jim,

Yes. It is possible. The WMTS GetCapabilities document can link tiles from a different server - and it is supported by all known WMTS clients.

What you want is to generate tiles with MapTiler - and use the included Amazon S3 uploader (see: http://www.maptiler.com/how-to/hosting-on-amazon-s3/) or generate a standard folder with tiles and viewer and upload everything to Amazon S3 or any other cloud storage or web server able to share the tiles via http.

Once you do this you get link to WMTS service directly usable for your tiles - which you can immediately use.

The only "magic" what happens  in the JavaScript tileviewer generated by MapTiler is passing the link to your real online location of metadata.json to our online service: http://wmts.maptiler.com/. You can do that also manually - by copy&paste URL of your metadata.json file generated by MapTiler to http://wmts.maptiler.com/ you get your own OGC WMTS metadata XML (GetCapabilities) and TileJSON endpoint.

If you want these hosted on your own server instead - just download these generated XML / JSON files and save them anywhere on the Internet (such as on your Amazon S3 next to the tiles). Your probably don't even need TileServer-PHP instance.

The map tiles are always served from your original location (Amazon S3), even if you use wmts.maptiler.com service, and all WMTS clients (such as QGIS, ArcGIS, Leaflet or OpenLayers or others) are accessing the map tiles from your original online location where you uploaded this - only the dynamic XML / JSON metadata with correct absolute links are served from our server.

MapTiler can't generate for you the XML and JSON files directly with the tiles, because it would need to know the exact final URL of your tiles - which is not known until you upload it to your hosting...

But, as I have said you can just copy the WMTS XML capabilities file and host it on your own server if you want to be completely independent of us for the map hosting and still have 100% compatible OGC WMTS Restful service or TileJSON AJAX endpoint.

The freedom of hosting and saving of the costs in this matter is a huge advantage of MapTiler - compared to any other mapping cloud providers.

Best regards,

Petr

P.S.
The http://www.tileserver.com/ hosting is something else - it is a high-performance tile hosting for MBTiles - with HTTPS, CDN with 42 servers in 4 continents and plans for serving unlimited traffic for fixed size - with possibility to serve large map layers (30 GB / 100 GB / 1 TB / etc) for a fixed price. You would probably pay more on Amazon S3 when hosting large maps then you pay us for the hosting - this is the reason why we offer our clients this hosting service as an alternative to other clouds.

BTW you may be also interested in vector tiles and the http://osm2vectortiles.org/ global web maps which you can host the same way (on your own server) - as vector base map. So you can easily make your own Google Maps for your country or whole world - on a standard virtual server with a 3 linux commands...

Jim Lacy

unread,
Feb 2, 2016, 2:50:46 PM2/2/16
to MapTiler Community
Thanks Petr for taking the time to respond in detail.  I think I understand, and now have some things to try.  Thanks for clarifying wmts.maptiler.com vs tileserver.com... that was my mistake.

By the way, when I say "magic," that's a compliment! ;)

Dalibor Janák

unread,
Mar 1, 2016, 6:17:00 AM3/1/16
to MapTiler Community
I add this ability to also to tileserver-php. It is described in ticket https://github.com/klokantech/tileserver-php/issues/69

Tileserver could work as a WMTS generator. It requires to add to folder with metadata.json of remote dataset and name it as remote layer. For example for folder layer named europe stored in labs.klokantech.com/tileserver/europe/ you need to create folder /europe/ in your local/remote server and put inside matadata.json with following metadata:

{
  "name": "europe",
  "version": "1.0.0",
  "description": "",
  "type": "overlay",
  "format": "png",
  "minzoom": "0",
  "maxzoom": "6",
  "bounds": [-36.96352111, 27.97971067, 81.09315622, 71.56346432],
  "tiles": [
  ],
  "scale": "1"
}

So into "standard" metadata file from MapTiler is added only variable "tiles": ["http://labs.klokantech.com/tileserver/europe/{z}/{x}/{y}.png"] with right url to remote server.


On Tuesday, February 2, 2016 at 4:40:11 PM UTC+1, Jim Lacy wrote:

Petr Pridal

unread,
Mar 1, 2016, 11:07:38 AM3/1/16
to MapTiler Community
In other words:

If you want to generate WMTS capabilities document for tiles you can do that now.

The step by step tutorial would be:

1) Upload the map tiles generated by MapTiler to any online hosting (such as Amazon S3, Google Cloud or another web hosting) - your "Server B".

2) On a server with PHP interpret install latest TileServer-PHP - your "Server A". This can have domain address like: wmts.yourcompany.com

3) On the "Server A" with TileServer-PHP create an empty folder with the same name as folder of your tiles on "Server B" and copy into this folder the "metadata.json" file generated by MapTiler

4) Modify the "metadata.json" file in a text editor and add a line like:


5) Start to use your map tiles in ArcGIS, QGIS or other WMTS clients by pointing them to your company address of "Server A". For example: http://wmts.yourcompany.com/wmts Tiles would be delivered from your "Server B".

Hope it is now more clear...

Please let us know if this run for you.

Petr

P.S.
If your are fine with public WMTS url on domain wmts.maptiler.com then you don't need to do any of these steps. It will run out of the box for your tiles after uploading them to your hosting ("Server B").

Jim Lacy

unread,
Mar 3, 2016, 3:34:48 PM3/3/16
to mapt...@googlegroups.com
Thanks Petr and Dalibor, this is great.  It partially works, but not completely.  Let me explain:

Server "A" with updated tileserver.php (and minor edit to metadata.json) = http://www.sco.wisc.edu/scoapps/tileserver/


This solution works exactly as I wanted for the sample applications at http://www.sco.wisc.edu/scoapps/tileserver/#2015/gmapsmaptiler.

However, when I attempt to view a WTMS service in QGIS, it doesn't work.  Specifically, the WMTS connection is fine, but no images appear in QGIS.

If I look at the xml generated by:


I noticed the "resource URL" includes an extra "/wmts/" in the URL:

<ResourceURL format="image/jpeg" resourceType="tile" template="http://wi-naip.s3-website-us-east-1.amazonaws.com/wmts/2015/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.jpg"/>

Seems it should be:

<ResourceURL format="image/jpeg" resourceType="tile" template="http://wi-naip.s3-website-us-east-1.amazonaws.com/2015/{TileMatrixSet}/{TileMatrix}/{TileCol}/{TileRow}.jpg"/>

This would explain why the connection works, but no images are retrieved. Maybe I didn't follow your instructions properly?

Thanks again.



--
You received this message because you are subscribed to a topic in the Google Groups "MapTiler Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/maptiler/muBxif20eOI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to maptiler+u...@googlegroups.com.
To post to this group, send email to mapt...@googlegroups.com.
Visit this group at https://groups.google.com/group/maptiler.
For more options, visit https://groups.google.com/d/optout.

Dalibor Janák

unread,
Mar 4, 2016, 3:27:17 AM3/4/16
to MapTiler Community
Hmm, true. WMTS sent it on /wmtts/ endpoint. My Mistake. It might work if you will put your data in this directories: 

/wmts/2015/GoogleMapsCompatible/
it's:
/wmts/<layername>/<tilematrixset>/
(tilematrixset is in this case always GoogleMapsCompatible if you are using mercator tiles)

This could work now. I will fix it in tileserver but I don't know actually how. 

D.


On Tuesday, February 2, 2016 at 4:40:11 PM UTC+1, Jim Lacy wrote:

Dalibor Janák

unread,
Mar 7, 2016, 9:05:52 AM3/7/16
to MapTiler Community
Jim,

I fixed this wrong wmts url problem. You can now download new version from tileserver-php's master. It should work now.

D.

On Tuesday, February 2, 2016 at 4:40:11 PM UTC+1, Jim Lacy wrote:

Jim Lacy

unread,
Mar 8, 2016, 1:13:46 PM3/8/16
to mapt...@googlegroups.com
Thanks, it works great now. And thank you for making this addition!

Reply all
Reply to author
Forward
0 new messages