Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeoJSON Serializer / Pagination #822

Merged
merged 27 commits into from
Nov 9, 2016
Merged

GeoJSON Serializer / Pagination #822

merged 27 commits into from
Nov 9, 2016

Conversation

irees
Copy link
Member

@irees irees commented Oct 13, 2016

Create a GeoJSONSerializer to use in paginated responses; it creates the correct response, with the regular serializer in 'properties'

This would remove the separate and manual attribute mapping present in each controller.

Resolves #616

@irees
Copy link
Member Author

irees commented Oct 18, 2016

Current GeoJSON:

{
    "type": "FeatureCollection",
    "features": [{
        "type": "Feature",
        "geometry": {
            "type": "Point",
            "coordinates": [-121.945154, 38.018914]
        },
        "properties": {
            "created_at": "2016-02-06T20:08:39.818Z",
            "updated_at": "2016-09-20T21:49:25.210Z",
            "onestop_id": "s-9q9-test",
            "tags": {
                "zone_id": "PITT",
                "stop_url": "http://www.bart.gov/stations/PITT/",
                "osm_way_id": "47228512",
                "wheelchair_boarding": "1"
            },
            "name": "Pittsburg/Bay Point",
            "identifiers": ["gtfs://f-9q9-bart/s/PITT"],
            "title": "Pittsburg/Bay Point",
            "timezone": "America/Los_Angeles",
            "operators_serving_stop": ["o-9q9-bart"],
            "routes_serving_stop": ["r-9q9-pittsburg~baypoint~sfia~millbrae"]
        },
        "id": "s-9q9-test"
    }]
}

Proposed GeoJSON, per_page=1

{
    "features": [{
        "geometry": {
            "type": "Point",
            "coordinates": [-121.945154, 38.018914]
        },
        "properties": {
            "identifiers": ["gtfs://f-9q9-bart/s/PITT"],
            "imported_from_feed_onestop_ids": ["f-9q9-bart"],
            "imported_from_feed_version_sha1s": ["dd7aca4a8e4c90908fd3603c097fabee75fea907", "a0a0e854e04362c0791629b91c93375f6471a2ea"],
            "created_or_updated_in_changeset_id": 924,
            "onestop_id": "s-9q9-test",
            "name": "Pittsburg/Bay Point",
            "tags": {
                "zone_id": "PITT",
                "stop_url": "http://www.bart.gov/stations/PITT/",
                "osm_way_id": "47228512",
                "wheelchair_boarding": "1"
            },
            "timezone": "America/Los_Angeles",
            "osm_way_id": 47228512,
            "served_by_vehicle_types": ["metro"],
            "wheelchair_boarding": true,
            "created_at": "2016-02-06T20:08:39.818Z",
            "updated_at": "2016-09-20T21:49:25.210Z",
            "operators_serving_stop": [{
                "operator_name": "Bay Area Rapid Transit",
                "operator_onestop_id": "o-9q9-bart"
            }],
            "routes_serving_stop": [{
                "operator_name": "Bay Area Rapid Transit",
                "operator_onestop_id": "o-9q9-bart",
                "route_name": "Pittsburg/Bay Point - SFIA/Millbrae",
                "route_onestop_id": "r-9q9-pittsburg~baypoint~sfia~millbrae"
            }]
        },
        "type": "Feature"
    }],
    "meta": {
        "sort_key": "id",
        "sort_order": "asc",
        "offset": 0,
        "per_page": 1,
        "next": "http://localhost:3000/api/v1/stops?offset=1&per_page=1&sort_key=id&sort_order=asc"
    }
}

Note: The top level type: "FeatureCollection" is still missing; working on getting it in the response now.

@irees
Copy link
Member Author

irees commented Oct 26, 2016

TODO: Before merging, make list of any properties that are removed or changed.

@irees irees mentioned this pull request Nov 2, 2016
8 tasks
GEOJSON_ENTITY_PROPERTIES = Proc.new { |properties, entity|
# properties for GeoJSON simple style spec
properties[:title] = "Route stop pattern #{entity.onestop_id}"
properties[:stroke] = "##{entity.route.color}" if entity.route.color.present?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

route stroke color

GEOJSON_ENTITY_PROPERTIES = Proc.new { |properties, entity|
# properties for GeoJSON simple style spec
properties[:title] = entity.name
properties[:stroke] = "##{entity.color}" if entity.color.present?
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rsp stroke color

@irees irees merged commit 23953c6 into master Nov 9, 2016
@irees irees deleted the geojson-serializer branch November 9, 2016 23:02
@irees irees removed the in progress label Nov 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant