Search in sources :

Example 46 with Placemark

use of de.micromata.opengis.kml.v_2_2_0.Placemark in project ddf by codice.

the class KmlMarshallerTest method unmarshall.

@Test
public void unmarshall() {
    final InputStream resourceAsStream = this.getClass().getResourceAsStream("/kmlPoint.kml");
    final Kml kml = kmlMarshaller.unmarshal(resourceAsStream).get();
    final Feature feature = kml.getFeature();
    assertThat(feature.getName(), is("Simple placemark"));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Feature(de.micromata.opengis.kml.v_2_2_0.Feature) Test(org.junit.Test)

Example 47 with Placemark

use of de.micromata.opengis.kml.v_2_2_0.Placemark in project ddf by codice.

the class KmlMarshallerTest method marshall.

@Test
public void marshall() throws SAXException, IOException, XpathException {
    Placemark placemark = new Placemark();
    placemark.setName("a");
    Kml kml = new Kml();
    kml.setFeature(placemark);
    final String kmlString = kmlMarshaller.marshal(kml);
    assertXpathExists("/m:kml", kmlString);
    assertXpathEvaluatesTo("a", "//m:Placemark/m:name", kmlString);
}
Also used : Placemark(de.micromata.opengis.kml.v_2_2_0.Placemark) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Test(org.junit.Test)

Example 48 with Placemark

use of de.micromata.opengis.kml.v_2_2_0.Placemark in project ddf by codice.

the class KmlMarshallerTest method unmarshallEmptyStream.

@Test(expected = NoSuchElementException.class)
public void unmarshallEmptyStream() {
    final ByteArrayInputStream inputStream = new ByteArrayInputStream("".getBytes(UTF_8));
    final Kml kml = kmlMarshaller.unmarshal(inputStream).get();
    final Feature feature = kml.getFeature();
    assertThat(feature.getName(), is("Simple placemark"));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Feature(de.micromata.opengis.kml.v_2_2_0.Feature) Test(org.junit.Test)

Example 49 with Placemark

use of de.micromata.opengis.kml.v_2_2_0.Placemark in project ddf by codice.

the class KmlTransformations method encloseDoc.

/**
 * Encapsulate the kml content (placemarks, etc.) with a style in a KML Document element. If
 * either content or style are not null, they will be in the resulting Document
 *
 * @param kml
 * @param style
 * @param documentId which should be the metacard id
 * @return KML DocumentType element with style and content
 */
public static Document encloseDoc(Placemark placemark, Style style, String documentId, String docName) {
    Document document = KmlFactory.createDocument();
    document.setId(documentId);
    document.setOpen(true);
    document.setName(docName);
    if (style != null) {
        document.getStyleSelector().add(style);
    }
    if (placemark != null) {
        document.getFeature().add(placemark);
    }
    return document;
}
Also used : Document(de.micromata.opengis.kml.v_2_2_0.Document)

Aggregations

Placemark (de.micromata.opengis.kml.v_2_2_0.Placemark)35 Test (org.junit.Test)29 Kml (de.micromata.opengis.kml.v_2_2_0.Kml)23 InputStream (java.io.InputStream)20 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)19 Point (de.micromata.opengis.kml.v_2_2_0.Point)19 TimeSpan (de.micromata.opengis.kml.v_2_2_0.TimeSpan)16 MultiGeometry (de.micromata.opengis.kml.v_2_2_0.MultiGeometry)15 LineString (de.micromata.opengis.kml.v_2_2_0.LineString)12 Polygon (de.micromata.opengis.kml.v_2_2_0.Polygon)10 BeforeClass (org.junit.BeforeClass)8 LinearRing (de.micromata.opengis.kml.v_2_2_0.LinearRing)5 Document (de.micromata.opengis.kml.v_2_2_0.Document)4 Feature (de.micromata.opengis.kml.v_2_2_0.Feature)4 Style (de.micromata.opengis.kml.v_2_2_0.Style)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 IOException (java.io.IOException)4 ProfilePlacemark (se.trixon.mapollage.profile.ProfilePlacemark)4 BalloonStyle (de.micromata.opengis.kml.v_2_2_0.BalloonStyle)3 IconStyle (de.micromata.opengis.kml.v_2_2_0.IconStyle)3