1

I need to add wms map in my project, and the url of wms server will be provided by users.

Are there any ways to know the type of server (wms or wmts) with the url proposed by users ? Or to know that the server supports tiles or not ?

I want to know this because in Openlayers3, there are two functions to getMap: ol.source.ImageWMS and ol.source.TileWMS. I think I need to know the type of server before calling the right function ol3.

  • In Openlayers 3: ol.source.ImageWMS: 'WMS servers providing single, untiled images'; ol.source.TileWMS: 'WMS servers providing tiles'. And I want to distinguish these two types. – cheesewind Jan 25 '17 at 14:14
3

With WMS & WMTS (as with all OGC services) you can ask for the capabilities of the service with the request=GetCapabilities request. A WMS will respond with a document starting:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE WMT_MS_Capabilities SYSTEM "http://localhost:8080/geoserver/schemas/wms/1.1.1/WMS_MS_Capabilities.dtd">
<WMT_MS_Capabilities version="1.1.1" updateSequence="430">
  <Service>
    <Name>OGC:WMS</Name>

While a WMTS will respond with:

<Capabilities xmlns="http://www.opengis.net/wmts/1.0" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xsi:schemaLocation="http://www.opengis.net/wmts/1.0 http://schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0">
  <ows:ServiceIdentification>
    <ows:Title>Web Map Tile Service - GeoWebCache</ows:Title>
    <ows:ServiceType>OGC WMTS</ows:ServiceType>
    <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion>

When asking a WMS for a WMTS capabilities document, it will reply with

<ServiceExceptionReport version="1.1.1">
<ServiceException code="InvalidFormat">
    Can't recognize service requested.
</ServiceException></ServiceExceptionReport>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.