Ejemplo n.º 1
0
def update(provider, city, predict):
    # Get the information for the city
    try:
        stations = wrapper.collect(provider, city)
    except:
        return
    # Update the database
    if predict == 'Yes':
        timeseries.update_city(stations, city)
    # Save the data for the map
    geojson = tools.json_to_geojson(stations)
    with open('static/geojson/{0}.geojson'.format(city), 'w') as outfile:
        json.dump(geojson, outfile)
    # Tell the server the city's data was updated
    with open('static/updates/{0}.txt'.format(city), 'w') as outfile:
        outfile.write(datetime.now().isoformat())
Ejemplo n.º 2
0
def update(provider, city, predict):
    # Get the information for the city
    try:
        stations = wrapper.collect(provider, city)
    except:
        return
    # Update the database
    if predict == 'Yes':
        timeseries.update_city(stations, city)
    # Save the data for the map
    geojson = tools.json_to_geojson(stations)
    with open('static/geojson/{0}.geojson'.format(city), 'w') as outfile:
        json.dump(geojson, outfile)
    # Tell the server the city's data was updated
    with open('static/updates/{0}.txt'.format(city), 'w') as outfile:
        outfile.write(datetime.now().isoformat())
Ejemplo n.º 3
0
country = parameters.country
countryRealName = parameters.countryRealName
predict = parameters.predict

# Load the files
stationsFile = tools.read_json('static/stations.json')
providersFile = tools.read_json('static/providers.json')
centersFile = tools.read_json('static/centers.json')
citiesFile = tools.read_json('static/cities.json')
namesFile = tools.read_json('static/names.json')
predictionsFile = tools.read_json('static/predictions.json')

if option in ('add', 'insert'):
    geo.add_city(city)
    # Get the current information for a city
    stations = wrapper.collect(provider, city)
    # Add the altitudes of every station
    stations = geography.add_altitudes(stations)
    # Extract latitudes, longitudes and station names
    latitudes = []
    longitudes = []
    names = []
    for station in stations:
        latitudes.append(station['lat'])
        longitudes.append(station['lon'])
        names.append(station['name'])
        geo.add_station(city, station['name'],
                        station['lat'], station['lon'], station['alt'])
    # City/Stations file
    stationsFile[city] = names
    # Provider/City file
Ejemplo n.º 4
0
country = parameters.country
countryRealName = parameters.countryRealName
predict = parameters.predict

# Load the files
stationsFile = tools.read_json('static/stations.json')
providersFile = tools.read_json('static/providers.json')
centersFile = tools.read_json('static/centers.json')
citiesFile = tools.read_json('static/cities.json')
namesFile = tools.read_json('static/names.json')
predictionsFile = tools.read_json('static/predictions.json')

if option in ('add', 'insert'):
    geo.add_city(city)
    # Get the current information for a city
    stations = wrapper.collect(provider, city)
    # Add the altitudes of every station
    stations = geography.add_altitudes(stations)
    # Extract latitudes, longitudes and station names
    latitudes = []
    longitudes = []
    names = []
    for station in stations:
        latitudes.append(station['lat'])
        longitudes.append(station['lon'])
        names.append(station['name'])
        geo.add_station(city, station['name'], station['lat'], station['lon'],
                        station['alt'])
    # City/Stations file
    stationsFile[city] = names
    # Provider/City file