def updateShorelineWarnings(self, shoreline, candidatePoints, candidatePoints_index): """Finds the best and most accurate predicted water elevation measure within 1 km of a town's shoreline. It works as follow: For each candidate point, if there exist a point in shoreline such that the distance between the candidate point and that point is the shoreline is within 1000 meters, append the water eleveation of that candidae point to the list of water elevation near shoreline. Find the maximum value of the list and return. Parameters ---------- shoreline : list list of points correspoinding to the shoreline of a specific town. candidatePoints : list list of points which a specific town that is a potential water elevation near shoreline warning. candidatePoints_index: list list of integers that will be used to access the water elevation measurement of a certain point in candidatePoints. Returns ------- This function returns the maximum elevation in a list of potential water elevation near shoreline warnings. """ waterElevNearShoreline = [] for i in range(1, len(candidatePoints)): for j in shoreline: if gdist(candidatePoints[i], j).meters < 1000: waterElevNearShoreline.append( self.ETA[candidatePoints_index[i]]) break try: return max(waterElevNearShoreline) except ValueError: return
def findCandidatePoints(self, center, maxDist, candidatePoints, candidatePoints_index): """ Finds all the points that is within a specific range relative to a certain point. It measures all the distances of each the points in self.fort_14 and appended it to a list. if its less than or equal to a certain distance. Index of appeded points is also appended to another list. This function filters all the points that could be included in the generation of warnings and thus minimized the search area later on for determining if certain points are inside a polygon. Parameters ---------- center : 2-tuple the reference point in which to measure the distance to all the points in (self.X,self.Y) maxDist : float the maximum distance from a point in self.X,self.Y to center to be included in candidatePoints candidatePoints: list stores all the included points candidatePoints_index : list stores all the indexes of all the included points in candidatePoints Returns ------- (results are returned in candidatePoints and candidatePoints_index) """ for i in range(1, len(self.X)): if gdist( center, (self.X[i], self.Y[i])).meters < maxDist + self.radiusOffset: if (self.ETA[i]) != -99999: candidatePoints.append((self.X[i], self.Y[i])) candidatePoints_index.append(i)
def findCandidatePoints(self, center, maxDist, candidatePoints, candidatePoints_index): for i in range(1, len(self.X)): if gdist(center, (self.X[i], self.Y[i])).meters < maxDist: if (self.ETA[i]) != -99999: candidatePoints.append((self.X[i], self.Y[i])) candidatePoints_index.append(i)
def updateNotifications(self, center, candidatePoints, candidatePoints_index, barangay_name): #get the value of the nearest point disPoints = [gdist(center, i).meters for i in candidatePoints] cPI = candidatePoints_index[(disPoints).index(min(disPoints))] maxElev = self.ETA[cPI] distance = min(disPoints) direction = self.getDirection(center, (self.X[cPI], self.Y[cPI])) #print("no points detected inside the polygon, notification of ",self.ETA[cPI],self.ETA[cPI],min(disPoints),self.getDirection(center,(self.X[cPI],self.Y[cPI]))) self.notifications.append( (barangay_name, maxElev, distance, direction))
def findMaxDist(self, a, arr): """ Gets the distance of the farthest point from the center of a list of points. findMaxDist helps in optimizing the search process in determining the points that are inside a polygon. Parameters ---------- a : 2-tuple center of all the points in arr arr: list list of points Returns ------- float returns the distance of the farthest point included in arr relative to a """ return max([gdist(a, i).meters for i in arr])
def findMaxDist(self, a, arr): return max([gdist(a, i).meters for i in arr])