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. Java——常用类(基础类型数据包装类)

    [包装类]   包装类(如Integer.Double等)这些类封装了一个相应的基础数据类型数值,并为其提供了一系列操作.     例如:java.lang.Integer类提供了以下构造方法:   ...

  2. 【CF1252J】Tiling Terrace(DP)

    题意:有一个长为n的串,每个字符是#或者.中的一个,#不超过50个 有3种覆盖串的方式:(.),(..),(.#.),分别能获得g1,g2,g3的收益,覆盖之间不能重叠 第一种方式不能使用超过K次,问 ...

  3. 【CF1236D】Alice and the Doll(set)

    题意:给定一个n*m的网格,其中k格有障碍 周驿东从(1,1)出发面朝右,每次行动前他可以选择顺时针旋转90度或不旋转,然后向自己朝向的位置走1格 问他能否不重复不遗漏的走过所有非障碍格 n,m,k& ...

  4. Packet Transactions: High-level Programming for Line-Rate Switches

    Name of article:Packet Transactions: High-level Programming for Line-Rate Switches Origin of the art ...

  5. Swift权限控制

    最后更新:2017-03-20 private: 只能在当前类里面访问 fileprivate: 只能在当前文件内访问 internal:internal访问级别所修饰的属性或方法在源代码所在的整个模 ...

  6. ES的副本数量、插入大批量数据前,副本数应该设置为0

    多副本可以提升检索的能力,但是如果副本数量太多,插入数据的时候容易出现卡顿现象: 因为主分片要把数据同步给所有的副本,所以建议副本数量最好是1-2个: ---- Es在索引数据的时候,如果存在副本,那 ...

  7. 9 关联管理器(RelatedManager)

    知识预览: class RelatedManager class RelatedManager "关联管理器"是在一对多或者多对多的关联上下文中使用的管理器.它存在于下面两种情况: ...

  8. TimeUtils

    public class TimeUtils { public static final int YEAR = 0; public static final int MONTH = 1; public ...

  9. 回望2017,基于深度学习的NLP研究大盘点

    回望2017,基于深度学习的NLP研究大盘点 雷锋网 百家号01-0110:31 雷锋网 AI 科技评论按:本文是一篇发布于 tryolabs 的文章,作者 Javier Couto 针对 2017 ...

  10. leetcode-mid-Linked list-328 Odd Even Linked List-NO

    mycode # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # sel ...