Reverse Geocode can not be turned off

6 posts / 0 new
Last post
Reverse Geocode can not be turned off

I am using the Distance API for alltoall distance matrix.

The following is what I set.

        String body = "&json={options:{unit:k, allToAll:true, doReverseGeocode:false}, " + destination + "}";
        String reqUrl = REQUEST_PREFIX_MATRIX + "&key=" + APP_KEY + "&outFormat=xml";
        logger.debug("call mapquest service: " + reqUrl + body);

My question is why my plan is being charged for the transaction of Geocode?

Even though I already turned it off. Please support. 

A directions api request will
A directions api request will incur geocode transactions if the locations are strings rather than lat/lngs and reverse geocodes if doReverseGeocode is not set to false or incorrectly set. I can't tell from the code snippet above what the rest of the request looks like. Can you post a sample request rather than a snippet of code that creates the request?

Here is my code.

Here is my code.

It looks like part of the request does something with geocoderResultDocument.

Actually I just need the distance and the geocoder is unnecessary.

Would you plese guide me how to turn if off? Thank you for your support.


    public List<Integer> getDistanceMatrixOneToMany(Coordinate origin,
            List<Coordinate> destinations) throws IOException, SAXException,
            ParserConfigurationException, XPathExpressionException,
            DOMException, DistanceException {

        List<Integer> result = new ArrayList<Integer>();

        String destination = "locations:[" + "{latLng: { lat:" + origin.getLatitude() + ", lng:" + origin.getLongitude() + "}}, ";

        for(int i=0;i<destinations.size();i++) {
            destination += "{latLng: { lat:" + destinations.get(i).getLatitude() + ", lng:" + destinations.get(i).getLongitude() + "}}";
                destination += ",";
        destination += "]";

        String body = "&json={options:{unit:k, allToall:false, doReverseGeocode:false}, " + destination + "}";
        String reqUrl = REQUEST_PREFIX_MATRIX + "&key=" + APP_KEY + "&outFormat=xml";
        logger.debug("call mapquest service: " + reqUrl + body);

        // prepare a URL to the geocoder
        URL url = new URL(reqUrl);
        // prepare an HTTP connection to the geocoder
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        conn.setRequestProperty("Content-Length", ""+ body.length());
        DataOutputStream outStream = new DataOutputStream(conn.getOutputStream());
        Document geocoderResultDocument = null;

        try {
            // open the connection and get results as InputSource.
            InputSource geocoderResultInputSource = new InputSource(conn.getInputStream());

            // read result and parse into XML Document
            geocoderResultDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(geocoderResultInputSource);
        } catch (Exception e) {
        } finally {

        // prepare XPath
        XPath xpath = XPathFactory.newInstance().newXPath();

        // a) obtain the formatted_address field for every result
        Node status = (Node) xpath.evaluate("/response/info/statusCode", geocoderResultDocument, XPathConstants.NODE);
        if(status.getTextContent().equals(STATUS_OK) || status.getTextContent().equals("605") || status.getTextContent().equals("602")) {
            Node matrix = (Node) xpath.evaluate("/response/distance", geocoderResultDocument, XPathConstants.NODE);

                String distances = matrix.getTextContent() + ",";

                int next = distances.indexOf(",");
                int j=0;
                while(next >= 0) {
                    Double d = Double.parseDouble(distances.substring(0, next))*1000;
                    logger.debug(">> distance is zero ? " + (d==0.0) + " (" + d + ")");
                    if(d == 0.0 && j>0) {
                        // cross check with direction service.
                        Coordinate to = new Coordinate(destinations.get(j).getLatitude(), destinations.get(j).getLongitude());
                        d = new Double(new VectorDistanceProvider().getDistance(origin, to, null))*2;
                    distances = distances.substring(next+1);
                    next = distances.indexOf(",");
                } ;           
        else {
            Node message = (Node) xpath.evaluate("/response/info/messages", geocoderResultDocument, XPathConstants.NODE);
            throw new DistanceException(status.getTextContent() + ":" + message.getTextContent());

        return result;



The option setting looks
The option setting looks correct even though I can't see what the rest of the request looks like. I see you have 16 reverse geocodes in the past month that all happened in one day along wtih 16k directions requests (open + licensed). I wonder if you're still seeing the reverse geocodes.

Open geocoding is my problem.

Open geocoding is my problem.

It took me almost 25k transactions last month.


Are the locations being
Are the locations being geocoded before being used in the route? It looks like there are 2-3 times the number of geocodes as routes on a daily basis so that number seems reasonable.