예제 #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
    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)
            else:
                count_found += 1
                add_feature(url, "sparql-location", country.iso)
        else:
            print "url not in dictionary: " + stripped_url

print "countries not found: " + str(count_not_found)
print "countries found: " + str(count_found)

# generate header string
header_string = "url" + csv_delimiter
예제 #3
0
    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)
            else:
                count_found += 1
                add_feature(url, "sparql-location", country.iso)
        else:
            print "url not in dictionary: " + stripped_url

print "countries not found: "+ str(count_not_found)
print "countries found: "+ str(count_found)



# generate header string
예제 #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