Created
October 23, 2012 18:55
-
-
Save JeffJacobson/3940798 to your computer and use it in GitHub Desktop.
Consuming USGS Elevation Web Service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------------------------ | |
// <auto-generated> | |
// This code was generated by a tool. | |
// Runtime Version:4.0.30319.269 | |
// | |
// Changes to this file may cause incorrect behavior and will be lost if | |
// the code is regenerated. | |
// </auto-generated> | |
//------------------------------------------------------------------------------ | |
// | |
// This source code was auto-generated by wsdl, Version=4.0.30319.1. | |
// | |
namespace Usgs.Elevation { | |
using System; | |
using System.Diagnostics; | |
using System.Xml.Serialization; | |
using System.ComponentModel; | |
using System.Web.Services.Protocols; | |
using System.Web.Services; | |
/// <remarks/> | |
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] | |
[System.Diagnostics.DebuggerStepThroughAttribute()] | |
[System.ComponentModel.DesignerCategoryAttribute("code")] | |
[System.Web.Services.WebServiceBindingAttribute(Name="Elevation_ServiceSoap", Namespace="http://gisdata.usgs.gov/XMLWebServices2/")] | |
public partial class Elevation_Service : System.Web.Services.Protocols.SoapHttpClientProtocol { | |
private System.Threading.SendOrPostCallback getElevationOperationCompleted; | |
private System.Threading.SendOrPostCallback getAllElevationsOperationCompleted; | |
/// <remarks/> | |
public Elevation_Service() { | |
this.Url = "http://gisdata.usgs.gov/XMLWebServices2/Elevation_service.asmx"; | |
} | |
/// <remarks/> | |
public event getElevationCompletedEventHandler getElevationCompleted; | |
/// <remarks/> | |
public event getAllElevationsCompletedEventHandler getAllElevationsCompleted; | |
/// <remarks/> | |
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://gisdata.usgs.gov/XMLWebServices2/getElevation", RequestNamespace="http://gisdata.usgs.gov/XMLWebServices2/", ResponseNamespace="http://gisdata.usgs.gov/XMLWebServices2/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] | |
public System.Xml.XmlNode getElevation(string X_Value, string Y_Value, string Elevation_Units, string Source_Layer, string Elevation_Only) { | |
object[] results = this.Invoke("getElevation", new object[] { | |
X_Value, | |
Y_Value, | |
Elevation_Units, | |
Source_Layer, | |
Elevation_Only}); | |
return ((System.Xml.XmlNode)(results[0])); | |
} | |
/// <remarks/> | |
public System.IAsyncResult BegingetElevation(string X_Value, string Y_Value, string Elevation_Units, string Source_Layer, string Elevation_Only, System.AsyncCallback callback, object asyncState) { | |
return this.BeginInvoke("getElevation", new object[] { | |
X_Value, | |
Y_Value, | |
Elevation_Units, | |
Source_Layer, | |
Elevation_Only}, callback, asyncState); | |
} | |
/// <remarks/> | |
public System.Xml.XmlNode EndgetElevation(System.IAsyncResult asyncResult) { | |
object[] results = this.EndInvoke(asyncResult); | |
return ((System.Xml.XmlNode)(results[0])); | |
} | |
/// <remarks/> | |
public void getElevationAsync(string X_Value, string Y_Value, string Elevation_Units, string Source_Layer, string Elevation_Only) { | |
this.getElevationAsync(X_Value, Y_Value, Elevation_Units, Source_Layer, Elevation_Only, null); | |
} | |
/// <remarks/> | |
public void getElevationAsync(string X_Value, string Y_Value, string Elevation_Units, string Source_Layer, string Elevation_Only, object userState) { | |
if ((this.getElevationOperationCompleted == null)) { | |
this.getElevationOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetElevationOperationCompleted); | |
} | |
this.InvokeAsync("getElevation", new object[] { | |
X_Value, | |
Y_Value, | |
Elevation_Units, | |
Source_Layer, | |
Elevation_Only}, this.getElevationOperationCompleted, userState); | |
} | |
private void OngetElevationOperationCompleted(object arg) { | |
if ((this.getElevationCompleted != null)) { | |
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); | |
this.getElevationCompleted(this, new getElevationCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); | |
} | |
} | |
/// <remarks/> | |
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://gisdata.usgs.gov/XMLWebServices2/getAllElevations", RequestNamespace="http://gisdata.usgs.gov/XMLWebServices2/", ResponseNamespace="http://gisdata.usgs.gov/XMLWebServices2/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] | |
public System.Xml.XmlNode getAllElevations(string X_Value, string Y_Value, string Elevation_Units) { | |
object[] results = this.Invoke("getAllElevations", new object[] { | |
X_Value, | |
Y_Value, | |
Elevation_Units}); | |
return ((System.Xml.XmlNode)(results[0])); | |
} | |
/// <remarks/> | |
public System.IAsyncResult BegingetAllElevations(string X_Value, string Y_Value, string Elevation_Units, System.AsyncCallback callback, object asyncState) { | |
return this.BeginInvoke("getAllElevations", new object[] { | |
X_Value, | |
Y_Value, | |
Elevation_Units}, callback, asyncState); | |
} | |
/// <remarks/> | |
public System.Xml.XmlNode EndgetAllElevations(System.IAsyncResult asyncResult) { | |
object[] results = this.EndInvoke(asyncResult); | |
return ((System.Xml.XmlNode)(results[0])); | |
} | |
/// <remarks/> | |
public void getAllElevationsAsync(string X_Value, string Y_Value, string Elevation_Units) { | |
this.getAllElevationsAsync(X_Value, Y_Value, Elevation_Units, null); | |
} | |
/// <remarks/> | |
public void getAllElevationsAsync(string X_Value, string Y_Value, string Elevation_Units, object userState) { | |
if ((this.getAllElevationsOperationCompleted == null)) { | |
this.getAllElevationsOperationCompleted = new System.Threading.SendOrPostCallback(this.OngetAllElevationsOperationCompleted); | |
} | |
this.InvokeAsync("getAllElevations", new object[] { | |
X_Value, | |
Y_Value, | |
Elevation_Units}, this.getAllElevationsOperationCompleted, userState); | |
} | |
private void OngetAllElevationsOperationCompleted(object arg) { | |
if ((this.getAllElevationsCompleted != null)) { | |
System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); | |
this.getAllElevationsCompleted(this, new getAllElevationsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); | |
} | |
} | |
/// <remarks/> | |
public new void CancelAsync(object userState) { | |
base.CancelAsync(userState); | |
} | |
} | |
/// <remarks/> | |
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] | |
public delegate void getElevationCompletedEventHandler(object sender, getElevationCompletedEventArgs e); | |
/// <remarks/> | |
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] | |
[System.Diagnostics.DebuggerStepThroughAttribute()] | |
[System.ComponentModel.DesignerCategoryAttribute("code")] | |
public partial class getElevationCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { | |
private object[] results; | |
internal getElevationCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : | |
base(exception, cancelled, userState) { | |
this.results = results; | |
} | |
/// <remarks/> | |
public System.Xml.XmlNode Result { | |
get { | |
this.RaiseExceptionIfNecessary(); | |
return ((System.Xml.XmlNode)(this.results[0])); | |
} | |
} | |
} | |
/// <remarks/> | |
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] | |
public delegate void getAllElevationsCompletedEventHandler(object sender, getAllElevationsCompletedEventArgs e); | |
/// <remarks/> | |
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "4.0.30319.1")] | |
[System.Diagnostics.DebuggerStepThroughAttribute()] | |
[System.ComponentModel.DesignerCategoryAttribute("code")] | |
public partial class getAllElevationsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { | |
private object[] results; | |
internal getAllElevationsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : | |
base(exception, cancelled, userState) { | |
this.results = results; | |
} | |
/// <remarks/> | |
public System.Xml.XmlNode Result { | |
get { | |
this.RaiseExceptionIfNecessary(); | |
return ((System.Xml.XmlNode)(this.results[0])); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Xml; | |
using Usgs.Elevation; | |
namespace UsgsElevationServiceTest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
double x = -122.89478301998749; | |
double y = 47.00290950656123; | |
string unit = "FEET"; // "METERS" | |
string sourceLayer = "*Elev_WA"; | |
XmlNode result; | |
using (var svc = new Elevation_Service { Url = "http://gisdata.usgs.gov/XMLWebServices2/Elevation_Service.asmx" }) | |
{ | |
result = svc.getElevation(x.ToString(), y.ToString(), unit, sourceLayer, "TRUE"); | |
} | |
double elevation = double.Parse(result.FirstChild.Value); | |
Console.WriteLine(elevation); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment