Esempio 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";
Esempio n. 2
0
def printfig(name,traj):
	C=trajcomp.get(traj);
	X = map(itemgetter(0), C) ;
	Y = map(itemgetter(1), C);
	plt.clf();
	fig, ax1 = plt.subplots()
	ax1.plot(X, Y, '-o')
	ax1.set_xlabel('X')
	ax1.set_ylabel('Y')
	#plt.show()
	plt.savefig(name)
Esempio n. 3
0
from operator import itemgetter 
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle


A=trajcomp.load("../../data/prague1.dat");
print "Reference is " + str(A)

# list of lists is suboptimal, but does not depend on numpy
for i in range(1,150):
  epsilon = i/10.0;
  epsilon = epsilon * epsilon;
  print epsilon;
  B = trajcomp.douglas_peucker(A,epsilon);
  trajcomp.summary(B);
  C =trajcomp.get(B)
  
  X = map(itemgetter(0), C) ;
  Y = map(itemgetter(1),C);
  plt.clf();
  fig, ax1 = plt.subplots()
  ax1.plot(X, Y, '-o')
  ax1.set_xlabel('X')
  ax1.set_ylabel('Y')
  
  ax2 = ax1.twinx()
  plt.ylim(ymax=(15*15),ymin=0);
  space=abs(max(X)-min(X))/20;
  
  ax2.bar(max(X)+2*space,epsilon,width=space);
  
Esempio n. 4
0
import trajcomp;
from operator import itemgetter 
import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle

print ("Loading first set of GeoLife Dataset");
A=trajcomp.geolife(15,"/home/martin/datasets/geolife/")
handles = range(A,trajcomp.size());
print "Found " + str(trajcomp.size())
xlimit = [39.689602,40.122410]
ylimit = [116.105789,116.670021]


# list of lists is suboptimal, but does not depend on numpy
for i in handles:
  A=trajcomp.get(i);
  trajcomp.summary(i);
  X = map(itemgetter(0), A) ;
  Y = map(itemgetter(1),A);
  #plt.clf()
  plt.plot(X, Y, '-')
 # Grossraum
#  plt.xlim([39.75,40.05]);
#  plt.ylim([116.116,116.667]);
  plt.xlim(xlimit);
  plt.ylim(ylimit)
  #plt.show()
  plt.savefig(("frame-%04d.png" % i), bbox_inches='tight')