def CreateLocationByProximityQuery(self): """Creates a query for locations within random miles from random center location. Returns a dictionary of search query parameters. """ self.CenterPoint = self.CreateRandomLattitudeLongitude() self.SearchDistanceMiles = random.uniform(self.minDistanceMiles, self.maxDistanceMiles) self.SearchDistanceMeters = GpMath.milesToMeters( self.SearchDistanceMiles) QueryParameterDic = {} QueryParameterDic['SearchType'] = 'LocationByProximity' QueryParameterDic['MaxResults'] = self.maxSearchResults QueryParameterDic['MaxDistanceMeters'] = self.SearchDistanceMeters QueryParameterDic['CenterPt'] = self.CenterPoint QueryParameterDic['HasShopsOnly'] = 'True' QueryParameterDic['FilterByTrueDistance'] = 'True' # Get a list of GpGridCells to search gpSearch = GpSearch() gpSearch.MaxSearchCellCount = self.MaxSearchCellCount centerGpPoint = GpPoint(self.CenterPoint[0], self.CenterPoint[1]) gpSearch.ComputeSearchListForMetersProximity(centerGpPoint, self.SearchDistanceMeters) self.FinalSearchResolution = gpSearch.FinalSearchResolution self.SearchGpGridCells = gpSearch.SearchCellList QueryParameterDic['SearchGridCells'] = self.SearchGpGridCells return QueryParameterDic
def CreateLocationByProximityQuery(self): """Creates a query for locations within random miles from random center location Returns a dictionary of search query parameters """ self.CenterPoint = self.randomGenerator.CreateRandomLattitudeLongitude() self.SearchDistanceMiles = self.randomGenerator.CreateRandomNumber(self.minDistanceMiles, self.maxDistanceMiles) self.SearchDistanceMeters = GeoConversion.ConvertMilesToMeters(self.SearchDistanceMiles) QueryParameterDic = {} QueryParameterDic["SearchType"] = "LocationByProximity" QueryParameterDic["MaxResults"] = self.maxSearchResults QueryParameterDic["MaxDistanceMeters"] = GeoConversion.ConvertMilesToMeters(self.SearchDistanceMiles) QueryParameterDic["CenterPt"] = self.CenterPoint QueryParameterDic["HasShopsOnly"] = "True" QueryParameterDic["FilterByTrueDistance"] = "True" # Get a list of GpGridCells to search gpSearch = GpSearch() gpSearch.MaxSearchCellCount = self.MaxSearchCellCount centerGpPoint = GpPoint(self.CenterPoint[0], self.CenterPoint[1]) gpSearch.ComputeSearchListForMetersProximity(centerGpPoint, self.SearchDistanceMeters) self.FinalSearchResolution = gpSearch.FinalSearchResolution self.SearchGpGridCells = gpSearch.SearchCellList QueryParameterDic["SearchGridCells"] = self.SearchGpGridCells return QueryParameterDic
def CreateLocationByProximityQuery(self): """Creates a query for locations within random miles from random center location. Returns a dictionary of search query parameters. """ self.CenterPoint = self.CreateRandomLattitudeLongitude() self.SearchDistanceMiles = random.uniform(self.minDistanceMiles,self.maxDistanceMiles) self.SearchDistanceMeters = GpMath.milesToMeters(self.SearchDistanceMiles) QueryParameterDic = {} QueryParameterDic['SearchType'] ='LocationByProximity' QueryParameterDic['MaxResults'] = self.maxSearchResults QueryParameterDic['MaxDistanceMeters'] = self.SearchDistanceMeters QueryParameterDic['CenterPt'] = self.CenterPoint QueryParameterDic['HasShopsOnly'] = 'True' QueryParameterDic['FilterByTrueDistance'] = 'True' # Get a list of GpGridCells to search gpSearch = GpSearch() gpSearch.MaxSearchCellCount = self.MaxSearchCellCount centerGpPoint = GpPoint(self.CenterPoint[0],self.CenterPoint[1]) gpSearch.ComputeSearchListForMetersProximity(centerGpPoint,self.SearchDistanceMeters) self.FinalSearchResolution = gpSearch.FinalSearchResolution self.SearchGpGridCells = gpSearch.SearchCellList QueryParameterDic['SearchGridCells'] = self.SearchGpGridCells return QueryParameterDic
def RunLocationByProximityQuery(self): """Runs a query for locations within random miles from random center location Returns a location Entity-Attribute dictionary """ self.CenterPoint = self.randomGenerator.CreateRandomLattitudeLongitude( ) self.SearchDistanceMiles = self.randomGenerator.CreateRandomNumber( self.minDistanceMiles, self.maxDistanceMiles) self.SearchDistanceMeters = GeoConversion.ConvertMilesToMeters( self.SearchDistanceMiles) QueryParameterDic = {} QueryParameterDic['SearchType'] = 'LocationByProximity' QueryParameterDic['MaxResults'] = self.maxSearchResults QueryParameterDic[ 'MaxDistanceMeters'] = GeoConversion.ConvertMilesToMeters( self.SearchDistanceMiles) QueryParameterDic['CenterPt'] = self.CenterPoint QueryParameterDic['HasShopsOnly'] = 'True' QueryParameterDic['FilterByTrueDistance'] = 'True' # Get a list of GpGridCells to search gpSearch = GpSearch() gpSearch.MaxSearchCellCount = self.MaxSearchCellCount centerGpPoint = GpPoint(self.CenterPoint[0], self.CenterPoint[1]) gpSearch.ComputeSearchListForMetersProximity(centerGpPoint, self.SearchDistanceMeters) self.FinalSearchResolution = gpSearch.FinalSearchResolution self.SearchGpGridCells = gpSearch.SearchCellList QueryParameterDic['SearchGridCells'] = self.SearchGpGridCells # Convert Query to JSON QueryJSON = DataConversion.dict_to_json(QueryParameterDic) print 'QueryJSON =' print QueryJSON resultsJSON = HttpInterface.get_data(self.HostAndPort, self.HttpPage, self.HttpAction, QueryJSON) if resultsJSON == "": # No entities found in search locationEntityAttributeDic = {} elif resultsJSON.startswith('Not found error'): locationEntityAttributeDic = {} else: results = DataConversion.json_to_dict(resultsJSON) locationClassEntityDic = results['c'] locationEntityAttributeDic = locationClassEntityDic['Location'] return locationEntityAttributeDic
def RunLocationByProximityQuery(self): """Runs a query for locations within random miles from random center location Returns a location Entity-Attribute dictionary """ self.CenterPoint = self.randomGenerator.CreateRandomLattitudeLongitude() self.SearchDistanceMiles = self.randomGenerator.CreateRandomNumber(self.minDistanceMiles,self.maxDistanceMiles) self.SearchDistanceMeters = GeoConversion.ConvertMilesToMeters(self.SearchDistanceMiles) QueryParameterDic = {} QueryParameterDic['SearchType'] ='LocationByProximity' QueryParameterDic['MaxResults'] = self.maxSearchResults QueryParameterDic['MaxDistanceMeters'] = GeoConversion.ConvertMilesToMeters(self.SearchDistanceMiles) QueryParameterDic['CenterPt'] = self.CenterPoint QueryParameterDic['HasShopsOnly'] = 'True' QueryParameterDic['FilterByTrueDistance'] = 'True' # Get a list of GpGridCells to search gpSearch = GpSearch() gpSearch.MaxSearchCellCount = self.MaxSearchCellCount centerGpPoint = GpPoint(self.CenterPoint[0],self.CenterPoint[1]) gpSearch.ComputeSearchListForMetersProximity(centerGpPoint,self.SearchDistanceMeters) self.FinalSearchResolution = gpSearch.FinalSearchResolution self.SearchGpGridCells = gpSearch.SearchCellList QueryParameterDic['SearchGridCells'] = self.SearchGpGridCells # Convert Query to JSON QueryJSON = DataConversion.dict_to_json(QueryParameterDic) print 'QueryJSON =' print QueryJSON resultsJSON = HttpInterface.get_data(self.HostAndPort,self.HttpPage,self.HttpAction,QueryJSON) if resultsJSON == "": # No entities found in search locationEntityAttributeDic = {} elif resultsJSON.startswith('Not found error'): locationEntityAttributeDic = {} else: results = DataConversion.json_to_dict(resultsJSON) locationClassEntityDic = results['c'] locationEntityAttributeDic = locationClassEntityDic['Location'] return locationEntityAttributeDic