using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization; namespace ConsoleApplication1
{
public class Program
{
public static void Main(string[] args)
{
StreamReader sr = new StreamReader(@"C:\Users\UserAccount\Desktop\20131103203219.txt");
string record = string.Empty; StringBuilder sb = new StringBuilder();
sb.Append('[');
while ((record = sr.ReadLine()) != null)
{
sb.Append(record + ',');
}
sb.Remove(sb.ToString().Length - , );
sb.Append(']'); JavaScriptSerializer js = new JavaScriptSerializer();
List<GPS> list = js.Deserialize(sb.ToString(), typeof(List<GPS>)) as List<GPS>; var list2 = from x in list
where x.Distance % < && x.SpeedMeter !=
orderby x.GPSTime ascending
select new { x.DuringTime, x.Distance, x.SpeedMeter }; // 求在起点处几个点的平均速度
var list3 = from x in list2
orderby (int)x.Distance / ascending
group x by (int)x.Distance / into gx
select new
{
gx.Key,
Distance = gx.Min(p => p.Distance),
Speed = gx.Average(p => p.SpeedMeter)
}; // 求每一圈的平均速度
var list4 = from x in list
where x.SpeedMeter !=
group x by (int)(x.Distance / ) into gx
orderby gx.Key ascending
select new
{
gx.Key,
Distance = gx.Min(p => p.Distance),
Speed = gx.Average(p => p.SpeedMeter)
}; StreamWriter sw = new StreamWriter(@"T:\kongston.txt");
foreach (var g in list4)
{
sw.WriteLine(js.Serialize(g));
Console.WriteLine(js.Serialize(g));
} sr.Close();
sw.Close();
sr.Dispose();
sw.Dispose();
}
}
} GPS类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text; namespace ConsoleApplication1
{
public class GPS
{
public double Longitude { get; set; } public double Latitude { get; set; } public double Accuracy { get; set; } public double Altitude { get; set; } public double SpeedMeter { get; set; } private long _GPSTime; public long GPSTime
{
get
{
return this._GPSTime;
}
set
{
this._GPSTime = value; // C# 解析GPS返回的时间
DateTime dt = new DateTime(, , ).AddMilliseconds(value).AddHours();
NormalTime = dt;
StringTime = dt.ToString("yyyy-MM-dd HH:mm:ss");
}
} public DateTime NormalTime { get; set; } public string StringTime { get; set; } public double Bearing { get; set; } public int DuringTime { get; set; } public double Distance { get; set; }
}
}

Linq 高级应用实例的更多相关文章

  1. Webform(Linq高级查、分页、组合查询)

    一.linq高级查 1.模糊查(包含) 1 public List<User> Select(string name) 2 { 3 return con.User.Where(r => ...

  2. 使用LINQ查询数据实例和理解

    使用LINQ查询数据实例和理解 var contacts= from customer in db.Customers where customer.Name.StartsWith("A&q ...

  3. LinQ高级查询、组合查询、IQueryable集合类型

    LinQ高级查询: 1.模糊查询(包含) Repeater1.DataSource = con.car.Where(r =>r.name.Contains(s)).ToList(); 2.开头 ...

  4. Linq高级查询,分页查询及查询分页结合

    一.高级查询与分页查询 1.以...开头    StartsWith Repeater1.DataSource=con.Users.Where(r=>r.Nickname.StartsWith( ...

  5. 2017年12月14日 LinQ高级查&&Asp.net WebForm Asp.net MVC

    LinQ的高级查询用法 开头:StartsWith()结尾:EndsWith()模糊:Contains() 个数:Count最大值:Max(r => r.price)最小值:Min(r => ...

  6. LinQ 高级查询

    高级查询 模糊查(包含):.Contains(name) 开头:.StartsWith(name) 结尾:.EndsWith(name) 个数:.Count() 最大值:Max(r => r.p ...

  7. [C#]Linq To Xml 实例操作- 转

    http://blog.sina.com.cn/s/blog_6c762bb301010oi5.html http://blog.xuite.net/cppbuilder/blog/9940157 在 ...

  8. LinQ综合应用实例

    直接上代码,内容很浅显易懂,在这里就不做更多的解释,解释见代码注释. using System; using System.Collections.Generic; using System.Linq ...

  9. LINQ高级编程 笔记

    相关资料:http://www.cnblogs.com/lifepoem/archive/2011/12/16/2288017.html 1.什么是LINQ 语言集成查询是一系列标准查询操作符的集合, ...

随机推荐

  1. jQuery .ready()

    https://www.w3schools.com/jquery/event_ready.asp Example Use ready() to make a function available af ...

  2. windows下数据库备份bat

    @echo offset "Ymd=%date:~,4%%date:~5,2%%date:~8,2%"C:/mysql/bin/mysqldump --opt -u root -- ...

  3. el-date-picker用法

    需求:1.默认时间是当天开始到此刻的时间 2.快捷键为今天.昨天.最近一周.最近30天.最近90天 3.不可以清空,必选项

  4. nginx的域名解析

    1.​创建域名解析结构: ngx_resolver_create(ngx_conf_t *cf, ngx_str_t *names, ngx_uint_t n) 这里面的names是dns服务器的地址 ...

  5. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_03 过滤器_2_FileNameFilter过滤器的使用和Lambda表达式

    复制一份上一节的代码 匿名内部类的形式 FilenameFilter 只有一个Accept方法.这样我们就可以使用lambda表达式 lambda表达式的前提条件 参数类型和,返回的大括号 都可以省掉 ...

  6. Tclientdataset的CloneCursor问题 clientdataset 复制 赋值 的问题

    http://www.myexception.cn/delphi/720245.html Tclientdataset的CloneCursor问题我的DBGRID所连接的数据源为cdsBook,然后用 ...

  7. Java ——变量类型

    变量声明 int a, b, c; // 声明三个int型整数:a. b.c int d = 3, e = 4, f = 5; // 声明三个整数并赋予初值 byte z = 22; // 声明并初始 ...

  8. 从新向你学习javase(第一天)

    1:阐述JDK和JRE之间区别 jdk(工具)>jre(运行环境)>jvm(虚拟机) 2: 能够使用常见的DOS命令 d:(进入D盘下),cd +路径(进入到当前路径),cd..(返回上一 ...

  9. myeclipse的修改背景颜色和字体

  10. VC调试方法大全

    VC调试方法大全 一.调试基础 调试快捷键 F5:  开始调试 Shift+F5: 停止调试 F10:   调试到下一句,这里是单步跟踪 F11:   调试到下一句,跟进函数内部 Shift+F11: ...