<?xml version="1.0"?>
<!DOCTYPE WMT_MS_Capabilities SYSTEM "http://schemas.opengis.net/wms/1.0.0/WMS_MS_Capabilities.dtd"
 [
 <!ELEMENT VendorSpecificCapabilities EMPTY>
 ]>  <!-- end of DOCTYPE declaration -->
<WMT_MS_Capabilities version="1.0.0">
<Service>
  <Name>OGC:WMS</Name>
  <Title>{{service.title}}</Title>
  <Abstract>{{service.abstract}}</Abstract>
{{if service.online_resource}}
  <OnlineResource>{{service.online_resource}}</OnlineResource>
{{else}}
  <OnlineResource>{{service.url}}</OnlineResource>
{{endif}}
  <Fees>{{service.get('fees', 'none')}}</Fees>
  <AccessConstraints>{{service.get('access_constraints', 'none')}}</AccessConstraints>
</Service>

<Capability>
  <Request>
    <Capabilities>
      <Format>
        <WMS_XML/>
      </Format>
      <DCPType>
        <HTTP>
          <Get onlineResource="{{service.url}}?"/>
        </HTTP>
      </DCPType>
    </Capabilities>
    <Map>
      <Format>
{{for format in formats}}
{{if wms100format(format)}}
        <{{wms100format(format)}}/>
{{endif}}
{{endfor}}
      </Format>
      <DCPType>
        <HTTP>
          <Get onlineResource="{{service.url}}?"/>
        </HTTP>
      </DCPType>
    </Map>
    <FeatureInfo>
      <Format>
{{for format in info_formats}}
{{if wms100info_format(format)}}
        <{{wms100info_format(format)}}/>
{{endif}}
{{endfor}}
      </Format>
      <DCPType>
        <HTTP>
          <Get onlineResource="{{service.url}}?"/>
        </HTTP>
      </DCPType>
    </FeatureInfo>
  </Request>
  <Exception>
    <Format>
      <INIMAGE/>
      <BLANK/>
      <WMS_XML/>
    </Format>
  </Exception>

{{def layer_capabilities(layer, with_srs=False)}}
  <Layer{{if layer.queryable}} queryable="1"{{endif}}>
    {{if layer.name}}
    <Name>{{ layer.name }}</Name>
    {{endif}}
    <Title>{{ layer.title }}</Title>
    <SRS>{{for s in srs}}{{s}} {{endfor}}</SRS>
    {{py: extent = layer_llbbox(layer)}}
    <LatLonBoundingBox minx="{{ extent[0] }}" miny="{{ extent[1] }}" maxx="{{ extent[2] }}" maxy="{{ extent[3] }}" />
    {{for srs_code, bbox in layer_srs_bbox(layer)}}
    <BoundingBox SRS="{{srs_code}}" minx="{{ bbox[0] }}" miny="{{ bbox[1] }}" maxx="{{ bbox[2] }}" maxy="{{ bbox[3] }}" />
    {{endfor}}
    {{if hasattr(layer, 'dimensions')}}
    {{if layer.dimensions}}
    {{for d in layer.dimensions}}
    {{if "time" in d }}
    <Dimension name="{{d}}" default="{{layer.dimensions[d].default}}" nearestValue="0" units="ISO8601" >{{','.join(layer.dimensions[d])}}</Dimension>
    {{else}}
    <Dimension name="{{d}}" default="{{layer.dimensions[d].default}}" nearestValue="0" >{{','.join(layer.dimensions[d])}}</Dimension>
    {{endif}}
    {{endfor}}
    {{endif}}
    {{endif}}
{{if layer.is_active and layer.has_legend and layer.legend_url}}
    <Style>
      <Name>default</Name>
      <Title>default</Title>
      <StyleURL>{{service.url}}{{layer.legend_url|escape}}</StyleURL>
    </Style>
{{endif}}
    {{if layer.res_range}}
    {{py: max_scale, min_scale = layer.res_range.scale_hint()}}
    <ScaleHint {{if min_scale}}min="{{min_scale}}"{{endif}} {{if max_scale}}max="{{max_scale}}"{{endif}} />
    {{endif}}
    {{for layer in layer.layers}}
{{layer_capabilities(layer, False)|indent}}
    {{endfor}}
  </Layer>
{{enddef}}

{{layer_capabilities(layers, True)}}

</Capability>
</WMT_MS_Capabilities>
