/**
   * Returns all the FeatureId and ID attributes based on the query against the spatial index
   *
   * @return all the FeatureId and ID attributes based on the query against the spatial index
   */
  protected synchronized Map<String, FeatureId> unrefinedSpatialMatches() {
    if (_unrefinedMatches == null) {
      Geometry geom = null;

      // _index.query returns geometries that intersect with provided envelope. To use later a
      // spatial filter that
      // provides geometries that don't intersect with the query envelope (_geom) should be used a
      // full extent
      // envelope in this method, instead of the query envelope (_geom)
      if (getFilter().getClass().getName().equals("org.geotools.filter.spatial.DisjointImpl")) {
        try {
          geom = WORLD_BOUNDS;
        } catch (Exception ex) {
          ex.printStackTrace();
          return _unrefinedMatches;
        }

      } else {
        geom = _geom;
      }

      SpatialIndex spatialIndex = sourceAccessor.two();
      @SuppressWarnings("unchecked")
      List<Pair<FeatureId, String>> fids = spatialIndex.query(geom.getEnvelopeInternal());
      _unrefinedMatches = new HashMap<>();
      for (Pair<FeatureId, String> match : fids) {
        _unrefinedMatches.put(match.two(), match.one());
      }
    }
    return _unrefinedMatches;
  }
 private void addLine(Coordinate[] pts) {
   SegmentString segStr = new BasicSegmentString(pts, null);
   List segChains = MonotoneChainBuilder.getChains(segStr.getCoordinates(), segStr);
   for (Iterator i = segChains.iterator(); i.hasNext(); ) {
     MonotoneChain mc = (MonotoneChain) i.next();
     index.insert(mc.getEnvelope(), mc);
   }
 }
 public List query(Envelope searchEnv) {
   return index.query(searchEnv);
 }