Package com.vividsolutions.jts.geom

Examples of com.vividsolutions.jts.geom.Geometry


      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);
      }
    } catch (Throwable t) { //NOPMD
      // have to prevent caching code from making the pipeline fail, log and discard errors
View Full Code Here


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

      return "BBOX (" + propertyName + "," + coordinates + ")";
    } else if (spatialOps instanceof BinarySpatialOpTypeInfo) {
      BinarySpatialOpTypeInfo binary = (BinarySpatialOpTypeInfo) spatialOps;
      String propertyName = binary.getPropertyName().getValue();
      if (binary.ifGeometry()) {
        Geometry geometry = null;
        WKTWriter writer = new WKTWriter();
        GeometryFactory factory = new GeometryFactory();
        AbstractGeometryInfo geom = binary.getGeometry();
        geometry = toGeometry(factory, geom);
        String wkt = writer.write(geometry);
        if (binary instanceof ContainsInfo) {
          return "CONTAINS(" + propertyName + "," + wkt + ")";
        } else if (binary instanceof CrossesInfo) {
          return "CROSSES(" + propertyName + "," + wkt + ")";
        } else if (binary instanceof DisjointInfo) {
          return "DISJOINT(" + propertyName + "," + wkt + ")";
        } else if (binary instanceof EqualsInfo) {
          return "EQUALS(" + propertyName + "," + wkt + ")";
        } else if (binary instanceof IntersectsInfo) {
          return "INTERSECTS(" + propertyName + "," + wkt + ")";
        } else if (binary instanceof OverlapsInfo) {
          return "OVERLAPS(" + propertyName + "," + wkt + ")";
        } else if (binary instanceof TouchesInfo) {
          return "TOUCHES(" + propertyName + "," + wkt + ")";
        } else if (binary instanceof WithinInfo) {
          return "WITHIN(" + propertyName + "," + wkt + ")";
        }
      } else if (spatialOps instanceof DistanceBufferTypeInfo) {
        DistanceBufferTypeInfo distanceBuffer = (DistanceBufferTypeInfo) spatialOps;
        AbstractGeometryInfo geom = distanceBuffer.getGeometry();
        GeometryFactory factory = new GeometryFactory();
        Geometry geometry = toGeometry(factory, geom);
        WKTWriter writer = new WKTWriter();
        String wkt = writer.write(geometry);
        String units = distanceBuffer.getDistance().getUnits();
        String distance = distanceBuffer.getDistance().getValue();
        if (distanceBuffer instanceof DWithinInfo) {
View Full Code Here

    }
    return null;
  }

  private Geometry toGeometry(GeometryFactory factory, AbstractGeometryInfo geom) {
    Geometry geometry = null;
    if (geom instanceof AbstractGeometryCollectionInfo) {
      AbstractGeometryCollectionInfo geomCollection = (AbstractGeometryCollectionInfo) geom;
      List<GeometryMemberInfo> members = geomCollection.getGeometryMemberList();
      if (geom instanceof MultiPointInfo) {
        Point[] points = new Point[members.size()];
View Full Code Here

    }
    return geometry;
  }

  private Geometry toSimpleGeometry(GeometryFactory factory, AbstractGeometryInfo geom) {
    Geometry geometry = null;
    if (geom instanceof PointTypeInfo) {
      PointTypeInfo point = (PointTypeInfo) geom;
      if (point.ifCoord()) {
        geometry = factory.createPoint(getCoordinates(Collections.singletonList(point.getCoord()))[0]);
      } else if (point.ifCoordinates()) {
View Full Code Here

      int count = 0;
      while (it.hasNext()) {
        log.debug("process feature");
        Object featureObj = it.next();
        Geometry geometry = layer.getFeatureModel().getGeometry(featureObj);
        InternalFeature feature = convertFeature(featureObj, geometry, layer, transformation,
            styleFilters, style.getLabelStyle(), featureIncludes);
        if (null != feature) {
          count++;
          if (count > offset) {
            features.add(feature);

            if (null != geometry) {
              Envelope envelope = geometry.getEnvelopeInternal();
              if (null == bounds) {
                bounds = new Envelope();
              }
              bounds.expandToInclude(envelope);
            }
View Full Code Here

        }
      }

      // If allowed, add the geometry (transformed!) to the InternalFeature:
      if ((featureIncludes & VectorLayerService.FEATURE_INCLUDE_GEOMETRY) != 0) {
        Geometry transformed;
        if (null != transformation) {
          transformed = geoService.transform(geometry, transformation);
        } else {
          transformed = geometry;
        }
View Full Code Here

      throw new LayerException(e);
    }
  }

  public Geometry getGeometry(Object feature) throws LayerException {
    Geometry geometry = (Geometry) asFeature(feature).getDefaultGeometry();
    geometry.setSRID(srid);
    return (Geometry) geometry.clone();
  }
View Full Code Here

    List<InternalFeature> oldFeatures;
    List<InternalFeature> newFeatures;
    InternalFeature feature;
    CoordinateReferenceSystem crs = beanLayer.getCrs();
    GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel());
    Geometry geometry;

    login("marino");
    oldFeatures = new ArrayList<InternalFeature>();
    newFeatures = new ArrayList<InternalFeature>();
    feature = converterService.toInternal(new Feature());
View Full Code Here

  public int getSrid() throws LayerException {
    return srid;
  }

  public Geometry getGeometry(Object feature) throws LayerException {
    Geometry geom = (Geometry) asFeature(feature).getDefaultGeometry();
    if (geom instanceof MultiLineString && vectorLayerInfo.getLayerType() == LayerType.LINESTRING) {
      return (Geometry) geom.getGeometryN(0).clone();
    } else if (geom instanceof MultiPolygon && vectorLayerInfo.getLayerType() == LayerType.POLYGON) {
      return (Geometry) geom.getGeometryN(0).clone();
    } else if (geom instanceof MultiPoint && vectorLayerInfo.getLayerType() == LayerType.POINT) {
      return (Geometry) geom.getGeometryN(0).clone();
    }
    return (Geometry) geom.clone();
  }
View Full Code Here

TOP

Related Classes of com.vividsolutions.jts.geom.Geometry

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.