bool GeoLocation::operator==(const GeoLocation& o) const
{
	// FIXME
	bool equal = true;
	equal = equal && (lat_.hasValue() ? lat_.value() == o.lat().value() : !o.lat().hasValue());
	equal = equal && (lon_.hasValue() ? lon_.value() == o.lon().value() : !o.lon().hasValue());
	return equal;
}
Example #2
0
void ApplicationUI::addMarker(QObject* mapObject, double lat, double lon, QString nombre){

	MapView* mapview = qobject_cast<MapView*>(mapObject);

	GeoLocation* loc = new GeoLocation(lat, lon, mapview);
	loc->setName(nombre);
	mapview->mapData()->clear();
	mapview->mapData()->add(loc);

}
Example #3
0
void Geocode::addressQueryResult(uint queryId, const GeoLocation& location) {
  if (m_id != queryId) {
    // We don't care about old queries.
    return;
  }

  if (m_country != location.address().country()) {
    m_country = location.address().country();
    emit countryChanged();
  }

  if (m_city != location.address().city()) {
    m_city = location.address().city();
    emit cityChanged();
  }

  if (m_suburb != location.address().district()) {
    m_suburb = location.address().district();
    emit suburbChanged();
  }
}
//! [0]
//! [1]
void MapViewDemo::addPinAtCurrentMapCenter() {
    if (mapView) {
        GeoLocation* newDrop = new GeoLocation();
        newDrop->setLatitude(mapView->latitude());
        newDrop->setLongitude(mapView->longitude());
        QString desc = QString("Coordinates: %1, %2").arg(mapView->latitude(),
                                0, 'f', 3).arg(mapView->longitude(), 0, 'f', 3);
        newDrop->setName("Dropped Pin");
        newDrop->setDescription(desc);

        // use the marker in the assets, as opposed to the default marker
        Marker flag;
        flag.setIconUri(UIToolkitSupport::absolutePathFromUrl(
                        QUrl("asset:///images/on_map_pin.png")));
        flag.setIconSize(QSize(60, 60));
        flag.setLocationCoordinate(QPoint(20, 59));
        flag.setCaptionTailCoordinate(QPoint(20, 1));
        newDrop->setMarker(flag);

        mapView->mapData()->add(newDrop);
    }
}
Example #5
0
void ExportEyepieceView::render() {
    float baseWidth = m_renderChart->width();
    float baseHeight = m_renderChart->height();

    if( m_renderImage )
        m_output = QImage( int(baseWidth * 2.25), int(baseHeight), QImage::Format_ARGB32 ); // 0.25 * baseWidth gap between the images
    else
        m_output = QImage( int(baseWidth), int(baseHeight), QImage::Format_ARGB32 );

    m_output.fill( Qt::white );
    QPainter op( &m_output );
    op.drawPixmap( QPointF(0,0), *m_renderChart );
    if( m_renderImage )
        op.drawPixmap( QPointF(baseWidth * 1.25,0), *m_renderImage );

    if( m_tickConfig != 0 && Options::useAltAz() ) { // FIXME: this is very skymap-state-heavy for my happiness --asimha
        // we must draw ticks
        QImage tickOverlay( baseWidth, baseHeight, QImage::Format_ARGB32 );
        tickOverlay.fill( Qt::transparent );

        QPainter p( &tickOverlay );
        p.setPen( Qt::red ); // FIXME: Determine color depending on situation, or make it configurable
        double rEnd = 0.85 * ( baseWidth / 2.);
        double rStart = 0.8 * ( baseWidth / 2.);
        QFont font;
        font.setPixelSize( ( rEnd - rStart ) );
        p.setFont( font );

        GeoLocation *geo = KStarsData::Instance()->geo();
        double alt0 = m_sp->alt().Degrees(); // altitude when hour = 0, i.e. at m_dt (see below).
        dms northAngle0 = EyepieceField::findNorthAngle( m_sp, geo->lat() );

        for( float hour = -3.5; hour <= 3.5; hour += 0.5 ) {
            dms rotation; // rotation

            // FIXME: Code duplication : code duplicated from EyepieceField. This should really be a member of SkyPoint or something.
            SkyPoint sp = SkyPoint::timeTransformed( m_sp, m_dt, geo, hour );
            double alt = sp.alt().Degrees();
            dms northAngle = EyepieceField::findNorthAngle( &sp, geo->lat() );

            rotation = ( northAngle - northAngle0 );
            if( m_tickConfig == 2 ) {
                // Dobsonian: add additional CW rotation by altitude, but compensate for the fact that we've already rotated by alt0
                rotation = rotation - dms( ( alt - alt0 ) );
            }
            rotation = rotation.reduce();
            p.save();
            p.translate( baseWidth/2.0, baseHeight/2.0 );
            p.rotate( -( rotation.Degrees() + 90.0 ) );
            p.drawLine( QPointF( rStart, 0 ), QPointF( rEnd, 0 ) );
            QTime ct = geo->UTtoLT( m_dt.addSecs( 3600.0 * hour ) ).time();
            p.drawText( QPointF( rEnd + 0.01 * baseWidth, 0 ), QString().sprintf( "%02d:%02d", ct.hour(), ct.minute() ) );
            p.restore();
        }
        p.end();
        op.drawImage( QPointF(0,0), tickOverlay );
        if( m_renderImage ) {
            op.drawImage( QPointF(baseWidth * 1.25, 0), tickOverlay );
        }
    }
    op.end();

    m_outputDisplay->setPixmap( (QPixmap::fromImage( m_output )).scaled( m_outputDisplay->width(), m_outputDisplay->height(), Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
}
GeoLocationDlg::GeoLocationDlg(QList<PsiAccount*> list) : QDialog(0), pa_(list)
{
	setAttribute(Qt::WA_DeleteOnClose);
	if(pa_.isEmpty())
		close();
	ui_.setupUi(this);
	setWindowIcon(IconsetFactory::icon("system/geolocation").icon());
	setModal(false);

	connect(ui_.pb_cancel, SIGNAL(clicked()), SLOT(close()));
 	connect(ui_.pb_ok, SIGNAL(clicked()), SLOT(setGeoLocation()));
	connect(ui_.pb_reset, SIGNAL(clicked()), SLOT(reset()));

	PsiAccount *pa = pa_.first();
	GeoLocation geoloc = pa->geolocation();
	if(geoloc.isNull())
		return;

	if (geoloc.alt().hasValue())
		ui_.le_altitude->setText(QString::number(geoloc.alt().value()));

	if (!geoloc.area().isEmpty())
		ui_.le_area->setText(geoloc.area());

	if (geoloc.bearing().hasValue())
		ui_.le_bearing->setText(QString::number(geoloc.bearing().value()));

	if (!geoloc.building().isEmpty())
		ui_.le_building->setText(geoloc.building());

	if (!geoloc.country().isEmpty())
		ui_.le_country->setText(geoloc.country());

	if (!geoloc.datum().isEmpty())
		ui_.le_datum->setText(geoloc.datum());

	if (!geoloc.description().isEmpty())
		ui_.le_description->setText(geoloc.description());

	if (geoloc.error().hasValue())
		ui_.le_error->setText(QString::number(geoloc.error().value()));

	if (!geoloc.floor().isEmpty())
		ui_.le_floor->setText(geoloc.floor());

	if (geoloc.lat().hasValue())
		ui_.le_latitude->setText(QString::number(geoloc.lat().value()));

	if (!geoloc.locality().isEmpty())
		ui_.le_locality->setText(geoloc.locality());

	if (geoloc.lon().hasValue())
		ui_.le_longitude->setText(QString::number(geoloc.lon().value()));

	if (!geoloc.postalcode().isEmpty())
		ui_.le_postalcode->setText(geoloc.postalcode());

	if (!geoloc.region().isEmpty())
		ui_.le_region->setText(geoloc.region());

	if (!geoloc.room().isEmpty())
		ui_.le_room->setText(geoloc.room());

	if (!geoloc.street().isEmpty())
		ui_.le_street->setText(geoloc.street());

	if (!geoloc.text().isEmpty())
		ui_.le_text->setText(geoloc.text());
}
Example #7
0
void MapCanvas::paintEvent( QPaintEvent * ) {
	QPainter pcanvas;
	LocationDialog *ld = (LocationDialog *)topLevelWidget();
  KStars *ks = (KStars *)ld->parent();

	//prepare the canvas
	pcanvas.begin( Canvas );
//	pcanvas.fillRect( 0, 0, width(), height(), QBrush( QColor( BGColor ) ) );
	pcanvas.drawPixmap( 0, 0, *bgImage );
//	pcanvas.setBrush( white );
	pcanvas.setPen( QPen( QColor( "SlateGrey" ) ) );

	//Draw cities
	QPoint o;

	for ( GeoLocation *g=ks->data()->geoList.first(); g; g = ks->data()->geoList.next() ) {
		o.setX( int( g->lng()->Degrees() + origin.x() ) );
		o.setY( height() - int( g->lat()->Degrees() + origin.y() ) );

		if ( o.x() >= 0 && o.x() <= width() && o.y() >=0 && o.y() <=height() ) {
			pcanvas.drawPoint( o.x(), o.y() );
		}
	}

  //redraw the cities that appear in the filtered list, with a white pen
	//If the list has not been filtered, skip the redraw.
	if ( ld->filteredList()->count() ) {
		pcanvas.setPen( white );
		for ( GeoLocation *g=ld->filteredList()->first(); g; g = ld->filteredList()->next() ) {
			o.setX( int( g->lng()->Degrees() + origin.x() ) );
			o.setY( height() - int( g->lat()->Degrees() + origin.y() ) );

			if ( o.x() >= 0 && o.x() <= width() && o.y() >=0 && o.y() <=height() ) {
				pcanvas.drawPoint( o.x(), o.y() );
			}
		}
	}

	GeoLocation *g = ld->selectedCity();
	if ( g ) {
		o.setX( int( g->lng()->Degrees() + origin.x() ) );
		o.setY( height() - int( g->lat()->Degrees() + origin.y() ) );

		pcanvas.setPen( red );
		pcanvas.setBrush( red );
		pcanvas.drawEllipse( o.x()-3, o.y()-3, 6, 6 );
		pcanvas.moveTo( o.x()-16, o.y() );
		pcanvas.lineTo( o.x()-8, o.y() );
		pcanvas.moveTo( o.x()+8, o.y() );
		pcanvas.lineTo( o.x()+16, o.y() );
		pcanvas.moveTo( o.x(), o.y()-16 );
		pcanvas.lineTo( o.x(), o.y()-8 );
		pcanvas.moveTo( o.x(), o.y()+8 );
		pcanvas.lineTo( o.x(), o.y()+16 );
		pcanvas.setPen( white );
		pcanvas.setBrush( white );
  }

	pcanvas.end();
	bitBlt( this, 0, 0, Canvas );
}