QGeoSearchReply* QGeoSearchManagerEngineNokia::reverseGeocode(const QGeoCoordinate &coordinate, QGeoBoundingArea *bounds) { if (!supportsReverseGeocoding()) { QGeoSearchReply *reply = new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError, "Reverse geocoding is not supported by this service provider.", this); emit error(reply, reply->error(), reply->errorString()); return reply; } QString requestString = "http://"; requestString += m_host; requestString += "/geocoder/rgc/2.0?referer=" + m_referer; if (!m_token.isNull()) requestString += "&token=" + m_token; if (!m_applicationId.isEmpty()) { requestString += "&app_id="; requestString += m_applicationId; } requestString += "&long="; requestString += trimDouble(coordinate.longitude()); requestString += "&lat="; requestString += trimDouble(coordinate.latitude()); requestString += "&lg="; requestString += languageToMarc(locale().language()); return search(requestString, bounds); }
QGeoSearchReply* QGeoSearchManagerEngineNokia::geocode(const QGeoAddress &address, QGeoBoundingArea *bounds) { if (!supportsGeocoding()) { QGeoSearchReply *reply = new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError, "Geocoding is not supported by this service provider.", this); emit error(reply, reply->error(), reply->errorString()); return reply; } QString requestString = "http://"; requestString += m_host; requestString += "/geocoder/gc/2.0?referer=" + m_referer; if (!m_token.isNull()) requestString += "&token=" + m_token; if (!m_applicationId.isEmpty()) { requestString += "&app_id="; requestString += m_applicationId; } requestString += "&lg="; requestString += languageToMarc(locale().language()); requestString += "&country="; requestString += address.country(); if (!address.state().isEmpty()) { requestString += "&state="; requestString += address.state(); } if (!address.city().isEmpty()) { requestString += "&city="; requestString += address.city(); } if (!address.postcode().isEmpty()) { requestString += "&zip="; requestString += address.postcode(); } if (!address.street().isEmpty()) { requestString += "&street="; requestString += address.street(); } // TODO? // street number has been removed from QGeoAddress // do we need to try to split it out from QGeoAddress::street // in order to geocode properly // Old code: // if (!address.streetNumber().isEmpty()) { // requestString += "&number="; // requestString += address.streetNumber(); // } return search(requestString, bounds); }
QGeoSearchReply* QGeoSearchManagerEngineCm::geocode(const QGeoAddress &address, QGeoBoundingArea *bounds) { if (!supportsGeocoding()) { QGeoSearchReply *reply = new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError, "Geocoding is not supported by this service provider.", this); emit error(reply, reply->error(), reply->errorString()); return reply; } QString searchString; if(!address.street().isEmpty()) { searchString += address.street(); searchString += ","; } if(!address.city().isEmpty()) { searchString += address.city(); searchString += ","; } if(!address.postcode().isEmpty()) { searchString += address.postcode(); searchString += ","; } if(!address.district().isEmpty()) { searchString += address.district(); searchString += ","; } if(!address.county().isEmpty()) { searchString += address.county(); searchString += ","; } if(!address.state().isEmpty()) { searchString += address.state(); searchString += ","; } if(!address.country().isEmpty()) { searchString += address.country(); searchString += ","; } if(!address.countryCode().isEmpty()) { searchString += address.countryCode(); searchString += ","; } // Note: this code is not called? DBG_CM(SEARCH_M, INFO_L, "Warning - geocode() method is called\n"); QString cmSearchUrl = "http://" + m_host + "/" + m_token +"/geocoding/v2/find.js?query="; cmSearchUrl += searchString; // return location information like road, city, county, country, postcode in returned results: cmSearchUrl += "&return_location=true"; return search(cmSearchUrl, QGeoSearchManager::SearchGeocode, -1, 0,bounds); }
QGeoSearchReply* QGeoSearchManagerEngineNokia::search(const QString &searchString, QGeoSearchManager::SearchTypes searchTypes, int limit, int offset, QGeoBoundingArea *bounds) { // NOTE this will eventually replaced by a much improved implementation // which will make use of the additionLandmarkManagers() if ((searchTypes != QGeoSearchManager::SearchTypes(QGeoSearchManager::SearchAll)) && ((searchTypes & supportedSearchTypes()) != searchTypes)) { QGeoSearchReply *reply = new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError, "The selected search type is not supported by this service provider.", this); emit error(reply, reply->error(), reply->errorString()); return reply; } QString requestString = "http://"; requestString += m_host; requestString += "/geocoder/gc/2.0?referer=" + m_referer; if (!m_token.isNull()) requestString += "&token=" + m_token; if (!m_applicationId.isEmpty()) { requestString += "&app_id="; requestString += m_applicationId; } requestString += "&lg="; requestString += languageToMarc(locale().language()); requestString += "&obloc="; requestString += searchString; if (limit > 0) { requestString += "&total="; requestString += QString::number(limit); } if (offset > 0) { requestString += "&offset="; requestString += QString::number(offset); } return search(requestString, bounds, limit, offset); }
QGeoSearchReply* QGeoSearchManagerEngineCm::reverseGeocode(const QGeoCoordinate &coordinate, QGeoBoundingArea *bounds) { if (!supportsReverseGeocoding()) { QGeoSearchReply *reply = new QGeoSearchReply(QGeoSearchReply::UnsupportedOptionError, "Reverse geocoding is not supported by this service provider.", this); emit error(reply, reply->error(), reply->errorString()); return reply; } // Prepare request url for ReverseGeocoding: // QString requestString = "http://" + m_host + "/" + m_token +"/geocoding/v2/find.js?around=51.51384,-0.10952&distance=closest"; QString requestString = "http://" + m_host + "/" + m_token +"/geocoding/v2/find.js?around="; requestString += QString::number(coordinate.latitude()); requestString += ","; requestString += QString::number(coordinate.longitude()); //requestString += "&zoom=18"; requestString += "&distance=closest"; requestString += "&return_location=true"; return search(requestString, bounds); }