use of org.geotoolkit.data.gx.xml.GxReader in project geotoolkit by Geomatys.
the class SoundCueTest method soundCueReadTest.
@Test
public void soundCueReadTest() throws IOException, XMLStreamException, URISyntaxException, KmlException {
final Feature document;
{
final KmlReader reader = new KmlReader();
final GxReader gxReader = new GxReader(reader);
reader.setInput(new File(pathToTestFile));
reader.addExtensionReader(gxReader);
final Kml kmlObjects = reader.read();
reader.dispose();
document = kmlObjects.getAbstractFeature();
}
assertEquals(KmlModelConstants.TYPE_DOCUMENT, document.getType());
assertEquals("gx:SoundCue example", document.getPropertyValue(KmlConstants.TAG_NAME));
assertEquals(Boolean.TRUE, document.getPropertyValue(KmlConstants.TAG_OPEN));
final Feature tour = (Feature) document.getProperty(KmlConstants.TAG_FEATURES).getValue();
assertEquals(GxModelConstants.TYPE_TOUR, tour.getType());
assertEquals("example", tour.getPropertyValue(KmlConstants.TAG_NAME));
Iterator<?> i = ((Iterable<?>) tour.getPropertyValue(KmlConstants.ATT_PLAYLIST)).iterator();
assertTrue("Expected at least one element.", i.hasNext());
final PlayList playList = (PlayList) i.next();
assertEquals(1, playList.getTourPrimitives().size());
final SoundCue soundCue = (SoundCue) playList.getTourPrimitives().get(0);
assertEquals("http://monsite.com/maressource", soundCue.getHref());
assertFalse("Expected exactly one element.", i.hasNext());
}
use of org.geotoolkit.data.gx.xml.GxReader in project geotoolkit by Geomatys.
the class TimePrimitivesTest method timePrimitivesReadTest.
@Test
public void timePrimitivesReadTest() throws IOException, XMLStreamException, URISyntaxException, KmlException {
final Feature document;
{
final KmlReader reader = new KmlReader();
final GxReader gxReader = new GxReader(reader);
reader.setInput(new File(pathToTestFile));
reader.addExtensionReader(gxReader);
final Kml kmlObjects = reader.read();
reader.dispose();
document = kmlObjects.getAbstractFeature();
}
assertEquals(KmlModelConstants.TYPE_DOCUMENT, document.getType());
assertEquals("Views with Time", document.getPropertyValue(KmlConstants.TAG_NAME));
assertEquals(Boolean.TRUE, document.getPropertyValue(KmlConstants.TAG_OPEN));
assertEquals("\n" + " In Google Earth, enable historical imagery and sunlight,\n" + " then click on each placemark to fly to that point in time.\n" + " ", document.getPropertyValue(KmlConstants.TAG_DESCRIPTION));
Iterator<?> i = ((Iterable<?>) document.getPropertyValue(KmlConstants.TAG_FEATURES)).iterator();
assertTrue("Expected at least one element.", i.hasNext());
{
final Feature placemark = (Feature) i.next();
assertEquals("Sutro Baths in 1946", placemark.getPropertyValue(KmlConstants.TAG_NAME));
final Camera camera0 = (Camera) placemark.getPropertyValue(KmlConstants.TAG_VIEW);
assertEquals(1, camera0.extensions().complexes(Names.VIEW).size());
final TimeStamp timeStamp = (TimeStamp) camera0.extensions().complexes(Names.VIEW).get(0);
final String when = "1946-07-29T05:00:00-08:00";
final Calendar calendarWhen = (Calendar) du.getCalendar(when).clone();
assertEquals(calendarWhen, timeStamp.getWhen());
assertEquals(-122.518172, camera0.getLongitude(), DELTA);
assertEquals(37.778036, camera0.getLatitude(), DELTA);
assertEquals(221.0, camera0.getAltitude(), DELTA);
assertEquals(70.0, camera0.getHeading(), DELTA);
assertEquals(75.0, camera0.getTilt(), DELTA);
}
assertTrue("Expected at least 2 elements.", i.hasNext());
{
final Feature placemark = (Feature) i.next();
assertEquals("Palace of Fine Arts in 2002", placemark.getPropertyValue(KmlConstants.TAG_NAME));
final Camera camera = (Camera) placemark.getPropertyValue(KmlConstants.TAG_VIEW);
assertEquals(1, camera.extensions().complexes(Names.VIEW).size());
final TimeSpan timeSpan = (TimeSpan) camera.extensions().complexes(Names.VIEW).get(0);
final String begin = "2002-07-09T19:00:00-08:00";
final Calendar calendarBegin = (Calendar) du.getCalendar(begin).clone();
assertEquals(calendarBegin, timeSpan.getBegin());
assertEquals(-122.444633, camera.getLongitude(), DELTA);
assertEquals(37.801899, camera.getLatitude(), DELTA);
assertEquals(139.629438, camera.getAltitude(), DELTA);
assertEquals(-70.0, camera.getHeading(), DELTA);
assertEquals(75.0, camera.getTilt(), DELTA);
}
assertFalse("Expected exactly 2 elements.", i.hasNext());
}
use of org.geotoolkit.data.gx.xml.GxReader in project geotoolkit by Geomatys.
the class Tour2Test method tour2ReadTest.
@Test
public void tour2ReadTest() throws IOException, XMLStreamException, URISyntaxException, KmlException {
final KmlReader reader = new KmlReader();
final GxReader gxReader = new GxReader(reader);
reader.setInput(new File(pathToTestFile));
reader.addExtensionReader(gxReader);
final Kml kmlObjects = reader.read();
reader.dispose();
final Feature tour = kmlObjects.getAbstractFeature();
assertEquals(GxModelConstants.TYPE_TOUR, tour.getType());
final PlayList playList = (PlayList) ((List) tour.getPropertyValue(KmlConstants.ATT_PLAYLIST)).get(0);
assertEquals(4, playList.getTourPrimitives().size());
final FlyTo flyTo = (FlyTo) playList.getTourPrimitives().get(0);
assertEquals(5, flyTo.getDuration(), DELTA);
assertEquals(EnumFlyToMode.SMOOTH, flyTo.getFlyToMode());
final LookAt lookAt = (LookAt) flyTo.getView();
assertEquals(-79.387, lookAt.getLongitude(), DELTA);
assertEquals(43.643, lookAt.getLatitude(), DELTA);
assertEquals(10, lookAt.getAltitude(), DELTA);
assertEquals(-172.3, lookAt.getHeading(), DELTA);
assertEquals(10, lookAt.getTilt(), DELTA);
assertEquals(1200, lookAt.getRange(), DELTA);
assertEquals(EnumAltitudeMode.RELATIVE_TO_GROUND, lookAt.getAltitudeMode());
final TourControl tourControl = (TourControl) playList.getTourPrimitives().get(1);
assertEquals(EnumPlayMode.PAUSE, tourControl.getPlayMode());
final SoundCue soundCue = (SoundCue) playList.getTourPrimitives().get(2);
assertEquals("http://dev.keyhole.com/codesite/cntowerfacts.mp3", soundCue.getHref());
final Wait wait = (Wait) playList.getTourPrimitives().get(3);
assertEquals(10, wait.getDuration(), DELTA);
}
use of org.geotoolkit.data.gx.xml.GxReader in project geotoolkit by Geomatys.
the class TourControlTest method tourControlReadTest.
@Test
public void tourControlReadTest() throws IOException, XMLStreamException, URISyntaxException, KmlException {
final Feature document;
{
final KmlReader reader = new KmlReader();
final GxReader gxReader = new GxReader(reader);
reader.setInput(new File(pathToTestFile));
reader.addExtensionReader(gxReader);
final Kml kmlObjects = reader.read();
reader.dispose();
document = kmlObjects.getAbstractFeature();
}
assertEquals(KmlModelConstants.TYPE_DOCUMENT, document.getType());
assertEquals("gx:TourControl example", document.getPropertyValue(KmlConstants.TAG_NAME));
assertEquals(Boolean.TRUE, document.getPropertyValue(KmlConstants.TAG_OPEN));
final Feature tour = (Feature) document.getProperty(KmlConstants.TAG_FEATURES).getValue();
assertEquals(GxModelConstants.TYPE_TOUR, tour.getType());
assertEquals("example", tour.getPropertyValue(KmlConstants.TAG_NAME));
Iterator<?> i = ((Iterable<?>) tour.getPropertyValue(KmlConstants.ATT_PLAYLIST)).iterator();
assertTrue("Expected at least one element.", i.hasNext());
final PlayList playList = (PlayList) i.next();
assertEquals(1, playList.getTourPrimitives().size());
final TourControl tourControl = (TourControl) playList.getTourPrimitives().get(0);
assertEquals(EnumPlayMode.PAUSE, tourControl.getPlayMode());
assertFalse("Expected exactly one element.", i.hasNext());
}
use of org.geotoolkit.data.gx.xml.GxReader in project geotoolkit by Geomatys.
the class TourTest method tourReadTest.
@Test
public void tourReadTest() throws IOException, XMLStreamException, URISyntaxException, KmlException {
final KmlReader reader = new KmlReader();
final GxReader gxReader = new GxReader(reader);
reader.setInput(new File(pathToTestFile));
reader.addExtensionReader(gxReader);
final Kml kmlObjects = reader.read();
reader.dispose();
final Feature document = kmlObjects.getAbstractFeature();
assertEquals(KmlModelConstants.TYPE_DOCUMENT, document.getType());
assertEquals("gx:AnimatedUpdate example", document.getPropertyValue(KmlConstants.TAG_NAME));
assertEquals(Boolean.TRUE, document.getPropertyValue(KmlConstants.TAG_OPEN));
Feature tour = (Feature) document.getProperty(KmlConstants.TAG_FEATURES).getValue();
assertEquals(GxModelConstants.TYPE_TOUR, tour.getType());
assertEquals("Play me!", tour.getPropertyValue(KmlConstants.TAG_NAME));
Iterator<?> i = ((Iterable<?>) tour.getPropertyValue(KmlConstants.ATT_PLAYLIST)).iterator();
assertTrue("Expected at least one element.", i.hasNext());
assertTrue(i.next() instanceof PlayList);
assertFalse("Expected exactly one element.", i.hasNext());
}
Aggregations