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. MongoDB可视化工具的安装

    MongoDBCompass MongoDB Compass是一款优秀可靠的mongodb可视化数据库管理软件.可以更加方便地与mongodb数据库进行交互,支持对数据库进行查询.分析或者查看数据库的 ...

  2. (转载)《利用Python进行数据分析·第2版》电子书

    https://www.jianshu.com/p/04d180d90a3f https://www.jianshu.com/p/04d180d90a3f https://www.jianshu.co ...

  3. grep匹配单词, 匹配单词开始, 匹配^ 的区别

    grep '^.....$' 是指, 匹配整个这个行中, 以什么开头, 以什么结尾. 指的是整行, 不是某个单词. grep -w (word) 指的是匹配整个单词, 而不能是单词的一部分, 如: g ...

  4. Python字典的json格式化处理(换行与不换行)

    Prefer = {"jim": {"War": 1.9, "the big bang": 1.0, "The lord of w ...

  5. python回调函数应用-获取jenkins构建结果

    需求背景: 现在用jenkins构建自动化测试(2个job),公司现将自动化纳入到发布系统 要求每次构建成功之后,把测试结果发送给发布系统.这就需要先获取jenkins构建的结果,如果构建结束,才能发 ...

  6. day50—JavaScript鼠标拖拽事件

    转行学开发,代码100天——2018-05-05 今天通过鼠标拖拽事件复习巩固一下鼠标事件. 鼠标拖拽事件需要记住两点: 1.距离不变 2.鼠标事件(按下,移动,抬起) <div id=&quo ...

  7. 阶段1 语言基础+高级_1-3-Java语言高级_06-File类与IO流_07 缓冲流_1_缓冲流的原理

    一个字节一个字节的读取,先读取到a,a给到os操作系统.os再给JVM,.jVM再把a给java程序 读完a再读取b.这样一层层的返回,效率低下 一次读取,缓冲区数组返回来.

  8. Shell脚本中的特殊字符(美元符、反斜杠、引号等)作用介绍

    Shell中的特殊字符有 1.$ 美元符 2.\ 反斜杠 3.` 反引号 4." 双引号 5.< ,>;,*,?,[,] 下面我一一举列说明 一.$符号 1.echo $? 显示 ...

  9. Mac015--在Mac下安装使用Vagrant

    网址:http://yansu.org/2014/04/10/install-vagrant-in-mac.html 一.安装Vagrant 下载地址在http://www.vagrantup.com ...

  10. 如何实现动态水球图 --》 echars结合echarts-liquidfill实现

    1)项目中作为项目依赖,安装到项目当中(注意必须要结合echars) npm install echarts vue-echarts --save npm install echarts-liquid ...