def computeBiggestCoordinatesFromResults(self, resCandidates): ''' Given all the results, compute the biggest group and return a random coordinates inside ''' # results e.g. [ [5.0, [lat,lon], "tags"] ] newResCandidates = ResCandidates() coordList = [] for res in resCandidates.getList(): # get coordinates in string format: for [computeBiggestGroupOfCoordinates] strCoo = res.getCoordStr() coordList.append(strCoo) # coo = res.getCoord() # for [computeYaelKmeansOfCoordinates] # coordList.append( coo ) # Print input coordinates list if self.verbose: print >> sys.stderr, "" print >> sys.stderr, "computeBiggestCoordinatesFromResults] coordList:", coordList # Compute the biggest group centerCoo, sumOfD = self.computeBiggestGroupOfCoordinates(coordList) # centerCoo = self.computeYaelKmeansOfCoordinates( coordList ) # find the relative "result" with all the info if len(centerCoo) > 0: for res in resCandidates.getList(): coord = res.getCoord() if coord == centerCoo: newResCandidates.addObj(res) return newResCandidates # otherwise something went wrong newResCandidates.add(0.0, self.defaultCoordinates, "no results") return newResCandidates
def computeBiggestCoordinatesFromResults( self, resCandidates ): ''' Given all the results, compute the biggest group and return a random coordinates inside ''' # results e.g. [ [5.0, [lat,lon], "tags"] ] newResCandidates = ResCandidates() coordList = [] for res in resCandidates.getList(): # get coordinates in string format: for [computeBiggestGroupOfCoordinates] strCoo = res.getCoordStr() coordList.append( strCoo ) # coo = res.getCoord() # for [computeYaelKmeansOfCoordinates] # coordList.append( coo ) # Print input coordinates list if self.verbose: print >> sys.stderr, "" print >> sys.stderr, "computeBiggestCoordinatesFromResults] coordList:", coordList # Compute the biggest group centerCoo, sumOfD = self.computeBiggestGroupOfCoordinates( coordList ) # centerCoo = self.computeYaelKmeansOfCoordinates( coordList ) # find the relative "result" with all the info if len(centerCoo) > 0: for res in resCandidates.getList(): coord = res.getCoord() if coord == centerCoo: newResCandidates.addObj( res ) return newResCandidates # otherwise something went wrong newResCandidates.add( 0.0, self.defaultCoordinates, "no results" ) return newResCandidates