예제 #1
0
void tst_QGeoBoundingCircle::center()
{
    QGeoBoundingCircle c;
    c.setCenter(QGeoCoordinate(1,1));
    QCOMPARE(c.center(), QGeoCoordinate(1,1));
    c.setCenter(QGeoCoordinate(5,10));
    QCOMPARE(c.center(), QGeoCoordinate(5,10));
}
예제 #2
0
void tst_QGeoBoundingCircle::radius()
{
    QGeoBoundingCircle c;
    c.setRadius(1.0);
    QCOMPARE(c.radius(), qreal(1.0));
    c.setRadius(5.0);
    QCOMPARE(c.radius(), qreal(5.0));
}
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);
}
/*!
    Sets the circle that will be drawn by this object to \a circle.

    This is equivalent to
    \code
        QGeoMapCircleObject *object;
        // setup object
        object->setCenter(circle.center());
        object->setRadius(circle.radius());
    \endcode
    \since 1.1
*/
void QGeoMapCircleObject::setCircle(const QGeoBoundingCircle &circle)
{
    QGeoBoundingCircle oldCircle = d_ptr->circle;

    if (oldCircle == circle)
        return;

    d_ptr->circle = circle;
    setOrigin(circle.center());
    setRadius(circle.radius());

    if (oldCircle.center() != d_ptr->circle.center())
        emit centerChanged(d_ptr->circle.center());

    if (oldCircle.radius() != d_ptr->circle.radius())
        emit radiusChanged(d_ptr->circle.radius());
}
예제 #5
0
void tst_QGeoBoundingCircle::translate()
{
    QFETCH(QGeoCoordinate, center);
    QFETCH(qreal, radius);
    QFETCH(double, lat);
    QFETCH(double, lon);
    QFETCH(QGeoCoordinate, newCenter);

    QGeoBoundingCircle c(center, radius);
    QGeoBoundingCircle d = c;

    c.translate(lat, lon);

    QCOMPARE(c.radius(), radius);
    QCOMPARE(c.center(), newCenter);

    c = d.translated(lat, lon);
    d.setRadius(1.0);

    QCOMPARE(c.radius(), radius);
    QCOMPARE(d.center(), center);
    QCOMPARE(c.center(), newCenter);
}
예제 #6
0
void tst_QGeoBoundingCircle::defaultConstructor()
{
    QGeoBoundingCircle c;
    QVERIFY(!c.center().isValid());
    QCOMPARE(c.radius(), qreal(-1.0));
}
예제 #7
0
void tst_QGeoBoundingCircle::type()
{
    QGeoBoundingCircle c;
    QCOMPARE(c.type(), QGeoBoundingArea::CircleType);
}