Bing Spatial Data Services
第9回から3回に渡って、
Bing Spatial Data Servicesには今のところ、
REST Servicesとレスポンス構造などは共通していますので、
Geocode Dataflow API
Geocode Dataflow APIの利用手順は次のようになります。
ジオコーディングまたは逆ジオコーディングするデータを次のURLへアップロードし、
ジョブを作成します。 - http://
spatial. virtualearth. net/ REST/ v1/ dataflows/ Geocode?input=xml&output=xml&key=BingMapsKey
アップロードしたデータは順次、
サーバーで処理されていきます。 - http://
ジョブの進行状態を次のURLで確認します。
- https://
spatial. virtualearth. net/ REST/ v1/ dataflows/jobID?output=xml&key=BingMapsKey
- https://
ジョブが完了したら、
次のURLから処理後のデータをダウンロードします。 - https://
spatial. virtualearth. net/ REST/ v1/ dataflows/ Geocode/jobID/output/ succeeded&key=BingMapsKey
- https://
アップロードおよびダウンロードするデータは、
日本のサポート状況
日本への対応ですが、
なお、
このように執筆時点ではAPIの結果が不安定であること、
Bing Maps Key
Geocode Dataflow APIの利用には、

それではもう少し詳しく手順を確認しコードを書いてみましょう。
データのアップロードとジョブの作成
ジオコーディング・
リクエストURLの書式
データは、
- http://
spatial. virtualearth. net/ REST/version/dataflows/ Geocode?
description=description&
input=input&
output=output&
key=BingMapsKey
※ HTTPだけではなくHTTPSも使用できます。
URLの各パラメーターの内容は次の通りです。
パラメーター |
説明 |
---|---|
version | APIのバージョン vと数字の組み合わせで記述します。 例:v1 |
description | データを説明するテキスト アプリケーションで使用するためのユーザー定義です。 |
input | アップロードするデータ形式 以下のいずれかを指定します。
|
output |
レスポンスの形式 JSON・
|
key | Bing Maps Key |
versionとkeyパラメーターは、
アップロードデータ
アップロードするデータは、
- xml:application/
xml - csv, tab, pipe:text/
plain
データ形式についてはこの後に詳しく説明します。
レスポンス
データをアップロードすると指定した形式
データ形式
まずアップロードするデータ形式についてみてみましょう。アップロードしたデータに処理結果が追加されたデータをダウンロードするため、
サポートしている形式は、
XML形式のサンプル
まずは、
<GeocodeFeed>
<GeocodeEntity Id="001" xmlns="http://schemas.microsoft.com/search/local/2010/5/geocode">
<GeocodeRequest Culture="en-us">
<Address AddressLine="16630 Redmond Way" AdminDistrict="WA" Locality="Redmond" PostalCode="98052" />
</GeocodeRequest>
</GeocodeEntity>
<GeocodeEntity Id="002" xmlns="http://schemas.microsoft.com/search/local/2010/5/geocode">
<GeocodeRequest Culture="ja-jp">
<Address AddressLine="" AdminDistrict="Tokyo" Locality="Shinjuku-ku" />
</GeocodeRequest>
</GeocodeEntity>
<GeocodeEntity Id="003" xmlns="http://schemas.microsoft.com/search/local/2010/5/geocode">
<ReverseGeocodeRequest Culture="en-us">
<Location Longitude="-122.11871" Latitude="47.673099"/>
</ReverseGeocodeRequest>
</GeocodeEntity>
<GeocodeEntity Id="004" xmlns="http://schemas.microsoft.com/search/local/2010/5/geocode">
<ReverseGeocodeRequest Culture="ja-jp">
<Location Longitude="139.71426866948605" Latitude="35.689996182918549"/>
</ReverseGeocodeRequest>
</GeocodeEntity>
</GeocodeFeed>
<GeocodeFeed>要素の中に、
ここで処理結果のデータもみてみましょう。ダウンロードデータは、
<?xml version="1.0"?>
<GeocodeFeed >
<GeocodeEntity Id="001" xmlns="http://schemas.microsoft.com/search/local/2010/5/geocode">
<GeocodeRequest Culture="en-us">
<Address AddressLine="16630 Redmond Way" AdminDistrict="WA" Locality="Redmond" PostalCode="98052" />
</GeocodeRequest>
<GeocodeResponse DisplayName="16630 Redmond Way, Redmond, WA 98052-4434" EntityType="Address" Confidence="High" StatusCode="Success">
<Address AddressLine="16630 Redmond Way" AdminDistrict="WA" CountryRegion="United States" FormattedAddress="16630 Redmond Way, Redmond, WA 98052-4434" Locality="Redmond" PostalCode="98052-4434" />
<InterpolatedLocation Latitude="47.673018" Longitude="-122.11844" />
</GeocodeResponse>
</GeocodeEntity>
<GeocodeEntity Id="002" xmlns="http://schemas.microsoft.com/search/local/2010/5/geocode">
<GeocodeRequest Culture="ja-jp">
<Address AddressLine="" AdminDistrict="Tokyo" Locality="Shinjuku-ku" />
</GeocodeRequest>
<GeocodeResponse DisplayName="Shinjuku-ku, Japan" EntityType="PopulatedPlace" Confidence="Medium" StatusCode="Success">
<Address AdminDistrict="Tokyo" CountryRegion="Japan" FormattedAddress="Shinjuku-ku, Japan" Locality="Shinjuku-ku" />
<RooftopLocation Latitude="35.6899961829185" Longitude="139.714268669486" />
</GeocodeResponse>
</GeocodeEntity>
<GeocodeEntity Id="003" xmlns="http://schemas.microsoft.com/search/local/2010/5/geocode">
<ReverseGeocodeRequest Culture="en-us">
<Location Latitude="47.673099" Longitude="-122.11871" />
</ReverseGeocodeRequest>
<GeocodeResponse DisplayName="16638 Redmond Way, Redmond, WA 98052" EntityType="Address" Confidence="Medium" StatusCode="Success">
<Address AddressLine="16638 Redmond Way" AdminDistrict="WA" CountryRegion="United States" FormattedAddress="16638 Redmond Way, Redmond, WA 98052" Locality="Redmond" PostalCode="98052" />
<InterpolatedLocation Latitude="47.6730955392122" Longitude="-122.118710651994" />
</GeocodeResponse>
</GeocodeEntity>
<GeocodeEntity Id="004" xmlns="http://schemas.microsoft.com/search/local/2010/5/geocode">
<ReverseGeocodeRequest Culture="ja-jp">
<Location Latitude="35.6899961829185" Longitude="139.714268669486" />
</ReverseGeocodeRequest>
<GeocodeResponse DisplayName="東京都" EntityType="AdminDivision1" Confidence="Medium" StatusCode="Success">
<Address AdminDistrict="東京都" CountryRegion="日本" FormattedAddress="東京都" />
<RooftopLocation Latitude="35.6899961829185" Longitude="139.714268669486" />
</GeocodeResponse>
</GeocodeEntity>
</GeocodeFeed>
冒頭でもふれていますが、
上記のアップロードデータにはありませんでしたが、
<?xml version="1.0"?>
<GeocodeFeed >
<GeocodeEntity Id="002" xmlns="http://schemas.microsoft.com/search/local/2010/5/geocode">
<GeocodeRequest Culture="ja-jp" Query="Osaka">
<Address AddressLine="" AdminDistrict="Tokyo" Locality="Shinjuku-ku" />
</GeocodeRequest>
<GeocodeResponse StatusCode="BadRequest" FaultReason="Query and Address cannot both be specified." />
</GeocodeEntity>
</GeocodeFeed>
CSV形式のデータ
続いてCSV形式です。XML形式と同じ内容のデータは次のようになります。当然ながら値の並びには決まりがあります。その内容は後で説明します。
1,en-us,,16630 Redmond Way,WA,,,,Redmond,98052,,,,,,,,,,,,,,,,,,,,,,
2,ja-jp,,,Tokyo,,,,Shinjuku-ku,,,,,,,,,,,,,,,,,,,,,,,
3,en-us,,,,,,,,,,,,,,,,,,,,,,,,,,,,47.673099,-122.11871
4,ja-jp,,,,,,,,,,,,,,,,,,,,,,,,,,,,35.689996182918549,139.71426866948605
1,en-us,,16630 Redmond Way,WA,,,,Redmond,98052,,,16630 Redmond Way,WA,United States,,"16630 Redmond Way, Redmond, WA 98052-4434",Redmond,98052-4434,,47.673302,-122.118576,47.673099,-122.11871,High,"16630 Redmond Way, Redmond, WA 98052-4434",Address,Success,,,
2,ja-jp,,,Tokyo,,,,Shinjuku-ku,,,,,Tokyo,Japan,,"Shinjuku-ku, Japan",Shinjuku-ku,,,35.6899961829185,139.714268669486,,,Medium,"Shinjuku-ku, Japan",PopulatedPlace,Success,,,
3,,,,,,,,,,,,16638 Redmond Way,WA,United States,,"16638 Redmond Way, Redmond, WA 98052",Redmond,98052,,,,47.6730955392122,-122.118710651994,Medium,"16638 Redmond Way, Redmond, WA 98052",Address,Success,,47.673099,-122.11871
4,,,,,,,,,,,,,Tokyo,Japan,,Tokyo,,,,35.6899961829185,139.714268669486,,,Medium,Tokyo,AdminDivision1,Success,,35.6899961829185,139.714268669486
タブ区切りとパイプ区切り形式のデータ
タブ区切りとパイプ区切りは、
1|en-us||16630 Redmond Way|WA||||Redmond|98052||||||||||||||||||||||
2|ja-jp|||Tokyo||||Shinjuku-ku|||||||||||||||||||||||
3|en-us||||||||||||||||||||||||||||47.673099|-122.11871
4|ja-jp||||||||||||||||||||||||||||35.689996182918549|139.71426866948605
1|en-us||16630 Redmond Way|WA||||Redmond|98052|||16630 Redmond Way|WA|United States||16630 Redmond Way, Redmond, WA 98052-4434|Redmond|98052-4434||47.673302|-122.118576|47.673099|-122.11871|High|16630 Redmond Way, Redmond, WA 98052-4434|Address|Success|||
2|ja-jp|||Tokyo||||Shinjuku-ku|||||Tokyo|Japan||Shinjuku-ku, Japan|Shinjuku-ku|||35.6899961829185|139.714268669486|||Medium|Shinjuku-ku, Japan|PopulatedPlace|Success|||
3||||||||||||16630 Redmond Way|WA|United States||16630 Redmond Way, Redmond, WA 98052-4434|Redmond|98052-4434||47.673302|-122.118576|||High|16630 Redmond Way, Redmond, WA 98052-4434|Address|Success||47.673099|-122.11871
4|||||||||||||Tokyo|Japan||Tokyo||||35.6899961829185|139.714268669486|||Medium|Tokyo|AdminDivision1|Success||35.6899961829185|139.714268669486
データの項目
次は、
@Id
GeocodeRequest/@Culture
GeocodeRequest/@Query
GeocodeRequest/Address/@AddressLine
GeocodeRequest/Address/@AdminDistrict
GeocodeRequest/Address/@CountryRegion
GeocodeRequest/Address/@District
GeocodeRequest/Address/@FormattedAddress
GeocodeRequest/Address/@Locality
GeocodeRequest/Address/@PostalCode
GeocodeRequest/Address/@PostalTown
GeocodeRequest/ConfidenceFilter/@MinimumConfidence
GeocodeResponse/Address/@AddressLine
GeocodeResponse/Address/@AdminDistrict
GeocodeResponse/Address/@CountryRegion
GeocodeResponse/Address/@District
GeocodeResponse/Address/@FormattedAddress
GeocodeResponse/Address/@Locality
GeocodeResponse/Address/@PostalCode
GeocodeResponse/Address/@PostalTown
GeocodeResponse/RooftopLocation/@Latitude
GeocodeResponse/RooftopLocation/@Longitude
GeocodeResponse/InterpolatedLocation/@Latitude
GeocodeResponse/InterpolatedLocation/@Longitude
GeocodeResponse/@Confidence
GeocodeResponse/@DisplayName
GeocodeResponse/@EntityType
GeocodeResponse/@StatusCode
GeocodeResponse/@FaultReason
ReverseGeocodeRequest/Location/@Latitude
ReverseGeocodeRequest/Location/@Longitude
少しわかりづらいと思いますが、
<GeocodeEntity>
<GeocodeRequest>
<Address AddressLine="..." />
</GeocodeRequest>
</GeocodeEntity>
XML形式の場合、
上記の各項目の内容は次の通りです。リクエスト
項目 | 説明 |
---|---|
Id | 入力データを区別する一意の値 例:1 |
Culture | 言語・ 規定値はen-us 例:ja-jp |
Query | クエリー形式で住所などの地域情報を指定 住所の指定と併せての使用はできません。 |
District | AdminDistrict すべての地域で使用するものではありません。 |
PostalTown | 住所を特定するための郵便区域 |
MinimumConfidence | 結果に求める最低限の一致度を指定 |
Location. Location. |
逆ジオコーディング時に経緯度を指定 |
項目 | 説明 |
---|---|
AddressLine | 番地なども含む住所 |
AdminDistrict | 広域な行政区域 日本では都道府県にあたります。 |
CountryRegion | 国名コード 例:JP |
Locality | AdminDistrict以下の行政上の都市など 日本では主に市区群になります。 |
PostalCode | 郵便番号 |
項目 | 説明 |
---|---|
FormattedAddress | 住所 |
RooftopLocation. RooftopLocation. |
住所の経緯度 |
InterpolatedLocation. InterpolatedLocation. |
2地点で補間した経緯度 道路を表す場合などに使用されます。 |
Confidence | 結果の一致度 |
DisplayName | 表示名 |
EntityType | 場所の種類 例:Address, Airport, Park など |
StatusCode | HTTPのステータスコード |
FaultReason | 処理に失敗した理由 |
EntityTypeは多数ありますので、
ジョブの状態の確認
データをアップロードし、
リクエストURLの書式
ジョブの状態は、
- http://
spatial. virtualearth. net/ REST/version/dataflows/ Geocode/jobID?
output=output&
key=BingMapsKey
※ HTTPおよびHTTPSが使用できます。
URLの各パラメーターの内容は次の通りです。
パラメーター |
説明 |
---|---|
jobID | データをアップロード時のレスポンスに含まれるジョブID |
output |
レスポンスの形式 JSON・
|
レスポンス
データをアップロードしたときと同様のジョブの状態を表すレスポンスが返ってきます。レスポンスにはジョブIDを含めた上記URL書式に従った状態を確認するURL自身も含まれています。
レスポンス形式は、
- xml:application/
xml - json:application/
json
それでは、
レスポンス内容
レスポンス内容には、
RESTサービス共通部分
レスポンスの構造は、
JSON・
{
"authenticationResultCode": "ValidCredentials",
"brandLogoUri": "http://spatial.virtualearth.net/Branding/logo_powered_by.png",
"copyright": "Copyright © 2010 Microsoft and its suppliers. (省略)",
"resourceSets": [
{
"estimatedTotal": 1,
"resources": [
(ジョブ情報)
]
}
],
"statusCode": 200,
"statusDescription": "OK",
"traceId": "..."
}
<Response xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.microsoft.com/search/local/ws/rest/v1">
<Copyright>Copyright © 2010 Microsoft and its suppliers. (省略)</Copyright>
<BrandLogoUri>http://spatial.virtualearth.net/Branding/logo_powered_by.png</BrandLogoUri>
<StatusCode>200</StatusCode>
<StatusDescription>OK</StatusDescription>
<AuthenticationResultCode>ValidCredentials</AuthenticationResultCode>
<TraceId>...</TraceId>
<ResourceSets>
<ResourceSet>
<EstimatedTotal>1</EstimatedTotal>
<Resources>
(ジョブ情報)
</Resources>
</ResourceSet>
</ResourceSets>
</Response>
各要素の内容は次の通りです。JSON・
要素名 | 説明 |
---|---|
StatusCode | HTTPのステータスコード |
StatusDescription | HTTPのステータスコードの説明 |
TraceId | リクエストごとに一意な値 |
Copyright | コピーライト情報 |
BrandLogoUri | Bingロゴ画像のURL |
ResourceSets | ResourceSetのコレクション |
ErrorDetails | エラー内容の文字列の配列 結果がエラーの場合に含まれています。 |
ResourceSetsはResourceSetのコレクションですが、
要素名 | 説明 |
---|---|
esitmatedTotal | ResruoceSetに含まれるResrouces内の項目数の概算値 |
Resources | ジョブ情報のコレクション |
ジョブ情報
続いて、
{
"__type": "DataflowJob:http://schemas.microsoft.com/search/local/ws/rest/v1",
"completedDate": "Wed, 17 Nov 2010 00:00:00 GMT",
"createdDate": "Wed, 17 Nov 2010 00:00:00 GMT",
"failedEntityCount": 1,
"id": "0940d2a7852942c88b94108db64a5b56",
"links": [
{
"role": "self",
"url": "https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/0940d2a7852942c88b94108db64a5b56"
},
{
"name": "succeeded",
"role": "output",
"url": "https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/0940d2a7852942c88b94108db64a5b56/output/succeeded"
},
{
"name": "failed",
"role": "output",
"url": "https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/0940d2a7852942c88b94108db64a5b56/output/failed"
}
],
"processedEntityCount": 19,
"status": "Completed",
"totalEntityCount": 19
}
<DataflowJob>
<Id>0940d2a7852942c88b94108db64a5b56</Id>
<Link role="self">https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/0940d2a7852942c88b94108db64a5b56</Link>
<Link role="output" name="succeeded">https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/0940d2a7852942c88b94108db64a5b56/output/succeeded</Link>
<Link role="output" name="failed">https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/0940d2a7852942c88b94108db64a5b56/output/failed</Link>
<Status>Completed</Status>
<CreatedDate>2010-11-17T00:00:00.00-08:00</CreatedDate>
<CompletedDate>2010-11-17T00:00:00.00-08:00</CompletedDate>
<TotalEntityCount>19</TotalEntityCount>
<ProcessedEntityCount>19</ProcessedEntityCount>
<FailedEntityCount>1</FailedEntityCount>
</DataflowJob>
各要素の内容は次の通りです。共通部分と同様にJSON・
要素名 | 説明 |
---|---|
Id | ジョブID |
Link | role属性・ role="self": ジョブの状態を確認するURL role="output", name="succeeded": 処理が成功したデータのダウンロード先 role="output", name="failed": 処理が失敗したデータのダウンロード先 |
Description | リクエスト時に設定したDescriptionの値 |
Status | ジョブの状態 Pending:処理中 Completed:完了 Aborted:エラーによる中断 |
CreateDate | ジョブが作成された日時 |
CompletedDate | ジョブが完了した日時 |
TotalEntityCount | アップロードしたデータ数 |
ProcessedEntityCount | 処理済みのデータ数 |
FailedEntityCount | 処理に失敗したデータ数 |
ErrorMessage | 処理が中断された場合のエラー情報 |
それぞれの要素、
HTTPステータスとHTTPヘッダー
補足として、
リクエストが失敗した場合、
結果のダウンロード
最後は結果のダウンロードです。ジョブの状態を確認し、
{
"name": "succeeded",
"role": "output",
"url": "https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/0940d2a7852942c88b94108db64a5b56/output/succeeded"
},
{
"name": "failed",
"role": "output",
"url": "https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/0940d2a7852942c88b94108db64a5b56/output/failed"
}
<Link role="output" name="succeeded">https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/0940d2a7852942c88b94108db64a5b56/output/succeeded</Link>
<Link role="output" name="failed">https://spatial.virtualearth.net/REST/v1/dataflows/Geocode/0940d2a7852942c88b94108db64a5b56/output/failed</Link>
ただし、
処理に成功したデータ
- https://
spatial. virtualearth. net/ REST/ v1/ dataflows/ Geocode/jobID/output/ succeeded&key=BingMapsKey
処理に失敗したデータ
- https://
spatial. virtualearth. net/ REST/ v1/ dataflows/ Geocode/jobID/output/ failed&key=BingMapsKey
データ形式は、
サンプルコード
それでは、
MSDN LibraryにもC#のサンプルコードがありますが、
ジョブクラスの作成
最初にジョブを表すクラスを作ります。実際にコードで使用するジョブ情報は、
class Job
{
public string Status { get; set; }
public Uri SuceededUri { get; set; }
public Uri FailedUri { get; set; }
public Uri SelfUri { get; set; }
}
データのアップロードとジョブの作成
次にデータをアップロードしジョブを作成するメソッドをProgramクラス内に記述します。引数はデータファイルと、
private static Job CreateJob(string dataFilePath, string dataFormat, string key, string description)
{
var uri = new Uri(string.Format("http://spatial.virtualearth.net/REST/v1/dataflows/Geocode?description={0}&input={1}&output=xml&key={2}",
Uri.EscapeUriString(description ?? ""),
Uri.EscapeUriString(dataFormat),
key));
using (var dataStream = File.OpenRead(dataFilePath))
{
// リクエスト作成
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "POST";
request.ContentType = (dataFormat.ToLower() == "xml") ?
"application/xml; charset=UTF-8" :
"text/plain; charset=UTF-8";
using (var requestStream = request.GetRequestStream())
{
var buffer = new byte[16384];
var bytesRead = dataStream.Read(buffer, 0, buffer.Length);
while (bytesRead > 0)
{
requestStream.Write(buffer, 0, bytesRead);
bytesRead = dataStream.Read(buffer, 0, buffer.Length);
}
}
// レスポンス取得
using (var response = (HttpWebResponse)request.GetResponse())
{
using (var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
var doc = XDocument.Parse(reader.ReadToEnd());
return ParseXDocument(doc);
}
}
}
throw new Exception();
}
上記コードのParseXDocumentメソッドは、
ジョブの進行状態の確認
ジョブの進行状態の確認を行うメソッドを作ります。引数にはJobクラスのオブジェクトとBing Maps Keyを指定し、
private static Job CheckStatus(Job job, string key)
{
var uri = new Uri(job.SelfUri.ToString() + "?output=xml&key=" + key);
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
using (var response = (HttpWebResponse)request.GetResponse())
{
var reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
var doc = XDocument.Parse(reader.ReadToEnd());
return ParseXDocument(doc);
}
}
ParseXDocumentメソッドの内容は次の通りです。
private static Job ParseXDocument(XDocument document)
{
var job = new Job();
XNamespace x = "http://schemas.microsoft.com/search/local/ws/rest/v1";
// <DataflowJob> 要素の参照
var element = (from j in document.Descendants(x + "DataflowJob") select j).First<XElement>();
// <Status> 要素の参照
job.Status = element.Element(x + "Status").Value;
// <Link> 要素の参照
foreach (var link in element.Descendants(x + "Link"))
{
if (link.Attribute("role").Value == "output")
{
switch (link.Attribute("name").Value)
{
case "succeeded":
job.SuceededUri = new Uri(link.Value);
break;
case "failed":
job.FailedUri = new Uri(link.Value);
break;
}
}
else if (link.Attribute("role").Value == "self")
{
job.SelfUri = new Uri(link.Value);
}
}
return job;
}
データのダウンロード
指定したURLからデータをダウンロードし、
private static void DownloadResult(Uri uri, string path)
{
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
using (var response = (HttpWebResponse)request.GetResponse())
{
using (var stream = response.GetResponseStream())
{
using (var writer = new StreamWriter(path))
{
using (var reader = new StreamReader(stream))
{
string line;
while ((line = reader.ReadLine()) != null)
{
writer.WriteLine(line);
}
}
}
}
}
}
メイン処理
以上で、
static void Main(string[] args)
{
string dataFilePath = "UploadData.xml";
string dataFormat = "xml";
string key = "取得した Bing Maps Key";
string description = null;
try
{
var job = new Job();
job = CreateJob(dataFilePath, dataFormat, key, description);
Console.WriteLine("Dataflow Job Location: {0}", job.SelfUri);
while (true)
{
job = CheckStatus(job, key);
Console.WriteLine("Dataflow Job Status: {0}", job.Status);
if (job.Status == "Aborted")
{
throw new Exception();
}
else if (job.Status == "Pending")
{
Thread.Sleep(TimeSpan.FromSeconds(30));
}
else
{
// job.Status == "Completed"
break;
}
}
// 結果のダウンロード
if (job.SuceededUri != null)
{
DownloadResult(new Uri(job.SuceededUri.ToString() + "?key=" + key), "Success.txt");
}
if (job.FailedUri != null)
{
DownloadResult(new Uri(job.FailedUri.ToString() + "?key=" + key), "Failed.txt");
}
}
catch (Exception e)
{
Console.WriteLine("Exception :" + e.Message);
}
}
以上で完成です。上記のコードではUploadData.
おわりに
今回の内容は以上です。ジオコーディングのバッチ処理を行うAPIについて紹介しました。現在利用できるBing Spatial Data Servicesについてはすべての内容を紹介したことになります。実際にAPIを利用するとなると、