コード例 #1
0
ファイル: TestPhotoOverlay.cpp プロジェクト: AsherBond/marble
void TestPhotoOverlay::simpleParseTest()
{
  QString const centerContent (
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
        "<kml xmlns=\"http://www.opengis.net/kml/2.2\""
        " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
        "<Folder>"
        "  <PhotoOverlay>"
        "    <rotation>12.455</rotation>"
        "    <ViewVolume>"
        "        <near>1000</near>"
        "        <leftFov>-60</leftFov>"
        "        <rightFov>60</rightFov>"
        "        <bottomFov>-45</bottomFov>"
        "        <topFov>45</topFov>"
        "    </ViewVolume>"
        "    <ImagePyramid>"
        "        <tileSize>219</tileSize>"
        "        <maxWidth>22</maxWidth>"
        "        <maxHeight>36</maxHeight>"
        "        <gridOrigin>lowerLeft</gridOrigin>"
        "    </ImagePyramid>"
        "    <Point>"
        "        <coordinates>45.78665,0.6565</coordinates>"
        "    </Point>"
        "    <shape>sphere</shape>"
        "  </PhotoOverlay>"
        "</Folder>"
        "</kml>" );

    GeoDataDocument* dataDocument = parseKml( centerContent  );
    QCOMPARE( dataDocument->folderList().size(), 1 );
    GeoDataFolder *folder = dataDocument->folderList().at( 0 );
    QCOMPARE( folder->size(), 1 );
    GeoDataPhotoOverlay *overlay = dynamic_cast<GeoDataPhotoOverlay*>( folder->child( 0 ) );
    QVERIFY( overlay != 0 );

    QFUZZYCOMPARE( overlay->rotation(), 12.455, 0.0001 );

    QFUZZYCOMPARE( overlay->viewVolume().near(), 1000.0, 0.0001 );
    QFUZZYCOMPARE( overlay->viewVolume().leftFov(), -60.0, 0.0001 );
    QFUZZYCOMPARE( overlay->viewVolume().rightFov(), 60.0, 0.0001 );
    QFUZZYCOMPARE( overlay->viewVolume().bottomFov(), -45.0, 0.0001 );
    QFUZZYCOMPARE( overlay->viewVolume().topFov(), 45.0, 0.0001 );

    QFUZZYCOMPARE( overlay->imagePyramid().tileSize(), 219, 0.0001 );
    QFUZZYCOMPARE( overlay->imagePyramid().maxWidth(), 22, 0.0001 );
    QFUZZYCOMPARE( overlay->imagePyramid().maxHeight(), 36, 0.0001 );
    QFUZZYCOMPARE( overlay->imagePyramid().gridOrigin(), GeoDataImagePyramid::LowerLeft, 0.0001 );

    QFUZZYCOMPARE( overlay->point().coordinates().longitude( GeoDataCoordinates::Degree ), 45.78665, 0.0001 );
    QFUZZYCOMPARE( overlay->point().coordinates().latitude( GeoDataCoordinates::Degree ), 0.6565, 0.0001 );

    QFUZZYCOMPARE( overlay->shape(), GeoDataPhotoOverlay::Sphere, 0.0001 );

    delete dataDocument;
}
コード例 #2
0
void TestScreenOverlay::simpleParseTest()
{
  QString const centerContent (
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
        "<kml xmlns=\"http://www.opengis.net/kml/2.2\""
        " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
        "<Folder>"
        "  <ScreenOverlay>"
        "    <overlayXY x=\"2.5\" y=\"-0.5\" xunits=\"fraction\" yunits=\"fraction\"/>"
        "    <screenXY x=\"0.5\" y=\"0.5\" xunits=\"insetpixels\" yunits=\"pixels\"/>"
        "    <rotationXY x=\"1.5\" y=\"3.5\" xunits=\"fraction\" yunits=\"insetPixels\"/>"
        "    <size x=\"23\" y=\"0.5\" xunits=\"pixels\" yunits=\"insetPixels\"/>"
        "    <rotation>23</rotation>"
        "    <drawOrder>9</drawOrder>"
        "  </ScreenOverlay>"
        "</Folder>"
        "</kml>" );

    GeoDataDocument* dataDocument = parseKml( centerContent  );
    QCOMPARE( dataDocument->folderList().size(), 1 );
    GeoDataFolder *folder = dataDocument->folderList().at( 0 );
    QCOMPARE( folder->size(), 1 );
    GeoDataScreenOverlay *overlay = dynamic_cast<GeoDataScreenOverlay*>( folder->child( 0 ) );
    QVERIFY( overlay != 0 );

    QCOMPARE( overlay->overlayXY().xunit(), GeoDataVec2::Fraction );
    QCOMPARE( overlay->overlayXY().yunit(), GeoDataVec2::Fraction );
    QCOMPARE( overlay->overlayXY().y(), -0.5 );
    QCOMPARE( overlay->overlayXY().x(), 2.5 );

    QCOMPARE( overlay->screenXY().xunit(), GeoDataVec2::Fraction ); // spelling error in kml, so fallback to default
    QCOMPARE( overlay->screenXY().yunit(), GeoDataVec2::Pixels );
    QCOMPARE( overlay->screenXY().x(), 0.5 );
    QCOMPARE( overlay->screenXY().y(), 0.5 );

    QCOMPARE( overlay->rotationXY().xunit(), GeoDataVec2::Fraction );
    QCOMPARE( overlay->rotationXY().yunit(), GeoDataVec2::InsetPixels );
    QCOMPARE( overlay->rotationXY().x(), 1.5 );
    QCOMPARE( overlay->rotationXY().y(), 3.5 );

    QCOMPARE( overlay->size().xunit(), GeoDataVec2::Pixels );
    QCOMPARE( overlay->size().yunit(), GeoDataVec2::InsetPixels );
    QCOMPARE( overlay->size().x(), 23.0 );
    QCOMPARE( overlay->size().y(), 0.5 );

    QCOMPARE( overlay->rotation(), 23.0 );
    QCOMPARE( overlay->drawOrder(), 9 );

    delete dataDocument;
}
コード例 #3
0
void TestListStyle::simpleParseTest()
{
  QString const content (
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
        "<kml xmlns=\"http://www.opengis.net/kml/2.2\""
        " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
        "<Document>"
        "  <name>The one and only BalloonStyle test case</name>"
        "  <Style id=\"my-list-style\">"
        "    <ListStyle>"
        "      <listItemType>checkOffOnly</listItemType>"
        "      <bgColor>aa112233</bgColor>"
        "      <ItemIcon>"
        "        <state>open error</state>"
        "        <href>https://developers.google.com/kml/documentation/images/itemicons.jpg</href>"
        "      </ItemIcon>"
        "      <ItemIcon>"
        "        <state>closed</state>"
        "        <href>https://developers.google.com/kml/documentation/images/itemicons1.jpg</href>"
        "      </ItemIcon>"
        "    </ListStyle>"
        "  </Style>"
        "  <Folder>"
        "  <Placemark>"
        "    <name>The first placemark</name>"
        "    <styleUrl>#my-list-style</styleUrl>"
        "    <Point><coordinates>80.0,30.0</coordinates></Point>"
        "  </Placemark>"
        "  </Folder>"
        "</Document>"
        "</kml>" );

    GeoDataDocument* dataDocument = parseKml( content  );
    QCOMPARE( dataDocument->folderList().size(), 1 );
    GeoDataFolder *folder = dataDocument->folderList().at( 0 );
    QCOMPARE( folder->size(), 1 );
    GeoDataPlacemark *placemark1 = dynamic_cast<GeoDataPlacemark*>( folder->child( 0 ) );
    QVERIFY( placemark1 != nullptr );

    QCOMPARE( placemark1->name(), QString( "The first placemark" ) );
    QCOMPARE( placemark1->style()->listStyle().listItemType(), GeoDataListStyle::CheckOffOnly );
    QCOMPARE( placemark1->style()->listStyle().backgroundColor().red(), 51 );
    QCOMPARE( placemark1->style()->listStyle().itemIconList().at(0)->state(), GeoDataItemIcon::Open | GeoDataItemIcon::Error );
    QCOMPARE( placemark1->style()->listStyle().itemIconList().at(0)->iconPath(), QString( "https://developers.google.com/kml/documentation/images/itemicons.jpg" ) );
    QCOMPARE( placemark1->style()->listStyle().itemIconList().at(1)->state(), GeoDataItemIcon::Closed );
    QCOMPARE( placemark1->style()->listStyle().itemIconList().at(1)->iconPath(), QString( "https://developers.google.com/kml/documentation/images/itemicons1.jpg" ) );

    delete dataDocument;
}
コード例 #4
0
ファイル: TestGeoDataTrack.cpp プロジェクト: fgx/fgx-marble
void TestGeoDataTrack::simpleParseTest()
{
    GeoDataDocument* dataDocument = parseKml( simpleExampleContent );
    GeoDataFolder *folder = dataDocument->folderList().at( 0 );
    QCOMPARE( folder->placemarkList().size(), 1 );
    GeoDataPlacemark* placemark = folder->placemarkList().at( 0 );
    QCOMPARE( placemark->geometry()->geometryId(), GeoDataTrackId );
    GeoDataTrack* track = static_cast<GeoDataTrack*>( placemark->geometry() );
    QCOMPARE( track->size(), 7 );
    {
        QDateTime when = track->whenList().at( 0 );
        QCOMPARE( when, QDateTime( QDate( 2010, 5, 28 ), QTime( 2, 2, 9 ), Qt::UTC ) );
    }
    {
        GeoDataCoordinates coord = track->coordinatesList().at( 0 );
        QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), -122.207881 );
        QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 37.371915 );
        QCOMPARE( coord.altitude(), 156.000000 );
    }
    {
        GeoDataCoordinates coord = track->coordinatesAt( QDateTime( QDate( 2010, 5, 28 ), QTime( 2, 2, 9 ), Qt::UTC ) );
        QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), -122.207881 );
        QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 37.371915 );
        QCOMPARE( coord.altitude(), 156.000000 );
    }

    delete dataDocument;
}
コード例 #5
0
ファイル: TestNetworkLink.cpp プロジェクト: fgx/fgx-marble
void TestNetworkLink::simpleParseTest()
{
    QString const centerContent (
    "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
    "<kml xmlns=\"http://www.opengis.net/kml/2.2\""
    " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
    "<Folder>"
    " <NetworkLink>"
    "  <refreshVisibility>1</refreshVisibility> <!-- boolean -->"
    "  <flyToView>1</flyToView>                 <!-- boolean -->"
    "  <Link>"
    "   <href>http://files.kde.org/marble/examples/kml/</href>"
    "   <refreshMode>onChange</refreshMode>"
    "   <refreshInterval>2.1</refreshInterval>"
    "   <viewRefreshMode>never</viewRefreshMode>"
    "   <viewRefreshTime>4.2</viewRefreshTime>"
    "   <viewBoundScale>1.5</viewBoundScale>"
    "   <viewFormat>BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]</viewFormat>"
    "   <httpQuery>SiteType=sw,gw,sp&amp;SiteCode=all&amp;Format=ge</httpQuery>"
    "  </Link>"
    " </NetworkLink>"
    "</Folder>"
    "</kml>");

    GeoDataDocument* dataDocument = parseKml( centerContent  );
    QCOMPARE( dataDocument->folderList().size(), 1 );
    GeoDataFolder *folder = dataDocument->folderList().at( 0 );
    QCOMPARE( folder->size(), 1 );
    GeoDataNetworkLink *networkLink = dynamic_cast<GeoDataNetworkLink*>( folder->child( 0 ) );
    QVERIFY( networkLink != 0 );

    QCOMPARE( networkLink->refreshVisibility(), true );
    QCOMPARE( networkLink->flyToView(), true );
    QCOMPARE( networkLink->link().href(), QString("http://files.kde.org/marble/examples/kml/") );
    QCOMPARE( networkLink->link().refreshMode(), GeoDataLink::OnChange );
    QFUZZYCOMPARE( networkLink->link().refreshInterval(), 2.1, 0.0001 );
    QCOMPARE( networkLink->link().viewRefreshMode(), GeoDataLink::Never);
    QFUZZYCOMPARE( networkLink->link().viewRefreshTime(), 4.2, 0.0001 );
    QFUZZYCOMPARE( networkLink->link().viewBoundScale(), 1.5, 0.0001 );
    QCOMPARE( networkLink->link().viewFormat(), QString("BBOX=[bboxWest],[bboxSouth],[bboxEast],[bboxNorth]") );
    QCOMPARE( networkLink->link().httpQuery(), QString("SiteType=sw,gw,sp&SiteCode=all&Format=ge"));

}
コード例 #6
0
ファイル: TestBalloonStyle.cpp プロジェクト: KDE/marble
void TestBalloonStyle::simpleParseTest()
{
  QString const content (
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
        "<kml xmlns=\"http://www.opengis.net/kml/2.2\""
        " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
        "<Document>"
        "  <name>The one and only BalloonStyle test case</name>"
        "  <Style id=\"my-balloon-style\">"
        "    <BalloonStyle>"
        "      <bgColor>aa112233</bgColor>"
        "      <textColor>bb445566</textColor>"
        "      <text>This is my balloon style. There are many like it, but this is mine.</text>"
        "      <displayMode>hide</displayMode>"
        "    </BalloonStyle>"
        "  </Style>"
        "  <Folder>"
        "  <Placemark>"
        "    <name>The first placemark</name>"
        "    <styleUrl>#my-balloon-style</styleUrl>"
        "    <Point><coordinates>80.0,30.0</coordinates></Point>"
        "  </Placemark>"
        "  </Folder>"
        "</Document>"
        "</kml>" );

    GeoDataDocument* dataDocument = parseKml( content  );
    QCOMPARE( dataDocument->folderList().size(), 1 );
    GeoDataFolder *folder = dataDocument->folderList().at( 0 );
    QCOMPARE( folder->size(), 1 );
    GeoDataPlacemark *placemark1 = dynamic_cast<GeoDataPlacemark*>( folder->child( 0 ) );
    QVERIFY( placemark1 != 0 );

    QCOMPARE( placemark1->name(), QString( "The first placemark" ) );
    QCOMPARE( placemark1->style()->balloonStyle().backgroundColor().red(), 51 );
    QCOMPARE( placemark1->style()->balloonStyle().textColor().blue(), 68 );
    QCOMPARE( placemark1->style()->balloonStyle().displayMode(), GeoDataBalloonStyle::Hide );
    QString const text = "This is my balloon style. There are many like it, but this is mine.";
    QCOMPARE( placemark1->style()->balloonStyle().text(), text );

    delete dataDocument;
}
コード例 #7
0
ファイル: TestGeoDataTrack.cpp プロジェクト: fgx/fgx-marble
void TestGeoDataTrack::withoutTimeTest()
{
    //"Simple Example" from kmlreference; when elements emptied
    QString content(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<kml xmlns=\"http://www.opengis.net/kml/2.2\""
" xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
"<Folder>"
"  <Placemark>"
"    <gx:Track>"
"      <when></when>"
"      <when></when>"
"      <when></when>"
"      <when></when>"
"      <when></when>"
"      <when></when>"
"      <when></when>"
"      <gx:coord>-122.207881 37.371915 156.000000</gx:coord>"
"      <gx:coord>-122.205712 37.373288 152.000000</gx:coord>"
"      <gx:coord>-122.204678 37.373939 147.000000</gx:coord>"
"      <gx:coord>-122.203572 37.374630 142.199997</gx:coord>"
"      <gx:coord>-122.203451 37.374706 141.800003</gx:coord>"
"      <gx:coord>-122.203329 37.374780 141.199997</gx:coord>"
"      <gx:coord>-122.203207 37.374857 140.199997</gx:coord>"
"    </gx:Track>"
"  </Placemark>"
"</Folder>"
"</kml>" );

    GeoDataDocument* dataDocument = parseKml( content );
    GeoDataFolder *folder = dataDocument->folderList().at( 0 );
    QCOMPARE( folder->placemarkList().size(), 1 );
    GeoDataPlacemark* placemark = folder->placemarkList().at( 0 );
    QCOMPARE( placemark->geometry()->geometryId(), GeoDataTrackId );
    GeoDataTrack* track = static_cast<GeoDataTrack*>( placemark->geometry() );
    QCOMPARE( track->size(), 7 );
    {
        GeoDataCoordinates coord = track->coordinatesList().at( 0 );
        QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), -122.207881 );
        QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 37.371915 );
        QCOMPARE( coord.altitude(), 156.000000 );
    }

    {
        const GeoDataLineString *lineString = track->lineString();
        QCOMPARE( lineString->size(), 7 );
        GeoDataCoordinates coord = lineString->at( 0 );
        QCOMPARE( coord.longitude( GeoDataCoordinates::Degree ), -122.207881 );
        QCOMPARE( coord.latitude( GeoDataCoordinates::Degree ), 37.371915 );
        QCOMPARE( coord.altitude(), 156.000000 );
    }

    delete dataDocument;
}
コード例 #8
0
void TestGroundOverlay::simpleParseTest()
{
  QString const centerContent (
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
        "<kml xmlns=\"http://www.opengis.net/kml/2.2\""
        " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
        "<Folder>"
            "<GroundOverlay>"
                "<altitude>0</altitude>"
                "<altitudeMode>absolute</altitudeMode>"
                "<LatLonBox>"
                    "<north>37.91904192681665</north>"
                    "<south>37.46543388598137</south>"
                    "<east>15.35832653742206</east>"
                    "<west>14.60128369746704</west>"
                    "<rotation>-0.1556640799496235</rotation>"
                 "</LatLonBox>"
             "</GroundOverlay>"
              "<GroundOverlay>"
                  "<altitude>233</altitude>"
                  "<drawOrder>2</drawOrder>"
                  "<LatLonBox>"
                      "<north>23.3765376</north>"
                      "<south>1.5743867869</south>"
                      "<east>33.78365874</east>"
                      "<west>94.352435642</west>"
                      "<rotation>6.346364378</rotation>"
                   "</LatLonBox>"
               "</GroundOverlay>"
        "</Folder>"
        "</kml>" );

    GeoDataDocument* dataDocument = parseKml( centerContent  );
    QCOMPARE( dataDocument->folderList().size(), 1 );
    GeoDataFolder *folder = dataDocument->folderList().at( 0 );
    QCOMPARE( folder->size(), 2 );
    GeoDataGroundOverlay *overlayFirst = dynamic_cast<GeoDataGroundOverlay*>( folder->child( 0 ) );
    GeoDataGroundOverlay *overlaySecond = dynamic_cast<GeoDataGroundOverlay*>( folder->child( 1 ) );
    QVERIFY( overlayFirst != 0 );
    QVERIFY( overlaySecond != 0 );

    QFUZZYCOMPARE( overlayFirst->altitude(), 0.0, 0.0001 );

    QFUZZYCOMPARE( overlayFirst->altitudeMode(), Absolute, 0.0001 );
    QCOMPARE( overlayFirst->drawOrder(), 0 );

    QFUZZYCOMPARE( overlayFirst->latLonBox().north(), 37.91904192681665 * DEG2RAD, 0.0001 );
    QFUZZYCOMPARE( overlayFirst->latLonBox().south(), 37.46543388598137 * DEG2RAD, 0.0001 );
    QFUZZYCOMPARE( overlayFirst->latLonBox().east(), 15.35832653742206 * DEG2RAD, 0.0001 );
    QFUZZYCOMPARE( overlayFirst->latLonBox().west(), 14.60128369746704 * DEG2RAD, 0.0001 );
    QFUZZYCOMPARE( overlayFirst->latLonBox().rotation(), -0.1556640799496235 * DEG2RAD, 0.0001 );

    QFUZZYCOMPARE( overlaySecond->altitude(), 233.0, 0.0001 );

    QCOMPARE( overlaySecond->altitudeMode(), ClampToGround );
    QCOMPARE( overlaySecond->drawOrder(), 2 );

    QFUZZYCOMPARE( overlaySecond->latLonBox().north(), 23.3765376 * DEG2RAD, 0.0001 );
    QFUZZYCOMPARE( overlaySecond->latLonBox().south(), 1.5743867869 * DEG2RAD, 0.0001 );
    QFUZZYCOMPARE( overlaySecond->latLonBox().east(), 33.78365874 * DEG2RAD, 0.0001 );
    QFUZZYCOMPARE( overlaySecond->latLonBox().west(), 94.352435642 * DEG2RAD, 0.0001 );
    QFUZZYCOMPARE( overlaySecond->latLonBox().rotation(), 6.346364378 * DEG2RAD, 0.0001 );

    delete dataDocument;
}
コード例 #9
0
ファイル: TestTour.cpp プロジェクト: PayalPradhan/marble
void TestTour::simpleParseTest()
{
  QString const centerContent (
        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
        "<kml xmlns=\"http://www.opengis.net/kml/2.2\""
        " xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
        "<Folder>"
        "   <gx:Tour>"
        "       <name>My Tour</name>"
        "       <description>This is my tour.</description>"
        "   </gx:Tour>"
        "   <gx:Tour id=\"tourId\">"
        "       <gx:Playlist>"
        "           <gx:TourControl id=\"space\">"
        "               <gx:playMode>pause</gx:playMode>"
        "           </gx:TourControl>"
        "       </gx:Playlist>"
        "   </gx:Tour>"
        "   <gx:Tour id=\"animUpd\">"
        "       <name>TourAnim</name>"
        "       <description>Tour with AnimatedUpdate</description>"
        "       <gx:Playlist>"
        "           <gx:AnimatedUpdate>"
        "               <gx:duration>5.0</gx:duration>"
        "               <Update>"
        "                   <targetHref>Whatever.jpg</targetHref>"
        "               </Update>"
        "           </gx:AnimatedUpdate>"
        "       </gx:Playlist>"
        "   </gx:Tour>"
        "</Folder>"
        "</kml>" );

    GeoDataDocument* dataDocument = parseKml( centerContent );
    QCOMPARE( dataDocument->folderList().size(), 1 );
    GeoDataFolder *folder = dataDocument->folderList().at( 0 );


    GeoDataTour *tour_1 = dynamic_cast<GeoDataTour*>(folder->child(0));
    GeoDataTour *tour_2 = dynamic_cast<GeoDataTour*>(folder->child(1));
    GeoDataTour *tour_3 = dynamic_cast<GeoDataTour*>(folder->child(2));

    QVERIFY(tour_1 != 0);
    QVERIFY(tour_2 != 0);
    QVERIFY(tour_3 != 0);

    QCOMPARE(tour_1->id(), QString(""));
    QCOMPARE(tour_1->name(), QString("My Tour"));
    QCOMPARE(tour_1->description(), QString("This is my tour."));

    QCOMPARE(tour_2->id(), QString("tourId"));
    QCOMPARE(tour_2->name(), QString());
    QCOMPARE(tour_2->description(), QString());

    QCOMPARE(tour_3->id(), QString("animUpd"));
    QCOMPARE(tour_3->name(), QString("TourAnim"));
    QCOMPARE(tour_3->description(), QString("Tour with AnimatedUpdate"));

    GeoDataPlaylist *playlist = tour_2->playlist();
    QVERIFY(playlist != 0);

    GeoDataTourControl *control = dynamic_cast<GeoDataTourControl*>(
                playlist->primitive(0));
    QVERIFY(control != 0);
    QCOMPARE(control->id(), QString("space"));
    QCOMPARE(control->playMode(), GeoDataTourControl::Pause);

    GeoDataPlaylist *playlist2 = tour_3->playlist();
    QVERIFY(playlist2 != 0);

    GeoDataAnimatedUpdate *update = dynamic_cast<GeoDataAnimatedUpdate*>(playlist2->primitive(0));
    QVERIFY(update != 0);
    QCOMPARE(update->duration(),5.0);
    QCOMPARE(update->update()->targetHref(),QString("Whatever.jpg"));

    delete dataDocument;
}
コード例 #10
0
ファイル: TestGeoDataTrack.cpp プロジェクト: fgx/fgx-marble
void TestGeoDataTrack::extendedDataParseTest()
{
    //"Example of Track with Extended Data" from kmlreference
    QString content(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<kml xmlns=\"http://www.opengis.net/kml/2.2\" xmlns:gx=\"http://www.google.com/kml/ext/2.2\">"
"  <Document>"
"    <name>GPS device</name>"
"    <Snippet>Created Wed Jun 2 15:33:39 2010</Snippet>"
"    <Schema id=\"schema\">"
"      <gx:SimpleArrayField name=\"heartrate\" type=\"int\">"
"        <displayName>Heart Rate</displayName>"
"      </gx:SimpleArrayField>"
"      <gx:SimpleArrayField name=\"cadence\" type=\"int\">"
"        <displayName>Cadence</displayName>"
"      </gx:SimpleArrayField>"
"      <gx:SimpleArrayField name=\"power\" type=\"float\">"
"        <displayName>Power</displayName>"
"      </gx:SimpleArrayField>"
"    </Schema>"
"    <Folder>"
"      <name>Tracks</name>"
"      <Placemark>"
"        <name>2010-05-28T01:16:35.000Z</name>"
"        <styleUrl>#multiTrack</styleUrl>"
"        <gx:Track>"
"          <when>2010-05-28T02:02:09Z</when>"
"          <when>2010-05-28T02:02:35Z</when>"
"          <when>2010-05-28T02:02:44Z</when>"
"          <when>2010-05-28T02:02:53Z</when>"
"          <when>2010-05-28T02:02:54Z</when>"
"          <when>2010-05-28T02:02:55Z</when>"
"          <when>2010-05-28T02:02:56Z</when>"
"          <gx:coord>-122.207881 37.371915 156.000000</gx:coord>"
"          <gx:coord>-122.205712 37.373288 152.000000</gx:coord>"
"          <gx:coord>-122.204678 37.373939 147.000000</gx:coord>"
"          <gx:coord>-122.203572 37.374630 142.199997</gx:coord>"
"          <gx:coord>-122.203451 37.374706 141.800003</gx:coord>"
"          <gx:coord>-122.203329 37.374780 141.199997</gx:coord>"
"          <gx:coord>-122.203207 37.374857 140.199997</gx:coord>"
"          <ExtendedData>"
"            <SchemaData schemaUrl=\"#schema\">"
"              <gx:SimpleArrayData name=\"cadence\">"
"                <gx:value>86</gx:value>"
"                <gx:value>103</gx:value>"
"                <gx:value>108</gx:value>"
"                <gx:value>113</gx:value>"
"                <gx:value>113</gx:value>"
"                <gx:value>113</gx:value>"
"                <gx:value>113</gx:value>"
"              </gx:SimpleArrayData>"
"              <gx:SimpleArrayData name=\"heartrate\">"
"                <gx:value>181</gx:value>"
"                <gx:value>177</gx:value>"
"                <gx:value>175</gx:value>"
"                <gx:value>173</gx:value>"
"                <gx:value>173</gx:value>"
"                <gx:value>173</gx:value>"
"                <gx:value>173</gx:value>"
"              </gx:SimpleArrayData>"
"              <gx:SimpleArrayData name=\"power\">"
"                <gx:value>327.0</gx:value>"
"                <gx:value>177.0</gx:value>"
"                <gx:value>179.0</gx:value>"
"                <gx:value>162.0</gx:value>"
"                <gx:value>166.0</gx:value>"
"                <gx:value>177.0</gx:value>"
"                <gx:value>183.0</gx:value>"
"              </gx:SimpleArrayData>"
"            </SchemaData>"
"          </ExtendedData>"
"        </gx:Track>"
"      </Placemark>"
"    </Folder>"
"  </Document>"
"</kml>" );

    GeoDataDocument* dataDocument = parseKml( content );
    GeoDataFolder *folder = dataDocument->folderList().at( 0 );
    QCOMPARE( folder->placemarkList().size(), 1 );
    GeoDataPlacemark* placemark = folder->placemarkList().at( 0 );
    QCOMPARE( placemark->geometry()->geometryId(), GeoDataTrackId );
    GeoDataTrack* track = static_cast<GeoDataTrack*>( placemark->geometry() );
    QCOMPARE( track->size(), 7 );

    {
        GeoDataSimpleArrayData *cadence = track->extendedData().simpleArrayData( "cadence" );
        QCOMPARE( cadence->size(), 7 );
        QCOMPARE( cadence->valueAt( 0 ), QVariant( "86" ) );
        QCOMPARE( cadence->valueAt( 6 ), QVariant( "113" ) );
    }
    {
        GeoDataSimpleArrayData *hr = track->extendedData().simpleArrayData( "heartrate" );
        QCOMPARE( hr->size(), 7 );
        QCOMPARE( hr->valueAt( 0 ), QVariant( "181" ) );
        QCOMPARE( hr->valueAt( 6 ), QVariant( "173" ) );
    }
    {
        GeoDataSimpleArrayData *power = track->extendedData().simpleArrayData( "power" );
        QCOMPARE( power->size(), 7 );
        QCOMPARE( power->valueAt( 0 ), QVariant( "327.0" ) );
        QCOMPARE( power->valueAt( 6 ), QVariant( "183.0" ) );
    }

    delete dataDocument;
}