Ejemplo n.º 1
0
    def handle(self):
        # self.rfile is a file-like object created by the handler;
        # we can now use e.g. readline() instead of raw recv() calls
        self.data="";
        while(self.data != "QUIT"):
			self.data = self.rfile.readline().strip()
			C=self.data.split();
			if C[0] == "GET":
				T = trajcomp.get(int(C[1]))
				self.wfile.write(json.dumps(T)+"\n")
			if C[0] == "SUBSETCORR":
				answer = top_k_subset_correlation(C[1:]);
				self.wfile.write(json.dumps(answer)+"\n");
			if C[0] == "JACCARD":
				answer = top_k_jaccard(C[1:]);
				self.wfile.write(json.dumps(answer)+"\n");
			if C[0] == "JACCARDID":
				answer = top_k_jaccard_id(int(C[1]));
				self.wfile.write(json.dumps(answer)+"\n");
			if C[0] == "INTERSECT":
				#print C[1:];
				answer = top_k_intersect(C[1:]);
				self.wfile.write(json.dumps(answer)+"\n");
			if C[0] == "DBSCAN":
				print C[1:];
				answer = dbscan_segmentation(C[1], C[2], C[3]);
				self.wfile.write(json.dumps(answer)+"\n");
			if C[0] == "DOUGLAS":
				print "Backendserver";
				print C[1:];
				T = trajcomp.douglas_peucker_online(C[1],float(C[2]));
				print "Result DP";
				print T;
				self.wfile.write(json.dumps(T)+"\n");
			if C[0] == "RESAMPLE":
				print "Resample backend";
				print C[1:];
				answer = resample_traj(C[1], int(C[2]));
				self.wfile.write(json.dumps(answer)+"\n");
			if C[0] == "THRESHOLD":
				print "Threshold backend";
				print C[1:];
				T = trajcomp.threshold(float(C[1]), float(C[2]), "../TestTraj.csv", "../TestTrajTimes.csv");
				self.wfile.write(json.dumps(T)+"\n");
			if C[0] == "PERSISTENCE":
				print "Peristence backend";
				print C[1:];
				T = trajcomp.persistence(float(C[1]), "../TestTraj.csv", "../TestTrajTimes.csv");
				self.wfile.write(json.dumps(T)+"\n");
			if C[0] == "GETGID":
				print "GETID backend";
				print C[1:];
				T = getID(C[1]);
				self.wfile.write(json.dumps(T)+"\n");

			if self.data=="HELO":
				self.wfile.write("HELO too\n");
			if self.data=="KILL":
				self.server.shutdown();
				self.data="QUIT";
Ejemplo n.º 2
0
def main(argv):
    inputfolder = ''
    outputfolder = ''
    orientationThresh = 0
    velocityThresh = 0
    try:
        opts, args = getopt.getopt(argv,"hi:o:t:v:")
    except getopt.GetoptError:
        print 'test.py -i <inputfolder> -o <outputfolder> -t <orientation Threshold> -v <velocity Threshold>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'densityAlgo.py -i <inputfolder> -o <outputfolder> -t <orientation Threshold> -v <velocity Threshold>'
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfolder = arg
        elif opt in ("-o", "--ofile"):
            outputfolder = arg
        elif opt in("-t"):
            eps = arg
        elif opt in("-v"):
            minPts = arg

    if not os.path.exists(inputfolder):
        print "inputfolder does not exist"
        return;

    print 'Input folder is "', inputfolder
    print 'Output folder is "', outputfolder
    if not os.path.exists(outputfolder):
        os.makedirs(outputfolder)

    for i in os.listdir(inputfolder):
        if(i.endswith(".csv")):
            print i
            newfolder = i.split(".")
            R = trajcomp.threshold(float(velocityThresh), float(orientationThresh),inputfolder+i,
            inputfolder+"times/"+i)
            # Do plots on result
            print R
            continue

        else:
            continue