Giter Club home page Giter Club logo

Comments (5)

clach04 avatar clach04 commented on June 11, 2024 1

I was going to open a similar issue :-)

I've jotted some notes down below however progressing this is not a priority for me, I'm putting my time into adding support for reverse_geocoder/reverse_geocode (offline) - longer term (and possibly a research path that may be worth checkout out), checkout https://github.com/geopy/geopy it supports MapQuest and a lot of other providers. I've not used it so can't vouch for it other than a cursory read.

reverse_geocoder/reverse_geocode with my minimal testing is looking suitable, I need to crunch it through my photos to see if it actually is suitable for my use case 🤞

NOTES:

  • MapQuest base URL has changed
  • actual url has changed (no php)
  • arguments have changed
  • payload has changed and parse_result() has no idea

URL and api change

old sample

https://open.mapquestapi.com/nominatim/v1/reverse.php?format=json&key=KEY_GOES_HERE&lat=37.7719809722222&lon=-122.298968972222

new sample

http://www.mapquestapi.com/geocoding/v1/reverse?key=KEY_GOES_HERE&location=37.368,-122.03&includeRoadMetadata=true&includeNearestIntersection=true

Payload change

parse (etc.) are expecting a dict like (note mappings in comments):

{
    'address': {
        'default': u'California',
        'country': u'United States of America',  # MapQuest field: ["results"]["locations"][0]["adminArea1"]  "US"
        'state': u'California',  # MapQuest field: ["results"]["locations"][0]["adminArea3"]  "CA"
        'city': u'Sunnyvale'  # MapQuest field: ["results"]["locations"][0]["adminArea5"]  "Sunnyvale"
    }
}

Current mapquest payload looks more like:

{
  "info": {
    "statuscode": 0,
    "copyright": {
      "text": "© 2022 MapQuest, Inc.",
      "imageUrl": "http://api.mqcdn.com/res/mqlogo.gif",
      "imageAltText": "© 2022 MapQuest, Inc."
    },
    "messages": []
  },
  "options": {
    "maxResults": 1,
    "ignoreLatLngInput": false
  },
  "results": [
    {
      "providedLocation": {
        "latLng": {
          "lat": 37.368,
          "lng": -122.03
        }
      },
      "locations": [
        {
          "street": "312 Old San Francisco Rd",
          "adminArea6": "Heritage District",
          "adminArea6Type": "Neighborhood",
          "adminArea5": "Sunnyvale",
          "adminArea5Type": "City",
          "adminArea4": "Santa Clara",
          "adminArea4Type": "County",
          "adminArea3": "CA",
          "adminArea3Type": "State",
          "adminArea1": "US",
          "adminArea1Type": "Country",
          "postalCode": "94086",
          "geocodeQualityCode": "P1AAA",
          "geocodeQuality": "POINT",
          "dragPoint": false,
          "sideOfStreet": "R",
          "linkId": "0",
          "unknownInput": "",
          "type": "s",
          "latLng": {
            "lat": 37.36798,
            "lng": -122.03018
          },
          "displayLatLng": {
            "lat": 37.36785,
            "lng": -122.03021
          },
          "mapUrl": ""
        }
      ]
    }
  ]
}

from elodie.

jmathai avatar jmathai commented on June 11, 2024

payload has changed and parse_result() has no idea

🤣 That's the quick conclusion that I came to. I believe the fix should be isolated though.

from elodie.

jmathai avatar jmathai commented on June 11, 2024

Documenting some inconsistencies with the MapQuest API and how to detect errors.

  1. ['info']['statuscode'] != 0 means an error (docs).
  2. ['options']['maxResults'] == -1 means Not Found (I think). And the case is not consistent between statuscode and maxResults.
    • However, it does not mean that ['results'] or ['results']['locations'] have a length of 0.

Edit: I'm not sure what maxResults == -1 means but it DOES NOT mean Not Found. I also believe the following is true: the data itself has changed (i.e. lat/lon for Sunnyvale, CA is different now and CA is returned instead of California.

from elodie.

jmathai avatar jmathai commented on June 11, 2024

I created branch mapquest-fix to stage my work so far which can be tracked in gh-426.

from elodie.

jmathai avatar jmathai commented on June 11, 2024

Took a break and came back with a much simpler change to get it working. @clach04 thanks for the comment - it got me thinking differently about the fix.

from elodie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.