zoukankan      html  css  js  c++  java
  • ArcEngine关于单位转换示例

    示例界面:

    转换代码:

     1     private void Button1_Click(object sender, System.Windows.RoutedEventArgs e)
     2         {
     3             // Get the AreaUnits value string name.
     4             string theSelectionText = ComboBox1.SelectedValue.ToString();
     5 
     6             // Get the input Square Meters value.
     7             double theInputValue = System.Convert.ToDouble(TextBox_Input_1.Text);
     8 
     9             // Create a placeholder output AreaUnits output value from the .ConvertFromSquareMeters Method. 
    10             double theOutputValue = 0;
    11 
    12             // For each AreaUnits type perform the .ConvertFromSquareMeters calculation.
    13             if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.Acres.Name)
    14             {
    15                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.Acres.ConvertFromSquareMeters(theInputValue);
    16             }
    17             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.Ares.Name)
    18             {
    19                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.Ares.ConvertFromSquareMeters(theInputValue);
    20             }
    21             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.Hectares.Name)
    22             {
    23                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.Hectares.ConvertFromSquareMeters(theInputValue);
    24             }
    25             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.SquareCentimeters.Name)
    26             {
    27                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.SquareCentimeters.ConvertFromSquareMeters(theInputValue);
    28             }
    29             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.SquareDecimeters.Name)
    30             {
    31                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.SquareDecimeters.ConvertFromSquareMeters(theInputValue);
    32             }
    33             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.SquareFeet.Name)
    34             {
    35                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.SquareFeet.ConvertFromSquareMeters(theInputValue);
    36             }
    37             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.SquareInches.Name)
    38             {
    39                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.SquareInches.ConvertFromSquareMeters(theInputValue);
    40             }
    41             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.SquareKilometers.Name)
    42             {
    43                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.SquareKilometers.ConvertFromSquareMeters(theInputValue);
    44             }
    45             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.SquareMeters.Name)
    46             {
    47                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.SquareMeters.ConvertFromSquareMeters(theInputValue);
    48             }
    49             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.SquareMiles.Name)
    50             {
    51                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.SquareMiles.ConvertFromSquareMeters(theInputValue);
    52             }
    53             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.SquareMillimeters.Name)
    54             {
    55                 theOutputValue = Esri.ArcGISRuntime.Geometry.AreaUnits.SquareMillimeters.ConvertFromSquareMeters(theInputValue);
    56             }
    57             else if (theSelectionText == Esri.ArcGISRuntime.Geometry.AreaUnits.SquareYards.Name)
    58             {
    59                 // NOTE: Using this long version you can also obtain information on the AreaUnit Class.
    60                 Esri.ArcGISRuntime.Geometry.AreaUnit myUnit_SquareYards = (Esri.ArcGISRuntime.Geometry.AreaUnit)Esri.ArcGISRuntime.Geometry.AreaUnit.Create(Esri.ArcGISRuntime.Geometry.AreaUnits.SquareYards.Id);
    61                 theOutputValue = myUnit_SquareYards.ConvertFromSquareMeters(theInputValue);
    62 
    63                 // Additional AreaUnit Properties that you could make use of in another application
    64                 int myAreaUnit_SquareYards_ID = myUnit_SquareYards.Id;
    65                 string myAreaUnit_SquareYards_Name = myUnit_SquareYards.Name;
    66                 Esri.ArcGISRuntime.Geometry.UnitType myAreaUnit_SquareYards_UnitType = myUnit_SquareYards.UnitType;
    67             }
    68 
    69             // Display the other XXXX AreaUnits values.
    70             TextBox_Output_1.Text = theOutputValue.ToString();
    71         }

    参考网址:https://developers.arcgis.com/net/desktop/api-reference/

  • 相关阅读:
    html 上传图片前预览
    php获取当月天数及当月第一天及最后一天、上月第一天及最后一天实现方法
    php 计算 pdf文件页数
    php 获取半年内每个月的订单数量, 总价, 月份
    php 获取两个数组之间不同的值
    小程序支付功能
    关于nginx的Job for nginx.service failed because the control process exited with error code.错误
    linux 安装 Apollo
    MongoDB待续。。。
    ABP vNext...待续
  • 原文地址:https://www.cnblogs.com/jinlun/p/6004762.html
Copyright © 2011-2022 走看看