elevation格式

What is Google Elevation ?

什么是Google Elevation?

Elevation is the height above or below a fixed reference point. The elevation is the referring to points on the Earth's surface.

高程是固定参考点之上或之下的高度。 海拔是地球表面上的参考点。

We also use the following two terms:

我们还使用以下两个术语:

- altitude: points above the surface

-高度:高于地面的点

- depth: points below the surface

-深度:表面以下的点

For example:

例如:

1. Simple elevation (one pair of coordinate - lat/lng)

1.简单标高(一对坐标-纬度/经度)

If you search (https://maps.googleapis.com/maps/api/elevation/json?locations=47.18998999999999,23.061813&key=YOUR_API_KEY), for a specific coordinate (47.18998999999999, 23.061813) in Google Maps, you will get the following elevation result from JSON :

如果您在Google地图中搜索( https://maps.googleapis.com/maps/api/elevation/json?locations=47.18998999999999,23.061813&key=YOUR_API_KEY )的特定坐标(47.18998999999999,23.061813),则会得到以下内容JSON的海拔结果:

elevation:    254.4218444824219

海拔:254.4218444824219

To test the Elevation without API KEY, there is an example on Google: https://developers.google.com/maps/documentation/javascript/examples/elevation-simple

要测试没有API KEY的海拔高度,请在Google上找到一个示例: https : //developers.google.com/maps/documentation/javascript/examples/elevation-simple

For C# Elevation sample, check the Elevation(string latitudeE, string longitudeE) function.

对于C#海拔示例,请检查Elevation(string latitudeE,string longitudeE)函数。

2. Multiple elevations (multiple pairs of coordinates - lat/lng)

2.多个高程(多对坐标-纬度/经度)

You can also request multiple elevation results, just by adding multiple pair of coordinates and separated by the PIPE character "|". If you request https://maps.googleapis.com/maps/api/elevation/json?locations=47.18998999999999,23.061813|47.16998999999999,23.061813&key=YOUR_API_KEY , you will get the following elevation results:

您也可以请求多个高程结果,只需添加多对坐标并以PIPE字符“ |”分隔即可。 如果您请求https://maps.googleapis.com/maps/api/elevation/json?locations=47.18998999999999,23.061813|47.16998999999999,23.061813&key=YOUR_API_KEY ,您将获得以下海拔结果:

//the elevation result for the first pair of coordinates

//第一对坐标的高程结果

elevation:    254.4218444824219

海拔:254.4218444824219

lat:    47.18998999999999

纬度:47.18998999999999

lng:    23.061813

lng:23.061813

//the elevation result for the second pair of coordinates

//第二对坐标的高程结果

elevation:    294.3569030761719

海拔:294.3569030761719

lat:    47.16998999999999

纬度:47.16998999999999

lng:    23.061813

lng:23.061813

For C# MultipleElevation sample, check the MultipleElevation(string multiplecoords) function.  (It asks the user for coordinates, until the input values are empty - when the Enter key is pressed for both of the coordinates - lat/lng)

对于C#MultipleElevation示例,请检查MultipleElevation(字符串multiplecoords)   功能。 (它要求用户输入坐标,直到输入值为空-当两个坐标都按Enter键时-纬度/经度)

3. Path elevations (multiple pairs of coordinates - lat/lng and number of samples)

3.路径标高(多对坐标-纬度/经度和样本数)

Another great feature is that you can requests elevation data along a straight line (path). For example starting from point A to point B, specifying the number of samples.

另一个重要功能是,您可以沿直线(路径)请求高程数据。 例如,从点A到点B,指定样本数。

You can ask for example 3 samples:

您可以要求3个示例:

- 2x Endpoints

-2个端点

- 1x Half-point

-1x半点

If you search for: https://maps.googleapis.com/maps/api/elevation/json?path=47.18998999999999,23.061813|47.16998999999999,23.0618131&samples=3&key=YOUR_API_KEY, you will get the following from the JSon results:

如果您搜索: https ://maps.googleapis.com/maps/api/elevation/json?path=47.18998999999999,23.061813|47.16998999999999,23.0618131&samples =3& key=YOUR_API_KEY,您将从JSon结果中获得以下信息:

//sample 1 - Endpoint

//样本1-端点

elevation    254.4218444824219

海拔254.4218444824219

lat    47.18998999999999

拉特47.18998999999999

lng    23.061813

lng 23.061813

//sample 2 - Half-point

//样本2-半点

elevation    288.4825134277344

海拔288.4825134277344

lat    47.17998999999999

拉特47.17998999999999

lng    23.06181305000942

lng 23.06181305000942

//sample 3 - Endpoint

//样本3-端点

elevation    294.3571472167969

海拔294.3571472167969

lat    47.16998999999999

拉特47.16998999999999

lng    23.0618131

lng 23.0618131

For C# PathElevation sample, check the PathElevation(string multiplecoords, string nrofsamples) function.  (It asks the user for coordinates until the input values are empty - when Enter key is pressed for both of the coordinates - lat/lng, after that it asks for the number of samples)

对于C#PathElevation示例,请检查PathElevation(字符串multicoords,字符串nrofsamples)函数。 (它要求用户输入坐标,直到输入值为空-按下两个坐标的Enter键-lat / lng,然后要求输入样本数)

* More details about how Elevation works and how we use it, you can find in the following links:

*有关海拔的工作原理以及我们如何使用它的更多详细信息,可以在以下链接中找到:

- Elevation Wiki

-海拔Wiki

- Google Elevation

-Google高程

C# Source Code sample:

C#源代码示例:

The following source code is written in C# Console Application (Framework 4.5). To save space, I created a single project for Simple Elevation, Multiple Elevations, Path Elevations and a class for deserializing the JSON.

以下源代码是用C#控制台应用程序(框架4.5)编写的。 为了节省空间,我为简单高程,多个高程,路径高程创建了一个项目,并为反序列化JSON创建了一个类。

To run it, you will need the following:

要运行它,您将需要以下内容:

-create a new API Key

-创建一个新的API密钥

-enable Maps Javascript API

-启用Maps Javascript API

-enable Maps Elevation API

启用Maps Elevation API

-enable GeoLocation API

-启用GeoLocation API

-enable GeoCoding API

启用GeoCoding API

-Visual Studio

-视觉工作室

Tip: don't forget to enable billing information in Google for the API and attach to the project

提示 :不要忘记在Google中为API启用结算信息并附加到项目中

In this article I will not cover, how to enable API Keys on Google, but you can find more information on their site:

在本文中,我不会介绍如何在Google上启用API密钥,但是您可以在其网站上找到更多信息:

https://developers.google.com/maps/documentation/javascript/get-api-key

https://developers.google.com/maps/documentation/javascript/get-api-key

Create a new Console application project and after that, from NuGet, install JSon.Net (Newtonsoft.Json):

创建一个新的Console应用程序项目,然后从NuGet中安装JSon.Net(Newtonsoft.Json):

- Step 1 - File->New-> Project  (I used .Net Framework 4.5)

- 步骤1-文件->新建->项目(我使用了.Net Framework 4.5)

- Step 2 - Install from Nuget Json.Net:

- 步骤2-从Nuget Json.Net安装:

- Step 3 - Create a New class in the project (I named it ElevResult.cs), this will be used for deserializing the JSON request.

- 步骤3-在项目中创建一个New类(我将其命名为ElevResult.cs),该类将用于反序列化JSON请求。

This is the final view of my project:

这是我的项目的最终视图:

The source code for ElevResult.cs:

ElevResult.cs的源代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Elevation_Art
{
public class GoogleElevCodeResponse
{
public string status { get; set; }
public resultsElev[] results { get; set; }
}
public class resultsElev
{
public string elevation { get; set; }
public locationElev location { get; set; }
public string resolution { get; set; }
}
public class locationElev
{
public string lat { get; set; }
public string lng { get; set; }
}
}

The source code for Program.cs:

Program.cs的源代码:

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
namespace Elevation_Art
{
class Program
{
const string apiKey = "YOUR_API_KEY"; //!!!!paste your API KEY HERE!!!!
static string baseUrlEL = "https://maps.googleapis.com/maps/api/elevation/json?locations="; // part of the URL for Elevation
static string baseUrlELP = "https://maps.googleapis.com/maps/api/elevation/json?path="; // part of the URL for Elevation
static string plusUrl = "&key=" + apiKey + "&sensor=false"; // part2 of the URL
static public int DisplayMenu() // I add a menu for selecting between 1 - Elevation / 2 - Elevation with Multiple Coordinates / 3 - PathElevation with Multiple Coordinates / 4 - Exit
{
Console.WriteLine();
Console.WriteLine("ELEVATION TUTORIAL (Select and hit Enter):");
Console.WriteLine();
Console.WriteLine("1. Elevation"); // 1 Elevation with single pair of coordinates
Console.WriteLine("2. Elevation with Multiple Coordinates"); // 2 Multiple Elevation results, from multiple pair of coordinates
Console.WriteLine("3. PathElevation with Multiple Coordinates"); // 3 Multiple Elevation (PathElevation) results, from multiple pair of coordinates and samples
Console.WriteLine("4. Exit"); // 4 Exit
Console.WriteLine();
var result = Console.ReadLine(); //waiting for an integer input for the menu; value can between 1-3
return Convert.ToInt32(result); //converting result to an integer for the menu
}
static void Main(string[] args)
{
int menuInput = 0;
do // do-while statement for the menu, it loops until the input is 3 (Exit)
{
Console.ForegroundColor = ConsoleColor.Green; // changing color for the console to green
menuInput = DisplayMenu(); //getting the result of the input for the menu
Console.ForegroundColor = ConsoleColor.Gray; // changing to default color
switch (menuInput.ToString()) //switch statement for checking if input is 1 - 3, 4 - Exit
{
case "1":    //if the input for menu is 1, then call the Elevation function
Console.WriteLine("===== ELEVATION =====");
Console.WriteLine("Enter a Latitude: ");
string latitudeE = Console.ReadLine();
Console.WriteLine("Enter a Longitude: ");
string longitudeE = Console.ReadLine();
Console.WriteLine("-------------------------------------");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("RESULT: " + Elevation(latitudeE, longitudeE) + " meters");
Console.ForegroundColor = ConsoleColor.Gray;
break;
case "2":    //if the input for menu is 2, then call the MultipleElevation function
Console.WriteLine("===== MULTIPLE ELEVATION =====");
string latitudeEM = string.Empty;
string longitudeEM = string.Empty;
StringBuilder sb = new StringBuilder();
do
{
Console.WriteLine("Enter a Latitude: ");
latitudeEM = Console.ReadLine();
Console.WriteLine("Enter a Longitude: ");
longitudeEM = Console.ReadLine();
sb.Append(latitudeEM + "," + longitudeEM + "|"); //format LAT/LNG coordinates and append to StringBuilder
} while ((latitudeEM.ToString() != "") || (longitudeEM.ToString() != "")); //request input from user, util LAT and LNG is empty char (Enter)
Console.WriteLine("-------------------------------------");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("RESULT: " + MultipleElevation(sb.ToString().Replace("|,|", "")) + " meters"); //call the function MultipleElevation
Console.ForegroundColor = ConsoleColor.Gray;
break;
case "3":    //if the input for menu is 3, then call the PathElevation function
Console.WriteLine("===== PATH ELEVATION =====");
string latitudeEMP = string.Empty;
string longitudeEMP = string.Empty;
StringBuilder sbp = new StringBuilder();
do
{
Console.WriteLine("Enter a Latitude: ");
latitudeEMP = Console.ReadLine();
Console.WriteLine("Enter a Longitude: ");
longitudeEMP = Console.ReadLine();
sbp.Append(latitudeEMP + "," + longitudeEMP + "|"); //format LAT/LNG coordinates and append to StringBuilder
} while ((latitudeEMP.ToString() != "") || (longitudeEMP.ToString() != "")); //request input from user, util LAT and LNG is empty char (Enter)
Console.WriteLine("Enter the number of samples: ");
string nrOfSamples = Console.ReadLine();
Console.WriteLine("-------------------------------------");
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("RESULT: " + PathElevation(sbp.ToString().Replace("|,|", ""),nrOfSamples) + " meters"); //call the function PathElevation
Console.ForegroundColor = ConsoleColor.Gray;
break;
}
} while (menuInput != 4);
}
private static string Elevation(string latitudeE, string longitudeE)
{
var json = new WebClient().DownloadString(baseUrlEL + latitudeE.Replace(" ", "") + ","
+ longitudeE.Replace(" ", "") + plusUrl);//concatenate URL with the input lat/lng and downloads the requested resource
GoogleElevCodeResponse jsonResult = JsonConvert.DeserializeObject<GoogleElevCodeResponse>(json); //deserializing the result to GoogleElevCodeResponse
string status = jsonResult.status; // get status
string geoElevation = String.Empty;
geoElevation += Environment.NewLine;
if (status == "OK") //check if status is OK
{
for (int i = 0; i < jsonResult.results.Length; i++) //loop throught the result for addresses
{
geoElevation += "Lat/Lng[" + i + "]: " + jsonResult.results[i].location.lat + " / " + jsonResult.results[i].location.lng + " Elevation[" + i + "]: " + jsonResult.results[i].elevation + Environment.NewLine; //append the result elevations and coords to every new line
}
return geoElevation; //return result
}
else
{
return status; //return status / error if not OK
}
}
private static string MultipleElevation(string multiplecoords)
{
var json = new WebClient().DownloadString(baseUrlEL + multiplecoords + plusUrl);//concatenate URL with the input lat/lng and downloads the requested resource
GoogleElevCodeResponse jsonResult = JsonConvert.DeserializeObject<GoogleElevCodeResponse>(json); //deserializing the result to GoogleElevCodeResponse
string status = jsonResult.status; // get status
string geoElevation = String.Empty;
geoElevation += Environment.NewLine;
if (status == "OK") //check if status is OK
{
for (int i = 0; i < jsonResult.results.Length; i++) //loop throught the result for addresses
{
geoElevation += "Lat/Lng[" + i + "]: " + jsonResult.results[i].location.lat + " / " + jsonResult.results[i].location.lng + " Elevation[" + i + "]: " + jsonResult.results[i].elevation + Environment.NewLine; //append the result elevations and coords to every new line
}
return geoElevation; //return result
}
else
{
return status; //return status / error if not OK
}
}
private static string PathElevation(string multiplecoords, string nrofsamples)
{
var json = new WebClient().DownloadString(baseUrlELP + multiplecoords+"&samples="+nrofsamples+ plusUrl);//concatenate URL with the input lat/lng and downloads the requested resource
GoogleElevCodeResponse jsonResult = JsonConvert.DeserializeObject<GoogleElevCodeResponse>(json); //deserializing the result to GoogleElevCodeResponse
string status = jsonResult.status; // get status
string geoElevation = String.Empty;
geoElevation += Environment.NewLine;
if (status == "OK") //check if status is OK
{
for (int i = 0; i < jsonResult.results.Length; i++) //loop throught the result for addresses
{
geoElevation += "Lat/Lng[" + i + "]: " + jsonResult.results[i].location.lat + " / " + jsonResult.results[i].location.lng + " Elevation[" + i + "]: " + jsonResult.results[i].elevation + Environment.NewLine; //append the result elevations and coords to every new line
}
return geoElevation; //return result
}
else
{
return status; //return status / error if not OK
}
}
}
}

Some screenshots of the working app

工作应用程序的一些屏幕截图

The menu: (Waiting for user input 1-4)

菜单:(等待用户输入1-4)

1. Simple Elevation (for the following coords: 47.18998999999999, 23.061813, check result in red):

1.简单高程(适用于以下坐标:47.18998999999999,23.061813,检查结果为红色):

2. Multiple Elevations (for the following coords: 47.18998999999999,23.061813|47.16998999999999,23.061813, check results in red):

2.多个高程(对于以下坐标:47.18998999999999,23.061813 | 47.16998999999999,23.061813,检查结果为红色):

3. PathElevations (for the following coords: 47.18998999999999,23.061813|47.16998999999999,23.061813 and with the number of samples: 3, check results in red):

3. PathElevations(对于以下坐标:47.18998999999999,23.061813 | 47.16998999999999,23.061813并带有样本数:3,检查结果为红色):

4. for Exit

4.出口

Source Code:

源代码:

ElevResult.cs

ElevResult.cs

Program.cs

Program.cs

Entire Project:

整个项目:

Elevation_Art2.zip

Elevation_Art2.zip

I wish you happy coding!

祝您编码愉快!

Molnár István

莫纳尔·伊斯特万

翻译自: https://www.experts-exchange.com/articles/33267/How-Google-Elevation-works-and-how-to-create-a-simple-C-App.html

elevation格式

elevation格式_Google Elevation的工作方式以及如何创建简单的C#应用​​程序?相关推荐

  1. 定时器工作方式0初值除32_51单片机C语言程序100例分析(2)定时器+中断

    #include<reg51.h> //包含 51 单片机寄存器定义的头文件 void main(void) {TMOD=0x01;// 使用定时器 T0 的模式 1TH0=(65536- ...

  2. 7. 【可编程定时器8253】:外部引脚、内部结构特点、计数启动方式、6种工作方式、控制字格式、应用

    文章目录 计数与定时 8253芯片特点 1. 外部引脚 2. 内部结构特点(含3个计数器.1个控制寄存器) 2. 计数启动方式(软件启动.硬件启动的定义) 3. 6种工作方式 不能自动重复计数的工作方 ...

  3. 【转】dicom通讯的工作方式及dicom标准简介!!

    转自:dicom通讯的工作方式及dicom标准简介 - assassinx - 博客园 本文主要讲述dicom标准及dicom通讯的工作方式.dicom全称医学数字图像与通讯 其实嘛就两个方面 那就是 ...

  4. 摈弃 Windows 低效率的工作方式,发掘 Linux 身上的 UNIX 气质

     [原文链接] 摈弃 Windows 低效率的工作方式,发掘 Linux 身上的 UNIX 气质 我已经半年没有使用 Windows 的方式工作了.Linux 高效的完成了我所有的工作. GNU/Li ...

  5. SVN+SSH协议工作方式全解析,以Sourceforge为例讲解如何在Windows下配置TortoiseSVN和Su

    分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow 也欢迎大家转载本篇文章.分享知识,造福人民,实现我们中华民族伟大复兴! 简单地说 ...

  6. 51单片机定时器工作方式1、2原理详解

    写在前面 1.本篇博文旨在帮助那些像我一样刚入门51单片机,如果你对定时器有一定了解,但是其中的的工作方式不能理解,那么这篇文章很适合你,如果你是大神的话-直接绕行吧-- 2.我在学习的过程中由于知识 ...

  7. dicom通讯的工作方式及dicom标准简介

    转自:http://www.cnblogs.com/assassinx/p/3223460.html 本文主要讲述dicom标准及dicom通讯的工作方式.dicom全称医学数字图像与通讯 其实嘛就两 ...

  8. vika维格表和飞书,多维表格如何改变我们的工作方式?

    在「云办公」的热潮下,对新时代的数据协作工具的要求也越来越高. 自 vika 维格表提出 「多维智能表格」 的理念后,在国内也掀起了一阵「数据协作」办公软件的风潮,市面上种类繁多.功能各异的多维智能表 ...

  9. 51单片机电路原理图_10个定时器精选电路方案带你学习时钟脉冲的工作方式

    可编程控制器中的定时器是根据时钟脉冲累积计时的,时钟脉冲有 1ms.10ms.100ms等不同规格.(定时器的工作过程实际上是对时钟脉冲计数)因工作需要,定时器除了占有自己编号的存储器位外,还占有一个 ...

最新文章

  1. tensorflow超参数优化,Tensorflow的超参数调整
  2. 英语----名词性从句的混合练习(上)
  3. Python3.5 Day1作业:实现用户密码登录,输错三次锁定。
  4. iphone three20 保存本地的图片
  5. python用三种方式定义字符串、并依次输出_Python 字符串格式化输出的3种方式
  6. c++程序添加资源文件及释放文件
  7. python将PDF文件转化为图片
  8. 虚拟机ubuntu与真实机实现实现复制粘贴、传输文件
  9. 蝙蝠侠大战超人:正义黎明[Batman v Superman: Dawn of Justice]
  10. Hadoop从零开始的搭建(伪分布式)
  11. linux单进程最大内存,x64 Linux中的单进程最大可能内存
  12. html中怎么让盒子模型居中,通过box盒子模型给元素内容设置居中
  13. php的qq邮箱正则表达式语法_正则表达式综合应用:qq邮箱提取
  14. “征服自己是最大的胜利,被征服是最大的耻辱和邪恶。”
  15. 回顾总结-----第九届中国云计算大会,量子计算机为最大亮点
  16. 用.bat文件多开微信及打开固定浏览器浏览固定页面 开机自启
  17. 用QQbot实现图灵机器人
  18. Java SE 6 新特性: 对脚本语言的支持 [VERY GOOD]
  19. 网间数据摆渡如何轻松实现数据安全交换
  20. 电影版本名词解析 (CAM,TS,TC,DVDSCR,DVDRIP,HR-HDTV)

热门文章

  1. 360Lib:Lanczos插值
  2. @Validated和@Valid
  3. Gym实践(一)——环境安装
  4. 酷炫的终端模拟器eDEX-UI
  5. 解决zabbix页connot connect to database;MariaDB 导入数据时 ERROR 1118 (42000) at line 1278: Row size too larg
  6. PAT Basic(乙级)---1009 (20 分)说反话
  7. 推荐一个好的查询快递的网站给大家。
  8. 移动安全规范 — 2 -蓝牙安全规范
  9. 身份证OCR识别是什么?
  10. “Mac OS X“录屏幕视频并转成gif