Package org.geomajas.layer.tile

Examples of org.geomajas.layer.tile.InternalTile


    cacheManager.drop(layerBeans);
  }

  @Test
  public void testRasterizeFromRebuildCache() throws Exception {
    InternalTile tile;
    // create metadata
    GetVectorTileRequest metadata = new GetVectorTileRequest();
    metadata.setCode(new TileCode(4, 8, 8));
    metadata.setCrs("EPSG:4326");
    metadata.setLayerId(layerBeansPoint.getId());
    metadata.setPanOrigin(new Coordinate(1, 1));
    metadata.setScale(16);
    metadata.setRenderer(TileMetadata.PARAM_SVG_RENDERER);
    metadata.setStyleInfo(layerBeansPointStyleInfo);
    metadata.setPaintLabels(false);
    metadata.setPaintGeometries(true);
    // get tile
    recorder.clear();
    tile = vectorLayerService.getTile(metadata);
    // find the key
    String url = tile.getFeatureContent();
    Assert.assertTrue(url.startsWith("http://test/rasterizing/layer/layerBeansPoint/"));
    Assert.assertTrue(url.contains("?"));
    String key = url.substring("http://test/rasterizing/layer/layerBeansPoint/".length(), url.indexOf(".png"));
    Object o = cacheManager.get(layerBeansPoint, CacheCategory.RASTER, key);
    Assert.assertNull("Unexpected raster in cache", o);
View Full Code Here


    cacheManager.drop(layerBeansPoint);
  }

  @Test
  public void testGetVectorTileRasterized() throws Exception {
    InternalTile tile;
    GetVectorTileRequest metadata;
    String url;
    // get tile
    metadata = createRequest();
    recorder.clear();
    tile = vectorLayerService.getTile(metadata);
    url = tile.getFeatureContent();
    Assert.assertTrue(url.contains("http://test"));
    Assert.assertEquals("", recorder.matches(CacheCategory.REBUILD, "Put item in cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE));
    // recreate same metadata and get tile again
    metadata = createRequest();
    recorder.clear();
    tile = vectorLayerService.getTile(metadata);
    Assert.assertEquals(removeRandom(url), removeRandom(tile.getFeatureContent()));
    cacheManager.drop(layerBeansMultiLine);
    Assert.assertEquals("", recorder.matches(CacheCategory.REBUILD, "Put item in cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE));
  }
View Full Code Here

    ThreadScopeContextHolder.clear();
  }

  @Test
  public void testGetTile() throws Exception {
    InternalTile tile;
    TileMetadata tmd = new GetVectorTileRequest();
    tmd.setCrs("EPSG:4326");
    tmd.setCode(new TileCode(1,0,0));
    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();
    tmd.setCode(new TileCode(1,0,0));
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
    Assert.assertEquals("<g id=\"beans.features.1-0-0\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-0-0.0\"><path fill-rule=\"evenodd\" d=\"M0 0l1 0 0 -1 -1 0 0 1 Z\" id=\"1\"/></g></g>", tile.getFeatureContent());
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));

    // first run, this should put things in the cache
    recorder.clear();
    tmd.setCode(new TileCode(1,1,0));
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
    Assert.assertEquals("<g id=\"beans.features.1-1-0\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-1-0.0\"><path fill-rule=\"evenodd\" d=\"M4 0l2 0 0 -3 -2 0 0 3 Z\" id=\"2\"/></g></g>", tile.getFeatureContent());
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));

    // first run, this should put things in the cache
    recorder.clear();
    tmd.setCode(new TileCode(1,1,1));
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
    Assert.assertEquals("<g id=\"beans.features.1-1-1\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-1-1.0\"><path fill-rule=\"evenodd\" d=\"M2 -1l4 0 1 -1 -5 0 0 1 Z\" id=\"3\"/></g></g>", tile.getFeatureContent());
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));

    // first run, this should put things in the cache
    recorder.clear();
    tmd.setCode(new TileCode(1,0,1));
    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"));

    // first run, this should put things in the cache
    recorder.clear();
    tmd.setCode(new TileCode(1,1,1));
    tmd.setScale(2.0);
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
    Assert.assertEquals("<g id=\"beans.features.1-1-1\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-1-1.0\"><path fill-rule=\"evenodd\" d=\"M4 -2l8 0 2 -2 -10 0 0 2 Z\" id=\"3\"/></g></g>", tile.getFeatureContent());
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Put item in cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));

    // get tile again, the result should be different because we changed the cached value
    recorder.clear();
    tmd.setCode(new TileCode(1,1,0));
    tmd.setScale(1.0);
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
    Assert.assertEquals("<g id=\"beans.features.1-1-0\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-1-0.0\"><path fill-rule=\"evenodd\" d=\"M4 0l2 0 0 -3 -2 0 0 3 Z\" id=\"2\"/></g></g>", tile.getFeatureContent());
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Got item from cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE));
  }
View Full Code Here

    ThreadScopeContextHolder.clear();
  }

  @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();
View Full Code Here

    Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));
  }

  @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);
    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());
    cache.clear(); // remove tile from cache

    // get tile again, should put tile in cache again but use features and string from 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.TILE, "Put item in cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Got item from cache"));
  }
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);
    Assert.assertEquals(
        "<g id=\"beans.features.1-1-1\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;" +
            "stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-1-1.0\">" +
            "<path fill-rule=\"evenodd\" d=\"M445278 0l0 -334111 222639 0 0 334111 -222639 0 Z\" " +
            "id=\"2\"></path><path fill-rule=\"evenodd\" " +
            "d=\"M222639 -111325l0 -111359 556597 0 -111319 111359 -445278 0 Z\" id=\"3\"/></g></g>",
        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());
    cache.clear(); // remove tile from cache

    cache = (DummyCacheService) cacheManager.getCacheForTesting(LAYER_BEANS, CacheCategory.FEATURE);
    Assert.assertEquals(1, cache.size());
    FeaturesCacheContainer fcc = (FeaturesCacheContainer) cache.getObject();
    List<InternalFeature> features = fcc.getFeatures();
    Assert.assertEquals(3, features.size());
    InternalFeature feature = features.get(2);
    Assert.assertEquals(2, feature.getGeometry().getCoordinates()[0].x, DELTA);
    Assert.assertEquals(1, feature.getGeometry().getCoordinates()[0].y, DELTA);

    // get tile again, should put tile in cache again but use features and string from cache
    recorder.clear();
    tile = vectorLayerService.getTile(tmd);
    Assert.assertNotNull(tile);
    Assert.assertEquals(
        "<g id=\"beans.features.1-1-1\"><g style=\"fill:#995500;fill-opacity:0.6;stroke:#995500;" +
            "stroke-opacity:0.3;stroke-width:1px;\" id=\"beans.features.1-1-1.0\">" +
            "<path fill-rule=\"evenodd\" d=\"M445278 0l0 -334111 222639 0 0 334111 -222639 0 Z\" " +
            "id=\"2\"></path><path fill-rule=\"evenodd\" " +
            "d=\"M222639 -111325l0 -111359 556597 0 -111319 111359 -445278 0 Z\" id=\"3\"/></g></g>",
        tile.getFeatureContent());
    Assert.assertEquals("", recorder.matches(CacheCategory.TILE, "Put item in cache"));
    Assert.assertEquals("", recorder.matches(CacheCategory.FEATURE, "Got item from cache"));

    cache = (DummyCacheService) cacheManager.getCacheForTesting(LAYER_BEANS, CacheCategory.FEATURE);
    Assert.assertEquals(1, cache.size());
View Full Code Here

        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

    securityManager.createSecurityContext(((LoginResponse)response).getToken());
  }

  @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"));
    org.junit.Assert.assertEquals("", recorder.matches(CacheCategory.TILE,
        "Put item in cache"));

    login("marino");
    recorder.clear();
    tile = layerService.getTile(tileMetadata);
    Assert.assertFalse(tile.getFeatureContent().contains("path"));
    org.junit.Assert.assertEquals("", recorder.matches(CacheCategory.TILE,
        "Put item in cache"));

    login("luc");
    recorder.clear();
    tile = layerService.getTile(tileMetadata);
    Assert.assertTrue(tile.getFeatureContent().contains("path"));
    org.junit.Assert.assertEquals("", recorder.matches(CacheCategory.TILE,
        "Got item from cache"));

    login("marino");
    recorder.clear();
    tile = layerService.getTile(tileMetadata);
    Assert.assertFalse(tile.getFeatureContent().contains("path"));
    org.junit.Assert.assertEquals("", recorder.matches(CacheCategory.TILE,
        "Got item from cache"));
  }
View Full Code Here

    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);
    InternalTile tile = new InternalTileImpl(tileMetadata.getCode(), tileExtent, tileMetadata.getScale());
    GetTileContainer response = new GetTileContainer();
    response.setTile(tile);
    pipelineService.execute(PipelineCode.PIPELINE_GET_VECTOR_TILE, layerId, context, response);
    log.debug("getTile response InternalTile {}", response);
    log.debug("getTile done on layer {}, time {}s", layerId, (System.currentTimeMillis() - ts) / 1000.0);
View Full Code Here

TOP

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

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.