Beispiel #1
0
def show_sample_trailhead(dataset_id):
    '''
    Show an example row of data
    '''
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No dataset Found", 404)

    features = get_sample_trailhead_features(dataset)

    keys = list(sorted(features[0]['properties'].keys()))
    args = dict(dataset=dataset, uploaded_features=features, uploaded_keys=keys)
    return render_template("dataset-07-show-sample-trailhead.html", **args)
Beispiel #2
0
def show_sample_trailhead(dataset_id):
    '''
    Show an example row of data
    '''
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No dataset Found", 404)

    features = get_sample_trailhead_features(dataset)

    keys = list(sorted(features[0]['properties'].keys()))
    args = dict(dataset=dataset,
                uploaded_features=features,
                uploaded_keys=keys)
    return render_template("dataset-07-show-sample-trailhead.html", **args)
Beispiel #3
0
def transformed_trailheads(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    # Download the original trailheads file
    uploaded_features = get_sample_trailhead_features(dataset)
    uploaded_keys = list(sorted(uploaded_features[0]['properties'].keys()))

    # Download the transformed trailheads file
    transformed_features = get_sample_transformed_trailhead_features(dataset)
    transformed_keys = list(sorted(transformed_features[0]['properties'].keys()))

    # Download the transformed trailheads messages file
    messages_path = '{0}/opentrails/trailheads-messages.json'.format(dataset.id)
    data = json.load(datastore.read(messages_path))

    try:
        messages = [(type, id, words) for (type, id, words) in data]
    except ValueError:
        # Old stored format.
        messages = [(type, None, words) for (type, words) in data]

    message_types = [message[0] for message in messages]

    vars = dict(
        dataset = dataset,
        messages = messages,
        uploaded_keys = uploaded_keys,
        uploaded_features = uploaded_features,
        transformed_features = transformed_features,
        transformed_keys = transformed_keys,
        transform_succeeded = bool('error' not in message_types)
        )

    return render_template('dataset-08-transformed-trailheads.html', **vars)
Beispiel #4
0
def transformed_trailheads(dataset_id):
    datastore = make_datastore(app.config['DATASTORE'])
    dataset = get_dataset(datastore, dataset_id)
    if not dataset:
        return make_response("No Dataset Found", 404)

    # Download the original trailheads file
    uploaded_features = get_sample_trailhead_features(dataset)
    uploaded_keys = list(sorted(uploaded_features[0]['properties'].keys()))

    # Download the transformed trailheads file
    transformed_features = get_sample_transformed_trailhead_features(dataset)
    transformed_keys = list(
        sorted(transformed_features[0]['properties'].keys()))

    # Download the transformed trailheads messages file
    messages_path = '{0}/opentrails/trailheads-messages.json'.format(
        dataset.id)
    data = json.load(datastore.read(messages_path))

    try:
        messages = [(type, id, words) for (type, id, words) in data]
    except ValueError:
        # Old stored format.
        messages = [(type, None, words) for (type, words) in data]

    message_types = [message[0] for message in messages]

    vars = dict(dataset=dataset,
                messages=messages,
                uploaded_keys=uploaded_keys,
                uploaded_features=uploaded_features,
                transformed_features=transformed_features,
                transformed_keys=transformed_keys,
                transform_succeeded=bool('error' not in message_types))

    return render_template('dataset-08-transformed-trailheads.html', **vars)