Package org.geomajas.layer

Examples of org.geomajas.layer.VectorLayer


  public void setId(String id) {
    this.id = id;
  }

  public void execute(PipelineContext context, GetFeaturesContainer response) throws GeomajasException {
    VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
    int featureIncludes = context.get(PipelineCode.FEATURE_INCLUDES_KEY, Integer.class);
    NamedStyleInfo style = context.getOptional(PipelineCode.STYLE_KEY, NamedStyleInfo.class);

    List<StyleFilter> styleFilters = null;
    if (style == null) {
      // no style specified, take the first
      style = layer.getLayerInfo().getNamedStyleInfos().get(0);
    } else if (style.getFeatureStyles().isEmpty()) {
      // only name specified, find it
      style = layer.getLayerInfo().getNamedStyleInfo(style.getName());
    }
    context.put(PipelineCode.STYLE_KEY, style);

    if ((featureIncludes & VectorLayerService.FEATURE_INCLUDE_STYLE) != 0) {
      if (style == null) {
View Full Code Here


    } else {
      throw new IllegalArgumentException("You must provide a feature or location search request.");
    }

    if (features != null) {
      VectorLayer layer = configurationService.getVectorLayer(request.getLayerId());
      String fileName = (request.getFilename() == null || "".equals(request.getFilename()) ? request.getLayerId()
          + EXTENSION : request.getFilename());
      if (!fileName.endsWith(EXTENSION) && !fileName.endsWith(".CSV")) {
        fileName += EXTENSION;
      }
View Full Code Here

  public void execute(PipelineContext context, Object response) throws GeomajasException {
    InternalFeature oldFeature = context.getOptional(PipelineCode.OLD_FEATURE_KEY, InternalFeature.class);
    InternalFeature newFeature = context.get(PipelineCode.FEATURE_KEY, InternalFeature.class);
    if (null != oldFeature) {
      String layerId = context.get(PipelineCode.LAYER_ID_KEY, String.class);
      VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
      if (securityContext.isFeatureUpdateAuthorized(layerId, oldFeature, newFeature)) {
        if (null == context.getOptional(PipelineCode.FEATURE_DATA_OBJECT_KEY)) {
          context.put(PipelineCode.FEATURE_DATA_OBJECT_KEY, layer.read(newFeature.getId()));
        }
      } else {
        throw new GeomajasSecurityException(ExceptionCode.FEATURE_UPDATE_PROHIBITED,
            oldFeature.getId(), securityContext.getUserId());
      }
View Full Code Here

  public void execute(PipelineContext context, Object response) throws GeomajasException {
    InternalFeature newFeature = context.getOptional(PipelineCode.FEATURE_KEY, InternalFeature.class);
    Object feature = context.get(PipelineCode.FEATURE_DATA_OBJECT_KEY);
    String layerId = context.get(PipelineCode.LAYER_ID_KEY, String.class);
    VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
    FeatureModel featureModel = layer.getFeatureModel();
    Boolean isCreateObject = context.getOptional(PipelineCode.IS_CREATE_KEY, Boolean.class);
    boolean isCreate  = false;
    if (null != isCreateObject && isCreateObject) {
      isCreate = true;
    }

    // Assure only writable attributes are set
    Map<String, Attribute> requestAttributes = newFeature.getAttributes();
    Map<String, Attribute> filteredAttributes = new HashMap<String, Attribute>();
    if (null != requestAttributes) {
      for (Map.Entry<String, Attribute> entry : requestAttributes.entrySet()) {
        String key = entry.getKey();
        if (securityContext.isAttributeWritable(layerId, newFeature, key)) {
          filteredAttributes.put(key, entry.getValue());
        }
      }
    }
    featureModel.setAttributes(feature, filteredAttributes);

    if (newFeature.getGeometry() != null) {
      featureModel.setGeometry(feature, newFeature.getGeometry());
    }

    Filter securityFilter;
    if (isCreate) {
      securityFilter = getSecurityFilter(layer, securityContext.getCreateAuthorizedArea(layerId));
    } else {
      securityFilter = getSecurityFilter(layer, securityContext.getUpdateAuthorizedArea(layerId));
    }
    if (securityFilter.evaluate(feature)) {
      context.put(PipelineCode.FEATURE_DATA_OBJECT_KEY, layer.saveOrUpdate(feature));
      if (isCreate) {
        newFeature.setId(featureModel.getId(feature));
      }
    } else {
      if (isCreate) {
View Full Code Here

  }

  public void execute(PipelineContext context, GetBoundsContainer response)
      throws GeomajasException {
    if (null == response.getEnvelope()) {
      VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
      CrsTransform crsTransform = context.get(PipelineCode.CRS_TRANSFORM_KEY, CrsTransform.class);
      Filter filter = context.get(PipelineCode.FILTER_KEY, Filter.class);
      Envelope bounds = layer.getBounds(filter);
      bounds = geoService.transform(bounds, crsTransform);
      response.setEnvelope(bounds);
    }
  }
View Full Code Here

  @RequestMapping(value = "/rasterizing/layer/{layerId}/{key}.png", method = RequestMethod.GET)
  public void getImage(@PathVariable String layerId, @PathVariable String key, HttpServletResponse response)
      throws Exception {

    try {
      VectorLayer layer = configurationService.getVectorLayer(layerId);
      RasterizingContainer rasterizeContainer = cacheManagerService.get(layer, CacheCategory.RASTER, key,
          RasterizingContainer.class);
      // if not in cache, try the rebuild cache and invoke the pipeline directly
      if (rasterizeContainer == null) {
        GetTileContainer tileContainer = new GetTileContainer();
        PipelineContext context = pipelineService.createContext();
        context.put(RasterizingPipelineCode.IMAGE_ID_KEY, key);
        context.put(PipelineCode.LAYER_ID_KEY, layerId);
        context.put(PipelineCode.LAYER_KEY, layer);

        // get data from rebuild cache
        RebuildCacheContainer rebuildCacheContainer = cacheManagerService.get(layer, CacheCategory.REBUILD, key,
            RebuildCacheContainer.class);
        if (null == rebuildCacheContainer) {
          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);
View Full Code Here

  private VectorLayer getVectorLayer(String layerId) throws GeomajasException {
    if (!securityContext.isLayerVisible(layerId)) {
      throw new GeomajasSecurityException(ExceptionCode.LAYER_NOT_VISIBLE, layerId, securityContext.getUserId());
    }
    VectorLayer layer = configurationService.getVectorLayer(layerId);
    if (null == layer) {
      throw new GeomajasException(ExceptionCode.VECTOR_LAYER_NOT_FOUND, layerId);
    }
    return layer;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public void saveOrUpdate(String layerId, CoordinateReferenceSystem crs, List<InternalFeature> oldFeatures,
      List<InternalFeature> newFeatures) throws GeomajasException {
    log.debug("saveOrUpdate start on layer {}", layerId);
    long ts = System.currentTimeMillis();
    VectorLayer layer = getVectorLayer(layerId);
    CrsTransform mapToLayer = geoService.getCrsTransform(crs, layer.getCrs());
    CrsTransform layerToMap = geoService.getCrsTransform(layer.getCrs(), crs);
    PipelineContext context = pipelineService.createContext();
    context.put(PipelineCode.LAYER_ID_KEY, layerId);
    context.put(PipelineCode.LAYER_KEY, layer);
    context.put(PipelineCode.CRS_TRANSFORM_KEY, mapToLayer);
    context.put(PipelineCode.CRS_BACK_TRANSFORM_KEY, layerToMap);
View Full Code Here

  @SuppressWarnings("unchecked")
  public List<InternalFeature> getFeatures(String layerId, CoordinateReferenceSystem crs, Filter queryFilter,
      NamedStyleInfo style, int featureIncludes, int offset, int maxResultSize) throws GeomajasException {
    log.debug("getFeatures start on layer {}", layerId);
    long ts = System.currentTimeMillis();
    VectorLayer layer = getVectorLayer(layerId);
    CrsTransform transformation = null;
    if ((featureIncludes & FEATURE_INCLUDE_GEOMETRY) != 0 && crs != null && !crs.equals(layer.getCrs())) {
      transformation = geoService.getCrsTransform(layer.getCrs(), crs);
    }
    GetFeaturesContainer container = new GetFeaturesContainer();
    PipelineContext context = pipelineService.createContext();
    context.put(PipelineCode.LAYER_ID_KEY, layerId);
    context.put(PipelineCode.LAYER_KEY, layer);
View Full Code Here

  @SuppressWarnings("unchecked")
  public Envelope getBounds(String layerId, CoordinateReferenceSystem crs, Filter queryFilter)
      throws GeomajasException {
    log.debug("getBounds start on layer {}", layerId);
    long ts = System.currentTimeMillis();
    VectorLayer layer = getVectorLayer(layerId);
    GetBoundsContainer container = new GetBoundsContainer();
    PipelineContext context = pipelineService.createContext();
    context.put(PipelineCode.LAYER_ID_KEY, layerId);
    context.put(PipelineCode.LAYER_KEY, layer);
    context.put(PipelineCode.CRS_KEY, crs);
    context.put(PipelineCode.CRS_TRANSFORM_KEY, geoService.getCrsTransform(layer.getCrs(), crs));
    context.put(PipelineCode.FILTER_KEY, queryFilter);
    pipelineService.execute(PipelineCode.PIPELINE_GET_BOUNDS, layerId, context, container);
    log.debug("getBounds done on layer {}, time {}s", layerId, (System.currentTimeMillis() - ts) / 1000.0);
    return container.getEnvelope();
  }
View Full Code Here

TOP

Related Classes of org.geomajas.layer.VectorLayer

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.