/**
   * Ensure Line crosses the other Line at a node.
   *
   * <p>
   *
   * @param layers a HashMap of key="TypeName" value="FeatureSource"
   * @param envelope The bounding box of modified features
   * @param results Storage for the error and warning messages
   * @return True if no features intersect. If they do then the validation failed.
   * @throws Exception DOCUMENT ME!
   * @see org.geotools.validation.IntegrityValidation#validate(java.util.Map,
   *     com.vividsolutions.jts.geom.Envelope, org.geotools.validation.ValidationResults)
   */
  public boolean validate(Map layers, Envelope envelope, ValidationResults results)
      throws Exception {
    boolean r = true;

    FeatureSource<SimpleFeatureType, SimpleFeature> fsLine =
        (FeatureSource<SimpleFeatureType, SimpleFeature>) layers.get(getLineTypeRef());

    FeatureCollection<SimpleFeatureType, SimpleFeature> fcLine = fsLine.getFeatures();
    FeatureIterator<SimpleFeature> fLine = fcLine.features();

    FeatureSource<SimpleFeatureType, SimpleFeature> fsRLine =
        (FeatureSource<SimpleFeatureType, SimpleFeature>) layers.get(getRestrictedLineTypeRef());

    FeatureCollection<SimpleFeatureType, SimpleFeature> fcRLine = fsRLine.getFeatures();

    while (fLine.hasNext()) {
      SimpleFeature line = fLine.next();
      FeatureIterator<SimpleFeature> fRLine = fcRLine.features();
      Geometry lineGeom = (Geometry) line.getDefaultGeometry();
      if (envelope.contains(lineGeom.getEnvelopeInternal())) {
        // 	check for valid comparison
        if (LineString.class.isAssignableFrom(lineGeom.getClass())) {
          while (fRLine.hasNext()) {
            SimpleFeature rLine = fRLine.next();
            Geometry rLineGeom = (Geometry) rLine.getDefaultGeometry();
            if (envelope.contains(rLineGeom.getEnvelopeInternal())) {
              if (LineString.class.isAssignableFrom(rLineGeom.getClass())) {
                if (lineGeom.intersects(rLineGeom)) {
                  if (!hasPair(
                      ((LineString) lineGeom).getCoordinateSequence(),
                      ((LineString) rLineGeom).getCoordinateSequence())) {
                    results.error(
                        rLine,
                        "Line does not intersect line at node covered by the specified Line.");
                    r = false;
                  }
                } else {
                  results.warning(rLine, "Does not intersect the LineString");
                }
                // do next.
              } else {
                fcRLine.remove(rLine);
                results.warning(
                    rLine, "Invalid type: this feature is not a derivative of a LineString");
              }
            } else {
              fcRLine.remove(rLine);
            }
          }
        } else {
          results.warning(line, "Invalid type: this feature is not a derivative of a LineString");
        }
      }
    }
    return r;
  }
    private boolean intersects(SimpleFeature feature) {
      GeometryDescriptor geomDescriptor = getGeometryAttDescriptor(feature.getFeatureType());

      Geometry bboxGeom = new GeometryFactory().toGeometry(bbox);

      Geometry geom = (Geometry) feature.getAttribute(geomDescriptor.getName());

      try {
        return geom.intersects(bboxGeom);
      } catch (Exception e) {
        // ok so exception happened during intersection.  This usually means geometry is a little
        // crazy
        // what to do?...
        EditPlugin.log("Can't do intersection so I'm assuming they intersect", e); // $NON-NLS-1$
        return false;
      }
    }
 private Map<String, Double> fetchPolygonValues(KmlFeature feature, List<String> parameters) {
   try {
     double totalArea = feature.getGeometry().getArea();
     if (totalArea == 0) return Collections.emptyMap();
     Map<SimpleFeature, Double> shares = new HashMap<>();
     SimpleFeatureIterator iterator = getIterator();
     while (iterator.hasNext()) {
       SimpleFeature shape = iterator.next();
       Geometry shapeGeo = (Geometry) shape.getDefaultGeometry();
       Geometry featureGeo = feature.getGeometry();
       if (!featureGeo.intersects(shapeGeo)) continue;
       double area = featureGeo.intersection(shapeGeo).getArea();
       shares.put(shape, area / totalArea);
     }
     return fetchValues(shares, parameters);
   } catch (Exception e) {
     log.error("failed to fetch polygon parameters", e);
     return Collections.emptyMap();
   }
 }
  private Set<HashMap<Integer, String>> csvRowGeometryIntersector(
      BufferedReader br, Geometry geom, int latColumnIndex, int lonColumnIndex) {
    Set<HashMap<Integer, String>> rowsFromIntersectingPoints =
        new HashSet<HashMap<Integer, String>>();
    try {
      String line = null;

      int i = 0;

      // run through each row
      while ((line = br.readLine()) != null) {
        if (i++ == 0) {
          continue;
        }

        // get point from line
        Point p = GeoCSVUtil.getPointFromRow(line, latColumnIndex, lonColumnIndex);

        // for a row, if it intersects with this geom, run through its 12 elements and tick off each
        // basic averager
        if (geom.intersects(p)) {
          rowsFromIntersectingPoints.add(GeoCSVUtil.getRowAsTable(line));
        }
      }
    } catch (IOException ex) {
      Logger.getLogger(PointCSVShapeFileIntersector.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
      try {
        br.close();
      } catch (IOException ex) {
        Logger.getLogger(PointCSVShapeFileIntersector.class.getName()).log(Level.SEVERE, null, ex);
      }
    }

    return rowsFromIntersectingPoints;
  }
示例#5
0
  @Override
  protected void execute() throws ProcessException {

    try {

      final Geometry geom1 = value(IntersectsDescriptor.GEOM1, inputParameters);
      Geometry geom2 = value(IntersectsDescriptor.GEOM2, inputParameters);

      // ensure geometries are in the same CRS
      final CoordinateReferenceSystem resultCRS = JTS.getCommonCRS(geom1, geom2);
      if (JTS.isConversionNeeded(geom1, geom2)) {
        geom2 = JTS.convertToCRS(geom2, resultCRS);
      }

      final boolean result = (Boolean) geom1.intersects(geom2);

      getOrCreate(IntersectsDescriptor.RESULT, outputParameters).setValue(result);

    } catch (FactoryException ex) {
      throw new ProcessException(ex.getMessage(), this, ex);
    } catch (TransformException ex) {
      throw new ProcessException(ex.getMessage(), this, ex);
    }
  }
示例#6
0
文件: Geo.java 项目: runeengh/basex
 /**
  * Returns a boolean value that shows if this geometry intersects another geometry.
  *
  * @param node1 xml element containing gml object(s)
  * @param node2 xml element containing gml object(s)
  * @return boolean value
  * @throws QueryException query exception
  */
 @Deterministic
 public Bln intersects(final ANode node1, final ANode node2) throws QueryException {
   final Geometry geo1 = checkGeo(node1);
   final Geometry geo2 = checkGeo(node2);
   return Bln.get(geo1.intersects(geo2));
 }
示例#7
0
 /**
  * Forms create edges between two shapes maintaining convexity.
  *
  * <p>Does not currently work if the shapes intersect
  *
  * @param shape1
  * @param shape2
  * @return
  */
 public Geometry connect(final Geometry shape1, final Geometry shape2) {
   if (shape1.intersects(shape2)) return shape1.union(shape2);
   return connect(shape1, shape2, getClosestPoints(shape1, shape2, distanceFnForCoordinate));
 }
  /**
   * Add a feature with layer name (typically feature type name), some attributes and a Geometry.
   * The Geometry must be in "pixel" space 0,0 lower left and 256,256 upper right.
   *
   * <p>For optimization, geometries will be clipped, geometries will simplified and features with
   * geometries outside of the tile will be skipped.
   *
   * @param layerName
   * @param attributes
   * @param geometry
   */
  public void addFeature(String layerName, Map<String, ?> attributes, Geometry geometry) {

    // split up MultiPolygon and GeometryCollection (without subclasses)
    if (geometry instanceof MultiPolygon || geometry.getClass().equals(GeometryCollection.class)) {
      splitAndAddFeatures(layerName, attributes, (GeometryCollection) geometry);
      return;
    }

    // skip small Polygon/LineString.
    if (geometry instanceof Polygon && geometry.getArea() < 1.0d) {
      return;
    }
    if (geometry instanceof LineString && geometry.getLength() < 1.0d) {
      return;
    }

    // clip geometry. polygons right outside. other geometries at tile
    // border.
    try {
      if (geometry instanceof Polygon) {
        Geometry original = geometry;
        geometry = polygonClipGeometry.intersection(original);

        // some times a intersection is returned as an empty geometry.
        // going via wkt fixes the problem.
        if (geometry.isEmpty() && original.intersects(polygonClipGeometry)) {
          Geometry originalViaWkt = new WKTReader().read(original.toText());
          geometry = polygonClipGeometry.intersection(originalViaWkt);
        }

      } else {
        geometry = clipGeometry.intersection(geometry);
      }
    } catch (TopologyException e) {
      // could not intersect. original geometry will be used instead.
    } catch (ParseException e1) {
      // could not encode/decode WKT. original geometry will be used instead.
    }

    // if clipping result in MultiPolygon, then split once more
    if (geometry instanceof MultiPolygon) {
      splitAndAddFeatures(layerName, attributes, (GeometryCollection) geometry);
      return;
    }

    // no need to add empty geometry
    if (geometry.isEmpty()) {
      return;
    }

    Layer layer = layers.get(layerName);
    if (layer == null) {
      layer = new Layer();
      layers.put(layerName, layer);
    }

    Feature feature = new Feature();
    feature.geometry = geometry;

    for (Map.Entry<String, ?> e : attributes.entrySet()) {
      // skip attribute without value
      if (e.getValue() == null) {
        continue;
      }
      feature.tags.add(layer.key(e.getKey()));
      feature.tags.add(layer.value(e.getValue()));
    }

    layer.features.add(feature);
  }
  @Override
  /**
   * inputData a HashMap of the input data:
   *
   * @param inputObservations: the observations
   * @param inputAuthoritativeData: the polygons
   * @param bufferSize: the size of the buffer around the polygons results a HashpMap of the
   *     results:
   * @result result: the input data with the polygon attributes attached, null values for no match
   * @result qual_result: the matched input only data with polygon attributes attached
   */
  public Map<String, IData> run(Map<String, List<IData>> inputData) throws ExceptionReport {

    HashMap<String, Object> metadataMap = new HashMap<String, Object>();
    ArrayList<SimpleFeature> list = new ArrayList<SimpleFeature>();
    List<IData> inputObs = inputData.get("inputObservations");
    List<IData> inputAuth = inputData.get("inputAuthoritativeData");
    List<IData> inputLit = inputData.get("bufferSize");
    IData observations = inputObs.get(0);
    IData authoritative = inputAuth.get(0);

    IData buffersize = inputLit.get(0);

    double doubleB = (Double) buffersize.getPayload();

    FeatureCollection obsFC = ((GTVectorDataBinding) observations).getPayload();
    FeatureCollection authFC = ((GTVectorDataBinding) authoritative).getPayload();

    SimpleFeatureIterator obsIt = (SimpleFeatureIterator) obsFC.features();

    SimpleFeatureIterator authIt = (SimpleFeatureIterator) authFC.features();

    // setup result feature

    SimpleFeature obsItFeat = obsIt.next();

    SimpleFeature obsItAuth = authIt.next();

    Collection<Property> property = obsItFeat.getProperties();
    Collection<Property> authProperty = obsItAuth.getProperties();

    // setup result type builder
    SimpleFeatureTypeBuilder resultTypeBuilder = new SimpleFeatureTypeBuilder();
    resultTypeBuilder.setName("typeBuilder");

    Iterator<Property> pItObs = property.iterator();
    Iterator<Property> pItAuth = authProperty.iterator();

    metadataMap.put("element", "elementBufferedMetadata");
    File metadataFile = createXMLMetadata(metadataMap);

    while (pItObs.hasNext() == true) {

      try {
        Property tempProp = pItObs.next();

        PropertyType type = tempProp.getDescriptor().getType();
        String name = type.getName().getLocalPart();
        Class<String> valueClass = (Class<String>) tempProp.getType().getBinding();

        resultTypeBuilder.add(name, valueClass);

      } catch (Exception e) {
        LOGGER.error("property error " + e);
      }
    }
    int i = 0;
    while (pItAuth.hasNext() == true) {
      try {
        Property tempProp = pItAuth.next();

        PropertyType type = tempProp.getDescriptor().getType();
        String name = type.getName().getLocalPart();
        Class<String> valueClass = (Class<String>) tempProp.getType().getBinding();

        if (i > 3) {

          resultTypeBuilder.add(name, valueClass);
        }

        i++;

      } catch (Exception e) {
        LOGGER.error("property error " + e);
      }
    }

    obsIt.close();
    authIt.close();
    resultTypeBuilder.add("withinBuffer", Integer.class);

    // set up result feature builder

    SimpleFeatureType type = resultTypeBuilder.buildFeatureType();
    SimpleFeatureBuilder resultFeatureBuilder = new SimpleFeatureBuilder(type);

    // process data here:

    SimpleFeatureIterator obsIt2 = (SimpleFeatureIterator) obsFC.features();

    int within = 0;

    FeatureCollection resultFeatureCollection = DefaultFeatureCollections.newCollection();

    while (obsIt2.hasNext() == true) {
      within = 0;
      SimpleFeature tempObs = obsIt2.next();
      Geometry obsGeom = (Geometry) tempObs.getDefaultGeometry();

      for (Property obsProperty : tempObs.getProperties()) {

        String name = obsProperty.getName().getLocalPart();
        Object value = obsProperty.getValue();

        resultFeatureBuilder.set(name, value);
        // LOGGER.warn("obs Property set " + name);
      }

      double bufferSizeDouble = doubleB;

      Geometry bufferGeom = obsGeom.buffer(bufferSizeDouble);

      int j = 0;
      SimpleFeatureIterator authIt2 = (SimpleFeatureIterator) authFC.features();
      while (authIt2.hasNext() == true) {

        SimpleFeature tempAuth = authIt2.next();
        Geometry authGeom = (Geometry) tempAuth.getDefaultGeometry();

        if (bufferGeom.intersects(authGeom) == true) {
          within = 1;
          j = 0;

          LOGGER.warn("Intersection = true");
          for (Property authProperty1 : tempAuth.getProperties()) {

            String name = authProperty1.getName().getLocalPart();
            Object value = authProperty1.getValue();
            // Class valueClass = (Class<String>)authProperty1.getType().getBinding();

            //		LOGGER.warn("Auth property " + name);
            if (j > 3) {
              resultFeatureBuilder.set(name, value);
              //	LOGGER.warn("Auth property set " + name);

            }

            j++;
          }
        }
      }
      resultFeatureBuilder.set("withinBuffer", within);

      SimpleFeature resultFeature = resultFeatureBuilder.buildFeature(tempObs.getName().toString());
      Geometry geom = (Geometry) tempObs.getDefaultGeometry();
      resultFeature.setDefaultGeometry(geom);

      list.add(resultFeature);

      // resultFeatureCollection.add(resultFeature);
      // LOGGER.warn("RESULT FEATURE " + resultFeatureCollection.getSchema().toString());
      // resultFeatureCollection = obsFC;
    }

    ListFeatureCollection listFeatureCollection = new ListFeatureCollection(type, list);
    LOGGER.warn("Result Feature Size " + listFeatureCollection.size());

    // sort HashMap
    GenericFileData gf = null;
    try {
      gf = new GenericFileData(metadataFile, "text/xml");
    } catch (IOException e) {
      LOGGER.error("GenericFileData " + e);
    }

    HashMap<String, IData> results = new HashMap<String, IData>();
    results.put("result", new GTVectorDataBinding((FeatureCollection) obsFC));
    results.put("qual_result", new GTVectorDataBinding((FeatureCollection) listFeatureCollection));
    results.put("metadata", new GenericFileDataBinding(gf));

    return results;
  }
  private SimpleFeatureCollection calculateRisk(
      SimpleFeatureCollection features,
      JDBCDataStore dataStore,
      String storeName,
      Integer precision,
      String connectionParams,
      int processing,
      int formula,
      int target,
      String materials,
      String scenarios,
      String entities,
      String severeness,
      String fpfield,
      int batch,
      boolean simulation,
      Geometry damageArea,
      Map<Integer, Double> damageValues,
      List<TargetInfo> changedTargets,
      Map<Integer, Map<Integer, Double>> cffs,
      List<String> psc,
      Map<Integer, Map<Integer, Double>> padrs,
      Map<Integer, Double> piss,
      List<Integer> distances,
      boolean extendedSchema)
      throws IOException, SQLException {

    if (precision == null) {
      precision = 3;
    }

    DefaultTransaction transaction = new DefaultTransaction();
    Connection conn = null;
    try {
      conn = dataStore.getConnection(transaction);

      // output FeatureType (risk)
      //  - id_geo_arco
      //  - geometria
      //  - rischio1
      //  - rischio2
      SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
      tb.add(
          "id_geo_arco", features.getSchema().getDescriptor("id_geo_arco").getType().getBinding());
      tb.add(
          "geometria",
          MultiLineString.class,
          features.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem());

      if (extendedSchema) {
        tb.add("rischio_sociale", Double.class);
        tb.add("rischio_ambientale", Double.class);
        tb.add("nr_corsie", Integer.class);
        tb.add("lunghezza", Integer.class);
        tb.add("nr_incidenti", Integer.class);
      } else {
        tb.add("rischio1", Double.class);
        tb.add("rischio2", Double.class);
      }
      // fake layer name (risk) used for WPS output. Layer risk must be defined in GeoServer
      // catalog
      tb.setName(new NameImpl(features.getSchema().getName().getNamespaceURI(), "risk"));
      SimpleFeatureType ft = tb.buildFeatureType();

      // feature level (1, 2, 3)
      int level = FormulaUtils.getLevel(features);

      LOGGER.info("Doing calculus for level " + level);

      Formula formulaDescriptor = Formula.load(conn, processing, formula, target);

      if (formulaDescriptor == null) {
        throw new ProcessException("Unable to load formula " + formula);
      }

      if (((!formulaDescriptor.hasGrid() && level == 3)
              || (!formulaDescriptor.hasNoGrid() && level < 3))
          && !extendedSchema) {
        LOGGER.info("Formula not supported on this level, returning empty collection");
        return new EmptyFeatureCollection(ft);
      } else {
        // iterator on source
        SimpleFeatureIterator iter = features.features();

        // result builder
        SimpleFeatureBuilder fb = new SimpleFeatureBuilder(ft);
        ListFeatureCollection result = new ListFeatureCollection(ft);
        int count = 0;
        Double[] risk = new Double[] {0.0, 0.0};

        // iterate source features
        try {
          // we will calculate risk in batch of arcs
          // we store each feature of the batch in a map
          // indexed by id
          Map<Number, SimpleFeature> temp = new HashMap<Number, SimpleFeature>();
          StringBuilder ids = new StringBuilder();
          String fk_partner = null;

          while (iter.hasNext()) {
            SimpleFeature feature = iter.next();
            Number id = (Number) feature.getAttribute("id_geo_arco");
            fk_partner = (String) feature.getAttribute("fk_partner");
            fb.add(id);
            fb.add(feature.getDefaultGeometry());
            if (formulaDescriptor.takeFromSource()) {
              risk[0] = ((Number) feature.getAttribute("rischio1")).doubleValue();
              risk[1] = ((Number) feature.getAttribute("rischio2")).doubleValue();
            }
            fb.add(risk[0]);
            fb.add(risk[1]);
            if (extendedSchema) {
              fb.add((Number) feature.getAttribute("nr_corsie"));
              fb.add((Number) feature.getAttribute("lunghezza"));
              fb.add((Number) feature.getAttribute("nr_incidenti"));
            }
            temp.put(id.intValue(), fb.buildFeature(id + ""));

            if (simulation) {
              Double pis = piss.get(id.intValue());
              Map<Integer, Double> padr = padrs.get(id.intValue());
              Map<Integer, Double> cff = cffs.get(id.intValue());

              Map<Integer, Map<Integer, Double>> simulationTargets =
                  new HashMap<Integer, Map<Integer, Double>>();

              if (!changedTargets.isEmpty()) {
                for (int distance : distances) {
                  Geometry buffer =
                      BufferUtils.iterativeBuffer(
                          (Geometry) feature.getDefaultGeometry(), (double) distance, 100);
                  for (TargetInfo targetInfo : changedTargets) {
                    if (targetInfo.getGeometry() != null) {
                      Geometry intersection = buffer.intersection(targetInfo.getGeometry());
                      if (intersection != null && intersection.getArea() > 0) {
                        Map<Integer, Double> distancesMap =
                            simulationTargets.get(targetInfo.getType());
                        if (distancesMap == null) {
                          distancesMap = new HashMap<Integer, Double>();
                          simulationTargets.put(targetInfo.getType(), distancesMap);
                        }
                        double value = 0.0;
                        if (targetInfo.isHuman()) {
                          value =
                              intersection.getArea()
                                  / targetInfo.getGeometry().getArea()
                                  * targetInfo.getValue();
                        } else {
                          value = intersection.getArea();
                        }
                        if (targetInfo.isRemoved()) {
                          value = -value;
                        }
                        distancesMap.put(distance, value);
                      }
                    }
                  }
                }
              }

              FormulaUtils.calculateSimulationFormulaValuesOnSingleArc(
                  conn,
                  level,
                  processing,
                  formulaDescriptor,
                  id.intValue(),
                  fk_partner,
                  materials,
                  scenarios,
                  entities,
                  severeness,
                  fpfield,
                  target,
                  simulationTargets,
                  temp,
                  precision,
                  cff,
                  psc,
                  padr,
                  pis,
                  null,
                  extendedSchema);

              result.addAll(temp.values());
              temp = new HashMap<Number, SimpleFeature>();
            } else if (damageArea != null) {
              Geometry arcGeometry = (Geometry) feature.getDefaultGeometry();
              if (arcGeometry != null && arcGeometry.intersects(damageArea)) {
                FormulaUtils.calculateSimulationFormulaValuesOnSingleArc(
                    conn,
                    level,
                    processing,
                    formulaDescriptor,
                    id.intValue(),
                    fk_partner,
                    materials,
                    scenarios,
                    entities,
                    severeness,
                    fpfield,
                    target,
                    null,
                    temp,
                    precision,
                    null,
                    null,
                    null,
                    null,
                    damageValues,
                    extendedSchema);
                result.addAll(temp.values());
              }
              temp = new HashMap<Number, SimpleFeature>();
            } else {
              ids.append("," + id);
              count++;
              // calculate batch items a time
              if (count % batch == 0) {
                LOGGER.info("Calculated " + count + " values");
                FormulaUtils.calculateFormulaValues(
                    conn,
                    level,
                    processing,
                    formulaDescriptor,
                    ids.toString().substring(1),
                    fk_partner,
                    materials,
                    scenarios,
                    entities,
                    severeness,
                    fpfield,
                    target,
                    temp,
                    precision,
                    extendedSchema);
                result.addAll(temp.values());
                ids = new StringBuilder();
                temp = new HashMap<Number, SimpleFeature>();
              }
            }
          }

          // final calculus for remaining items not in batch size
          LOGGER.info("Calculating remaining items");
          if (ids.length() > 0) {
            FormulaUtils.calculateFormulaValues(
                conn,
                level,
                processing,
                formulaDescriptor,
                ids.toString().substring(1),
                fk_partner,
                materials,
                scenarios,
                entities,
                severeness,
                fpfield,
                target,
                temp,
                precision,
                extendedSchema);
          }
          result.addAll(temp.values());

          LOGGER.info("Calculated " + result.size() + " values");

        } finally {
          iter.close();
        }
        return result;
      }

    } finally {
      transaction.close();
      if (conn != null) {
        conn.close();
      }
    }
  }
  @Execute
  /**
   * inputData a HashMap of the input data:
   *
   * @param inputObservations: the observations
   * @param inputAuthoritativeData: the polygons
   * @param bufferSize: the size of the buffer in the same units as the input data (degrees for
   *     lat/long) results a HashpMap of the results:
   * @result result: the input data with the polygon attributes attached, null values for no match
   * @result qual_result: the matched input only data with polygon attributes attached
   * @result metadata: an unused output that was supposed to return an XML document for GeoNetwork
   */
  public void runBuffer() {

    Logger LOGGER = Logger.getLogger(BufferAuthoritativeDataComparison.class);

    SimpleFeatureIterator obsIt = (SimpleFeatureIterator) obsFC.features();

    SimpleFeatureIterator authIt = (SimpleFeatureIterator) authFC.features();

    // setup result feature

    SimpleFeature obsItFeat = obsIt.next();

    SimpleFeature obsItAuth = authIt.next();

    Collection<Property> property = obsItFeat.getProperties();
    Collection<Property> authProperty = obsItAuth.getProperties();

    // setup result type builder
    SimpleFeatureTypeBuilder resultTypeBuilder = new SimpleFeatureTypeBuilder();
    resultTypeBuilder.setName("typeBuilder");

    Iterator<Property> pItObs = property.iterator();
    Iterator<Property> pItAuth = authProperty.iterator();

    metadataMap.put("element", "elementBufferedMetadata");
    metadataFile = createXMLMetadata(metadataMap);

    while (pItObs.hasNext() == true) {

      try {
        Property tempProp = pItObs.next();

        PropertyType type = tempProp.getDescriptor().getType();
        String name = type.getName().getLocalPart();
        Class<String> valueClass = (Class<String>) tempProp.getType().getBinding();

        resultTypeBuilder.add(name, valueClass);

      } catch (Exception e) {
        LOGGER.error("property error " + e);
      }
    }
    int i = 0;
    while (pItAuth.hasNext() == true) {
      try {
        Property tempProp = pItAuth.next();

        PropertyType type = tempProp.getDescriptor().getType();
        String name = type.getName().getLocalPart();
        Class<String> valueClass = (Class<String>) tempProp.getType().getBinding();

        if (i > 3) {

          resultTypeBuilder.add(name, valueClass);
        }

        i++;

      } catch (Exception e) {
        LOGGER.error("property error " + e);
      }
    }

    obsIt.close();
    authIt.close();
    resultTypeBuilder.add("withinBuffer", Integer.class);

    // set up result feature builder

    SimpleFeatureType type = resultTypeBuilder.buildFeatureType();
    SimpleFeatureBuilder resultFeatureBuilder = new SimpleFeatureBuilder(type);

    // process data here:

    SimpleFeatureIterator obsIt2 = (SimpleFeatureIterator) obsFC.features();

    int within = 0;

    resultFeatureCollection = DefaultFeatureCollections.newCollection();

    while (obsIt2.hasNext() == true) {
      within = 0;
      SimpleFeature tempObs = obsIt2.next();
      Geometry obsGeom = (Geometry) tempObs.getDefaultGeometry();

      for (Property obsProperty : tempObs.getProperties()) {

        String name = obsProperty.getName().getLocalPart();
        Object value = obsProperty.getValue();

        resultFeatureBuilder.set(name, value);
        // LOGGER.warn("obs Property set " + name);
      }

      double bufferSizeDouble = Double.parseDouble(bufferSize);

      Geometry bufferGeom = obsGeom.buffer(bufferSizeDouble);

      int j = 0;
      SimpleFeatureIterator authIt2 = (SimpleFeatureIterator) authFC.features();
      while (authIt2.hasNext() == true) {

        SimpleFeature tempAuth = authIt2.next();
        Geometry authGeom = (Geometry) tempAuth.getDefaultGeometry();

        if (bufferGeom.intersects(authGeom) == true) {
          within = 1;
          j = 0;

          LOGGER.warn("Intersection = true");
          for (Property authProperty1 : tempAuth.getProperties()) {

            String name = authProperty1.getName().getLocalPart();
            Object value = authProperty1.getValue();
            // Class valueClass = (Class<String>)authProperty1.getType().getBinding();

            //		LOGGER.warn("Auth property " + name);
            if (j > 3) {
              resultFeatureBuilder.set(name, value);
              //	LOGGER.warn("Auth property set " + name);

            }

            j++;
          }
        }
      }
      resultFeatureBuilder.set("withinBuffer", within);

      SimpleFeature resultFeature = resultFeatureBuilder.buildFeature(tempObs.getName().toString());
      Geometry geom = (Geometry) tempObs.getDefaultGeometry();
      resultFeature.setDefaultGeometry(geom);

      list.add(resultFeature);

      // resultFeatureCollection.add(resultFeature);
      // LOGGER.warn("RESULT FEATURE " + resultFeatureCollection.getSchema().toString());
      // resultFeatureCollection = obsFC;
    }

    listFeatureCollection = new ListFeatureCollection(type, list);
    LOGGER.warn("Result Feature Size " + listFeatureCollection.size());
  }