Ejemplo n.º 1
0
 def _GetGridPointsWithinRadius(self):
     """ Create a dictionary of GpGridPoints within distanceMeters from a center point.
     
     Scan through the GridPoints in the bounding box region. Add all in-bound points to the dictionary.
     Associate a weight with each GridPoint that is inversely proportional to its distance from the
     center point.
     """
     radiusMeters = self.SearchBoundaryMeters
     self.gpGridPointsInBoundsDic = {}
     stepSize = MAXIMUM_RESOLUTION - self.MaxSearchResolution + 1
     for latInt in range(self.SWCornerGridPoint.LattitudeInt,self.NWCornerGridPoint.LattitudeInt + stepSize, \
                         stepSize):
         for lonInt in range (self.SWCornerGridPoint.LongitudeInt,self.SECornerGridPoint.LongitudeInt + stepSize, \
                              stepSize):
             gridPoint = GpGridPoint()
             gridPoint.InitFromIntLatLon(latInt,lonInt,self.MaxSearchResolution)
             gpPoint = GpPoint(gridPoint.LattitudeFloat,gridPoint.LongitudeFloat)
             distanceMeters = GpMath.distance(self.CenterGpPoint,gpPoint)
             if distanceMeters <= radiusMeters:
                 weight = self._WeightGridPointByDistance(distanceMeters)
                 self.gpGridPointsInBoundsDic[gridPoint.ToShortString()] = weight
Ejemplo n.º 2
0
    def _GetBoundingBoxCells(self):
        """ Get three GpGridPoint corners of a Bounding Box for distanceMeters from a center point.

        The corner points are set to the MaxSearchResolution
        """
        centerGpPoint = self.CenterGpPoint
        degreesOffset = GpMath.distanceMetersToDegrees(centerGpPoint, self.SearchBoundaryMeters)
        # Get bounding corner points
        swCornerF = GpPoint(centerGpPoint.lat - degreesOffset.lat, \
                           centerGpPoint.lon - degreesOffset.lon)
        self.SWCornerGridPoint = GpGridPoint()
        self.SWCornerGridPoint.InitFromGpPoint(swCornerF, self.MaxSearchResolution)

        nwCornerF = GpPoint(centerGpPoint.lat + degreesOffset.lat, \
                           centerGpPoint.lon - degreesOffset.lon)
        self.NWCornerGridPoint = GpGridPoint()
        self.NWCornerGridPoint.InitFromGpPoint(nwCornerF,self.MaxSearchResolution)

        seCornerF = GpPoint(centerGpPoint.lat - degreesOffset.lat, \
                           centerGpPoint.lon + degreesOffset.lon)
        self.SECornerGridPoint = GpGridPoint()
        self.SECornerGridPoint.InitFromGpPoint(seCornerF,self.MaxSearchResolution)
Ejemplo n.º 3
0
 def ComputeSearchListForMilesProximity(self,centerGpPoint, distanceMiles):
     distanceMeters = GpMath.milesToMeters(distanceMiles)
     self.ComputeSearchListForMetersProximity(centerGpPoint, distanceMeters)