当前位置: 首页>>代码示例>>Python>>正文


Python Candidate.score方法代码示例

本文整理汇总了Python中omgeo.places.Candidate.score方法的典型用法代码示例。如果您正苦于以下问题:Python Candidate.score方法的具体用法?Python Candidate.score怎么用?Python Candidate.score使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在omgeo.places.Candidate的用法示例。


在下文中一共展示了Candidate.score方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _geocode

# 需要导入模块: from omgeo.places import Candidate [as 别名]
# 或者: from omgeo.places.Candidate import score [as 别名]
    def _geocode(self, location):
        query = {
            'SingleLine':location.query,
            'Address':location.address,
            'City':location.city,
            'State':location.state,
            'Zip':location.postal,
            'Country':location.country,
            'outfields':'Loc_name,Addr_Type,Zip4_Type',
            'f':'json'}

        query = self.append_token_if_needed(query)
        response_obj = self._get_json_obj(self._endpoint, query)

        try:
            wkid = response_obj['spatialReference']['wkid']
        except KeyError:
            pass

        returned_candidates = []  # this will be the list returned
        try:
            for rc in response_obj['candidates']:
                c = Candidate()
                c.locator = rc['attributes']['Loc_name']
                c.score = rc['score']
                c.match_addr = rc['address']
                c.x = rc['location']['x']
                c.y = rc['location']['y']
                c.wkid = wkid
                c.geoservice = self.__class__.__name__
                returned_candidates.append(c)
        except KeyError:
            pass
        return returned_candidates
开发者ID:lliss,项目名称:python-omgeo,代码行数:36,代码来源:__init__.py

示例2: _geocode

# 需要导入模块: from omgeo.places import Candidate [as 别名]
# 或者: from omgeo.places.Candidate import score [as 别名]
    def _geocode(self, location):
        query = {
            'Address':location.address,
            'City':location.city,
            'Postcode':location.postal,
            'Country':location.country,
            'outfields':'Loc_name',
            'f':'json'}

        query = self.append_token_if_needed(query)

        response_obj = self._get_json_obj(self._endpoint, query)
        if response_obj is False: return []
        
        returned_candidates = [] # this will be the list returned
        try:
            for rc in response_obj['candidates']: 
                c = Candidate()
                c.locator = rc['attributes']['Loc_name']
                c.score = rc['score']
                c.match_addr = rc['address']
                c.x = rc['location']['x']
                c.y = rc['location']['y']
                c.wkid = self._wkid
                c.geoservice = self.__class__.__name__
                returned_candidates.append(c)
        except KeyError as ex:
            print "I'm not what you expected, but hey, I'm still JSON! %s" % ex #TODO: put on error stack
            return []
        return returned_candidates
开发者ID:jwalgran,项目名称:python-omgeo,代码行数:32,代码来源:__init__.py

示例3: _create_candidate_from_intersection_element

# 需要导入模块: from omgeo.places import Candidate [as 别名]
# 或者: from omgeo.places.Candidate import score [as 别名]
 def _create_candidate_from_intersection_element(intersection_element, source_operation):
     c = Candidate()
     c.locator = source_operation
     c.match_addr = _get_text_from_nodelist(
         intersection_element.getElementsByTagName("FULLINTERSECTION")[0].childNodes) + ", WASHINGTON, DC"
     c.y = float(_get_text_from_nodelist(intersection_element.getElementsByTagName("LATITUDE")[0].childNodes))
     c.x = float(_get_text_from_nodelist(intersection_element.getElementsByTagName("LONGITUDE")[0].childNodes))
     confidence_level_elements = intersection_element.getElementsByTagName("ConfidenceLevel")
     c.score = float(_get_text_from_nodelist(confidence_level_elements[0].childNodes))
     c.geoservice = self.__class__.__name__
     return c
开发者ID:netconstructor,项目名称:python-omgeo,代码行数:13,代码来源:__init__.py

示例4: _create_candidate_from_address_element

# 需要导入模块: from omgeo.places import Candidate [as 别名]
# 或者: from omgeo.places.Candidate import score [as 别名]
 def _create_candidate_from_address_element(match, source_operation):
     if match.getElementsByTagName("FULLADDRESS").length > 0:
         full_address = _get_text_from_nodelist(match.getElementsByTagName("FULLADDRESS")[0].childNodes)
     else:
         full_address = _get_text_from_nodelist(
             match.getElementsByTagName("STNAME")[0].childNodes) + " " + _get_text_from_nodelist(match.getElementsByTagName("STREET_TYPE")[0].childNodes)
     city = _get_text_from_nodelist(match.getElementsByTagName("CITY")[0].childNodes)
     state = _get_text_from_nodelist(match.getElementsByTagName("STATE")[0].childNodes)
     zipcode = _get_text_from_nodelist(match.getElementsByTagName("ZIPCODE")[0].childNodes)
     c = Candidate()
     c.match_addr = full_address + ", " + city + ", " + state + ", " + zipcode
     confidence_level_elements = match.getElementsByTagName("ConfidenceLevel")
     c.score = float(_get_text_from_nodelist(confidence_level_elements[0].childNodes))
     c.y = float(_get_text_from_nodelist(match.getElementsByTagName("LATITUDE")[0].childNodes))
     c.x = float(_get_text_from_nodelist(match.getElementsByTagName("LONGITUDE")[0].childNodes))
     c.locator = source_operation
     c.geoservice = self.__class__.__name__
     return c
开发者ID:netconstructor,项目名称:python-omgeo,代码行数:20,代码来源:__init__.py


注:本文中的omgeo.places.Candidate.score方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。