如何使用Java从Bing elevationAPI获取高程值?

时间:2015-02-25 21:35:49

标签: java

我尝试使用以下Java代码从Bing elevationAPI获取高程数据:

public static void elevationAPI (double latitude, double longitude )throws IOException {
    int responseCode = 0;

    try{    
        URL url = new URL("http://dev.virtualearth.net/REST/v1/Elevation/List?points="+ latitude + "," + longitude + "&key=MyKey");

        HttpURLConnection con=(HttpURLConnection)url.openConnection();

        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

        responseCode = con.getResponseCode();
        Writer writer = new StringWriter();
        char[] buffer = new char[1024];

        int n=0; 
        while( (n = in.read(buffer)) != -1){ 
            writer.write(buffer, 0, n);
        }

但是,我没有使用此查询获得任何高程值。

我的结果是:

{
    "authenticationResultCode":"ValidCredentials",
    "brandLogoUri":"http:\/\/dev.virtualearth.net\/Branding\/logo_powered_by.png",
    "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.",
    "resourceSets":[
        {
            "estimatedTotal":1,
            "resources":[
                 {
                     "__type":"ElevationData:http:\/\/schemas.microsoft.com\/search\/local\/ws\/rest\/v1",
                     "elevations":[0],
                     "zoomLevel":8
                 }
             ]
         }
    ],
    "statusCode":200,
    "statusDescription":"OK",   "traceId":"b9dc9583749c42bab8f8e6ee04d7dba6|BN20130723|02.00.130.200|ak.t0.tiles.virtualearth.net"
}

0 个答案:

没有答案