本文整理汇总了Python中common.utilities.inversion_of_control.Dependency.get_away_stores_within_lat_long_range方法的典型用法代码示例。如果您正苦于以下问题:Python Dependency.get_away_stores_within_lat_long_range方法的具体用法?Python Dependency.get_away_stores_within_lat_long_range怎么用?Python Dependency.get_away_stores_within_lat_long_range使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common.utilities.inversion_of_control.Dependency
的用法示例。
在下文中一共展示了Dependency.get_away_stores_within_lat_long_range方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Store
# 需要导入模块: from common.utilities.inversion_of_control import Dependency [as 别名]
# 或者: from common.utilities.inversion_of_control.Dependency import get_away_stores_within_lat_long_range [as 别名]
#.........这里部分代码省略.........
# this is a business property representing the closed_date that we should associate with this object
@property
def closed_date(self):
if self._closed_date is not None:
return self._closed_date
elif self._assumed_closed_date is not None:
return self._assumed_closed_date
return None
##################################################### Factory Methods ###########################################################################
@classmethod
def simple_init_with_address(cls, store_id, company_id, longitude, latitude):
store = Store()
store.store_id = store_id
store.company_id = company_id
store.address = Address()
store.address.latitude = latitude
store.address.longitude = longitude
return store
@classmethod
def standard_init(cls, store_id, company_id, address_id, phone_number, store_format, company_generated_store_number, note, opened_date, closed_date, assumed_opened_date, assumed_closed_date):
# define properties
store = Store()
store.store_id = store_id
store.company_id = company_id
store.address_id = address_id
store.phone_number = phone_number
store.note = note
store.store_format = store_format
store.company_generated_store_number = company_generated_store_number
store._opened_date = opened_date
store._closed_date = closed_date
store._assumed_opened_date = assumed_opened_date
store._assumed_closed_date = assumed_closed_date
return store
@classmethod
def select_by_id(cls, store_id):
data_repository = Dependency("DataRepository", HasMethods("get_store_by_id")).value
return data_repository.get_store_by_id(store_id)
################################################## Object Model Methods ########################################################################
def select_trade_areas_of_competitive_companies_within_range(self):
"""
This returns all stores belonging to competitive_companies within 1 degree latitude/longitude in each way
"""
search_limits = GeographicalCoordinate(self.address.longitude, self.address.latitude, threshold=SignalDecimal(1)).get_search_limits()
return self.__data_repository.select_away_trade_areas_within_lat_long_range(self, search_limits["longitudes"], search_limits["latitudes"])
def select_stores_of_competitive_companies_within_range(self):
"""
This returns all stores belonging to competitive_companies within 1 degree latitude/longitude in each way
"""
return self.__select_competitive_company_stores(self.address.latitude, self.address.longitude)
def select_stores_of_competitive_companies_within_old_problem_range(self):
"""
This returns all stores belonging to competitive_companies within 1 degree latitude/longitude in each way of the old problematic address.
This should only be used for finding stores related to an old address (i.e. for cleaning them out)
"""
return self.__select_competitive_company_stores(self.problem_latitude, self.problem_longitude)
def select_trade_areas(self):
return self.__data_repository.select_trade_areas_by_store_id_require_shape(self.store_id)
def select_zips_within_range(self):
"""
This returns all zip codes whose centroid within 1 degree latitude/longitude in each way
"""
search_limits = GeographicalCoordinate(self.address.longitude, self.address.latitude, threshold=SignalDecimal(0.3)).get_search_limits()
return self.__data_repository.get_zips_within_lat_long_range(search_limits["latitudes"], search_limits["longitudes"])
##################################################### Private Methods ###########################################################################
def __select_problem_longitude_and_latitude(self):
long_lat = self.__data_repository.get_problem_long_lat(self)
self.__problem_longitude = SignalDecimal(long_lat.longitude)
self.__problem_latitude = SignalDecimal(long_lat.latitude)
def __select_competitive_company_stores(self, latitude, longitude):
"""
This returns all stores belonging to competitive_companies within 1 degree latitude/longitude in each way
"""
search_limits = GeographicalCoordinate(longitude, latitude, threshold=SignalDecimal(0.4)).get_search_limits()
return self.__data_repository.get_away_stores_within_lat_long_range(self, search_limits["latitudes"], search_limits["longitudes"])
def __eq__(self, other):
return self.store_id == other.store_id and self.company_id == other.company_id and self.address_id == other.address_id and self.phone_number == other.phone_number \
and self.note == other.note and self.store_format == other.store_format