根据数据最后一个字段正负判断方向,增加字段进行区分方向的不同!? 40C

数据格式如下:
432417e51e7d340a,2018-02-07 09:20:52,120.707309,30.633297,0.0
432417e51e7d340a,2018-02-07 09:25:55,120.71122,30.64435,1.2861781
432417e51e7d340a,2018-02-07 09:26:53,120.707309,30.633297,-1.2861781
432417e51e7d340a,2018-02-07 09:28:27,120.70445,30.63925,0.7170383
432417e51e7d340a,2018-02-07 09:32:21,120.707309,30.633297,-0.7170383
432417e51e7d340a,2018-02-07 09:37:07,120.70445,30.63925,0.7170383
432417e51e7d340a,2018-02-07 09:38:59,120.707309,30.633297,-0.7170383
432417e51e7d340a,2018-02-07 09:40:33,120.707309,30.633297,0.0
432417e51e7d340a,2018-02-07 09:41:17,120.70445,30.63925,0.7170383
432417e51e7d340a,2018-02-07 09:41:58,120.707309,30.633297,-0.7170383
432417e51e7d340a,2018-02-07 09:44:00,120.70445,30.63925,0.7170383
432417e51e7d340a,2018-02-07 09:47:12,120.71122,30.64435,0.56913984
432417e51e7d340a,2018-02-07 09:47:52,120.707309,30.633297,-1.2861781
432417e51e7d340a,2018-02-07 09:49:51,120.715865,30.64935,1.9659712
432417e51e7d340a,2018-02-07 10:09:32,120.72743,30.64796,0.559644
432417e51e7d340a,2018-02-07 10:13:45,120.78822,30.678701,6.7269063
432417e51e7d340a,2018-02-07 10:15:35,120.817392,30.696594,3.4293442
432417e51e7d340a,2018-02-07 10:24:30,120.83463,30.72041,2.899088
432417e51e7d340a,2018-02-07 10:27:14,120.82615,30.70921,-1.4039326
432417e51e7d340a,2018-02-07 10:32:32,120.81779,30.70191,-1.1261663
432417e51e7d340a,2018-02-07 10:34:57,120.83463,30.72041,2.530099
432417e51e7d340a,2018-02-07 10:36:56,120.83463,30.72041,0.0
432417e51e7d340a,2018-02-07 10:37:49,120.84623,30.72688,1.3184185
432417e51e7d340a,2018-02-07 10:38:28,120.852487,30.734512,0.99814034
432417e51e7d340a,2018-02-07 10:39:45,120.86842,30.73819,1.4541836
432417e51e7d340a,2018-02-07 10:40:57,120.853132,30.745325,-0.6269398
432417e51e7d340a,2018-02-07 10:45:49,120.79159,30.691897,-8.345741
432417e51e7d340a,2018-02-07 10:55:17,120.70348,30.64357,-9.178058
432417e51e7d340a,2018-02-07 10:59:44,120.6837,30.63107,1.073965
结果文件格式:
432417e51e7d340a,2018-02-07 09:20:52,120.707309,30.633297,0.0,1
432417e51e7d340a,2018-02-07 09:25:55,120.71122,30.64435,1.2861781,1
432417e51e7d340a,2018-02-07 09:26:53,120.707309,30.633297,-1.2861781,1
432417e51e7d340a,2018-02-07 09:28:27,120.70445,30.63925,0.7170383,1
432417e51e7d340a,2018-02-07 09:32:21,120.707309,30.633297,-0.7170383,1
432417e51e7d340a,2018-02-07 09:37:07,120.70445,30.63925,0.7170383,1
432417e51e7d340a,2018-02-07 09:38:59,120.707309,30.633297,-0.7170383,1
432417e51e7d340a,2018-02-07 09:40:33,120.707309,30.633297,0.0,1
432417e51e7d340a,2018-02-07 09:41:17,120.70445,30.63925,0.7170383,1
432417e51e7d340a,2018-02-07 09:41:58,120.707309,30.633297,-0.7170383,1
432417e51e7d340a,2018-02-07 09:44:00,120.70445,30.63925,0.7170383,1
432417e51e7d340a,2018-02-07 09:47:12,120.71122,30.64435,0.56913984,1
432417e51e7d340a,2018-02-07 09:47:52,120.707309,30.633297,-1.2861781,1
432417e51e7d340a,2018-02-07 09:49:51,120.715865,30.64935,1.9659712,1
432417e51e7d340a,2018-02-07 10:09:32,120.72743,30.64796,0.559644,1
432417e51e7d340a,2018-02-07 10:13:45,120.78822,30.678701,6.7269063,1
432417e51e7d340a,2018-02-07 10:15:35,120.817392,30.696594,3.4293442,1
432417e51e7d340a,2018-02-07 10:24:30,120.83463,30.72041,2.899088,1
432417e51e7d340a,2018-02-07 10:27:14,120.82615,30.70921,-1.4039326,2
432417e51e7d340a,2018-02-07 10:32:32,120.81779,30.70191,-1.1261663,2
432417e51e7d340a,2018-02-07 10:34:57,120.83463,30.72041,2.530099,3
432417e51e7d340a,2018-02-07 10:36:56,120.83463,30.72041,0.0,3
432417e51e7d340a,2018-02-07 10:37:49,120.84623,30.72688,1.3184185,3
432417e51e7d340a,2018-02-07 10:38:28,120.852487,30.734512,0.99814034,3
432417e51e7d340a,2018-02-07 10:39:45,120.86842,30.73819,1.4541836,3
432417e51e7d340a,2018-02-07 10:40:57,120.853132,30.745325,-0.6269398,4
432417e51e7d340a,2018-02-07 10:45:49,120.79159,30.691897,-8.345741,4
432417e51e7d340a,2018-02-07 10:55:17,120.70348,30.64357,-9.178058,4
432417e51e7d340a,2018-02-07 10:59:44,120.6837,30.63107,1.073965,4
字段分别是:用户id,时间,经纬度,行驶距离(正负表示方向),若该用户行驶距离字段连续出现两个相同符号,则该用户行驶方向发生改变。
(若行驶距离字段符号为0按大于零处理)

2个回答

最后的方向是相对于初始经纬度的方向吧,那就直接比较经纬度就行了啊

int sign = 0;
if (Float.valueOf(s3[4]) >= 0){
sign = 1;
}else {
sign = -1;
}
s3[5] = new String("1");
//System.out.println(s3[5]);
int count1 = 1;

    for (int i = 0;i < str.length-1;i++){
        String[] s1 = str[i].split(",");
        String[] s2 = str[i+1].split(",");
        if (!s1[0].equals(temp)){
            temp = s1[0];
            s1[5] = String.valueOf(1);
            if (Float.valueOf(s3[4]) >= 0){
                sign = 1;
            }else {
                sign = -1;
            }
            count1 = 1;
            System.out.println(s1[0] + "," + s1[1] + "," + s1[2] + "," + s1[3] + "," + s1[4] + "," + s1[5]);
            writer.write(s1[0] + "," + s1[1] + "," + s1[2] + "," + s1[3] + "," + s1[4] + "," + s1[5] + "\r\n");
        }else if (s1[0].equals(temp) && s2[0].equals(temp)){
            if (Float.valueOf(s1[4]) >= 0 && Float.valueOf(s2[4]) >= 0 && sign == -1){
                count1+=1;
                s1[5] = String.valueOf(count1);
                sign = 1;
                System.out.println(s1[0] + "," + s1[1] + "," + s1[2] + "," + s1[3] + "," + s1[4] + "," + s1[5]);
                writer.write(s1[0] + "," + s1[1] + "," + s1[2] + "," + s1[3] + "," + s1[4] + "," + s1[5] + "\r\n");
            }else if (Float.valueOf(s1[4]) < 0 && Float.valueOf(s2[4]) < 0 && sign == 1){
                count1+=1;
                s1[5] = String.valueOf(count1);
                sign = -1;
                System.out.println(s1[0] + "," + s1[1] + "," + s1[2] + "," + s1[3] + "," + s1[4] + "," + s1[5]);
                writer.write(s1[0] + "," + s1[1] + "," + s1[2] + "," + s1[3] + "," + s1[4] + "," + s1[5] + "\r\n");
            }else {
                s1[5] = String.valueOf(count1);
                System.out.println(s1[0] + "," + s1[1] + "," + s1[2] + "," + s1[3] + "," + s1[4] + "," + s1[5]);
                writer.write(s1[0] + "," + s1[1] + "," + s1[2] + "," + s1[3] + "," + s1[4] + "," + s1[5] + "\r\n");
            }
        }else if (s1[0].equals(temp) && !s2[0].equals(temp)){
            s1[5] = String.valueOf(count1);
            count1 = 1;
            System.out.println(s1[0] + "," + s1[1] + "," + s1[2] + "," + s1[3] + "," + s1[4] + "," + s1[5]);
            writer.write(s1[0] + "," + s1[1] + "," + s1[2] + "," + s1[3] + "," + s1[4] + "," + s1[5] + "\r\n");
        }

// else if (s1[0].equals(temp) && s2[0].equals(temp) && !s1[8].equals(s2[8])){
//
// }
}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
判断方向
1.外积的大小为正时,可以确定b在a的逆时针位置2.外积的大小为负时,可以确定b在a的顺时针位置3.当1,2都不满足时,表示p2位于直线p0p1上(不一定在线段上)cos在角度大于90度或这小于-90度时为负,所以a与b的内积dot(a,b)为负时,可确定p2位于线段p0p1的后方4.当3不满足时,判断b的大小如果大于a的,在前方5.不符合上述情况,则可以确定p2位于p0p1上string ccw...
根据正负进行统计
字段 fa fb fcrn数据 rn a1 b2 -1rn a1 b2 -2rn a1 b2 -3rnrn a1 b2 1rn a1 b2 2rn a1 b2 3rnrn a1 b1 -1rn a1 b1 -2rn a1 b1 -3rnrn a1 b1 1rn a1 b1 2rn a1 b1 3rn预想结果rn a1 b1 -6rn a1 b1 6rn a1 b2 -6rn a1 b2 6rn如何根据fa,fb进行统计(并且也要根据fc的正负)
根据鼠标移动炮台方向
![图片说明](https://img-ask.csdn.net/upload/201611/06/1478417300_550987.png)把图中的红点(355,600)当做为原点,根据鼠标在窗口点击的位置改变炮台的方向,如何实现rn这个功能,求解
推箱子-根据keycode判断推的方向
script type="text/javascript"> document.onkeyup=document.onkeydown=function (e) { //console.log(e); console.log(e.keyCode);//记录当前按键的键值 //左37,上38,右39,下40 //shift 16 //c
js判断鼠标滑轮滚动方向并根据滚动的方向触发不同的事件
var scrollFunc = function (e) { var direct = 0; e = e || window.event; if (e.wheelDelta) { //判断浏览器IE,谷歌滑轮事件 if (e.wheelDelta > 0) { //当滑轮向上滚动时
ImageView 不同方向的圆角
ImageView 不同方向的圆角,可分别设置上、下、左、右四个方向不同的圆角,也可用作圆形ImageView
多边形的方向判断
本文用三维空间来解决二维平面问题 , 从而得出了一个简单的点与有向线段之间关系的 判别式 , 并在此基础上根据凸凹点的性质及有向多边形的性质提出了不用解任何方程组也不用计 算三角函数的判定平面多边形的简单性 、 方向及内外点的简单 、 强健而高效的算法
VB判断鼠标移动方向
VB如何判断鼠标移动方向?
移动端,判断滑动方向
直接看代码:   var windowHeight = $(window).height(); $(&quot;body&quot;).css(&quot;height&quot;, windowHeight); var startX, startY, moveEndX, moveEndY, X, Y; $(&quot;body&quot;).on(&quot;touchstart&quot;, function(e) { e.p...
Vector3.Dot 方向判断
当两个向量夹角超过90度,就变成了负数,所以可以判断是否在背面.Vector3 dir1, dir2; dir1 = me.transform.forward; dir2 = (target.transform.position - me.transform.position).normalized; Debug.DrawRay(me.transform
判断鼠标方向js
判断鼠标方向的javascript代码,值得一看
向量运用-判断方向
return point.x * point2.y -  point2.x * point.y --[[ -- 点与直线 方向获取, 上 /下 :dir > 0 表示 point 在 point 2下面
鼠标和滚轮方向判断
鼠标和滚轮方向判断1.鼠标进入方向判断:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <link rel="stylesheet" href=""> </head> <body> <div id="a" style="width:200px;heig
viewpager判断滑动方向
viewpager 向左 or 向右 判断
判断鼠标进入方向
判断鼠标进入方向
UIScrollView的滑动方向判断
如何判断UIScrollView的滑动方向,在UIScrollViewDelegate的- (void)scrollViewDidScroll:(UIScrollView *)scrollView 委托方法中进行监听,通过panGestureRecognizer的translatedPoint上的x,y进行左右上下判断。 - (void)scrollViewDidScroll:(UIScrollVi
c8051f340摆动判断方向
c8051f340摆动判断方向,通过两个霍尔传感器,判断前进和后退的方向
android判断手势滑动方向
switch (event.getAction()) { // 判斷觸控的動作 case MotionEvent.ACTION_DOWN: // 按下 downX = event.getX(); downY = event.getY(); return true; case MotionEvent.ACTION_MOVE: // 拖曳 return ...
touch滑动判断方向
script> var startX = 0, startY = 0; function touchStart(evt){ try{ var touch = evt.touches[0], //获取第一个触点 x = Number(touch.pageX), //页面触点X坐标
如何判断移动方向?!
在光电开关中间有一个带有不透明栅格的透明塑料尺,可以在光电开关的中间移动,我如何才能判断尺子的移动方向啊?!光电开关应该选择两只或者一个发送端两个接收端的吧?!请给出判断流程,如果需要增加电路,该怎么做呢?!百思不得其解,谢谢大侠们了!
判断网页滚动方向
这种方式,当一直向下滚动的时候,只会显示一次‘down’,只有两次方向不一样时才会重新显示。 var scrollAction,originalDir; window.onscroll = function (e) { var direction = scrollFunc(); if(direction&amp;amp;&amp;amp;originalDir!=direction){ i...
滚动方向判断的问题
我初学vb,现遇到一个难题,各位师兄弟请指点迷津,谢谢!!!rn rn 问题:rn 在我的窗体上放置了一个listBox控件,当添加多项内容后,右边自动出现了滚动条,当鼠标去点击上下两个滚动按钮时,我怎样才能判断滚动方向呢??rnrn 高分征解!
如何判断鼠标移动的方向
如何判断鼠标移动的方向?是不是有这样的函数?rnrn我用 GetCursorPos取得鼠标, 中间Sleep(1)延时一下,再取出一下鼠标位置判断,发现鼠标有抖动,像死了一样,根本不行。rnrn另外,光标到了边界,再移动鼠标就没办法判断了。也就是如何知道鼠标一直在动,就像有些游戏里,拉鼠标可以原地一直转圈。rnrn请问各位高手有何妙计。多谢。
栈开口方向的判断
不管栈开口方向向上还是向下,内存地址加一永远向上#include&amp;lt;stdio.h&amp;gt;int main(void){    int a;    int b;    printf(&quot;%d   %d\n&quot;,&amp;amp;a,&amp;amp;b);    if(&amp;amp;a&amp;gt;&amp;amp;b)        printf(&quot;开口向下\n&quot;);    else        printf(&quot;开口向上\n&quo
滚动视图方向判断
////判断滚动的方向 //- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{ //     //    oldContentOffsetY = scrollView.contentOffset.y; //     //} // //- (void)scrollViewDidEndDecelerating:(
判断栈的增长方向
func() { int a; int b; }在不同的编译器下,a,b的在栈上的位置可能不同。例如gcc3.x是按定义的顺序入栈的,但gcc4.x正好相反。你不能用它来判断栈的方向。 但无论如何,函数调用的顺序不会变,所以其参数压栈的先后顺序也不会变.#include<stdio.h>void func1(); void func2(int *a);void func1() { int a
android-判断滑动方向
看xy谁滑动的绝对值大,谁大就是向谁的方向滑动
jquery 判断鼠标移动方向
如何判断鼠标移动方向,了解思想是利用e.clientX记住两次的鼠标坐标,再把二者相减,可以得出鼠标移动方向,问题是弄了很久也不见得效果,希望回复者不要把刚开始的x坐标置为0.懂得请帮忙!不甚感激!
方向
上学以来一直在想自己将来想干什么,能干什么。迷失了好久,找不到方向,最近终于理清了想法,找到将来要发展的方向----数据库。但不知道从哪方面下手,需要掌握些什么,希望各位前辈能给指点迷津。
方向?
导师是研究入侵检测的,我也逃脱不了入侵检测的宿命。rn可是感觉很是模糊,不知道该怎么学习rn毕业了我想做出点东西,我也看到snort源码,具体没有研究过rn这里有没有高手,能不能给指点一下应该如何学习,怎么下手,不胜感谢。rn我是因该在windows入手,还是在linux入手,还请高手指教。
根据经纬度计算方向角
import math def rad(d): return d * 3.14159 / 180.0 def deg(d): return d*180.0/3.14159 def CalculateAngle(lat1,lat2,lon1,lon2): ilat1 = (int)(0.50 + lat1 * 360000.0) ilat2 = (int)(0.50 + lat2 * 360000....
根据语言设置布局方向
正常的布局方向为LTR,但有些语言需要反向,比如阿语,是RTL的, 那么会在androidManifast.xml 中application 标签中增加 android:supportsRtl=&quot;true&quot; 来自动适配LTR和RTL 。但是这种适配是自动根据布局适配的,比如直接绘制的布局。这就需要根据语言绘制不同布局了。如下方法可以获取是import android.text.TextUtils...
数据窗口的打印方向?
因为数据窗口中的数据太长,需要纵向打印rn请问在数据窗口哪个属性可以控制纸张的打印方向,例如:纵向、横向,是pb70rn谢谢!
java运动不同方向类
实现不同不同方向运动的类,包括直线、椭圆、纵向、横向之类的
Flutter之支持不同的屏幕尺寸和方向
介绍 本文是medium的一篇文章的翻译,再加上自己的一点理解,已得到作者的同意。 主要讲的是在平板和手机中,处理适配不同屏幕的问题。 原文地址:medium.com/flutter-community/developing-for-multiple-screen-sizes-a nd-orientations-in-flutter-fragments-in-flutter-a4c51b84943...
c++打印不同方向的三角形
#include<iostream> #include<iomanip>using namespace std;int main() { //a图 for(int i=1;i<=10;i++) { for(int j=1;j<=i;j++) { cout<<"*"; } cout<<en
jquery不同方向来回运动
jquery不同随机方向来回运动rndivrnrnposition:absoluternrnrn ern wrn 2rnrnrn这个3个div 不同方向来回运动怎么写
.NET方向和Java方向相比
.NET方向和Java方向相比,那个更好?[color=#FF0000][/color]
图像的X方向和Y方向
 图像的坐标,如下图。图像是长*宽,长=列(column),宽=行(row)
安卓判断滑动方向onTouchEvent
public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initvie
相关热词 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池 c#5.0 安装程序 c# 分页算法 c# gmail 发邮件 c# 多层文件