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

422 Error When Using External Geocoder and Mapbox GL JS #496

Open
mcollins-GPI opened this issue Apr 7, 2023 · 0 comments
Open

422 Error When Using External Geocoder and Mapbox GL JS #496

mcollins-GPI opened this issue Apr 7, 2023 · 0 comments

Comments

@mcollins-GPI
Copy link

  1. I am using an external geocoder with the Mapbox geocoder widget.
  2. The results return and are concatenated to the standard geocoder results correctly.
  3. When clicking on a result in the geocoder tool menu, it navigates correctly to the point identified in the list.
  4. It also throws a 422 error, and I am not sure why.

This is the code where I implement it:

externalGeocoder: async (queryString) => {
    const filters = {
        geom_column: 'geom',
        filter: `cast(busstopid as text) like '${queryString}%' or address like upper('${queryString}%')`,
        precision: 9,
        columns: 'address as place_name, address as text, busstopid',
        id_column: 'internal_id',
        limit: 5,
    };
    // get data from both the GTFS feed and MIIPS if possible
    const generalData = await utilities.getData(`${URL.base}/v1/geojson/gtfs_data?`, filters);
    const miipsData = await utilities.getData(
        `${URL.base}/mama/miips/read_serial_number_geocoder/${queryString}`
    );

    if (miipsData.features) {
        return generalData.features.concat(miipsData.features);
    } else {
        return generalData.features;
    }
}

This is the object the external geocoder is creating:

{
    "type": "FeatureCollection",
    "features": [
        {
            "id": 13419,
            "type": "Feature",
            "center": [
                -73.94012,
                40.765427
            ],
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -73.94012,
                    40.765427
                ]
            },
            "place_name": "34 AV/VERNON BL",
            "properties": {
                "text": "34 AV/VERNON BL",
                "busstopid": 552207,
                "place_name": "34 AV/VERNON BL"
            }
        },
        {
            "id": 14304,
            "type": "Feature",
            "center": [
                -74.107189,
                40.671472
            ],
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -74.107189,
                    40.671472
                ]
            },
            "place_name": "34 ST/HOBOKEN LIGHT RAIL STATION",
            "properties": {
                "text": "34 ST/HOBOKEN LIGHT RAIL STATION",
                "busstopid": 805054,
                "place_name": "34 ST/HOBOKEN LIGHT RAIL STATION"
            }
        },
        {
            "id": 14305,
            "type": "Feature",
            "center": [
                -74.10723,
                40.671416
            ],
            "geometry": {
                "type": "Point",
                "coordinates": [
                    -74.10723,
                    40.671416
                ]
            },
            "place_name": "34 ST/HOBOKEN LIGHT RAIL STATION",
            "properties": {
                "text": "34 ST/HOBOKEN LIGHT RAIL STATION",
                "busstopid": 805056,
                "place_name": "34 ST/HOBOKEN LIGHT RAIL STATION"
            }
        }
    ]
}

I looked into the repo and tried to discern from the error and payload what I was doing wrong. The results seem to work correctly, but it also seems like it is trying to use the external result with the standard geocoder somehow, which seems wrong. I am not sure how to drill down into this further to better diagnose the behavior, but any help would be most appreciated.

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

No branches or pull requests

1 participant