dongtan7201 2015-06-30 07:34
浏览 26

Bing Traffic API消失事件,结果波动

I'm parsing the Bing API for traffic accidents in the area, I use the URL

http://dev.virtualearth.net/REST/v1/Traffic/Incidents/37,-105,45,-94?o=xml&severity=3,4&key=#######myapikey######

A sample result is:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
   <Copyright>Copyright © 2015 Microsoft and its suppliers. All rights reserved. This API cannot be accessed and the content and any results may not be used, reproduced or transmitted in any manner without express written permission from Microsoft Corporation.</Copyright>
   <BrandLogoUri>http://dev.virtualearth.net/Branding/logo_powered_by.png</BrandLogoUri>
   <StatusCode>200</StatusCode>
   <StatusDescription>OK</StatusDescription>
   <AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
   <TraceId>b6b8a1174b3c40738f754f3ed0d443db|BN20130731|02.00.174.2300|BN20010843</TraceId>
   <ResourceSets>
      <ResourceSet>
         <EstimatedTotal>3</EstimatedTotal>
         <Resources>
            <TrafficIncident>
               <Point>
                  <Latitude>38.8677</Latitude>
                  <Longitude>-94.80368</Longitude>
               </Point>
               <Source>4</Source>
               <IncidentId>9000000669</IncidentId>
               <LastModifiedUTC>2015-06-24T15:12:15.0238037Z</LastModifiedUTC>
               <StartTimeUTC>2015-05-20T16:45:09Z</StartTimeUTC>
               <EndTimeUTC>2015-07-10T17:19:00Z</EndTimeUTC>
               <Type>Miscellaneous</Type>
               <Severity>Serious</Severity>
               <Verified>true</Verified>
               <RoadClosed>true</RoadClosed>
               <Description>is closed between I-35 and I-35 - closed</Description>
               <ToPoint>
                  <Latitude>38.8677</Latitude>
                  <Longitude>-94.80368</Longitude>
               </ToPoint>
            </TrafficIncident>
            <TrafficIncident>
               <Point>
                  <Latitude>38.95653</Latitude>
                  <Longitude>-94.74221</Longitude>
               </Point>
               <Source>4</Source>
               <IncidentId>9000000690</IncidentId>
               <LastModifiedUTC>2015-06-24T15:12:15.0238037Z</LastModifiedUTC>
               <StartTimeUTC>2015-05-27T17:08:07Z</StartTimeUTC>
               <EndTimeUTC>2015-10-05T09:04:00Z</EndTimeUTC>
               <Type>Miscellaneous</Type>
               <Severity>Serious</Severity>
               <Verified>true</Verified>
               <RoadClosed>true</RoadClosed>
               <Description>is closed between W 95th St and W 95th St - closed</Description>
               <ToPoint>
                  <Latitude>38.95653</Latitude>
                  <Longitude>-94.74221</Longitude>
               </ToPoint>
            </TrafficIncident>
            <TrafficIncident>
               <Point>
                  <Latitude>38.94201</Latitude>
                  <Longitude>-94.74218</Longitude>
               </Point>
               <Source>4</Source>
               <IncidentId>9000000691</IncidentId>
               <LastModifiedUTC>2015-06-24T15:12:15.0238037Z</LastModifiedUTC>
               <StartTimeUTC>2015-05-27T17:10:13Z</StartTimeUTC>
               <EndTimeUTC>2015-10-05T09:05:00Z</EndTimeUTC>
               <Type>Miscellaneous</Type>
               <Severity>Serious</Severity>
               <Verified>true</Verified>
               <RoadClosed>true</RoadClosed>
               <Description>is closed between W 103rd St and W 103rd St - closed</Description>
               <ToPoint>
                  <Latitude>38.94201</Latitude>
                  <Longitude>-94.74218</Longitude>
               </ToPoint>
            </TrafficIncident>
         </Resources>
      </ResourceSet>
   </ResourceSets>
</Response>

However the results are fluctuating, some times I get 5 results, 1 second later 2 and one second later again the same 5 as before.

Also these fluctuations are regardless of StartTimeUTC, EndTimeUTC which should indicate the start and end of the validity of the Incident report.

Because I need to send alert emails when accidents appear in the result I currently insert the values of IncidentId in an APC array and extract only those with a high hit and dismiss those appearing seldomly.

Anyone knows why this happens and how to solve it efficiently?

EDIT:

To load the xml file I use something like this in PHP5:

$xml = simplexml_load_file("http://dev.virtualearth.net/REST/v1/Traffic/Incidents/37,-105,45,-94?o=xml&severity=3,4&key=#######myapikey######");

I don't see any documentation telling how to set a timeout and so I have the impression that the simplexml_load_file() function should wait for the entire loading of the xml response.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 AT89C51控制8位八段数码管显示时钟。
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 下图接收小电路,谁知道原理
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度
    • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
    • ¥15 ETLCloud 处理json多层级问题