QGeoSearchReply* QGeoSearchManagerEngineCm::search(const QString &searchString, QGeoSearchManager::SearchTypes searchTypes, int limit, int offset, QGeoBoundingArea *bounds) { // Prepare request url for Geocoding: QString requestString = "http://" + m_host + "/" + m_token +"/geocoding/v2/find.js?query=" + searchString; if (limit > 0) { // Number of results to return requestString += "&results=" + QString::number(limit); } if (offset > 0) { // Number of results to skip from beginning (allow paging of results) requestString += "&skip=" + QString::number(offset); } if ((bounds) && (bounds->isValid())) { QGeoBoundingBox* box = 0; QGeoBoundingCircle* circle = 0; switch (bounds->type()) { // Note: Searching with Bounding area specified could be extremely slow for large areas // so use it only with high zoom level in frontend map application case QGeoBoundingArea::BoxType: box = static_cast<QGeoBoundingBox*>(bounds); if (box && box->isValid()) { DBG_CM(SEARCH_M, INFO_L, "Using search with bounding box specified"); // "southern_latitude,western_longitude,northern_latitude,eastern_longitude" requestString += "&bbox="; requestString += QString::number(box->bottomLeft().latitude()) + "," ; // southern_latitude requestString += QString::number(box->bottomLeft().longitude()) + "," ; // western_longitude requestString += QString::number(box->topRight().latitude()) + "," ; // northern_latitude requestString += QString::number(box->topRight().longitude()); // eastern_longitude requestString += "&bbox_only=false"; } break; case QGeoBoundingArea::CircleType: circle = static_cast<QGeoBoundingCircle*>(bounds); if (circle && circle->isValid()) { DBG_CM(SEARCH_M, ERR_L, "Using search with circle area specified: Not implemented. Around area is ignored!"); } break; default: break; } } // return location information like road, city, county, country, postcode in returned results: // requestString += "&return_location=true"; return search(requestString, bounds, limit, offset); }
/*! Returns whether the bounding box \a boundingBox is contained within this bounding box. */ bool QGeoBoundingBox::contains(const QGeoBoundingBox &boundingBox) const { return (contains(boundingBox.topLeft()) && contains(boundingBox.topRight()) && contains(boundingBox.bottomLeft()) && contains(boundingBox.bottomRight())); }
QDeclarativeGeoBoundingBox::QDeclarativeGeoBoundingBox(const QGeoBoundingBox& box, QObject* parent) : QObject(parent), m_declarativeBottomLeft(box.bottomLeft()), m_declarativeBottomRight(box.bottomRight()), m_declarativeTopLeft(box.topLeft()), m_declarativeTopRight(box.topRight()), m_declarativeCenter(box.center()), m_box(box), m_height(box.height()), m_width(box.width()) { }