本文整理汇总了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
示例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
示例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
示例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