Package org.geomajas.layer

Examples of org.geomajas.layer.VectorLayer


  private Map<VectorLayer, Filter> dtoAttributeCriterionToFilters(AttributeCriterion criterion)
      throws GeomajasException {
    Map<VectorLayer, Filter> filters = new LinkedHashMap<VectorLayer, Filter>();
    Filter f;
    VectorLayer l = configurationService.getVectorLayer(criterion.getServerLayerId());
    if (l == null) {
      throw new GeomajasException(ExceptionCode.LAYER_NOT_FOUND, criterion.getServerLayerId());
    }

    String operator = criterion.getOperator();
View Full Code Here


    Map<VectorLayer, Filter> filters = new LinkedHashMap<VectorLayer, Filter>();
    Filter f;
    Geometry mapGeom = converter.toInternal(criterion.getGeometry());

    for (String serverLayerId : criterion.getServerLayerIds()) {
      VectorLayer vl = configurationService.getVectorLayer(serverLayerId);
      if (vl == null) {
        throw new GeomajasException(ExceptionCode.LAYER_NOT_FOUND, serverLayerId);
      }

      // Transform geometry to layer CRS:
      Geometry layerGeometry = geoService.transform(mapGeom, mapCrs, vectorLayerService.getCrs(vl));

      switch (criterion.getOperator()) {
        case SearchByLocationRequest.QUERY_INTERSECTS:
          f = filterService.createIntersectsFilter(layerGeometry, vl.getFeatureModel()
              .getGeometryAttributeName());
          break;
        case SearchByLocationRequest.QUERY_CONTAINS:
          f = filterService.createContainsFilter(layerGeometry, vl.getFeatureModel()
              .getGeometryAttributeName());
          break;

        case SearchByLocationRequest.QUERY_TOUCHES:
          f = filterService.createTouchesFilter(layerGeometry, vl.getFeatureModel()
              .getGeometryAttributeName());
          break;

        case SearchByLocationRequest.QUERY_WITHIN:
          f = filterService
              .createWithinFilter(layerGeometry, vl.getFeatureModel().getGeometryAttributeName());
          break;

        default:
          throw new GeomajasException(ExceptionCode.ATTRIBUTE_UNKNOWN, "QueryType");
      }
View Full Code Here

    }
    ClientVectorLayerInfo vectorInfo = (ClientVectorLayerInfo) clientLayerInfo;
    VectorLayerRasterizingInfo extraInfo = (VectorLayerRasterizingInfo) vectorInfo
        .getWidgetInfo(VectorLayerRasterizingInfo.WIDGET_KEY);
    ReferencedEnvelope areaOfInterest = mapContext.getAreaOfInterest();
    VectorLayer layer = configurationService.getVectorLayer(vectorInfo.getServerLayerId());
    // need to clone the extra info object before changing it !
    VectorLayerRasterizingInfo copy = cloneInfo(extraInfo);
    // we now replace the style filters by simple filters on an artificial extra style attribute
    for (FeatureStyleInfo style : copy.getStyle().getFeatureStyles()) {
      style.setFormula(STYLE_INDEX_ATTRIBUTE_NAME + " = " + style.getIndex());
    }
    // create the style
    Style style = styleFactoryService.createStyle(layer, copy);
    // estimate the buffer
    MetaBufferEstimator estimator = new MetaBufferEstimator();
    estimator.visit(style);
    int bufferInPixels = estimator.getBuffer();
    // expand area to include buffer
    Rectangle tileInpix = mapContext.getViewport().getScreenArea();
    ReferencedEnvelope metaArea = new ReferencedEnvelope(areaOfInterest);
    metaArea.expandBy(bufferInPixels / tileInpix.getWidth() * areaOfInterest.getWidth(),
        bufferInPixels / tileInpix.getHeight() * areaOfInterest.getHeight());
    // fetch features in meta area
    Crs layerCrs = vectorLayerService.getCrs(layer);
    Envelope layerBounds = geoService.transform(metaArea, (Crs) areaOfInterest.getCoordinateReferenceSystem(),
        layerCrs);
    Filter filter = filterService.createBboxFilter(layerCrs, layerBounds,
        layer.getLayerInfo().getFeatureInfo().getGeometryType().getName());
    if (extraInfo.getFilter() != null) {
      filter = filterService.createAndFilter(filter, filterService.parseFilter(extraInfo.getFilter()));
    }
    List<InternalFeature> features = vectorLayerService.getFeatures(vectorInfo.getServerLayerId(),
        mapContext.getCoordinateReferenceSystem(), filter, extraInfo.getStyle(),
View Full Code Here

  }

  public void execute(PipelineContext context, Object result) throws GeomajasException {
    try {
      log.debug("UpdateFeatureInvalidateStep start");
      VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);

      // invalidate the area of the old feature
      InternalFeature oldFeature = context.getOptional(PipelineCode.OLD_FEATURE_KEY, InternalFeature.class);
      if (null != oldFeature) {
        // get original geometry from storage to assure not changed by transformation and available
        Object feature = layer.read(oldFeature.getId());
        context.put(PipelineCode.FEATURE_DATA_OBJECT_KEY, feature); // put in context to prevent getting twice
        FeatureModel featureModel = layer.getFeatureModel();
        Geometry oldGeometry = featureModel.getGeometry(feature);
        if (null != oldGeometry) {
          // invalidate
          recorder.record("layer", "Invalidate geometry for old version of feature");
          Envelope oldEnvelope = oldGeometry.getEnvelopeInternal();
View Full Code Here

   * objects in the cache.
   *
   * @return true when features are not converted lazily
   */
  private boolean isCacheable(PipelineContext context) throws GeomajasException {
    VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
    return !(layer instanceof VectorLayerLazyFeatureConversionSupport &&
        ((VectorLayerLazyFeatureConversionSupport) layer).useLazyFeatureConversion());
  }
View Full Code Here

      throw new RestException(e, RestException.PROBLEM_READING_LAYERSERVICE, layerId);
    }
    if (features.size() > 0) {
      VectorLayerInfo info = features.get(0).getLayer().getLayerInfo();
      model.addAttribute(VECTOR_LAYER_INFO, info);
      VectorLayer layer = configurationService.getVectorLayer(layerId);
      if (orderBy != null) {
        Collections.sort(features, createComparator(layer, orderBy, dir));
      }
      model.addAttribute(FEATURE_COLLECTION, features);
      model.addAttribute(ATTRIBUTES, attrs);
View Full Code Here

      return result;
    }
  }

  private Filter createBBoxFilter(String layerId, Envelope... bbox) throws RestException {
    VectorLayer layer = configurationService.getVectorLayer(layerId);
    for (Envelope envelope : bbox) {
      if (envelope != null) {
        try {
          return filterService.createBboxFilter(layer.getLayerInfo().getCrs(), envelope, layer
              .getFeatureModel().getGeometryAttributeName());
        } catch (LayerException e) {
          throw new RestException(e, RestException.PROBLEM_READING_LAYERSERVICE, layerId);
        }
      }
View Full Code Here

    if (l instanceof VectorLayer) {
      if (null == styleName || null == featureStyleId || "".equals(styleName) || "".equals(featureStyleId)) {
        throw new AdvancedviewsException(AdvancedviewsException.REQUIRED_PARAMETER_MISSING);
      }

      VectorLayer vl = (VectorLayer) l;
      NamedStyleInfo nsi = vl.getLayerInfo().getNamedStyleInfo(styleName);
      if (null == nsi) {
        throw new AdvancedviewsException(AdvancedviewsException.NO_SUCH_NAMEDSTYLE, styleName);
      }

      FeatureStyleInfo fsi = null;
      for (FeatureStyleInfo tmp : nsi.getFeatureStyles()) {
        if (featureStyleId.equals(tmp.getStyleId())) {
          fsi = tmp;
          break;
        }
      }

      if (null == fsi) {
        throw new AdvancedviewsException(AdvancedviewsException.NO_SUCH_FEATURESTYLE, featureStyleId);
      }

      return createIcon(vl.getLayerInfo().getLayerType(), fsi, iconSize, null);
    } else {
      String url = null;
      if (null != styleName && !"".equals(styleName)) {
        url = styleName;
      }
View Full Code Here

        // delete ?
        InternalFeature oldFeature = context.getOptional(PipelineCode.OLD_FEATURE_KEY, InternalFeature.class);
        if (null != oldFeature) {
          String layerId = context.get(PipelineCode.LAYER_ID_KEY, String.class);
          if (securityContext.isFeatureDeleteAuthorized(layerId, oldFeature)) {
            VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);
            Object featureObj = layer.read(oldFeature.getId());
            if (null != featureObj) {
              // @todo no security checks before invalidating, the delete may still fail at this moment,
              // in which case the invalidation should not have been done. Still better to invalidate too
              // much then too little.
              //Filter securityFilter = getSecurityFilter(layer,
              //   securityContext.getDeleteAuthorizedArea(layerId));
              //if (securityFilter.evaluate(featureObj)) {
              //  layer.delete(oldFeature.getId());
              //} else {
              //  throw new GeomajasSecurityException(ExceptionCode.FEATURE_DELETE_PROHIBITED,
              //      oldFeature.getId(), securityContext.getUserId());
              //}
              Geometry geometry = layer.getFeatureModel().getGeometry(featureObj);
              if (null != geometry) {
                recorder.record("layer", "Invalidate geometry for deleted feature");
                cacheManager.invalidate(layer, geometry.getEnvelopeInternal());
              }
            }
View Full Code Here

  public <CONTAINER extends CacheContainer> CONTAINER getContainer(String keyKey, String contextKey,
      String[] keys, CacheCategory category, PipelineContext pipelineContext,
      CachingSupportServiceContextAdder contextAdder, Class<CONTAINER> containerClass) {
    CONTAINER cc = null;
    try {
      VectorLayer layer = pipelineContext.getOptional(PipelineCode.LAYER_KEY, VectorLayer.class);
      String cacheKey = null;
      if (keyKey != null) {
        cacheKey = pipelineContext.getOptional(keyKey, String.class);
      }
      if (cacheKey != null) {
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.