Exemple #1
0
def show_sample_segment(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_segment_features(dataset)

    keys = list(sorted(features[0]['properties'].keys()))
    args = dict(dataset=dataset, uploaded_features=features, uploaded_keys=keys)
    return render_template("dataset-02-show-sample-segment.html", **args)
Exemple #2
0
def show_sample_segment(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_segment_features(dataset)

    keys = list(sorted(features[0]['properties'].keys()))
    args = dict(dataset=dataset,
                uploaded_features=features,
                uploaded_keys=keys)
    return render_template("dataset-02-show-sample-segment.html", **args)
Exemple #3
0
def transformed_segments(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 segments file
    uploaded_features = get_sample_segment_features(dataset)
    uploaded_keys = list(sorted(uploaded_features[0]['properties'].keys()))

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

    # Download the transformed segments messages file
    transformed_segments_messages = dataset.id + '/opentrails/segments-messages.json'
    data = json.load(datastore.read(transformed_segments_messages))

    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-03-transformed-segments.html', **vars)
Exemple #4
0
def transformed_segments(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 segments file
    uploaded_features = get_sample_segment_features(dataset)
    uploaded_keys = list(sorted(uploaded_features[0]['properties'].keys()))

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

    # Download the transformed segments messages file
    transformed_segments_messages = dataset.id + '/opentrails/segments-messages.json'
    data = json.load(datastore.read(transformed_segments_messages))

    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-03-transformed-segments.html', **vars)