use of org.geotoolkit.data.kml.xml.KmlReader in project geotoolkit by Geomatys.
the class BalloonStyleTest method balloonStyleReadTest.
@Test
public void balloonStyleReadTest() throws IOException, XMLStreamException, URISyntaxException, KmlException {
final Feature document;
{
final KmlReader reader = new KmlReader();
reader.setInput(new File(pathToTestFile));
final Kml kmlObjects = reader.read();
reader.dispose();
document = kmlObjects.getAbstractFeature();
}
assertEquals(KmlModelConstants.TYPE_DOCUMENT, document.getType());
assertEquals("BalloonStyle.kml", document.getPropertyValue(KmlConstants.TAG_NAME));
assertEquals(Boolean.TRUE, document.getPropertyValue(KmlConstants.TAG_OPEN));
Iterator<?> i = ((Iterable<?>) document.getPropertyValue(KmlConstants.TAG_STYLE_SELECTOR)).iterator();
assertTrue("Expected at least one element.", i.hasNext());
final Style style = (Style) i.next();
assertEquals("exampleBalloonStyle", style.getIdAttributes().getId());
final BalloonStyle balloonStyle = style.getBalloonStyle();
assertEquals(new Color(187, 255, 255, 255), balloonStyle.getBgColor());
final Cdata text = new DefaultCdata("\n" + " <b><font color=\"#CC0000\" size=\"+3\">$[name]</font></b>\n" + " <br/><br/>\n" + " <font face=\"Courier\">$[description]</font>\n" + " <br/><br/>\n" + " Extra text that will appear in the description balloon\n" + " <br/><br/>\n" + " $[geDirections]\n" + " ");
assertEquals(text, balloonStyle.getText());
assertFalse("Expected exactly one element.", i.hasNext());
i = ((Iterable<?>) document.getPropertyValue(KmlConstants.TAG_FEATURES)).iterator();
assertTrue("Expected at least one element.", i.hasNext());
Feature placemark = (Feature) i.next();
assertEquals(KmlModelConstants.TYPE_PLACEMARK, placemark.getType());
assertEquals("BalloonStyle", placemark.getPropertyValue(KmlConstants.TAG_NAME));
assertEquals("An example of BalloonStyle", placemark.getPropertyValue(KmlConstants.TAG_DESCRIPTION));
assertEquals(new URI("#exampleBalloonStyle"), placemark.getPropertyValue(KmlConstants.TAG_STYLE_URL));
final Point point = (Point) placemark.getPropertyValue(KmlConstants.TAG_GEOMETRY);
final CoordinateSequence coordinates = point.getCoordinateSequence();
assertEquals(1, coordinates.size());
final Coordinate coordinate = coordinates.getCoordinate(0);
assertEquals(-122.370533, coordinate.x, DELTA);
assertEquals(37.823842, coordinate.y, DELTA);
assertEquals(0, coordinate.z, DELTA);
assertFalse("Expected exactly one element.", i.hasNext());
}
use of org.geotoolkit.data.kml.xml.KmlReader in project geotoolkit by Geomatys.
the class CameraTest method cameraReadTest.
@Test
public void cameraReadTest() throws IOException, XMLStreamException, KmlException, URISyntaxException {
final KmlReader reader = new KmlReader();
reader.setInput(new File(pathToTestFile));
final Kml kmlObjects = reader.read();
reader.dispose();
final Feature feature = kmlObjects.getAbstractFeature();
assertEquals(KmlModelConstants.TYPE_PHOTO_OVERLAY, feature.getType());
final Camera camera = (Camera) feature.getPropertyValue(KmlConstants.TAG_VIEW);
assertEquals(4, camera.getLongitude(), DELTA);
assertEquals(43, camera.getLatitude(), DELTA);
assertEquals(625, camera.getAltitude(), DELTA);
assertEquals(2, camera.getHeading(), DELTA);
assertEquals(1, camera.getTilt(), DELTA);
assertEquals(2, camera.getRoll(), DELTA);
assertEquals(EnumAltitudeMode.RELATIVE_TO_GROUND, camera.getAltitudeMode());
}
Aggregations