Search in sources :

Example 56 with Kml

use of de.micromata.opengis.kml.v_2_2_0.Kml 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 57 with Kml

use of de.micromata.opengis.kml.v_2_2_0.Kml 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 58 with Kml

use of de.micromata.opengis.kml.v_2_2_0.Kml 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 59 with Kml

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

the class KmlTransformations method encloseKml.

/**
 * Wrap KML document with the opening and closing kml tags
 *
 * @param document
 * @param folderId which should be the subscription id if it exists
 * @return completed KML
 */
public static Kml encloseKml(Document doc, String docId, String docName) {
    Kml kml = KmlFactory.createKml();
    if (doc != null) {
        kml.setFeature(doc);
        // Id should be subscription id
        doc.setId(docId);
        doc.setName(docName);
        doc.setOpen(false);
    }
    return kml;
}
Also used : Kml(de.micromata.opengis.kml.v_2_2_0.Kml)

Example 60 with Kml

use of de.micromata.opengis.kml.v_2_2_0.Kml 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

Kml (de.micromata.opengis.kml.v_2_2_0.Kml)53 InputStream (java.io.InputStream)34 Test (org.junit.Test)31 Placemark (de.micromata.opengis.kml.v_2_2_0.Placemark)15 BeforeClass (org.junit.BeforeClass)13 NetworkLink (de.micromata.opengis.kml.v_2_2_0.NetworkLink)10 Folder (de.micromata.opengis.kml.v_2_2_0.Folder)9 Geometry (org.locationtech.jts.geom.Geometry)8 Document (de.micromata.opengis.kml.v_2_2_0.Document)7 MetacardImpl (ddf.catalog.data.impl.MetacardImpl)6 Metacard (ddf.catalog.data.Metacard)4 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)4 LinearRing (de.micromata.opengis.kml.v_2_2_0.LinearRing)4 MultiGeometry (de.micromata.opengis.kml.v_2_2_0.MultiGeometry)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 IOException (java.io.IOException)4 UriBuilder (javax.ws.rs.core.UriBuilder)4 Handlebars (com.github.jknack.handlebars.Handlebars)3 Template (com.github.jknack.handlebars.Template)3 Feature (de.micromata.opengis.kml.v_2_2_0.Feature)3