예제 #1
0
  private GeoServerTileLayer mockTileLayer(String layerName, List<String> gridSetNames)
      throws Exception {

    GeoServerTileLayer tileLayer = mock(GeoServerTileLayer.class);
    when(tld.layerExists(eq(layerName))).thenReturn(true);
    when(tld.getTileLayer(eq(layerName))).thenReturn(tileLayer);
    when(tileLayer.getName()).thenReturn(layerName);
    when(tileLayer.isEnabled()).thenReturn(true);

    final MimeType mimeType1 = MimeType.createFromFormat("image/png");
    final MimeType mimeType2 = MimeType.createFromFormat("image/jpeg");
    when(tileLayer.getMimeTypes()).thenReturn(ImmutableList.of(mimeType1, mimeType2));

    Map<String, GridSubset> subsets = Maps.newHashMap();
    Multimap<SRS, GridSubset> bySrs = LinkedHashMultimap.create();

    GridSetBroker broker = gridSetBroker;

    for (String gsetName : gridSetNames) {
      GridSet gridSet = broker.get(gsetName);
      XMLGridSubset xmlGridSubset = new XMLGridSubset();
      String gridSetName = gridSet.getName();
      xmlGridSubset.setGridSetName(gridSetName);
      GridSubset gridSubSet = xmlGridSubset.getGridSubSet(broker);
      subsets.put(gsetName, gridSubSet);
      bySrs.put(gridSet.getSrs(), gridSubSet);

      when(tileLayer.getGridSubset(eq(gsetName))).thenReturn(gridSubSet);
    }
    for (SRS srs : bySrs.keySet()) {
      List<GridSubset> list = ImmutableList.copyOf(bySrs.get(srs));
      when(tileLayer.getGridSubsetsForSRS(eq(srs))).thenReturn(list);
    }
    when(tileLayer.getGridSubsets()).thenReturn(subsets.keySet());

    // sanity check
    for (String gsetName : gridSetNames) {
      assertTrue(tileLayer.getGridSubsets().contains(gsetName));
      assertNotNull(tileLayer.getGridSubset(gsetName));
    }

    return tileLayer;
  }
예제 #2
0
 private void tileMatrixSet(StringBuilder str, GridSet gridSet) {
   str.append("  <TileMatrixSet>\n");
   str.append("    <ows:Identifier>" + gridSet.getName() + "</ows:Identifier>\n");
   // If the following is not good enough, please get in touch and we will try to fix it :)
   str.append(
       "    <ows:SupportedCRS>urn:ogc:def:crs:EPSG::"
           + gridSet.getSrs().getNumber()
           + "</ows:SupportedCRS>\n");
   // TODO detect these str.append("
   // <WellKnownScaleSet>urn:ogc:def:wkss:GlobalCRS84Pixel</WellKnownScaleSet>\n");
   Grid[] grids = gridSet.getGrids();
   for (int i = 0; i < grids.length; i++) {
     double[] tlCoordinates = gridSet.getOrderedTopLeftCorner(i);
     tileMatrix(
         str,
         grids[i],
         tlCoordinates,
         gridSet.getTileWidth(),
         gridSet.getTileHeight(),
         gridSet.isScaleWarning());
   }
   str.append("  </TileMatrixSet>\n");
 }