Esempio n. 1
0
    void update( double t )
    {
        osg::Vec3d pos;
        GeoMath::interpolate(
            _startLat.as(Units::RADIANS), _startLon.as(Units::RADIANS),
            _endLat.as(Units::RADIANS), _endLon.as(Units::RADIANS),
            t,
            pos.y(), pos.x() );

        GeoPoint geo(
            _track->getMapNode()->getMapSRS(),
            osg::RadiansToDegrees(pos.x()),
            osg::RadiansToDegrees(pos.y()),
            10000.0,
            ALTMODE_ABSOLUTE);

        // update the position label.
        _track->setPosition(geo);

        if ( g_showCoords )
        {
            _track->setFieldValue( FIELD_POSITION, s_format(geo) );
        }
        else
            _track->setFieldValue( FIELD_POSITION, "" );
    }
Esempio n. 2
0
TrackNode * TrackNode::fromGPX(Document* d, Layer* L, QXmlStreamReader& stream)
{
    qreal Lat = stream.attributes().value("lat").toString().toDouble();
    qreal Lon = stream.attributes().value("lon").toString().toDouble();

    QString sid = (stream.attributes().hasAttribute("id") ? stream.attributes().value("id").toString() : stream.attributes().value("xml:id").toString());
    IFeature::FId id(IFeature::Point, sid.toLongLong());
    TrackNode* Pt = CAST_TRACKNODE(d->getFeature(id));
    if (!Pt) {
        Pt = g_backend.allocTrackNode(L, Coord(Lon,Lat));
        Pt->setId(id);
        Pt->setLastUpdated(Feature::Log);
        L->add(Pt);
    } else {
        Pt->setPosition(Coord(Lon,Lat));
        if (Pt->lastUpdated() == Feature::NotYetDownloaded)
            Pt->setLastUpdated(Feature::OSMServer);
    }

    if (stream.name() == "wpt")
        Pt->setTag("_waypoint_", "yes");

    QDateTime time = QDateTime::currentDateTime();
    stream.readNext();
    while(!stream.atEnd() && !stream.isEndElement()) {
        if (stream.name() == "time") {
            stream.readNext();
            QString dtm = stream.text().toString();
            time = QDateTime::fromString(dtm.left(19), Qt::ISODate);
            stream.readNext();
        } else if (stream.name() == "ele") {
            stream.readNext();
            Pt->setElevation(stream.text().toString().toFloat());
            stream.readNext();
        } else if (stream.name() == "speed") {
            stream.readNext();
            Pt->setSpeed(stream.text().toString().toFloat());
            stream.readNext();
        } else if (stream.name() == "name") {
            stream.readNext();
            Pt->setTag("name", stream.text().toString());
            stream.readNext();
        } else if (stream.name() == "cmt") {
            stream.readNext();
            Pt->setTag("_comment_", stream.text().toString());
            stream.readNext();
        } else if (stream.name() == "desc") {
            stream.readNext();
            Pt->setTag("_description_", stream.text().toString());
            stream.readNext();
        }
        else if (stream.name() == "cmt")
        {
            stream.readNext();
            Pt->setTag("_comment_", stream.text().toString());
            stream.readNext();
        }
        else if (stream.name() == "extensions") // for OpenStreetBugs
        {
            QString str = stream.readElementText(QXmlStreamReader::IncludeChildElements);
            QDomDocument doc;
            doc.setContent(str);

            QDomNodeList li = doc.elementsByTagName("id");
            if (li.size()) {
                QString id = li.at(0).toElement().text();
                Pt->setId(IFeature::FId(IFeature::Point | IFeature::Special, id.toLongLong()));
                Pt->setTag("_special_", "yes"); // Assumed to be OpenstreetBugs as they don't use their own namesoace
                Pt->setSpecial(true);
            }
        }

        stream.readNext();
    }
    Pt->setTime(time);

    return Pt;
}