Пример #1
0
def get_country_local(
    lat,
    lon,
):
    cc = CountryChecker(
        '/home/martin/downloads/TM_WORLD_BORDERS-0.3/TM_WORLD_BORDERS-0.3.shp')
    country = cc.getCountry(Point(lat, lon)).iso
    return country
Пример #2
0
    for article in json_data:
        urls = article_urls_dictionary[article]
        if urls is None:
            print "article not found: " + article
        else:
            for url in urls:
                add_feature(url, "wikipedia-location", json_data[article])
count_not_found = 0
count_found = 0
if args.sparql_location is not None:
    print "merging sparql-location"
    used_features.append("sparql-location")
    with open(args.sparql_location) as json_input:
        json_data = json.load(json_input)

    country_checker = CountryChecker(args.world_borders)
    for url in url_features_dictionary:
        try:
            parsed_url = urlparse(url)
        except UnicodeEncodeError:
            print "UnicodeEncodeError for: " + url.encode("utf8")
            count_not_found += 1
            add_feature(url, "sparql-location", empty_feature_marker)
            continue
        stripped_url = '{uri.scheme}://{uri.netloc}/'.format(uri=parsed_url)
        if stripped_url in json_data:
            #country = country_lookup.get_country(json_data[stripped_url][0], json_data[stripped_url][1])
            country = country_checker.getCountry(
                Point(json_data[stripped_url][0], json_data[stripped_url][1]))
            if (country is None):
                count_not_found += 1
Пример #3
0
    for article in json_data:
        urls = article_urls_dictionary[article]
        if urls is None:
            print "article not found: " +  article
        else:
            for url in urls:
                add_feature(url, "wikipedia-location", json_data[article])
count_not_found = 0    
count_found = 0
if args.sparql_location is not None:
    print "merging sparql-location"
    used_features.append("sparql-location")
    with open(args.sparql_location) as json_input:    
        json_data = json.load(json_input)
    
    country_checker = CountryChecker(args.world_borders)
    for url in url_features_dictionary:
        try:
            parsed_url = urlparse(url)
        except UnicodeEncodeError:
            print "UnicodeEncodeError for: " + url.encode("utf8")
            count_not_found += 1
            add_feature(url, "sparql-location", empty_feature_marker)
            continue
        stripped_url = '{uri.scheme}://{uri.netloc}/'.format(uri=parsed_url)
        if stripped_url in json_data:
            #country = country_lookup.get_country(json_data[stripped_url][0], json_data[stripped_url][1])
            country = country_checker.getCountry(Point(json_data[stripped_url][0], json_data[stripped_url][1]))
            if (country is None):
                count_not_found += 1
                add_feature(url, "sparql-location", empty_feature_marker)
Пример #4
0
def get_country_local(lat, lon,):
    cc = CountryChecker('/home/martin/downloads/TM_WORLD_BORDERS-0.3/TM_WORLD_BORDERS-0.3.shp')
    country = cc.getCountry(Point(lat,lon)).iso
    return country