Mobile GMaps Home Page
 FAQFAQ    SearchSearch    MemberlistMemberlist    UsergroupsUsergroups   RegisterRegister  
 ProfileProfile    Log in to check your private messagesLog in to check your private messages    Log inLog in 

[proposal] range for uploading data of GPS positions

 
Post new topic   Reply to topic   printer-friendly view    MGMaps Forum Index -> Developer Forum
View previous topic :: View next topic  
Author Message
m1k0
Junior


Joined: 03 Jul 2008
Posts: 7

Phone Type: Unknown

PostPosted: Sat Apr 04, 2009 7:01 pm    Post subject: [proposal] range for uploading data of GPS positions Reply with quote

Hi,
I wrote some code where we can set range (time, distance) for upliading GPS data

In GPSSynchronizer.java:175
Code:
      // + second filter
      if (fixTime > lastFixTime && com.m1k0.mgmaps.Util.isAllowedUpload(fixTime, point)) {


Code:
package com.m1k0.mgmaps;

import com.mgmaps.components.GPoint;
import com.mgmaps.log.Logger;

/**
 *
 * @author m1k0
 */
public class Util {

    /** Time  in sec. - Unix Time */
    private static int lastTimeUpload = 0;
    private static int rangeTimeMin = 30;
    private static int rangeTimeMax = 3600;
    private static GPoint lastGPoint = null;
    /** Distance in milimeters! */
    private static long rangeDistanceMin = 500;

    public static boolean isAllowedUpload(int currentFixTime, GPoint currentGPoint) {
        Logger.debug("isAllowedUpload("+ currentFixTime+","+currentGPoint+")");
        boolean ret = false;

        if (lastTimeUpload == 0 || lastGPoint == null) {
            ret = true;
        } else {
            int deltaTime = currentFixTime - lastTimeUpload;
            Logger.debug("isAllowedUpload() deltaTime:"+deltaTime);
            if (deltaTime > rangeTimeMax) {
                ret = true;
            } else if (deltaTime > rangeTimeMin) {
                // check movenents
                long move = GPoint.meterDistance(lastGPoint, currentGPoint);
                Logger.debug("isAllowedUpload() move:"+move);
                if (move >= rangeDistanceMin){
                    ret = true;
                }
            }
        }

        if (ret == true) {
            lastTimeUpload = currentFixTime;
            lastGPoint = currentGPoint;
        }
        Logger.debug("isAllowedUpload("+ currentFixTime+","+currentGPoint+"):"+ret);
        return ret;
    }
}

Plain class com.m1k0.mgmaps.Util in attachment



Util.java
 Description:
com.m1k0.mgmaps.Util

Download
 Filename:  Util.java
 Filesize:  1.58 KB
 Downloaded:  477 Time(s)

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MGMaps Forum Index -> Developer Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
MGMaps topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group