// Reduce the list of places to those that are contained within the bounds
void GeoSearchReplyBb::boundPlaces( const QList<QtMobilitySubset::QGeoPlace> & unboundPlaces )
{
    // Bound only if the bounds are valid and not empty. If the bounds are empty the bounds area is zero, so assume the bounds
    // are only useful for the centre location, as a hint where to search in the case of geocoding.
    if ( _bounds && _bounds->isValid() && !_bounds->isEmpty() ) {
        for ( int i = 0 ; i < unboundPlaces.size() ; i++ ) {
            if ( _bounds->contains( unboundPlaces.at(i).coordinate() ) ) {
                addPlace( unboundPlaces.at(i) );
            }
        }
    } else {
        // there are no bounds, add all places.
        setPlaces( unboundPlaces );
    }

}
Example #2
0
void QGeoSearchReplyCm::networkFinished()
{
    if (!m_reply)
        return;

    if (m_reply->error() != QNetworkReply::NoError) {
        setError(QGeoSearchReply::CommunicationError, m_reply->errorString());
        m_reply->deleteLater();
        return;
    };

    QGeoCodeParser parser;
    if (parser.parse(m_reply)) {
        setPlaces(parser.results());
        setFinished(true);
    } else {
        // add a qWarning with the actual parser.errorString()
        setError(QGeoSearchReply::ParseError, "The response from the service was not in a recognisable format.");
    }

    m_reply->deleteLater();
}