Package org.geomajas.layer.feature

Examples of org.geomajas.layer.feature.InternalFeature


    this.coordHeight = coordHeight;
  }

  public void writeObject(Object object, GraphicsDocument document, boolean asChild) throws RenderException {
    try {
      InternalFeature feature = (InternalFeature) object;
      Geometry geom = feature.getGeometry();
      if (feature.isClipped()) {
        geom = feature.getClippedGeometry();
      }
      geom = transformer.transform(geom);
      if (isPointLike(feature)) {
        if (feature.getStyleInfo().getSymbol() != null) {
          SymbolInfo info = feature.getStyleInfo().getSymbol();
          for (Coordinate coordinate : geom.getCoordinates()) {
            if (info.getRect() != null) {
              writeRectangle(document, coordinate, feature, info.getRect());
            } else if (info.getCircle() != null) {
              RectInfo rectInfo = new RectInfo();
              rectInfo.setW(info.getCircle().getR() * 2);
              rectInfo.setH(info.getCircle().getR() * 2);
              writeRectangle(document, coordinate, feature, rectInfo);
            } else if (info.getImage() != null) {
              writeImage(document, coordinate, feature, info.getImage());
            }
          }
        }
      } else {
        document.writeObject(geom, asChild);
        document.writeAttribute("style", "WIDTH: 100%; HEIGHT: 100%");
        document.writeAttribute("coordsize", coordWidth + "," + coordHeight);
        document.writeAttribute("type", "#" + feature.getStyleInfo().getStyleId());
        document.writeAttribute("id", feature.getId());
      }
    } catch (TransformException e) {
      log.warn("could not render feature");
    }
  }
View Full Code Here


  @Test
  public void testCalcDefaultLabelPosition() throws Exception {
    Geometry geometry;
    GeometryFactory factory = new GeometryFactory(new PrecisionModel(), 4326);
    Coordinate coordinate;
    InternalFeature feature = new InternalFeatureImpl();
    feature.setId("x");
    feature.setLabel("Label x");
    coordinate = geoService.calcDefaultLabelPosition(feature);
    Assert.assertNull(coordinate);

    feature.setGeometry(factory.createMultiPolygon(new Polygon[] {}));
    coordinate = geoService.calcDefaultLabelPosition(feature);
    Assert.assertNull(coordinate);

    feature.setGeometry(JTS.toGeometry(new Envelope(10, 20, 30, 40)));
    coordinate = geoService.calcDefaultLabelPosition(feature);
    // this tests current behaviour, without claims that this is the "best" (or even "good") position
    Assert.assertEquals(15.0, coordinate.x, DELTA);
    Assert.assertEquals(35.0, coordinate.y, DELTA);

    geometry = factory.createLineString(new Coordinate[] { new Coordinate(5,4), new Coordinate(30,10) });
    feature.setGeometry(geometry);
    coordinate = geoService.calcDefaultLabelPosition(feature);
    // this tests current behaviour, without claims that this is the "best" (or even "good") position
    Assert.assertEquals(5.0, coordinate.x, DELTA);
    Assert.assertEquals(4.0, coordinate.y, DELTA);
  }
View Full Code Here

    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();
          log.debug("invalidate old feature area {}", oldEnvelope);
          cacheManager.invalidate(layer, oldEnvelope);
        }
      }

      // invalidate area for new feature
      InternalFeature feature = context.get(PipelineCode.FEATURE_KEY, InternalFeature.class);
      Geometry geometry = feature.getGeometry();
      if (null != geometry) {
        recorder.record("layer", "Invalidate geometry for new feature");
        Envelope envelope = geometry.getEnvelopeInternal();
        log.debug("invalidate new feature area {}", envelope);
        cacheManager.invalidate(layer, envelope);
View Full Code Here

      for (InternalFeature feature : features) {
        coll.add(convertorService.toSimpleFeature(feature, sft));
      }
      parser.write(coll, response.getOutputStream());
    } else {
      InternalFeature feature = (InternalFeature) ff;
      parser.write(convertorService.toSimpleFeature(feature, sft), response.getOutputStream());
    }
    response.getOutputStream().flush();
  }
View Full Code Here

    this.id = id;
  }

  public void execute(PipelineContext context, Object result) throws GeomajasException {
    try {
      InternalFeature newFeature = context.getOptional(PipelineCode.FEATURE_KEY, InternalFeature.class);
      if (null == newFeature) {
        // 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());
              }
            }
          } else {
            throw new GeomajasSecurityException(ExceptionCode.FEATURE_DELETE_PROHIBITED,
                oldFeature.getId(), securityContext.getUserId());
          }
        }
      }
    } catch (Throwable t) { //NOPMD
      // have to prevent caching code from making the pipeline fail, log and discard errors
View Full Code Here

    this.id = id;
  }

  public void execute(PipelineContext context, Object response) throws GeomajasException {
    Object feature = context.get(PipelineCode.FEATURE_DATA_OBJECT_KEY);
    InternalFeature newFeature = context.get(PipelineCode.FEATURE_KEY, InternalFeature.class);
    VectorLayer layer = context.get(PipelineCode.LAYER_KEY, VectorLayer.class);

//    // Not needed for existing features, but no problem to re-set feature id
//    String id = featureModel.getId(feature);
//    newFeature.setId(id);
View Full Code Here

    int count = oldFeatures.size();
    for (int i = 0; i < count; i++) {
      context.put(PipelineCode.INDEX_KEY, i);
      context.put(PipelineCode.OLD_FEATURE_KEY, oldFeatures.get(i));
      InternalFeature newFeature = newFeatures.get(i);
      context.put(PipelineCode.FEATURE_KEY, newFeature);

      pipelineService.execute(pipelineInfo, context, newFeature);
    }
  }
View Full Code Here

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

  public void execute(PipelineContext context, Object response) throws GeomajasException {
    InternalFeature feature = context.get(PipelineCode.FEATURE_KEY, InternalFeature.class);
    if (null != feature.getGeometry()) {
      CrsTransform mapToLayer = context.get(PipelineCode.CRS_TRANSFORM_KEY, CrsTransform.class);
      feature.setGeometry(geoService.transform(feature.getGeometry(), mapToLayer));
    }
  }
View Full Code Here

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

  public void execute(PipelineContext context, Object response) throws GeomajasException {
    InternalFeature feature = context.get(PipelineCode.FEATURE_KEY, InternalFeature.class);
    if (null != feature.getGeometry()) {
      CrsTransform layerToMap = context.get(PipelineCode.CRS_BACK_TRANSFORM_KEY, CrsTransform.class);
      feature.setGeometry(geoService.transform(feature.getGeometry(), layerToMap));
    }
  }
View Full Code Here

    // convert feature geometries to layer, need to copy to assure cache is not affected
    List<InternalFeature> features = new ArrayList<InternalFeature>();
    for (InternalFeature feature : tile.getFeatures()) {
      if (null != feature.getGeometry()) {
        InternalFeature newFeature = feature.cloneWithoutGeometry();
        newFeature.setGeometry(geoService.transform(feature.getGeometry(), transform));
        features.add(newFeature);
      }
    }
    // replace the contents of the list
    tile.setFeatures(features);
View Full Code Here

TOP

Related Classes of org.geomajas.layer.feature.InternalFeature

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.