Search in sources :

Example 11 with Kml

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

the class TestKmlEndpoint method testGetAvailableSourcesVisibleByDefault.

@Test
public void testGetAvailableSourcesVisibleByDefault() throws UnknownHostException, MalformedURLException, IllegalArgumentException, UriBuilderException, SourceUnavailableException {
    when(mockUriInfo.getQueryParameters(false)).thenReturn(mockMap);
    KmlEndpoint kmlEndpoint = new KmlEndpoint(mockBranding, mockFramework);
    Kml response = kmlEndpoint.getAvailableSources(mockUriInfo);
    assertThat(response, notNullValue());
    assertThat(response.getFeature(), instanceOf(Folder.class));
    Folder folder = (Folder) response.getFeature();
    assertThat(folder.getFeature(), notNullValue());
    assertThat(folder.getFeature().size(), is(2));
    assertThat(folder.getFeature().get(0), instanceOf(NetworkLink.class));
    assertThat(folder.getFeature().get(1), instanceOf(NetworkLink.class));
    NetworkLink nl1 = (NetworkLink) folder.getFeature().get(0);
    assertThat(nl1.getName(), anyOf(is(REMOTE_SITE_NAME), is(LOCAL_SITE_NAME)));
    assertThat(nl1.isVisibility(), is(false));
    NetworkLink nl2 = (NetworkLink) folder.getFeature().get(1);
    assertThat(nl2.getName(), anyOf(is(REMOTE_SITE_NAME), is(LOCAL_SITE_NAME)));
    assertThat(nl2.isVisibility(), is(false));
}
Also used : NetworkLink(de.micromata.opengis.kml.v_2_2_0.NetworkLink) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Folder(de.micromata.opengis.kml.v_2_2_0.Folder) Test(org.junit.Test)

Example 12 with Kml

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

the class KMLTransformerImpl method encloseDoc.

/**
     * Encapsulate the kml content (placemarks, etc.) with a style in a KML Document element If
     * either content or style are 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) throws IllegalArgumentException {
    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)

Example 13 with Kml

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

the class TestKmlEndpoint method testGetAvailableSources.

@Test
public void testGetAvailableSources() throws UnknownHostException, MalformedURLException, IllegalArgumentException, UriBuilderException, SourceUnavailableException {
    when(mockUriInfo.getQueryParameters(false)).thenReturn(mockMap);
    KmlEndpoint kmlEndpoint = new KmlEndpoint(mockBranding, mockFramework);
    Kml response = kmlEndpoint.getAvailableSources(mockUriInfo);
    assertThat(response, notNullValue());
    assertThat(response.getFeature(), instanceOf(Folder.class));
    Folder folder = (Folder) response.getFeature();
    assertThat(folder.getFeature(), notNullValue());
    assertThat(folder.getFeature().size(), is(2));
    assertThat(folder.getFeature().get(0), instanceOf(NetworkLink.class));
    assertThat(folder.getFeature().get(1), instanceOf(NetworkLink.class));
    NetworkLink nl1 = (NetworkLink) folder.getFeature().get(0);
    assertThat(nl1.getName(), anyOf(is(REMOTE_SITE_NAME), is(LOCAL_SITE_NAME)));
    NetworkLink nl2 = (NetworkLink) folder.getFeature().get(1);
    assertThat(nl2.getName(), anyOf(is(REMOTE_SITE_NAME), is(LOCAL_SITE_NAME)));
}
Also used : NetworkLink(de.micromata.opengis.kml.v_2_2_0.NetworkLink) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Folder(de.micromata.opengis.kml.v_2_2_0.Folder) Test(org.junit.Test)

Aggregations

Kml (de.micromata.opengis.kml.v_2_2_0.Kml)9 NetworkLink (de.micromata.opengis.kml.v_2_2_0.NetworkLink)6 LineString (com.vividsolutions.jts.geom.LineString)4 CatalogTransformerException (ddf.catalog.transform.CatalogTransformerException)4 Folder (de.micromata.opengis.kml.v_2_2_0.Folder)4 Test (org.junit.Test)4 Placemark (de.micromata.opengis.kml.v_2_2_0.Placemark)3 IOException (java.io.IOException)3 UriBuilder (javax.ws.rs.core.UriBuilder)3 Handlebars (com.github.jknack.handlebars.Handlebars)2 Template (com.github.jknack.handlebars.Template)2 BinaryContentImpl (ddf.catalog.data.impl.BinaryContentImpl)2 Document (de.micromata.opengis.kml.v_2_2_0.Document)2 Geometry (de.micromata.opengis.kml.v_2_2_0.Geometry)2 Link (de.micromata.opengis.kml.v_2_2_0.Link)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 GeometryCollection (com.vividsolutions.jts.geom.GeometryCollection)1 Point (com.vividsolutions.jts.geom.Point)1 Polygon (com.vividsolutions.jts.geom.Polygon)1