예제 #1
0
 def test_datasets(self):
     
     expected = """
     <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://earthexplorer.usgs.gov/inventory/soap">
       <soapenv:Header/>
       <soapenv:Body>
         <soap:datasets soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
           <node xsi:type="xsd:string">EE</node>
           <datasetName xsi:type="xsd:string">L8</datasetName>
           <apiKey xsi:type="xsd:string">USERS API KEY</apiKey>
           <lowerLeft xsi:type="soap:Service_Class_Coordinate">
             <latitude xsi:type="xsd:double">44.60847</latitude>
             <longitude xsi:type="xsd:double">-99.69639</longitude>
           </lowerLeft>
           <upperRight xsi:type="soap:Service_Class_Coordinate">
             <latitude xsi:type="xsd:double">44.60847</latitude>
             <longitude xsi:type="xsd:double">-99.69639</longitude>
           </upperRight>
           <startDate xsi:type="xsd:string">2014-10-01T00:00:00Z</startDate>
           <endDate xsi:type="xsd:string">2014-10-01T23:59:59Z</endDate>
         </soap:datasets>
       </soapenv:Body>
     </soapenv:Envelope>
     """
     
     ll = { "longitude": -99.69639, "latitude": 44.60847 }
     ur = { "longitude": -99.69639, "latitude": 44.60847 }
     start_date = "2014-10-01T00:00:00Z"
     end_date = "2014-10-01T23:59:59Z"
     
     request = soap.datasets("L8", "EE", ll=ll, ur=ur, start_date=start_date, end_date=end_date, api_key="USERS API KEY")
     request = minidom.parseString(request).toprettyxml()
     
     assert compare_xml(request, expected)
예제 #2
0
파일: api.py 프로젝트: jonas-eberle/usgs
def datasets(dataset, node, ll=None, ur=None, start_date=None, end_date=None):

    api_key = _get_api_key()

    xml = soap.datasets(dataset, node, ll=ll, ur=ur, start_date=start_date, end_date=end_date, api_key=api_key)
    r = requests.post(USGS_API, xml)

    root = ElementTree.fromstring(r.text)
    _check_for_usgs_error(root)

    items = root.findall("SOAP-ENV:Body/ns1:datasetsResponse/return/item", NAMESPACES)

    data = map(lambda item: {el.tag: xsi.get(el) for el in item}, items)

    return data
예제 #3
0
    def test_datasets(self):

        expected = """
        <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://earthexplorer.usgs.gov/inventory/soap">
          <soapenv:Header/>
          <soapenv:Body>
            <soap:datasets soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
              <node xsi:type="xsd:string">EE</node>
              <datasetName xsi:type="xsd:string">L8</datasetName>
              <apiKey xsi:type="xsd:string">USERS API KEY</apiKey>
              <lowerLeft xsi:type="soap:Service_Class_Coordinate">
                <latitude xsi:type="xsd:double">44.60847</latitude>
                <longitude xsi:type="xsd:double">-99.69639</longitude>
              </lowerLeft>
              <upperRight xsi:type="soap:Service_Class_Coordinate">
                <latitude xsi:type="xsd:double">44.60847</latitude>
                <longitude xsi:type="xsd:double">-99.69639</longitude>
              </upperRight>
              <startDate xsi:type="xsd:string">2014-10-01T00:00:00Z</startDate>
              <endDate xsi:type="xsd:string">2014-10-01T23:59:59Z</endDate>
            </soap:datasets>
          </soapenv:Body>
        </soapenv:Envelope>
        """

        ll = {"longitude": -99.69639, "latitude": 44.60847}
        ur = {"longitude": -99.69639, "latitude": 44.60847}
        start_date = "2014-10-01T00:00:00Z"
        end_date = "2014-10-01T23:59:59Z"

        request = soap.datasets("L8",
                                "EE",
                                ll=ll,
                                ur=ur,
                                start_date=start_date,
                                end_date=end_date,
                                api_key="USERS API KEY")
        request = minidom.parseString(request).toprettyxml()

        assert compare_xml(request, expected)
예제 #4
0
파일: api.py 프로젝트: danlopez00/usgs
def datasets(dataset, node, ll=None, ur=None, start_date=None, end_date=None):

    api_key = _get_api_key()

    xml = soap.datasets(dataset,
                        node,
                        ll=ll,
                        ur=ur,
                        start_date=start_date,
                        end_date=end_date,
                        api_key=api_key)
    r = requests.post(USGS_API, xml)

    root = ElementTree.fromstring(r.text)
    _check_for_usgs_error(root)

    items = root.findall("SOAP-ENV:Body/ns1:datasetsResponse/return/item",
                         NAMESPACES)

    data = map(lambda item: {el.tag: xsi.get(el) for el in item}, items)

    return data