Adds WMS service folder

pull/293/head
Javier Arce 11 years ago
parent 049f99bab8
commit 6dbac1580f

@ -1 +1 @@
Subproject commit d01b7f1c5af23202307a54534024596baa3a81bd
Subproject commit 0595a660981e45469f9824a6f10db275d2c859f3

@ -0,0 +1,103 @@
# encoding: utf-8
require 'uri'
require 'nokogiri'
require 'typhoeus'
module CartoDB
module WMS
class Proxy
SERVER_XPATH = "//OnlineResource[1]"
FORMATS_XPATH = "//GetMap/Format"
LAYERS_XPATH = "//Layer/Layer[BoundingBox or LatLonBoundingBox]"
def initialize(url, preloaded_xml=nil)
@url = url
@response = preloaded_xml
end
def serialize
run
{ server: server, formats: formats, layers: layers }
end
def run
request_capabilities unless response
self
end
def request_capabilities
response = Typhoeus.get(url)
raise URI::InvalidURIError unless [200, 201].include?(response.code)
@response = response.response_body
nil
end
def document
Nokogiri::XML::Document.parse(response).remove_namespaces!
end
def server
(document.at_xpath(SERVER_XPATH) || {})['href']
end
def formats
document.xpath(FORMATS_XPATH).map(&:text)
end
def layers
document.xpath(LAYERS_XPATH).map { |element|
name = element.xpath("./Name").first
title = element.xpath("./Title").first
{
name: (name.text if name),
title: (title.text if title),
crs: crs_for_element(element),
srs: srs_for_element(element),
bounding_boxes: bounding_boxes_for(element),
attribution: nil
}
}
end
def crs_for_element(element)
crs = element.xpath("./CRS").map { |element|
element.text
}.compact
end
def srs_for_element(element)
srs = element.xpath("./SRS").map { |element|
element.text
}.compact
end
def bounding_boxes_for(element)
bounding_boxes = element.xpath("./BoundingBox").map { |element|
srs = element.xpath("./@SRS").first
crs = element.xpath("./@CRS").first
minx = element.xpath("./@minx").first
miny = element.xpath("./@miny").first
maxx = element.xpath("./@maxx").first
maxy = element.xpath("./@maxy").first
{
srs: (srs.value if srs),
crs: (crs.value if crs),
minx: (minx.value if minx),
miny: (miny.value if miny),
maxx: (maxx.value if maxx),
maxy: (maxy.value if maxy),
}
}
end
attr_reader :response
private
attr_reader :url
end # Proxy
end # WMS
end # CartoDB

@ -0,0 +1,657 @@
<?xml version="1.0"?>
<WMS_Capabilities version="1.3.0" xmlns="http://www.opengis.net/wms" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:esri_wms="http://www.esri.com/wms"
xsi:schemaLocation="http://www.opengis.net/wms http://schemas.opengis.net/wms/1.3.0/capabilities_1_3_0.xsd http://www.esri.com/wms http://basemap.nationalmap.gov/arcgis/services/USGSImageryTopo/MapServer/WMSServer?version=1.3.0&amp;service=WMS&amp;request=GetSchemaExtension">
<Service>
<Name>USGSImageryTopo WMS</Name>
<Title>USGSImageryTopo</Title>
<Abstract>WMS</Abstract>
<KeywordList><Keyword></Keyword></KeywordList>
<OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://basemap.nationalmap.gov/arcgis/services/USGSImageryTopo/MapServer/WMSServer"/>
<ContactInformation>
<ContactPersonPrimary>
<ContactPerson>&gt;</ContactPerson>
<ContactOrganization>&gt;</ContactOrganization>
</ContactPersonPrimary>
<ContactPosition>&gt;</ContactPosition>
<ContactAddress>
<AddressType>&gt;</AddressType>
<Address></Address>
<City></City>
<StateOrProvince></StateOrProvince>
<PostCode></PostCode>
<Country></Country>
</ContactAddress>
<ContactVoiceTelephone></ContactVoiceTelephone>
<ContactFacsimileTelephone></ContactFacsimileTelephone>
<ContactElectronicMailAddress></ContactElectronicMailAddress>
</ContactInformation>
<Fees></Fees>
<AccessConstraints></AccessConstraints>
<MaxWidth>2048</MaxWidth>
<MaxHeight>2048</MaxHeight>
</Service>
<Capability>
<Request>
<GetCapabilities>
<Format>application/vnd.ogc.wms_xml</Format>
<Format>text/xml</Format>
<DCPType>
<HTTP><Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://basemap.nationalmap.gov/arcgis/services/USGSImageryTopo/MapServer/WMSServer"/></Get></HTTP>
</DCPType>
</GetCapabilities>
<GetMap>
<Format>image/bmp</Format>
<Format>image/jpeg</Format>
<Format>image/tiff</Format>
<Format>image/png</Format>
<Format>image/png8</Format>
<Format>image/png24</Format>
<Format>image/png32</Format>
<Format>image/gif</Format>
<Format>image/svg+xml</Format>
<DCPType>
<HTTP><Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://basemap.nationalmap.gov/arcgis/services/USGSImageryTopo/MapServer/WMSServer"/></Get></HTTP>
</DCPType>
</GetMap>
<GetFeatureInfo>
<Format>application/vnd.esri.wms_raw_xml</Format>
<Format>application/vnd.esri.wms_featureinfo_xml</Format>
<Format>application/vnd.ogc.wms_xml</Format>
<Format>text/xml</Format>
<Format>text/html</Format>
<Format>text/plain</Format>
<DCPType>
<HTTP><Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://basemap.nationalmap.gov/arcgis/services/USGSImageryTopo/MapServer/WMSServer"/></Get></HTTP>
</DCPType>
</GetFeatureInfo>
<esri_wms:GetStyles>
<Format>application/vnd.ogc.sld+xml</Format>
<DCPType>
<HTTP><Get><OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="http://basemap.nationalmap.gov/arcgis/services/USGSImageryTopo/MapServer/WMSServer"/></Get></HTTP>
</DCPType>
</esri_wms:GetStyles>
</Request>
<Exception>
<Format>application/vnd.ogc.se_xml</Format>
<Format>application/vnd.ogc.se_inimage</Format>
<Format>application/vnd.ogc.se_blank</Format>
<Format>text/xml</Format>
<Format>XML</Format>
</Exception>
<Layer>
<Title>Layers</Title>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:4269</CRS>
<CRS>EPSG:4267</CRS>
<CRS>EPSG:54004</CRS>
<CRS>EPSG:54008</CRS>
<CRS>EPSG:3785</CRS>
<CRS>EPSG:102113</CRS>
<CRS>EPSG:3857</CRS>
<CRS>EPSG:102100</CRS>
<CRS>EPSG:900913</CRS>
<CRS>EPSG:7250</CRS>
<CRS>EPSG:102016</CRS>
<CRS>EPSG:102017</CRS>
<CRS>EPSG:3571</CRS>
<CRS>EPSG:3572</CRS>
<CRS>EPSG:3573</CRS>
<CRS>EPSG:3574</CRS>
<CRS>EPSG:3575</CRS>
<CRS>EPSG:3576</CRS>
<CRS>EPSG:3338</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-179.999999999987</westBoundLongitude><eastBoundLongitude>179.999999999987</eastBoundLongitude><southBoundLatitude>-88.9999999999999</southBoundLatitude><northBoundLatitude>88.9999999999999</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="-179.999999999987" miny="-88.9999999999999" maxx="179.999999999987" maxy="88.9999999999999"/>
<BoundingBox CRS="EPSG:4326" minx="-88.9999999999999" miny="-179.999999999987" maxx="88.9999999999999" maxy="179.999999999987"/>
<BoundingBox CRS="EPSG:3857" minx="-57845181.481398" miny="-43671999.9717797" maxx="36550267.9771861" maxy="54010853.1992924"/>
<Layer queryable="1">
<Title>Level 15 - 1:18K - 24k QUAD </Title>
<Abstract>Level 15 - 1:18K - 24k QUAD </Abstract>
<MinScaleDenominator>17060.900298</MinScaleDenominator>
<MaxScaleDenominator>25564.419643</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Elevation (Line)</Title>
<Abstract>Elevation (Line)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Structure</Title>
<Abstract>Structure</Abstract>
</Layer>
<Layer queryable="1">
<Title>Geographic Name</Title>
<Abstract>Geographic Name</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 14 - 1:36k - Town QUAD</Title>
<Abstract>Level 14 - 1:36k - Town QUAD</Abstract>
<MinScaleDenominator>25565.364583</MinScaleDenominator>
<MaxScaleDenominator>51127.894345</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Elevation (Line)</Title>
<Abstract>Elevation (Line)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Structure</Title>
<Abstract>Structure</Abstract>
</Layer>
<Layer queryable="1">
<Title>Geographic Name</Title>
<Abstract>Geographic Name</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 13 - 1:72k - City</Title>
<Abstract>Level 13 - 1:72k - City</Abstract>
<MinScaleDenominator>51128.839286</MinScaleDenominator>
<MaxScaleDenominator>102255.788690</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Elevation (Line)</Title>
<Abstract>Elevation (Line)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Structure</Title>
<Abstract>Structure</Abstract>
</Layer>
<Layer queryable="1">
<Title>Geographic Name</Title>
<Abstract>Geographic Name</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 12 - 1:144k - Cities</Title>
<Abstract>Level 12 - 1:144k - Cities</Abstract>
<MinScaleDenominator>102256.733631</MinScaleDenominator>
<MaxScaleDenominator>204512.522321</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Elevation (Line)</Title>
<Abstract>Elevation (Line)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Structure</Title>
<Abstract>Structure</Abstract>
</Layer>
<Layer queryable="1">
<Title>Geographic Name</Title>
<Abstract>Geographic Name</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 11 - 1:288k - Metro</Title>
<Abstract>Level 11 - 1:288k - Metro</Abstract>
<MinScaleDenominator>204513.467262</MinScaleDenominator>
<MaxScaleDenominator>409025.044643</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Elevation (Line)</Title>
<Abstract>Elevation (Line)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Structure</Title>
<Abstract>Structure</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 10 - 1:577k - County</Title>
<Abstract>Level 10 - 1:577k - County</Abstract>
<MinScaleDenominator>409025.989583</MinScaleDenominator>
<MaxScaleDenominator>818050.089286</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Elevation (Line)</Title>
<Abstract>Elevation (Line)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Structure</Title>
<Abstract>Structure</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 9 - 1:1.15M - Counties</Title>
<Abstract>Level 9 - 1:1.15M - Counties</Abstract>
<MinScaleDenominator>818051.034226</MinScaleDenominator>
<MaxScaleDenominator>1636099.233631</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Structure</Title>
<Abstract>Structure</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 8 - 1:2.3M - States</Title>
<Abstract>Level 8 - 1:2.3M - States</Abstract>
<MinScaleDenominator>1636100.178571</MinScaleDenominator>
<MaxScaleDenominator>3272198.467262</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Structure</Title>
<Abstract>Structure</Abstract>
</Layer>
<Layer queryable="1">
<Title>Geographic Name</Title>
<Abstract>Geographic Name</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 7 - 1:4.6M - Region</Title>
<Abstract>Level 7 - 1:4.6M - Region</Abstract>
<MinScaleDenominator>3272199.412202</MinScaleDenominator>
<MaxScaleDenominator>6544397.879464</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Geographic Name</Title>
<Abstract>Geographic Name</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 6 - 1:9.2M - Time Zone</Title>
<Abstract>Level 6 - 1:9.2M - Time Zone</Abstract>
<MinScaleDenominator>6544398.824405</MinScaleDenominator>
<MaxScaleDenominator>13088795.758929</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Geographic Name</Title>
<Abstract>Geographic Name</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 5 - 1:18M - Continental US</Title>
<Abstract>Level 5 - 1:18M - Continental US</Abstract>
<MinScaleDenominator>13088796.703869</MinScaleDenominator>
<MaxScaleDenominator>26177591.517857</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Geographic Name</Title>
<Abstract>Geographic Name</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 4 - 1:37M - Continent</Title>
<Abstract>Level 4 - 1:37M - Continent</Abstract>
<MinScaleDenominator>26177592.462798</MinScaleDenominator>
<MaxScaleDenominator>52355183.035714</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Transportation</Title>
<Abstract>Transportation</Abstract>
</Layer>
<Layer queryable="1">
<Title>Geographic Name</Title>
<Abstract>Geographic Name</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 3 - 1:73M - Hemisphere</Title>
<Abstract>Level 3 - 1:73M - Hemisphere</Abstract>
<MinScaleDenominator>52355183.980655</MinScaleDenominator>
<MaxScaleDenominator>104710365.126488</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Outline)</Title>
<Abstract>Hydrography (Outline)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 2 - 1:147M - World</Title>
<Abstract>Level 2 - 1:147M - World</Abstract>
<MinScaleDenominator>104710366.071429</MinScaleDenominator>
<MaxScaleDenominator>167962034.769345</MaxScaleDenominator>
<Layer queryable="1">
<Title>Elevation (Relief)</Title>
<Abstract>Elevation (Relief)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Fill)</Title>
<Abstract>Boundary (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
</Layer>
</Layer>
<Layer queryable="1">
<Title>Level 0 and 1 - 1:584M and 1:292M Globe</Title>
<Abstract>Level 0 and 1 - 1:584M and 1:292M Globe</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-179.999988541187</westBoundLongitude><eastBoundLongitude>179.999988541187</eastBoundLongitude><southBoundLatitude>-88.9999999999999</southBoundLatitude><northBoundLatitude>83.6041545451803</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="-179.999988541187" miny="-88.9999999999999" maxx="179.999988541187" maxy="83.6041545451803"/>
<BoundingBox CRS="EPSG:4326" minx="-88.9999999999999" miny="-179.999988541187" maxx="83.6041545451803" maxy="179.999988541187"/>
<BoundingBox CRS="EPSG:3857" minx="-20037507.0672" miny="-30240971.9584" maxx="20037507.0672" maxy="18398924.7227"/>
<MinScaleDenominator>167962035.714286</MinScaleDenominator>
<Layer queryable="1">
<Title>Hydrography (Fill)</Title>
<Abstract>Hydrography (Fill)</Abstract>
</Layer>
<Layer queryable="1">
<Title>Boundary (Outline)</Title>
<Abstract>Boundary (Outline)</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-179.999988541187</westBoundLongitude><eastBoundLongitude>179.999988541187</eastBoundLongitude><southBoundLatitude>-88.9999999999999</southBoundLatitude><northBoundLatitude>83.6041545451803</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="-179.999988541187" miny="-88.9999999999999" maxx="179.999988541187" maxy="83.6041545451803"/>
<BoundingBox CRS="EPSG:4326" minx="-88.9999999999999" miny="-179.999988541187" maxx="83.6041545451803" maxy="179.999988541187"/>
<BoundingBox CRS="EPSG:3857" minx="-20037507.0672" miny="-30240971.9584" maxx="20037507.0672" maxy="18398924.7227"/>
<Layer queryable="1">
<Name>121</Name>
<Title>_</Title>
<Abstract>_</Abstract>
<CRS>CRS:84</CRS>
<CRS>EPSG:4326</CRS>
<CRS>EPSG:3857</CRS>
<EX_GeographicBoundingBox><westBoundLongitude>-179.999988541187</westBoundLongitude><eastBoundLongitude>179.999988541187</eastBoundLongitude><southBoundLatitude>-88.9999999999999</southBoundLatitude><northBoundLatitude>83.6041545451803</northBoundLatitude></EX_GeographicBoundingBox>
<BoundingBox CRS="CRS:84" minx="-179.999988541187" miny="-88.9999999999999" maxx="179.999988541187" maxy="83.6041545451803"/>
<BoundingBox CRS="EPSG:4326" minx="-88.9999999999999" miny="-179.999988541187" maxx="83.6041545451803" maxy="179.999988541187"/>
<BoundingBox CRS="EPSG:3857" minx="-20037507.0672" miny="-30240971.9584" maxx="20037507.0672" maxy="18398924.7227"/>
<Style>
<Name>default</Name>
<Title>121</Title>
<LegendURL width="32" height="16">
<Format>image/png</Format>
<OnlineResource xlink:href="http://basemap.nationalmap.gov/arcgis/services/USGSImageryTopo/MapServer/WMSServer?request=GetLegendGraphic%26version=1.3.0%26format=image/png%26layer=121" xlink:type="simple" xmlns:xlink="http://www.w3.org/1999/xlink"/>
</LegendURL>
</Style>
</Layer>
</Layer>
</Layer>
</Layer>
</Capability>
</WMS_Capabilities>

File diff suppressed because one or more lines are too long

@ -0,0 +1,219 @@
<?xml version="1.0" standalone="no"?>
<!-- The DTD (Document Type Definition) given here must correspond to the version number declared in the WMT_MS_Capabilities element below. -->
<!DOCTYPE WMT_MS_Capabilities SYSTEM "http://www2.demis.nl/WMS/capabilities_1_0_0.dtd" [
<!-- Output formats known to this server are defined here
if necessary (only if a format not already listed in the WMT
Capabilities DTD is needed). To define a new format, place
an entity definition for KnownFormats like the one below in
the DOCTYPE declaration of your Capabilities XML, listing at
minimum all of the formats you support and separating each
by logical-OR (|) characters. Then, define a new element
for any formats not predefined by WMT. For example, in the
following list "SGI" is a server-specific format, while all
the others are known WMT-wide. Thus, SGI is included in the
KnownFormats list and a new empty element <SGI/> is
defined. -->
<!ENTITY % KnownFormats " SGI | GIF | JPEG | PNG | WebCGM | SVG | GML.1
| WMS_XML | MIME | INIMAGE | PPM | BLANK " >
<!ELEMENT SGI EMPTY> <!-- Silicon Graphics RGB Format -->
<!-- other vendor-specific elements defined here -->
<!ELEMENT VendorSpecificCapabilities (YMD)>
<!ELEMENT YMD (Title, Abstract)>
<!ATTLIST YMD required (0 | 1) "0">
]>
<!-- end of DOCTYPE declaration -->
<!-- The version number listed in the WMT_MS_Capabilities element here must correspond to the DTD declared above. See the WMT specification document for how to respond when a client requests a version number not implemented by the server. -->
<WMT_MS_Capabilities version="1.0.0">
<Service>
<!-- The WMT-defined name for this type of service -->
<Name>GetMap</Name>
<!-- Human-readable title for pick lists -->
<Title>World Map</Title>
<!-- Narrative description providing additional information -->
<Abstract>None</Abstract>
<Keywords></Keywords>
<!-- Top-level address of service or service provider. See also onlineResource attributes of <DCPType> children. -->
<OnlineResource>http://www2.demis.nl</OnlineResource>
<!-- Fees or access constraints imposed. -->
<Fees>none</Fees>
<AccessConstraints>none</AccessConstraints>
</Service>
<Capability>
<Request>
<Map>
<Format>
<GIF/>
<JPEG/>
<PNG/>
<BMP/>
</Format>
<DCPType>
<HTTP>
<!-- The URL here for HTTP GET requests includes only the prefix before the query string.-->
<Get onlineResource="http://www2.demis.nl/WMS/wms.ashx?wms=WorldMap&amp;"/>
</HTTP>
</DCPType>
</Map>
<Capabilities>
<Format>
<WMS_XML/>
</Format>
<DCPType>
<HTTP>
<!-- The URL here for HTTP GET requests includes only the prefix before the query string.-->
<Get onlineResource="http://www2.demis.nl/WMS/wms.ashx?wms=WorldMap&amp;"/>
</HTTP>
</DCPType>
</Capabilities>
<FeatureInfo>
<Format>
<MIME/>
</Format>
<DCPType>
<HTTP>
<!-- The URL here for HTTP GET requests includes only the prefix before the the query string.-->
<Get onlineResource="http://www2.demis.nl/WMS/wms.ashx?wms=WorldMap&amp;"/>
</HTTP>
</DCPType>
</FeatureInfo>
</Request>
<Exception>
<Format>
<WMS_XML/>
<INIMAGE/>
<BLANK/>
</Format>
</Exception>
<Layer>
<Title>World Map</Title>
<Abstract/>
<SRS>EPSG:4326</SRS>
<LatLonBoundingBox minx="-180" miny="-90" maxx="180" maxy="90"/>
<BoundingBox SRS="EPSG:4326" minx="-184" miny="-90" maxx="180" maxy="90"/>
<Layer queryable="1">
<Name>Bathymetry</Name>
<Title>Bathymetry</Title>
<BoundingBox SRS="EPSG:4326" minx="-180" miny="-90" maxx="180" maxy="90"/>
<ScaleHint min="0" max="14000"/>
</Layer>
<Layer queryable="1">
<Name>Countries</Name>
<Title>Countries</Title>
<BoundingBox SRS="EPSG:4326" minx="-184" miny="-90" maxx="180" maxy="85"/>
<ScaleHint min="0" max="14000"/>
</Layer>
<Layer queryable="1">
<Name>Topography</Name>
<Title>Topography</Title>
<BoundingBox SRS="EPSG:4326" minx="-184" miny="-90" maxx="180" maxy="90"/>
<ScaleHint min="0" max="14000"/>
</Layer>
<Layer queryable="0">
<Name>Hillshading</Name>
<Title>Hillshading</Title>
<BoundingBox SRS="EPSG:4326" minx="-180" miny="-90" maxx="180" maxy="90"/>
<ScaleHint min="0" max="14000"/>
</Layer>
<Layer queryable="1">
<Name>Builtup areas</Name>
<Title>Builtup areas</Title>
<BoundingBox SRS="EPSG:4326" minx="-180" miny="-55" maxx="180" maxy="75"/>
<ScaleHint min="0" max="1400"/>
</Layer>
<Layer queryable="1">
<Name>Coastlines</Name>
<Title>Coastlines</Title>
<BoundingBox SRS="EPSG:4326" minx="-184" miny="-90" maxx="180" maxy="85"/>
<ScaleHint min="0" max="11200"/>
</Layer>
<Layer queryable="1">
<Name>Waterbodies</Name>
<Title>Waterbodies</Title>
<BoundingBox SRS="EPSG:4326" minx="-184" miny="-79.0616683959961" maxx="180" maxy="85"/>
<ScaleHint min="0" max="5600"/>
</Layer>
<Layer queryable="1">
<Name>Inundated</Name>
<Title>Inundated</Title>
<BoundingBox SRS="EPSG:4326" minx="-180" miny="-50" maxx="180" maxy="80"/>
<ScaleHint min="0" max="1400"/>
</Layer>
<Layer queryable="1">
<Name>Rivers</Name>
<Title>Rivers</Title>
<BoundingBox SRS="EPSG:4326" minx="-180" miny="-55" maxx="180" maxy="85"/>
<ScaleHint min="0" max="11200"/>
</Layer>
<Layer queryable="1">
<Name>Streams</Name>
<Title>Streams</Title>
<BoundingBox SRS="EPSG:4326" minx="-180" miny="-55" maxx="180" maxy="85"/>
<ScaleHint min="0" max="5600"/>
</Layer>
<Layer queryable="1">
<Name>Railroads</Name>
<Title>Railroads</Title>
<BoundingBox SRS="EPSG:4326" minx="-170" miny="-55" maxx="180" maxy="80"/>
<ScaleHint min="0" max="840"/>
</Layer>
<Layer queryable="1">
<Name>Highways</Name>
<Title>Highways</Title>
<BoundingBox SRS="EPSG:4326" minx="-175" miny="-55" maxx="180" maxy="75"/>
<ScaleHint min="0" max="700"/>
</Layer>
<Layer queryable="1">
<Name>Roads</Name>
<Title>Roads</Title>
<BoundingBox SRS="EPSG:4326" minx="-184" miny="-55" maxx="180" maxy="75"/>
<ScaleHint min="0" max="420"/>
</Layer>
<Layer queryable="1">
<Name>Trails</Name>
<Title>Trails</Title>
<BoundingBox SRS="EPSG:4326" minx="-184" miny="-50" maxx="180" maxy="80"/>
<ScaleHint min="0" max="280"/>
</Layer>
<Layer queryable="1">
<Name>Borders</Name>
<Title>Borders</Title>
<BoundingBox SRS="EPSG:4326" minx="-184" miny="-60" maxx="176" maxy="75"/>
<ScaleHint min="0" max="11200"/>
</Layer>
<Layer queryable="1">
<Name>Cities</Name>
<Title>Cities</Title>
<BoundingBox SRS="EPSG:4326" minx="-180" miny="-55" maxx="180" maxy="75"/>
<ScaleHint min="0" max="28000"/>
</Layer>
<Layer queryable="1">
<Name>Settlements</Name>
<Title>Settlements</Title>
<BoundingBox SRS="EPSG:4326" minx="-180" miny="-55" maxx="180" maxy="85"/>
<ScaleHint min="0" max="560"/>
</Layer>
<Layer queryable="0">
<Name>Spot elevations</Name>
<Title>Spot elevations</Title>
<BoundingBox SRS="EPSG:4326" minx="-179.983093261719" miny="-89.83837890625" maxx="179.991439819336" maxy="83.5204086303711"/>
<ScaleHint min="0" max="280"/>
</Layer>
<Layer queryable="1">
<Name>Airports</Name>
<Title>Airports</Title>
<BoundingBox SRS="EPSG:4326" minx="-184" miny="-55" maxx="180" maxy="80"/>
<ScaleHint min="0" max="560"/>
</Layer>
<Layer queryable="1">
<Name>Ocean features</Name>
<Title>Ocean features</Title>
<BoundingBox SRS="EPSG:4326" minx="-180" miny="-62.9231796264648" maxx="179.999420166016" maxy="68.6906585693359"/>
<ScaleHint min="0" max="2800"/>
</Layer>
</Layer>
</Capability>
</WMT_MS_Capabilities>

@ -0,0 +1,110 @@
# encoding: utf-8
gem 'minitest'
require 'minitest/autorun'
require_relative '../../proxy'
include CartoDB::WMS
describe Proxy do
before do
@endpoint = "http://basemap.nationalmap.gov" +
"/arcgis/services/USGSImageryTopo/MapServer/WMSServer"
@query_params = "?service=WMS&request=GetCapabilities"
@url = @endpoint + @query_params
@fixture_xml = File.expand_path('../../fixtures/wms.xml', __FILE__)
@xml = File.read(@fixture_xml)
sample_response = {
server: @url,
formats: ["image/jpeg", "image/png"],
layers: [
{
name: "layer 1",
attribution: "attribution message"
},
{
name: "layer 2",
attribution: "attribution message"
}
]
}
end
describe '#initialize' do
it 'takes a URL for the service capabilities' do
lambda { Proxy.new }.must_raise ArgumentError
Proxy.new(@url)
end
it 'accepts an optional preloaded response' do
proxy = Proxy.new(@url, @xml)
proxy.response.must_equal @xml
end
end
describe '#serialize' do
it 'returns a hash representation of the WMS capabilities' do
proxy = Proxy.new(@url, @xml)
representation = proxy.serialize
representation.fetch(:server).wont_be_nil
representation.fetch(:formats).wont_be_empty
representation.fetch(:layers).wont_be_empty
end
end
describe '#run' do
it 'will not touch the preloaded response if passed at initialization' do
proxy = Proxy.new(@url, @xml)
proxy.response.must_equal @xml
proxy.run
proxy.response.must_equal @xml
end
end
describe '#server' do
it 'returns the HTTP/HTTPS entry point for the services' do
proxy = Proxy.new(@url, @xml)
proxy.run
proxy.server.must_equal @endpoint
end
end
describe '#layers' do
it 'returns available layers' do
proxy = Proxy.new(@url, @xml)
proxy.run
proxy.layers.length.must_equal 3
url = "http://www2.demis.nl/worldmap/wms.asp?request=GetCapabilities&version=1.0.0"
proxy = Proxy.new(url)
proxy.run
proxy.layers.wont_be_empty
url = "http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs?service=WMS&request=GetCapabilities"
proxy = Proxy.new(url)
proxy.run
proxy.layers.wont_be_empty
end
end
describe '#formats' do
it 'returns the supported formats' do
expected_formats = [
'image/bmp',
'image/jpeg',
'image/tiff',
'image/png',
'image/png8',
'image/png24',
'image/png32',
'image/gif',
'image/svg+xml'
]
proxy = Proxy.new(@url, @xml)
proxy.run
proxy.formats.sort.must_equal expected_formats.sort
end
end
end # Proxy
Loading…
Cancel
Save