use of org.geotoolkit.data.kml.model.Kml in project geotoolkit by Geomatys.
the class GroundOverlayTest method groundOverlayReadTest.
@Test
public void groundOverlayReadTest() throws IOException, XMLStreamException, KmlException, URISyntaxException {
final KmlReader reader = new KmlReader();
reader.setInput(new File(pathToTestFile));
final Kml kmlObjects = reader.read();
reader.dispose();
final Feature groundOverlay = kmlObjects.getAbstractFeature();
assertEquals(KmlModelConstants.TYPE_GROUND_OVERLAY, groundOverlay.getType());
assertEquals("GroundOverlay.kml", groundOverlay.getPropertyValue(KmlConstants.TAG_NAME));
assertEquals("7fffffff", KmlUtilities.toKmlColor((Color) groundOverlay.getPropertyValue(KmlConstants.TAG_COLOR)));
assertEquals(1, groundOverlay.getPropertyValue(KmlConstants.TAG_DRAW_ORDER));
final Icon icon = (Icon) groundOverlay.getPropertyValue(KmlConstants.TAG_ICON);
assertEquals("http://www.google.com/intl/en/images/logo.gif", icon.getHref());
assertEquals(RefreshMode.ON_INTERVAL, icon.getRefreshMode());
assertEquals(86400, icon.getRefreshInterval(), DELTA);
assertEquals(0.75, icon.getViewBoundScale(), DELTA);
final LatLonBox latLonBox = (LatLonBox) groundOverlay.getPropertyValue(KmlConstants.TAG_LAT_LON_BOX);
assertEquals(37.83234, latLonBox.getNorth(), DELTA);
assertEquals(37.832122, latLonBox.getSouth(), DELTA);
assertEquals(-122.373033, latLonBox.getEast(), DELTA);
assertEquals(-122.373724, latLonBox.getWest(), DELTA);
assertEquals(45, latLonBox.getRotation(), DELTA);
}
use of org.geotoolkit.data.kml.model.Kml in project geotoolkit by Geomatys.
the class SoundCueTest method soundCueWriteTest.
@Test
public void soundCueWriteTest() throws KmlException, IOException, XMLStreamException, ParserConfigurationException, SAXException, URISyntaxException {
final GxFactory gxFactory = DefaultGxFactory.getInstance();
final KmlFactory kmlFactory = DefaultKmlFactory.getInstance();
final SoundCue soundCue = gxFactory.createSoundCue();
soundCue.setHref("http://monsite.com/maressource");
final PlayList playList = gxFactory.createPlayList();
playList.setTourPrimitives(Arrays.asList((AbstractTourPrimitive) soundCue));
final Feature tour = gxFactory.createTour();
tour.setPropertyValue(KmlConstants.TAG_NAME, "example");
tour.setPropertyValue(KmlConstants.ATT_PLAYLIST, playList);
final Feature document = kmlFactory.createDocument();
document.setPropertyValue(KmlConstants.TAG_NAME, "gx:SoundCue example");
document.setPropertyValue(KmlConstants.TAG_OPEN, Boolean.TRUE);
document.setPropertyValue(KmlConstants.TAG_FEATURES, tour);
final Kml kml = kmlFactory.createKml(null, document, null, null);
kml.addExtensionUri(GxConstants.URI_GX, "gx");
final File temp = File.createTempFile("testSoundCue", ".kml");
temp.deleteOnExit();
final KmlWriter writer = new KmlWriter();
final GxWriter gxWriter = new GxWriter(writer);
writer.setOutput(temp);
writer.addExtensionWriter(GxConstants.URI_GX, gxWriter);
writer.write(kml);
writer.dispose();
DomCompare.compare(new File(pathToTestFile), temp);
}
use of org.geotoolkit.data.kml.model.Kml in project geotoolkit by Geomatys.
the class Tour3Test method tour3ReadTest.
/*
* Methode de test en lecture
*/
@Test
public void tour3ReadTest() throws IOException, XMLStreamException, URISyntaxException, KmlException {
// Instanciation du reader Kml
final KmlReader reader = new KmlReader();
// Instanciation du reader d'extensions à partir du reader Kml
final GxReader gxReader = new GxReader(reader);
// Affectation au reader Kml du fichier de lecture et d'un reader d'extensions
reader.setInput(new File(pathToTestFile));
reader.addExtensionReader(gxReader);
// Lecture, puis libération du reader Kml
final Kml kmlObjects = reader.read();
reader.dispose();
// Vérification du contenu lu...
final NetworkLinkControl networkLinkControl = kmlObjects.getNetworkLinkControl();
final Update update = networkLinkControl.getUpdate();
assertEquals(new URI("http://myserver.com/Bof.kml"), update.getTargetHref());
assertEquals(1, update.getUpdates().size());
final Delete delete = (Delete) update.getUpdates().get(0);
assertEquals(1, delete.getFeatures().size());
assertEquals(GxModelConstants.TYPE_TOUR, delete.getFeatures().get(0).getType());
final Feature tour = delete.getFeatures().get(0);
final PlayList playlist = (PlayList) ((List) tour.getPropertyValue(KmlConstants.ATT_PLAYLIST)).get(0);
assertEquals(0, playlist.getTourPrimitives().size());
}
use of org.geotoolkit.data.kml.model.Kml in project geotoolkit by Geomatys.
the class TourControlTest method tourControlWriteTest.
@Test
public void tourControlWriteTest() throws KmlException, IOException, XMLStreamException, ParserConfigurationException, SAXException, URISyntaxException {
final GxFactory gxFactory = DefaultGxFactory.getInstance();
final KmlFactory kmlFactory = DefaultKmlFactory.getInstance();
final TourControl tourControl = gxFactory.createTourControl();
tourControl.setPlayMode(EnumPlayMode.PAUSE);
final PlayList playList = gxFactory.createPlayList();
playList.setTourPrimitives(Arrays.asList((AbstractTourPrimitive) tourControl));
final Feature tour = gxFactory.createTour();
tour.setPropertyValue(KmlConstants.TAG_NAME, "example");
tour.setPropertyValue(KmlConstants.ATT_PLAYLIST, playList);
final Feature document = kmlFactory.createDocument();
document.setPropertyValue(KmlConstants.TAG_NAME, "gx:TourControl example");
document.setPropertyValue(KmlConstants.TAG_OPEN, Boolean.TRUE);
document.setPropertyValue(KmlConstants.TAG_FEATURES, tour);
final Kml kml = kmlFactory.createKml(null, document, null, null);
kml.addExtensionUri(GxConstants.URI_GX, "gx");
final File temp = File.createTempFile("testTourControl", ".kml");
temp.deleteOnExit();
final KmlWriter writer = new KmlWriter();
final GxWriter gxWriter = new GxWriter(writer);
writer.setOutput(temp);
writer.addExtensionWriter(GxConstants.URI_GX, gxWriter);
writer.write(kml);
writer.dispose();
DomCompare.compare(new File(pathToTestFile), temp);
}
use of org.geotoolkit.data.kml.model.Kml in project geotoolkit by Geomatys.
the class TrackTest method trackReadTest.
@Test
public void trackReadTest() 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 folder = kmlObjects.getAbstractFeature();
assertEquals(KmlModelConstants.TYPE_FOLDER, folder.getType());
Feature placemark = (Feature) ((List) folder.getPropertyValue(KmlConstants.TAG_FEATURES)).get(0);
assertEquals(KmlModelConstants.TYPE_PLACEMARK, placemark.getType());
final Track track = (Track) placemark.getPropertyValue(KmlConstants.TAG_GEOMETRY);
assertEquals(2, track.getWhens().size());
assertEquals(2, track.getCoord().size());
String when0 = "2010-05-28T02:02:09Z";
String when1 = "2010-05-28T02:02:35Z";
ISODateParser du = new ISODateParser();
Calendar cal = du.getCalendar(when0);
assertEquals(cal, track.getWhens().get(0));
cal = du.getCalendar(when1);
assertEquals(cal, track.getWhens().get(1));
CoordinateSequence coordinates = track.getCoord();
Coordinate coordinate0 = coordinates.getCoordinate(0);
Coordinate coordinate1 = coordinates.getCoordinate(1);
assertEquals(-122.207881, coordinate0.x, DELTA);
assertEquals(37.371915, coordinate0.y, DELTA);
assertEquals(156, coordinate0.z, DELTA);
assertEquals(-122.205712, coordinate1.x, DELTA);
assertEquals(37.373288, coordinate1.y, DELTA);
assertEquals(152, coordinate1.z, DELTA);
assertEquals(2, track.getAngles().size());
Angles angles0 = track.getAngles().get(0);
assertEquals(45.54676, angles0.getHeading(), DELTA);
assertEquals(66.2342, angles0.getTilt(), DELTA);
assertEquals(77, angles0.getRoll(), DELTA);
Angles angles1 = track.getAngles().get(1);
assertEquals(46.54676, angles1.getHeading(), DELTA);
assertEquals(67.2342, angles1.getTilt(), DELTA);
assertEquals(78, angles1.getRoll(), DELTA);
}
Aggregations