Package org.geomajas.layer.tile

Examples of org.geomajas.layer.tile.TileMetadata


  }

  @Test
  public void testGetTile() throws Exception {
    InternalTile tile;
    TileMetadata tmd = new GetVectorTileRequest();
    tmd.setCrs("EPSG:4326");
    tmd.setCode(new TileCode(1,0,1));
    tmd.setLayerId(LAYER_BEANS);
    tmd.setRenderer(TileMetadata.PARAM_SVG_RENDERER);
    tmd.setScale(1.0);
    tmd.setPanOrigin(new Coordinate(0, 0));

    // first run, this should put things in the cache
    recorder.clear();
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
    Assert.assertEquals("<g id=\"beans.features.1-0-1\"/>", tile.getFeatureContent());
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));

    // verify that data is in the cache
    DummyCacheService cache = (DummyCacheService) cacheManager.getCacheForTesting(LAYER_BEANS, CacheCategory.TILE);
    Assert.assertEquals(1, cache.size());
    TileCacheContainer tcc = (TileCacheContainer) cache.getObject();
    tcc.getTile().setFeatureContent("<dummy />");

    // get tile again, the result should be different because we changed the cached value
    recorder.clear();
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
    Assert.assertEquals("<dummy />", tile.getFeatureContent());
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Got item from cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE));

    // ask for different layer, should not be found in cache as context is different
    recorder.clear();
    tmd.setLayerId(LAYER_COUNTRIES);
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
    //Assert.assertEquals(4, features.size());
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));
View Full Code Here


  }

  @Test
  public void testGetTileCheckFeatureStringCache() throws Exception {
    InternalTile tile;
    TileMetadata tmd = new GetVectorTileRequest();
    tmd.setCrs("EPSG:4326");
    tmd.setCode(new TileCode(1,0,1));
    tmd.setLayerId(LAYER_BEANS);
    tmd.setRenderer(TileMetadata.PARAM_SVG_RENDERER);
    tmd.setScale(1.0);
    tmd.setPanOrigin(new Coordinate(0, 0));

    // first run, this should put things in the cache
    recorder.clear();
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
View Full Code Here

          log.error("Data to rebuild the raster image is no longer available for key " + key);
          response.sendError(HttpServletResponse.SC_NO_CONTENT);
          return;
        }
        recorder.record(CacheCategory.REBUILD, "Got rebuild info from cache");
        TileMetadata tileMetadata = rebuildCacheContainer.getMetadata();
        context.put(PipelineCode.TILE_METADATA_KEY, tileMetadata);
        Crs crs = geoService.getCrs2(tileMetadata.getCrs());
        context.put(PipelineCode.CRS_KEY, crs);
        CrsTransform layerToMap = geoService.getCrsTransform(layer.getCrs(), crs);
        context.put(PipelineCode.CRS_TRANSFORM_KEY, layerToMap);
        Envelope layerExtent = dtoConverterService.toInternal(layer.getLayerInfo().getMaxExtent());
        Envelope tileExtent = geoService.transform(layerExtent, layerToMap);
        context.put(PipelineCode.TILE_MAX_EXTENT_KEY, tileExtent);
        // can't stop here, we have only prepared the context, not built the tile !
        InternalTile tile = new InternalTileImpl(tileMetadata.getCode(), tileExtent, tileMetadata.getScale());
        tileContainer.setTile(tile);
        securityContextAdder.restoreSecurityContext(rebuildCacheContainer.getContext());

        pipelineService.execute(RasterizingPipelineCode.PIPELINE_GET_VECTOR_TILE_RASTERIZING, layerId, context,
            tileContainer);
View Full Code Here

   * @throws Exception oops
   */
  @Test
  public void testGetTileWithTransformationCheckFeatureCache() throws Exception {
    InternalTile tile;
    TileMetadata tmd = new GetVectorTileRequest();
    tmd.setCrs("EPSG:900913");
    tmd.setCode(new TileCode(1,1,1));
    tmd.setLayerId(LAYER_BEANS);
    tmd.setRenderer(TileMetadata.PARAM_SVG_RENDERER);
    tmd.setScale(1.0);
    tmd.setPanOrigin(new Coordinate(0, 0));

    // first run, this should put things in the cache
    recorder.clear();
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
View Full Code Here

  }

  @Test
  public void testGetTile() throws Exception {
    InternalTile tile;
    TileMetadata tileMetadata = new GetVectorTileRequest();
    tileMetadata.setCode(new TileCode(2, 1, 1));
    tileMetadata.setCrs(beanLayer.getLayerInfo().getCrs());
    tileMetadata.setLayerId(LAYER_ID);
    tileMetadata.setRenderer(TileMetadata.PARAM_SVG_RENDERER);
    tileMetadata.setScale(1);
    tileMetadata.setPanOrigin(new Coordinate(0,0));

    login("luc");
    recorder.clear();
    tile = layerService.getTile(tileMetadata);
    Assert.assertTrue(tile.getFeatureContent().contains("path"));
View Full Code Here

    this.id = id;
  }

  public void execute(PipelineContext context, GetTileContainer response) throws GeomajasException {
    VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
    TileMetadata metadata = context.get(PipelineCode.TILE_METADATA_KEY, TileMetadata.class);
    CrsTransform layerToMap = context.get(PipelineCode.CRS_TRANSFORM_KEY, CrsTransform.class);
    CrsTransform maptoLayer = geoService.getCrsTransform(layerToMap.getTarget(), layerToMap.getSource());

    String geomName = layer.getLayerInfo().getFeatureInfo().getGeometryType().getName();

    String epsg = Integer.toString(geoService.getSridFromCrs(layer.getCrs()));
    // transform tile bounds back to layer coordinates
    // TODO: for non-affine transforms this is not accurate enough !
    Envelope bounds = geoService.transform(response.getTile().getBounds(), maptoLayer);
    Filter filter = filterService.createBboxFilter(epsg, bounds, geomName);
    if (null != metadata.getFilter()) {
      filter = filterService.createAndFilter(filterService.parseFilter(metadata.getFilter()), filter);
    }

    context.put(PipelineCode.FILTER_KEY, filter);
  }
View Full Code Here

TOP

Related Classes of org.geomajas.layer.tile.TileMetadata

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.