当前位置: 首页>>代码示例>>Java>>正文


Java STRtree.insert方法代码示例

本文整理汇总了Java中com.vividsolutions.jts.index.strtree.STRtree.insert方法的典型用法代码示例。如果您正苦于以下问题:Java STRtree.insert方法的具体用法?Java STRtree.insert怎么用?Java STRtree.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.vividsolutions.jts.index.strtree.STRtree的用法示例。


在下文中一共展示了STRtree.insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: union

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
/**
     * Computes the union of the input geometries.
     *
     * @return the union of the input geometries
     * or null if no input geometries were provided
     */
    public Geometry union() {
        if (this.inputPolys.isEmpty()) {
            return null;
        }
        this.geomFactory = ((Geometry) this.inputPolys.iterator().next()).getFactory();

        /**
         * A spatial index to organize the collection
         * into groups of close geometries.
         * This makes unioning more efficient, since vertices are more likely
         * to be eliminated on each round.
         */
//    STRtree index = new STRtree();
        STRtree index = new STRtree(STRTREE_NODE_CAPACITY);
        for (Object inputPoly : inputPolys) {
            Geometry item = (Geometry) inputPoly;
            index.insert(item.getEnvelopeInternal(), item);
        }
        List itemTree = index.itemsTree();

//    printItemEnvelopes(itemTree);

        Geometry unionAll = this.unionTree(itemTree);
        return unionAll;
    }
 
开发者ID:gegy1000,项目名称:Earth,代码行数:32,代码来源:CascadedPolygonUnion.java

示例2: union

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
/**
	 * Computes the union of the input geometries.
	 * 
	 * @return the union of the input geometries
	 * @return null if no input geometries were provided
	 */
	public Geometry union()
	{
		if (inputPolys.isEmpty())
			return null;
		geomFactory = ((Geometry) inputPolys.iterator().next()).getFactory();
		
		/**
		 * A spatial index to organize the collection
		 * into groups of close geometries.
		 * This makes unioning more efficient, since vertices are more likely 
		 * to be eliminated on each round.
		 */
//    STRtree index = new STRtree();
    STRtree index = new STRtree(STRTREE_NODE_CAPACITY);
    for (Iterator i = inputPolys.iterator(); i.hasNext(); ) {
      Geometry item = (Geometry) i.next();
      index.insert(item.getEnvelopeInternal(), item);
    }
    List itemTree = index.itemsTree();

//    printItemEnvelopes(itemTree);
    
    Geometry unionAll = unionTree(itemTree);
    return unionAll;
	}
 
开发者ID:GitHubDroid,项目名称:geodroid_master_update,代码行数:32,代码来源:CascadedPolygonUnion.java

示例3: union

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
/**
	 * Computes the union of the input geometries.
	 * 
	 * @return the union of the input geometries
	 * or null if no input geometries were provided
	 */
	public Geometry union()
	{
		if (inputPolys.isEmpty())
			return null;
		geomFactory = ((Geometry) inputPolys.iterator().next()).getFactory();
		
		/**
		 * A spatial index to organize the collection
		 * into groups of close geometries.
		 * This makes unioning more efficient, since vertices are more likely 
		 * to be eliminated on each round.
		 */
//    STRtree index = new STRtree();
    STRtree index = new STRtree(STRTREE_NODE_CAPACITY);
    for (Iterator i = inputPolys.iterator(); i.hasNext(); ) {
      Geometry item = (Geometry) i.next();
      index.insert(item.getEnvelopeInternal(), item);
    }
    List itemTree = index.itemsTree();

//    printItemEnvelopes(itemTree);
    
    Geometry unionAll = unionTree(itemTree);
    return unionAll;
	}
 
开发者ID:Jules-,项目名称:terraingis,代码行数:32,代码来源:CascadedPolygonUnion.java

示例4: createSTRTreeIndex

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
private static List createSTRTreeIndex(final List<Geometry> geomList) {
    final STRtree index = new STRtree(16);

    final PrecisionModel pm = new PrecisionModel(1000000);
    for (final Geometry item : geomList) {
        final Geometry g = GeometryPrecisionReducer.reduce(item, pm);
        index.insert(g.getEnvelopeInternal(), g);
    }

    return index.itemsTree();
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:12,代码来源:GISUtils.java

示例5: build

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
public static STRtree build(Geometry g) {
    STRtree tree = new STRtree(STR_TREE_NODE_CAPACITY);
    List sections = computeFacetSequences(g);
    for (Object section1 : sections) {
        FacetSequence section = (FacetSequence) section1;
        tree.insert(section.getEnvelope(), section);
    }
    tree.build();
    return tree;
}
 
开发者ID:gegy1000,项目名称:Earth,代码行数:11,代码来源:FacetSequenceTreeBuilder.java

示例6: STRtreeJts

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
public STRtreeJts(IFeatureCollection<Feat> collection) {
  this.collection = collection;
  stree = new STRtree();
  for (int i = 0; i < collection.size(); ++i) {
    IEnvelope egeox = collection.get(i).getGeom().getEnvelope();
    Envelope envelopeJts = new Envelope(egeox.maxX(), egeox.minX(),
        egeox.maxY(), egeox.minY());
    stree.insert(envelopeJts, i);
  }
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:11,代码来源:STRtreeJts.java

示例7: validate

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
@Override
public void validate () {
    // Project all stop coordinates and put them in a spatial index
    HashMap<Stop, Coordinate> projectedCoordinateForStop = new HashMap<>();
    STRtree stopSpatialIndex = new STRtree();
    for (Stop stop : feed.stops) {
        // Only validate point where vehicles stop, excluding logical "parent stations"
        if (stop.location_type != 0) continue;
        Coordinate projectedStopCoordinate = Util.projectLatLonToMeters(stop.stop_lat, stop.stop_lon);
        stopSpatialIndex.insert(new Envelope(projectedStopCoordinate), stop);
        projectedCoordinateForStop.put(stop, projectedStopCoordinate);
    }
    stopSpatialIndex.build();

    // Track which stops have already been reported in an error message so we don't report them more than once.
    Set<Stop> reportedStops = new HashSet<>();
    projectedCoordinateForStop.forEach((stop, coord) -> {
        if (reportedStops.contains(stop)) return;
        Envelope queryEnvelope = new Envelope(coord);
        queryEnvelope.expandBy(BUFFER_METERS);
        List<Stop> nearby = (List<Stop>)stopSpatialIndex.query(queryEnvelope).stream()
                .filter(s -> !reportedStops.contains(s)).collect(Collectors.toList());
        // The nearby stops list will include at least one stop, the one for which we're performing the query.
        // We want to include that one in the referenced entities along with the duplicates.
        if (nearby.size() > 1) {
            // TODO including bad_value and info entries - settle on one or the other
            String badStopIds = nearby.stream().map(Stop::getId).filter(s -> !s.equals(stop.stop_id))
                    .map(sid -> "stopId=" + sid).collect(Collectors.joining("; "));
            NewGTFSError error = NewGTFSError.forEntity(stop, DUPLICATE_STOP).setBadValue(badStopIds);
            int i = 1;
            for (Stop nearbyStop : nearby) {
                error.addInfo("stop_id " + i, nearbyStop.stop_id);
                i += 1;
            }
            registerError(error);
            reportedStops.addAll(nearby);
        }
    });
}
 
开发者ID:conveyal,项目名称:gtfs-lib,代码行数:40,代码来源:DuplicateStopsValidator.java

示例8: RtreePartitioning

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
/**
 * Instantiates a new rtree partitioning.
 *
 * @param samples the sample list
 * @param partitions the partitions
 * @throws Exception the exception
 */
public RtreePartitioning(List<Envelope> samples, int partitions) throws Exception
{
	STRtree strtree=new STRtree(samples.size()/partitions);
	for (Envelope sample : samples) {
		strtree.insert(sample, sample);
   	}

   	List<Envelope> envelopes=strtree.queryBoundary();
	for (Envelope envelope : envelopes) {
   		grids.add(envelope);
   	}
}
 
开发者ID:DataSystemsLab,项目名称:GeoSpark,代码行数:20,代码来源:RtreePartitioning.java

示例9: union

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
/**
     * Computes the union of the input geometries.
     * <p/>
     * This method discards the input geometries as they are processed.
     * In many input cases this reduces the memory retained
     * as the operation proceeds.
     * Optimal memory usage is achieved
     * by disposing of the original input collection
     * before calling this method.
     *
     * @return the union of the input geometries
     * or null if no input geometries were provided
     * @throws IllegalStateException if this method is called more than once
     */
    public Geometry union() {
        if (inputPolys == null)
            throw new IllegalStateException("union() method cannot be called twice");
        if (inputPolys.isEmpty())
            return null;
        geomFactory = ((Geometry) inputPolys.iterator().next()).getFactory();

        /**
         * A spatial index to organize the collection
         * into groups of close geometries.
         * This makes unioning more efficient, since vertices are more likely
         * to be eliminated on each round.
         */
//    STRtree index = new STRtree();
        STRtree index = new STRtree(STRTREE_NODE_CAPACITY);
        for (Iterator i = inputPolys.iterator(); i.hasNext(); ) {
            Geometry item = (Geometry) i.next();
            index.insert(item.getEnvelopeInternal(), item);
        }
        // To avoiding holding memory remove references to the input geometries,
        inputPolys = null;

        List itemTree = index.itemsTree();
//    printItemEnvelopes(itemTree);
        Geometry unionAll = unionTree(itemTree);
        return unionAll;
    }
 
开发者ID:Semantive,项目名称:jts,代码行数:42,代码来源:CascadedPolygonUnion.java

示例10: buildIndex

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
private void buildIndex() {
    index = new STRtree();

    for (int i = 0; i < rings.size(); i++) {
        LinearRing ring = (LinearRing) rings.get(i);
        Envelope env = ring.getEnvelopeInternal();
        index.insert(env, ring);
    }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:10,代码来源:IndexedNestedRingTester.java

示例11: build

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
public static STRtree build(Geometry g) {
    STRtree tree = new STRtree(STR_TREE_NODE_CAPACITY);
    List sections = computeFacetSequences(g);
    for (Iterator i = sections.iterator(); i.hasNext(); ) {
        FacetSequence section = (FacetSequence) i.next();
        tree.insert(section.getEnvelope(), section);
    }
    tree.build();
    return tree;
}
 
开发者ID:Semantive,项目名称:jts,代码行数:11,代码来源:FacetSequenceTreeBuilder.java

示例12: testDisallowedInserts

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
public void testDisallowedInserts() {
  STRtree t = new STRtree(5);
  t.insert(new Envelope(0, 0, 0, 0), new Object());
  t.insert(new Envelope(0, 0, 0, 0), new Object());
  t.query(new Envelope());
  try {
    t.insert(new Envelope(0, 0, 0, 0), new Object());
    assertTrue(false);
  }
  catch (AssertionFailedException e) {
    assertTrue(true);
  }
}
 
开发者ID:Semantive,项目名称:jts,代码行数:14,代码来源:STRtreeTest.java

示例13: reindex

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
/** */
private void reindex () {
    _envelope = new Envelope();
    _spatialIndex = new STRtree();
    for (int i = 0; i < _features.size(); i += 1) {
        VectorFeature feature = _features.get(i);
        Envelope featureEnvelope = feature.getEnvelope();
        _envelope.expandToInclude(featureEnvelope);
        _spatialIndex.insert(featureEnvelope, feature);
    }
}
 
开发者ID:reuven,项目名称:modelingcommons,代码行数:12,代码来源:VectorDataset.java

示例14: featureCollectionToSTRtree

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
/**
 * Extracts features from a {@link FeatureCollection} into an {@link STRtree}.
 * 
 * @param collection the feature collection.
 * @return the tree containing the features.
 */
public static STRtree featureCollectionToSTRtree( SimpleFeatureCollection collection ) {
    STRtree tree = new STRtree();
    SimpleFeatureIterator featureIterator = collection.features();
    while( featureIterator.hasNext() ) {
        SimpleFeature feature = featureIterator.next();
        Geometry geometry = (Geometry) feature.getDefaultGeometry();
        tree.insert(geometry.getEnvelopeInternal(), feature);
    }
    featureIterator.close();
    return tree;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:18,代码来源:FeatureUtilities.java

示例15: finalCleanup

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
public void finalCleanup( final double pFinalCleanupDist ) {
    if (isFirstStatsCalculation) {
        throw new IllegalArgumentException("The first round needs to be filtered on all data.");
    }
    pm.beginTask("Creating points indexes...", leftOverCoordinateList.size());
    final STRtree leftOverCoordinatesTree = new STRtree(leftOverCoordinateList.size());
    for( Coordinate c : leftOverCoordinateList ) {
        leftOverCoordinatesTree.insert(new Envelope(c), c);
    }
    pm.done();

    final AtomicInteger removedCount = new AtomicInteger();
    Geometry[] triangles = getTriangles();
    final List<Coordinate> newLeftOverCoordinateList = new ArrayList<Coordinate>();
    pm.beginTask("Final cleanup through triangle to point distance filter...", triangles.length);
    ThreadedRunnable tRun = new ThreadedRunnable(threadsNum, null);
    for( int i = 0; i < triangles.length; i++ ) {
        final Geometry triangle = triangles[i];
        tRun.executeRunnable(new Runnable(){
            public void run() {
                runFinalFilter(leftOverCoordinatesTree, newLeftOverCoordinateList, triangle, pFinalCleanupDist, removedCount);
            }
        });
    }
    tRun.waitAndClose();
    pm.done();

    pm.message("Final points removed from non ground: " + removedCount.get());
    pm.message("Final points left as non ground: " + newLeftOverCoordinateList.size());
    leftOverCoordinateList.clear();
    leftOverCoordinateList.addAll(newLeftOverCoordinateList);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:33,代码来源:TinHandler.java


注:本文中的com.vividsolutions.jts.index.strtree.STRtree.insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。