Пример #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";
Пример #2
0
def main(argv):
    inputfolder = ''
    outputfolder = ''
    eps = 0
    try:
        opts, args = getopt.getopt(argv,"hi:o:e:")
    except getopt.GetoptError:
        print 'test.py -i <inputfolder> -o <outputfolder>'
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print 'densityAlgo.py -i <inputfolder> -o <outputfolder> -e <epsilon>'
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfolder = arg
        elif opt in ("-o", "--ofile"):
            outputfolder = arg
        elif opt in("-e"):
            eps = 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")):
            newfolder = i.split(".")
            R = trajcomp.douglas_peucker_online(inputfolder+i,float(eps))
            # Do plots on result
            print R
            continue

        else:
            continue
Пример #3
0
def douglas_peucker(d, e):
	r = trajcomp.douglas_peucker_online(d,float(e));
	return r;