Пример #1
0
  /*
   * Generates xml for View-based Network Link
   *
   * @param networkLinkUrl - url to set as the Link href.
   *
   * @return Networklink
   */
  private NetworkLink generateViewBasedNetworkLink(URL networkLinkUrl, String sourceId) {
    // create network link and give it a name
    NetworkLink networkLink = KmlFactory.createNetworkLink();
    networkLink.setName(sourceId);
    networkLink.setOpen(true);
    networkLink.setVisibility(this.visibleByDefault);

    // create link and add it to networkLinkElements
    Link link = networkLink.createAndSetLink();
    LOGGER.debug("View Based Network Link href: {}", networkLinkUrl.toString());
    link.setHref(networkLinkUrl.toString());
    link.setViewRefreshMode(ViewRefreshMode.ON_STOP);
    link.setViewRefreshTime(DEFAULT_VIEW_REFRESH_TIME);
    link.setViewFormat(VIEW_FORMAT_STRING);
    link.setViewBoundScale(1);
    link.setHttpQuery(COUNT_PARAM + maxResults);

    return networkLink;
  }
Пример #2
0
  private Kml createRootNetworkLink(UriInfo uriInfo) throws UnknownHostException {
    Kml kml = KmlFactory.createKml();
    NetworkLink rootNetworkLink = kml.createAndSetNetworkLink();

    rootNetworkLink.setName(this.productName);
    rootNetworkLink.setSnippet(KmlFactory.createSnippet().withMaxLines(0));
    UriBuilder baseUrlBuidler = UriBuilder.fromUri(uriInfo.getBaseUri());
    baseUrlBuidler.replacePath("");
    this.baseUrl = baseUrlBuidler.build().toString();
    String descriptionHtml = description;
    Handlebars handlebars = new Handlebars(templateLoader);
    try {
      Template template = handlebars.compile("description");
      descriptionHtml = template.apply(this);
      LOGGER.debug(descriptionHtml);
    } catch (IOException e) {
      LOGGER.error("Failed to apply description Template", e);
    }
    rootNetworkLink.setDescription(descriptionHtml);
    rootNetworkLink.setOpen(true);
    rootNetworkLink.setVisibility(false);
    Link link = rootNetworkLink.createAndSetLink();
    UriBuilder builder = UriBuilder.fromUri(uriInfo.getBaseUri());
    builder =
        generateEndpointUrl(
            servicesContextRoot
                + FORWARD_SLASH
                + CATALOG_URL_PATH
                + FORWARD_SLASH
                + KML_TRANSFORM_PARAM
                + FORWARD_SLASH
                + "sources",
            builder);
    link.setHref(builder.build().toString());
    link.setViewRefreshMode(ViewRefreshMode.NEVER);
    link.setRefreshMode(RefreshMode.ON_INTERVAL);
    link.setRefreshInterval(REFRESH_INTERVAL);

    return kml;
  }