當前位置: 首頁>>代碼示例>>Python>>正文


Python Dependency.get_zips_within_lat_long_range方法代碼示例

本文整理匯總了Python中common.utilities.inversion_of_control.Dependency.get_zips_within_lat_long_range方法的典型用法代碼示例。如果您正苦於以下問題:Python Dependency.get_zips_within_lat_long_range方法的具體用法?Python Dependency.get_zips_within_lat_long_range怎麽用?Python Dependency.get_zips_within_lat_long_range使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common.utilities.inversion_of_control.Dependency的用法示例。


在下文中一共展示了Dependency.get_zips_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_zips_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
開發者ID:erezrubinstein,項目名稱:aa,代碼行數:104,代碼來源:store.py


注:本文中的common.utilities.inversion_of_control.Dependency.get_zips_within_lat_long_range方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。