给定lat/long中的现有点,(以KM表示)和方位(以度数转换为弧度)的距离,我想计算新的纬度/经度.这个网站反复出现,但我无法让这个公式为我工作.
采用上述链接的公式为:
lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(?))
lon2 = lon1 + atan2(sin(?)*sin(d/R)*cos(lat1), cos(d/R)?sin(lat1)*sin(lat2))
Run Code Online (Sandbox Code Playgroud)
上述公式适用于MSExcel,其中 -
asin = arc sin()
d = distance (in any unit)
R = Radius of the earth (in the same unit as above)
and hence d/r = is the angular distance (in radians)
atan2(a,b) = arc tan(b/a)
? is the bearing (in radians, clockwise from north);
Run Code Online (Sandbox Code Playgroud)
这是我在Python中获得的代码.
import math
R = 6378.1 #Radius of the Earth
brng = 1.57 #Bearing is 90 degrees converted …Run Code Online (Sandbox Code Playgroud) Linq的新手,如果这是基本的,请道歉.此查询抛出错误{"无法将DBNull.Value强制转换为'System.Int64'.请枚举结果时使用可空类型."}.
private void AddLevels(long rootid)
{
var results = from row in data.AsEnumerable()
where row.Field<long>("ParentID") == rootid
select row;
foreach (DataRow row in results)
{
//do stuff
}
}
Run Code Online (Sandbox Code Playgroud)
列ParentID确实接受空值 - 我需要单独处理这些吗?
EDIT2:下面的实际解决方案仍然使用Linq.
编辑:我通过废除Linq并仅使用DataTable.Select语句解决了这个问题.如果有人对性能差异有所了解我会感兴趣.
int i = amount; //amount will always start at 0
int j = i + 1;
GroupBox[] verGroup;
verGroup = new GroupBox[i];
verGroup[i].Name = "verGroup" + i.ToString();
verGroup[i].Width = 400;
verGroup[i].Height = 120;
verGroup[i].Left = 5;
verGroup[i].Top = 5 + (verGroup[i].Height * i) + (10 * i);
verGroup[i].Text = "Verification #" + j.ToString();
pnlVer.Controls.Add(verGroup[i]);
Run Code Online (Sandbox Code Playgroud)
它在verGroup [i] .Name中给了我一个IndexOutofRangeException.但索引是0,这肯定是它想要的?
我也试过了
verGroup = new GroupBox[5]
Run Code Online (Sandbox Code Playgroud)
但是会抛出"对象引用未设置为对象的实例"错误.
如果有人能指出我正确的方向,将不胜感激.
我有一个不是特别复杂的SQL查询,可以在Server Mgt Studio中运行时返回我想要的内容,但是当我在C#中运行它时,DataGrid会出现空白.(是的 - 主机名已经消毒,我不仅仅有一个糟糕的命名方案.)
希望眼睛比我更敏锐的人可以解决这个问题.
SQL查询:
SELECT MachineName, InstanceName, CounterName,
AVG(CASE WHEN CounterValue > 0 THENCounterValue ELSE NULL END)/1024 as 'Mean (KB)'
FROM DataCollector.dbo.JobCounterSummary
WHERE
((MachineName = '\\HOST001' AND (InstanceName = 'D:' OR InstanceName = 'E:')) OR
(MachineName = '\\HOST002' AND (InstanceName = 'E:' OR InstanceName = 'G:')) OR
(MachineName = '\\HOST003' AND (InstanceName = 'G:' OR InstanceName = 'H:')) OR
(MachineName = '\\HOST004' AND (InstanceName = 'G:' OR InstanceName = 'H:') OR
(MachineName = '\\HOST005' AND InstanceName = …Run Code Online (Sandbox Code Playgroud)