2017-08-05 62 views
2

我需要一些幫助從這個GML編碼的WMS響應XML文件中獲取天氣細節溫度等。這是我從天氣服務獲得的,它提供了帶有Web服務目錄服務(CSW),Web地圖服務(WMS)和Web特徵服務(WFS)的開放數據。與JSON/XML不同,我不知道這個文件中發生了什麼。請建議對斯威夫特3.解析GML編碼的WFS響應XML文件

<?xml version="1.0" encoding="UTF-8"?> 
<wfs:FeatureCollection 
    timeStamp="2017-07-31T15:48:01Z" 
    numberMatched="1" 
    numberReturned="1" 
    xmlns:wfs="http://www.opengis.net/wfs/2.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:xlink="http://www.w3.org/1999/xlink" 
    xmlns:om="http://www.opengis.net/om/2.0" 
    xmlns:omso="http://inspire.ec.europa.eu/schemas/omso/3.0" 
    xmlns:ompr="http://inspire.ec.europa.eu/schemas/ompr/3.0" 
    xmlns:gml="http://www.opengis.net/gml/3.2" 
    xmlns:gmd="http://www.isotc211.org/2005/gmd" 
    xmlns:gco="http://www.isotc211.org/2005/gco" 
    xmlns:swe="http://www.opengis.net/swe/2.0" 
    xmlns:gmlcov="http://www.opengis.net/gmlcov/1.0" 
    xmlns:sam="http://www.opengis.net/sampling/2.0" 
    xmlns:sams="http://www.opengis.net/samplingSpatial/2.0" 
    xmlns:target="http://xml.fmi.fi/namespace/om/atmosphericfeatures/1.0" 
    xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd 
    http://www.opengis.net/gmlcov/1.0 http://schemas.opengis.net/gmlcov/1.0/gmlcovAll.xsd 
    http://www.opengis.net/sampling/2.0 http://schemas.opengis.net/sampling/2.0/samplingFeature.xsd 
    http://www.opengis.net/samplingSpatial/2.0 http://schemas.opengis.net/samplingSpatial/2.0/spatialSamplingFeature.xsd 
    http://www.opengis.net/swe/2.0 http://schemas.opengis.net/sweCommon/2.0/swe.xsd 
    http://inspire.ec.europa.eu/schemas/omso/3.0 http://inspire.ec.europa.eu/schemas/omso/3.0/SpecialisedObservations.xsd 
    http://inspire.ec.europa.eu/schemas/ompr/3.0 http://inspire.ec.europa.eu/schemas/ompr/3.0/Processes.xsd 
    http://xml.fmi.fi/namespace/om/atmosphericfeatures/1.0 http://xml.fmi.fi/schema/om/atmosphericfeatures/1.0/atmosphericfeatures.xsd"> 

    <wfs:member> 
     <omso:GridSeriesObservation gml:id="WFS-l9pen.SrlipXUb8ZfAc8nS2h_8.JTowuYWbbpdOs2_llx4efR060aeWzDtdOufXlmw48rp1w36d3R0629dnTTw36d3THv7ZeWHPlhaWLLn07qmnbltQ_wp37hjvCY2PlzrUi0Kcd06aMmrhnZd2Spp25bUP8KhE4V2nBm07sk7Lh5ZefSth2ackhmZ8u_Tk51mNmbRy2ZujXl899_LJf39svLvy09MOLZliaWzL2y7KnnhlqZmzfjw7MtambTfjSV3XpmcNbbh8RNPPph3Y8tK1dCA1tunnz07s9TL46VjTsM5lbd.TLsrM0aeWzDtZXDDyw7a1I.XfwkZdOfR0rWqZdvDLyw9OvLLWhQ5ZefPryy1oSOu3Tk09PNbVfTuyRNPLLj6ad.6tavp3ZKfDLlyTadZ1fTuyVZtOs6vp3ZK02nWtNw.NO3rtr6d2StCvp3ZI_Xn0rQiZe9Dfp3dK3qm_ph2Q9m_rkh7.2XlW5Xy4emjLyp.duLfsZ1tTN_eHs39ckPf2y8q4JuXJp67Yezf1yQ9_bLyrckac.iHs39ckPf2y8q3qHLLj08NPTD0079zHRXNQ5Zcenhp6Yemnfug7d_Xd0r2pYcmnD00790fZvxYdkHHj67euzD00791d1LDk04emnfumV4OPH129dmHpp37qwwqWHJpw9NO_dOy9KfXlmw48syvBx4.u3rsw9NO_dWGFSw5NOHpp37p2XpT68s2HHlp14OPH129dmHpp37q.KWHJpw9NO_dE05s3Xnlg48fXb12YemnfubnPpv5ZcnHrl5eb.nJXmFm26XTrNv5ZceHn0dOtGnlsw7XTrn15ZsOPK6dcN.nd0dOtvXZ008N.nd0x7.2Xlhz5Wh007ctPpl4T8hNDpp25bW_dlrGq1IYA-"> 
        <om:phenomenonTime> 
       <gml:TimePeriod gml:id="time-interval-1-1"> 
        <gml:beginPosition>2017-07-31T16:00:00Z</gml:beginPosition> 
        <gml:endPosition>2017-08-02T03:00:00Z</gml:endPosition> 
       </gml:TimePeriod> 
      </om:phenomenonTime> 
      <om:resultTime> 
       <gml:TimeInstant gml:id="time-1-1"> 
        <gml:timePosition>2017-07-31T12:00:00Z</gml:timePosition> 
       </gml:TimeInstant> 
      </om:resultTime> 

     <om:procedure xlink:href="http://xml.fmi.fi/inspire/process/hirlam"/> 
      <om:parameter> 
       <om:NamedValue> 
        <om:name xlink:href="http://xml.fmi.fi/inspire/process/hirlam"/> 
        <om:value> 
         <gml:TimeInstant gml:id="analysis-time-1-1"> 
          <gml:timePosition>2017-07-31T12:00:00Z</gml:timePosition> 
         </gml:TimeInstant> 
        </om:value> 
       </om:NamedValue> 
      </om:parameter> 
      <om:observedProperty xlink:href="http://data.fmi.fi/fmi-apikey/e35dc8fd-a855-4db5-a327-418120f64a86/meta?observableProperty=forecast&amp;param=GeopHeight,Temperature,Pressure,Humidity,WindDirection,WindSpeedMS,WindUMS,WindVMS,MaximumWind,WindGust,DewPoint,TotalCloudCover,WeatherSymbol3,LowCloudCover,MediumCloudCover,HighCloudCover,Precipitation1h,PrecipitationAmount,RadiationGlobalAccumulation,RadiationLWAccumulation,RadiationNetSurfaceLWAccumulation,RadiationNetSurfaceSWAccumulation,RadiationDiffuseAccumulation&amp;language=eng"/> 
        <om:featureOfInterest> 
       <sams:SF_SpatialSamplingFeature gml:id="enn-s-1-1-"> 
      <sam:sampledFeature> 
     <target:LocationCollection gml:id="sampled-target-1-1"> 
      <target:member> 
      <target:Location gml:id="forloc-geoid-634963-pos"> 
       <gml:identifier codeSpace="http://xml.fmi.fi/namespace/stationcode/geoid">634963</gml:identifier> 
      <gml:name codeSpace="http://xml.fmi.fi/namespace/locationcode/name">Tampere</gml:name> 
      <gml:name codeSpace="http://xml.fmi.fi/namespace/locationcode/geoid">634963</gml:name> 
      <target:representativePoint xlink:href="#point-634963"/> 
      <target:country codeSpace="http://xml.fmi.fi/namespace/location/country">Finland</target:country> 
      <target:timezone>Europe/Helsinki</target:timezone> 
      <target:region codeSpace="http://xml.fmi.fi/namespace/location/region">Finland</target:region>    
      </target:Location></target:member> 
     </target:LocationCollection> 
     </sam:sampledFeature> 
       <sams:shape> 
        <gml:MultiPoint gml:id="sf-1-1-"> 
         <gml:pointMembers> 
          <gml:Point gml:id="point-634963" srsName="http://www.opengis.net/def/crs/EPSG/0/4258" srsDimension="2"> 
           <gml:name>Tampere</gml:name> 
           <gml:pos>61.49911 23.78712 </gml:pos> 
          </gml:Point> 
         </gml:pointMembers> 
        </gml:MultiPoint> 
       </sams:shape> 
      </sams:SF_SpatialSamplingFeature> 
     </om:featureOfInterest> 
       <om:result> 
     <gmlcov:MultiPointCoverage gml:id="mpcv-1-1"> 
      <gml:domainSet> 
      <gmlcov:SimpleMultiPoint gml:id="mp-1-1" srsName="http://xml.fmi.fi/gml/crs/compoundCRS.php?crs=4258&amp;time=unixtime" srsDimension="3"> 
       <gmlcov:positions> 
       61.49911 23.78712 1501516800 
       61.49911 23.78712 1501520400 
       61.49911 23.78712 1501524000 
       61.49911 23.78712 1501527600 
       61.49911 23.78712 1501531200 
       </gmlcov:positions> 
      </gmlcov:SimpleMultiPoint> 
      </gml:domainSet> 
      <gml:rangeSet> 
      <gml:DataBlock> 
       <gml:rangeParameters/> 
       <gml:doubleOrNilReasonTupleList> 
       113.01 18.26 1007.03 92.74 259.0 3.79 
       113.01 17.79 1007.48 90.02 250.0 3.04 
       113.01 17.13 1007.82 93.62 229.0 2.19 
       113.01 16.42 1008.18 95.53 216.0 2.26 
       113.01 15.9 1008.89 97.09 211.0 2.74 
       </gml:doubleOrNilReasonTupleList> 
      </gml:DataBlock> 
      </gml:rangeSet> 
      <gml:coverageFunction> 
      <gml:CoverageMappingRule> 
       <gml:ruleDefinition>Linear</gml:ruleDefinition> 
      </gml:CoverageMappingRule> 
      </gml:coverageFunction> 
      <gmlcov:rangeType> 
      <swe:DataRecord> 
       <swe:field name="GeopHeight" xlink:href="http://"/> 
       <swe:field name="Temperature" xlink:href="http://"/> 
       <swe:field name="Pressure" xlink:href="http://"/> 
       <swe:field name="Humidity" xlink:href="http://"/> 
       <swe:field name="WindDirection" xlink:href="http://"/> 
       <swe:field name="WindSpeedMS" xlink:href="http://"/> 
       </swe:DataRecord> 
      </gmlcov:rangeType> 
     </gmlcov:MultiPointCoverage> 
     </om:result> 

     </omso:GridSeriesObservation> 
    </wfs:member> 

</wfs:FeatureCollection> 

回答

0

一些解決方案,我不能幫你迅速的,但我也許可以點你怎麼看這個文件:

什麼,你基本上需要的是這三個要素:

<gmlcov:positions> 
    61.49911 23.78712 1501516800 
    61.49911 23.78712 1501520400 
    61.49911 23.78712 1501524000 
    61.49911 23.78712 1501527600 
    61.49911 23.78712 1501531200 
    </gmlcov:positions> 

    <gml:doubleOrNilReasonTupleList> 
     113.01 18.26 1007.03 92.74 259.0 3.79 
     113.01 17.79 1007.48 90.02 250.0 3.04 
     113.01 17.13 1007.82 93.62 229.0 2.19 
     113.01 16.42 1008.18 95.53 216.0 2.26 
     113.01 15.9 1008.89 97.09 211.0 2.74 
    </gml:doubleOrNilReasonTupleList> 

<swe:DataRecord> 
    <swe:field name="GeopHeight" xlink:href="http://"/> 
    <swe:field name="Temperature" xlink:href="http://"/> 
    <swe:field name="Pressure" xlink:href="http://"/> 
    <swe:field name="Humidity" xlink:href="http://"/> 
    <swe:field name="WindDirection" xlink:href="http://"/> 
    <swe:field name="WindSpeedMS" xlink:href="http://"/> 
</swe:DataRecord> 

第一個告訴你的位置和測量時間:

61.49911 23.78712 1501516800

Latitude: 61.49911 
Longitude: 23.7812 
Unixtime: 1501516800 --> which translates to: Mon Jul 31 16:00:00 2017 UTC 

第二個是實際測量數據,而第三個給你的測定的含義。
所以這就是你的第一次測量:

GeopHeight | Temperature | Pressure | Humidity | WindDirection | WindSpeedMs 
113.01  | 18.26  | 1007.03 | 92.74 | 259.0   | 3.79 

我希望這有助於。

+0

謝謝,它容易看到參數和值。問題是將它們取出( –

+0

Ach好吧,對不起,我誤解了。 – ylka