예제 #1
0
  /** @see {@link KMLReflector#organizeFormatOptionsParams(Map, Map)} */
  @Test
  public void testKmlFormatOptionsAsKVP() throws Exception {
    final String layerName =
        MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart();

    final String baseUrl = "wms/kml?layers=" + layerName + "&styles=&mode=superoverlay";
    final String requestUrl =
        baseUrl + "&kmltitle=myCustomLayerTitle&kmscore=10&legend=true&kmattr=true";
    Document dom = getAsDOM(requestUrl);
    XpathEngine xpath = XMLUnit.newXpathEngine();

    // print(dom);
    // all the kvp parameters (which should be set as format_options now are correctly parsed)
    String result = xpath.evaluate("//kml:NetworkLink/kml:Link/kml:href", dom);
    Map<String, Object> kvp = KvpUtils.parseQueryString(result);
    List<String> formatOptions = Arrays.asList(((String) kvp.get("format_options")).split(";"));
    assertEquals(9, formatOptions.size());
    assertTrue(formatOptions.contains("LEGEND:true"));
    assertTrue(formatOptions.contains("SUPEROVERLAY:true"));
    assertTrue(formatOptions.contains("AUTOFIT:true"));
    assertTrue(formatOptions.contains("KMPLACEMARK:false"));
    assertTrue(formatOptions.contains("OVERLAYMODE:auto"));
    assertTrue(formatOptions.contains("KMSCORE:10"));
    assertTrue(formatOptions.contains("MODE:superoverlay"));
    assertTrue(formatOptions.contains("KMATTR:true"));
    assertTrue(formatOptions.contains("KMLTITLE:myCustomLayerTitle"));
  }
예제 #2
0
  @Test
  public void testGML3() throws Exception {
    Document dom =
        getAsDOM(
            "wfs?request=getfeature&version=1.0.0&outputFormat=gml3&typename="
                + MockData.BASIC_POLYGONS.getPrefix()
                + ":"
                + MockData.BASIC_POLYGONS.getLocalPart());
    assertEquals("FeatureCollection", dom.getDocumentElement().getLocalName());
    assertNull(getFirstElementByTagName(dom, "gml:outerBoundaryIs"));
    assertNotNull(getFirstElementByTagName(dom, "gml:exterior"));

    dom =
        getAsDOM(
            "wfs?request=getfeature&version=1.1.0&outputFormat=gml3&typename="
                + MockData.BASIC_POLYGONS.getPrefix()
                + ":"
                + MockData.BASIC_POLYGONS.getLocalPart());
    assertEquals("FeatureCollection", dom.getDocumentElement().getLocalName());
    assertNull(getFirstElementByTagName(dom, "gml:outerBoundaryIs"));
    assertNotNull(getFirstElementByTagName(dom, "gml:exterior"));

    dom =
        getAsDOM(
            "wfs?request=getfeature&version=1.0.0&outputFormat=text/xml; subtype%3Dgml/3.1.1&typename="
                + MockData.BASIC_POLYGONS.getPrefix()
                + ":"
                + MockData.BASIC_POLYGONS.getLocalPart());
    assertEquals("FeatureCollection", dom.getDocumentElement().getLocalName());
    assertNull(getFirstElementByTagName(dom, "gml:outerBoundaryIs"));
    assertNotNull(getFirstElementByTagName(dom, "gml:exterior"));

    dom =
        getAsDOM(
            "wfs?request=getfeature&version=1.1.0&outputFormat=text/xml; subtype%3Dgml/3.1.1&typename="
                + MockData.BASIC_POLYGONS.getPrefix()
                + ":"
                + MockData.BASIC_POLYGONS.getLocalPart());
    assertEquals("FeatureCollection", dom.getDocumentElement().getLocalName());
    assertNull(getFirstElementByTagName(dom, "gml:outerBoundaryIs"));
    assertNotNull(getFirstElementByTagName(dom, "gml:exterior"));
  }
예제 #3
0
 @Test
 public void testGML32() throws Exception {
   Document dom =
       getAsDOM(
           "wfs?request=getfeature&version=2.0.0&outputFormat=gml32&typename="
               + MockData.BASIC_POLYGONS.getPrefix()
               + ":"
               + MockData.BASIC_POLYGONS.getLocalPart());
   assertEquals(WFS.NAMESPACE, dom.getDocumentElement().getNamespaceURI());
   assertEquals("FeatureCollection", dom.getDocumentElement().getLocalName());
 }
예제 #4
0
  /** Do some spot checks on the KML generated when an overlay hierarchy is requested. */
  @Test
  public void testSuperOverlayReflection() throws Exception {
    final String layerName =
        MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart();

    final String requestUrl = "wms/kml?layers=" + layerName + "&styles=&mode=superoverlay";
    Document dom = getAsDOM(requestUrl);
    // print(dom);
    assertEquals("kml", dom.getDocumentElement().getLocalName());
    assertXpathExists("kml:kml/kml:Document/kml:Folder/kml:NetworkLink/kml:Link/kml:href", dom);
    assertXpathExists("kml:kml/kml:Document/kml:LookAt/kml:longitude", dom);
  }
예제 #5
0
  @Test
  public void testKmlTitleFormatOption() throws Exception {
    final String layerName =
        MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart();

    final String requestUrl =
        "wms/kml?layers="
            + layerName
            + "&styles=&mode=superoverlay&format_options=kmltitle:myCustomLayerTitle";
    // System.out.println(getAsServletResponse(requestUrl).getContentType());
    Document dom = getAsDOM(requestUrl);
    // print(dom);
    assertEquals("kml", dom.getDocumentElement().getLocalName());
    assertXpathEvaluatesTo("myCustomLayerTitle", "/kml:kml/kml:Document/kml:name", dom);
  }
예제 #6
0
  public void testVectorScaleRange() throws Exception {
    Document doc =
        getAsDOM(
            "wms?request=getmap&service=wms&version=1.1.1"
                + "&format="
                + KMLMapOutputFormat.MIME_TYPE
                + "&layers="
                + MockData.BASIC_POLYGONS.getPrefix()
                + ":"
                + MockData.BASIC_POLYGONS.getLocalPart()
                + "&styles=scaleRange&height=1024&width=1024&bbox=-180,-90,180,90&srs=EPSG:4326");

    assertEquals(
        getFeatureSource(MockData.BASIC_POLYGONS).getFeatures().size(),
        doc.getElementsByTagName("Placemark").getLength());
  }
예제 #7
0
 public void testContentDisposition() throws Exception {
   MockHttpServletResponse resp =
       getAsServletResponse(
           "wms?request=getmap&service=wms&version=1.1.1"
               + "&format="
               + KMZMapOutputFormat.MIME_TYPE
               + "&layers="
               + MockData.BASIC_POLYGONS.getPrefix()
               + ":"
               + MockData.BASIC_POLYGONS.getLocalPart()
               + "&styles="
               + MockData.BASIC_POLYGONS.getLocalPart()
               + "&height=1024&width=1024&bbox=-180,-90,180,90&srs=EPSG:4326");
   assertEquals(
       "attachment; filename=cite-BasicPolygons.kmz", resp.getHeader("Content-Disposition"));
 }
예제 #8
0
  public void testVectorWithFeatureId() throws Exception {
    Document doc =
        getAsDOM(
            "wms?request=getmap&service=wms&version=1.1.1"
                + "&format="
                + KMLMapOutputFormat.MIME_TYPE
                + "&layers="
                + MockData.BASIC_POLYGONS.getPrefix()
                + ":"
                + MockData.BASIC_POLYGONS.getLocalPart()
                + "&styles="
                + MockData.BASIC_POLYGONS.getLocalPart()
                + "&height=1024&width=1024&bbox=-180,-90,180,90&srs=EPSG:4326"
                + "&featureid=BasicPolygons.1107531493643");

    assertEquals(1, doc.getElementsByTagName("Placemark").getLength());
  }
예제 #9
0
  @Test
  public void testKmlVisibleFormatOption() throws Exception {
    final String layerName =
        MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart();

    String requestUrl = "wms/kml?layers=" + layerName + "&format_options=kmlvisible:true";
    Document dom = getAsDOM(requestUrl);

    // print(dom);
    assertEquals("kml", dom.getDocumentElement().getLocalName());
    assertXpathEvaluatesTo("1", "/kml:kml/kml:Document/kml:NetworkLink/kml:visibility", dom);

    requestUrl = "wms/kml?layers=" + layerName + "&format_options=kmlvisible:false";
    dom = getAsDOM(requestUrl);
    assertEquals("kml", dom.getDocumentElement().getLocalName());
    assertXpathEvaluatesTo("0", "/kml:kml/kml:Document/kml:NetworkLink/kml:visibility", dom);
  }
예제 #10
0
  @Test
  public void testWmsRepeatedLayerWithNonStandardStyleAndCqlFiler() throws Exception {
    final String layerName =
        MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart();
    final String titleName = MockData.BASIC_POLYGONS.getLocalPart();
    final String abstractValue = "abstract about " + titleName;

    String requestUrl =
        "wms/kml?mode=refresh&layers="
            + layerName
            + ","
            + layerName
            + "&styles=Default,Default&cql_filter=att1<10;att1>1000";
    Document dom = getAsDOM(requestUrl);

    assertEquals("kml", dom.getDocumentElement().getLocalName());

    assertXpathEvaluatesTo("2", "count(kml:kml/kml:Document/kml:NetworkLink)", dom);
    assertXpathEvaluatesTo(titleName, "kml:kml/kml:Document/kml:NetworkLink[1]/kml:name", dom);
    assertXpathEvaluatesTo(
        abstractValue, "kml:kml/kml:Document/kml:NetworkLink[1]/kml:description", dom);
    assertXpathEvaluatesTo(titleName, "kml:kml/kml:Document/kml:NetworkLink[2]/kml:name", dom);
    assertXpathEvaluatesTo(
        abstractValue, "kml:kml/kml:Document/kml:NetworkLink[2]/kml:description", dom);

    XpathEngine xpath = XMLUnit.newXpathEngine();

    String url1 = xpath.evaluate("/kml:kml/kml:Document/kml:NetworkLink[1]/kml:Url/kml:href", dom);
    String url2 = xpath.evaluate("/kml:kml/kml:Document/kml:NetworkLink[2]/kml:Url/kml:href", dom);

    assertNotNull(url1);
    assertNotNull(url2);

    Map<String, Object> kvp1 = KvpUtils.parseQueryString(url1);
    Map<String, Object> kvp2 = KvpUtils.parseQueryString(url2);

    assertEquals(layerName, kvp1.get("layers"));
    assertEquals(layerName, kvp2.get("layers"));

    assertEquals("Default", kvp1.get("styles"));
    assertEquals("Default", kvp2.get("styles"));

    assertEquals("att1<10", kvp1.get("cql_filter"));
    assertEquals("att1>1000", kvp2.get("cql_filter"));
  }
예제 #11
0
  @Test
  public void testKmlRefreshFormatOption() throws Exception {
    final String layerName =
        MockData.BASIC_POLYGONS.getPrefix() + ":" + MockData.BASIC_POLYGONS.getLocalPart();

    String requestUrl = "wms/kml?layers=" + layerName + "&format_options=kmlrefresh:expires";
    Document dom = getAsDOM(requestUrl);

    // print(dom);
    assertEquals("kml", dom.getDocumentElement().getLocalName());
    assertXpathEvaluatesTo(
        "onExpire", "/kml:kml/kml:Document/kml:NetworkLink/kml:Url/kml:refreshMode", dom);

    requestUrl = "wms/kml?layers=" + layerName + "&format_options=kmlrefresh:60";
    dom = getAsDOM(requestUrl);
    assertXpathEvaluatesTo(
        "onInterval", "/kml:kml/kml:Document/kml:NetworkLink/kml:Url/kml:refreshMode", dom);
    assertXpathEvaluatesTo(
        "60.0", "/kml:kml/kml:Document/kml:NetworkLink/kml:Url/kml:refreshInterval", dom);
  }