Exemplo n.º 1
0
void GPSDisplay::debugPositionUpdate()
{
#if MAPPER_DEVELOPMENT_BUILD
    if (! visible)
        return;

    QTime now = QTime::currentTime();
    float offset = now.msecsSinceStartOfDay() / (float)(10 * 1000);
    float accuracy = 12 + 7 * qSin(2 + offset);
    float altitude = 400 + 10 * qSin(1 + 0.1f * offset);

    MapCoordF coord(30 * qSin(0.5f * offset), 30 * qCos(0.53f * offset));
    emit mapPositionUpdated(coord, accuracy);

    if (georeferencing.isValid() && ! georeferencing.isLocal())
    {
        bool ok;
        LatLon latLon = georeferencing.toGeographicCoords(coord, &ok);
        if (ok)
        {
            emit latLonUpdated(latLon.latitude(), latLon.longitude(), altitude, accuracy);
        }
    }

    gps_updated = true;
    tracking_lost = false;
    has_valid_position = true;
    latest_gps_coord = coord;
    latest_gps_coord_accuracy = accuracy;
    updateMapWidget();
#endif
}
Exemplo n.º 2
0
// slot
void GeoreferencingDialog::projectionChanged()
{
	ScopedMultiSignalsBlocker block(
	            crs_selector,
	            lat_edit, lon_edit
	);
	
	if (georef->getState() == Georeferencing::Normal)
	{
		const std::vector< QString >& parameters = georef->getProjectedCRSParameters();
		auto temp = CRSTemplateRegistry().find(georef->getProjectedCRSId());
		if (!temp || temp->parameters().size() != parameters.size())
		{
			// The CRS id is not there anymore or the number of parameters has changed.
			// Enter as custom spec.
			crs_selector->setCurrentCRS(CRSTemplateRegistry().find("PROJ.4"), { georef->getProjectedCRSSpec() });
		}
		else
		{
			crs_selector->setCurrentCRS(temp, parameters);
		}
	}
	
	LatLon latlon = georef->getGeographicRefPoint();
	double latitude  = latlon.latitude();
	double longitude = latlon.longitude();
	lat_edit->setValue(latitude);
	lon_edit->setValue(longitude);
	QString osm_link =
	  QString("http://www.openstreetmap.org/?lat=%1&lon=%2&zoom=18&layers=M").
	  arg(latitude).arg(longitude);
	QString worldofo_link =
	  QString("http://maps.worldofo.com/?zoom=15&lat=%1&lng=%2").
	  arg(latitude).arg(longitude);
	link_label->setText(
	  tr("<a href=\"%1\">OpenStreetMap</a> | <a href=\"%2\">World of O Maps</a>").
	  arg(osm_link).
	  arg(worldofo_link)
	);
	
	QString error = georef->getErrorText();
	if (error.length() == 0)
		status_field->setText(tr("valid"));
	else
		status_field->setText(QString("<b style=\"color:red\">") % error % "</b>");
}