本文整理汇总了Java中com.vividsolutions.jts.index.strtree.STRtree类的典型用法代码示例。如果您正苦于以下问题:Java STRtree类的具体用法?Java STRtree怎么用?Java STRtree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
STRtree类属于com.vividsolutions.jts.index.strtree包,在下文中一共展示了STRtree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: compute
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
private void compute()
{
// already computed
if (minClearancePts != null) return;
// initialize to "No Distance Exists" state
minClearancePts = new Coordinate[2];
minClearance = Double.MAX_VALUE;
// handle empty geometries
if (inputGeom.isEmpty()) {
return;
}
STRtree geomTree = FacetSequenceTreeBuilder.build(inputGeom);
Object[] nearest = geomTree.nearestNeighbour(new MinClearanceDistance());
MinClearanceDistance mcd = new MinClearanceDistance();
minClearance = mcd.distance(
(FacetSequence) nearest[0],
(FacetSequence) nearest[1]);
minClearancePts = mcd.getCoordinates();
}
开发者ID:Jules-,项目名称:terraingis,代码行数:24,代码来源:MinimumClearance.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
* 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
示例3: compute
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
private void compute() {
// already computed
if (this.minClearancePts != null) {
return;
}
// initialize to "No Distance Exists" state
this.minClearancePts = new Coordinate[2];
this.minClearance = Double.MAX_VALUE;
// handle empty geometries
if (this.inputGeom.isEmpty()) {
return;
}
STRtree geomTree = FacetSequenceTreeBuilder.build(this.inputGeom);
Object[] nearest = geomTree.nearestNeighbour(new MinClearanceDistance());
MinClearanceDistance mcd = new MinClearanceDistance();
this.minClearance = mcd.distance(
(FacetSequence) nearest[0],
(FacetSequence) nearest[1]);
this.minClearancePts = mcd.getCoordinates();
}
开发者ID:gegy1000,项目名称:Earth,代码行数:25,代码来源:MinimumClearance.java
示例4: CountryBoundaries
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
public CountryBoundaries(GeometryCollection countriesBoundaries)
{
index = new STRtree();
geometrySizeCache = new HashMap<>(400);
geometriesByIsoCodes = new HashMap<>(400);
for(int i = 0; i < countriesBoundaries.getNumGeometries(); ++i)
{
Geometry countryBoundary = countriesBoundaries.getGeometryN(i);
Map<String,String> props = (Map<String,String>) countryBoundary.getUserData();
if(props == null) continue;
if(props.containsKey(ISO3166_1_ALPHA2) || props.containsKey(ISO3166_2))
{
insertIntoIndex(countryBoundary);
insertIntoIsoCodes(countryBoundary);
}
}
}
开发者ID:westnordost,项目名称:StreetComplete,代码行数:21,代码来源:CountryBoundaries.java
示例5: readSTRtreeNode
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
private STRtree.STRtreeNode readSTRtreeNode(Kryo kryo, Input input){
int level = input.readInt();
STRtree.STRtreeNode node = new STRtree.STRtreeNode(level);
int childrenSize = input.readInt();
boolean isLeaf = (input.readByte() & 0x01) == 1;
ArrayList children = new ArrayList();
if(isLeaf){
for(int i = 0;i < childrenSize; ++i){
children.add(readItemBoundable(kryo, input));
}
}else{
for(int i = 0;i < childrenSize; ++i){
children.add(readSTRtreeNode(kryo, input));
}
}
node.setChildBoundables(children);
return node;
}
开发者ID:DataSystemsLab,项目名称:GeoSpark,代码行数:19,代码来源:SpatialIndexSerde.java
示例6: call
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
@Override
public Iterator<T> call(Iterator<SpatialIndex> treeIndexes) throws Exception {
SpatialIndex treeIndex = treeIndexes.next();
final Object[] localK;
if(treeIndex instanceof STRtree)
{
localK = ((STRtree)treeIndex).kNearestNeighbour(queryCenter.getEnvelopeInternal(), queryCenter, new GeometryItemDistance(), k);
}
else
{
throw new Exception("[KnnJudgementUsingIndex][Call] QuadTree index doesn't support KNN search.");
}
List<T> result = new ArrayList();
for(int i=0;i<localK.length;i++)
{
result.add((T) localK[i]);
}
return result.iterator();
}
开发者ID:DataSystemsLab,项目名称:GeoSpark,代码行数:20,代码来源:KnnJudgementUsingIndex.java
示例7: registerClasses
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
@Override
public void registerClasses(Kryo kryo) {
GeometrySerde serializer = new GeometrySerde();
SpatialIndexSerde indexSerializer = new SpatialIndexSerde(serializer);
log.info("Registering custom serializers for geometry types");
kryo.register(Point.class, serializer);
kryo.register(LineString.class, serializer);
kryo.register(Polygon.class, serializer);
kryo.register(MultiPoint.class, serializer);
kryo.register(MultiLineString.class, serializer);
kryo.register(MultiPolygon.class, serializer);
kryo.register(GeometryCollection.class, serializer);
kryo.register(Circle.class, serializer);
kryo.register(Envelope.class, serializer);
// TODO: Replace the default serializer with default spatial index serializer
kryo.register(Quadtree.class, indexSerializer);
kryo.register(STRtree.class, indexSerializer);
}
开发者ID:DataSystemsLab,项目名称:GeoSpark,代码行数:21,代码来源:GeoSparkKryoRegistrator.java
示例8: test
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
@Test
public void test() throws Exception {
kryo.register(Quadtree.class, spatialIndexSerde);
kryo.register(STRtree.class, spatialIndexSerde);
// test correctness
testCorrectness(Quadtree.class);
testCorrectness(STRtree.class);
// workbench of compare size
compareSize(Quadtree.class);
compareSize(STRtree.class);
// // workbench of compare time
compareTime(Quadtree.class);
compareTime(STRtree.class);
}
开发者ID:DataSystemsLab,项目名称:GeoSpark,代码行数:19,代码来源:SpatialIndexSerdeTest.java
示例9: compareSize
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
public void compareSize(Class aClass) throws IOException {
final int indexSize = 10000;
SpatialIndex tree = generateIndex(indexSize, aClass);
// do without serde first
byte[] noSerde = serializeIndexNoKryo(tree);
// do with serde
if(aClass == Quadtree.class) kryo.register(Quadtree.class, new SpatialIndexSerde());
else kryo.register(STRtree.class, new SpatialIndexSerde());
byte[] withSerde = serializeIndexKryo(tree);
System.out.println("\n==== test size of " + aClass.toString() + "====");
System.out.println("original size : " + noSerde.length);
System.out.println("with serde kryo size : " + withSerde.length);
System.out.println("percent : " + (double)withSerde.length / (double)noSerde.length);
}
开发者ID:DataSystemsLab,项目名称:GeoSpark,代码行数:18,代码来源:SpatialIndexSerdeTest.java
示例10: compute
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
private void compute() {
// already computed
if (minClearancePts != null) return;
// initialize to "No Distance Exists" state
minClearancePts = new Coordinate[2];
minClearance = Double.MAX_VALUE;
// handle empty geometries
if (inputGeom.isEmpty()) {
return;
}
STRtree geomTree = FacetSequenceTreeBuilder.build(inputGeom);
Object[] nearest = geomTree.nearestNeighbour(new MinClearanceDistance());
MinClearanceDistance mcd = new MinClearanceDistance();
minClearance = mcd.distance(
(FacetSequence) nearest[0],
(FacetSequence) nearest[1]);
minClearancePts = mcd.getCoordinates();
}
开发者ID:Semantive,项目名称:jts,代码行数:23,代码来源:MinimumClearance.java
示例11: 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
示例12: 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
示例13: generate
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
public void generate(File landsFile) {
STRtree lands = lands(landsFile);
List<Geometry> world = splittedWorld(lands);
List<Geometry> oceans = oceans(lands, world);
ShapefileWriter.write(new File("/workspace/oceans.shp"), oceans, MultiPolygon.class);
}
开发者ID:Mappy,项目名称:fpm,代码行数:8,代码来源:Oceans.java
示例14: splittedWorld
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static List<Geometry> splittedWorld(STRtree tree) {
return LargePolygonSplitter.split(world(), 5, g -> {
List<Geometry> query = tree.query(g.getEnvelopeInternal());
return query.stream().mapToInt(Geometry::getNumPoints).sum() < 2000;
});
}
开发者ID:Mappy,项目名称:fpm,代码行数:8,代码来源:Oceans.java
示例15: lands
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
private static STRtree lands(File file) {
STRtree tree = new STRtree();
try (ShapefileIterator iterator = new ShapefileIterator(file, true)) {
iterator.forEachRemaining(feature -> {
for (Polygon polygon : PolygonsUtils.polygons(feature.getGeometry())) {
for (Geometry p : LargePolygonSplitter.split(polygon, 30)) {
tree.insert(p.getEnvelopeInternal(), p);
}
}
});
}
return tree;
}
开发者ID:Mappy,项目名称:fpm,代码行数:14,代码来源:Oceans.java
示例16: difference
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static Geometry difference(STRtree tree, AtomicInteger counter, Geometry geom) {
List<Geometry> query = tree.query(geom.getEnvelopeInternal());
log.info("{} {} {}", counter.getAndDecrement(), query.size(), geom.getEnvelopeInternal());
if (!query.isEmpty()) {
List<Geometry> collect = query.stream().map(t -> t.buffer(DELTA)).collect(toList());
return geom.difference(CascadedPolygonUnion.union(collect).buffer(-1 * DELTA));
}
return geom;
}
开发者ID:Mappy,项目名称:fpm,代码行数:11,代码来源:Oceans.java
示例17: FilteredGeometrySerializer
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
public FilteredGeometrySerializer(TomtomWorld tomtom, GeometrySerializer serializer, MultiPolygon poly) {
this.tree = new STRtree();
for (Country country : tomtom.getCountries()) {
Geometry geometry = country.getGeometry();
for (Geometry geo : PolygonsUtils.polygons(geometry)) {
List<Geometry> split = LargePolygonSplitter.split(geo, 10);
for (Geometry g : split) {
tree.insert(g.getEnvelopeInternal(), g);
}
}
}
this.serializer = serializer;
this.poly = poly;
}
开发者ID:Mappy,项目名称:fpm,代码行数:15,代码来源:FilteredGeometrySerializer.java
示例18: SplittedAreas
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
public SplittedAreas() {
try {
this.tree = new STRtree();
int i = 1;
WKTReader reader = new WKTReader();
for (String line : IOUtils.readLines(getClass().getResourceAsStream("/split.csv"), UTF_8)) {
tree.insert(reader.read(line).getEnvelopeInternal(), String.valueOf(i++));
}
}
catch (IOException | ParseException e) {
throw propagate(e);
}
}
开发者ID:Mappy,项目名称:fpm,代码行数:14,代码来源:SplittedAreas.java
示例19: 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
示例20: buildIndex
import com.vividsolutions.jts.index.strtree.STRtree; //导入依赖的package包/类
private void buildIndex() {
this.index = new STRtree();
for (Object ring1 : rings) {
LinearRing ring = (LinearRing) ring1;
Envelope env = ring.getEnvelopeInternal();
this.index.insert(env, ring);
}
}
开发者ID:gegy1000,项目名称:Earth,代码行数:10,代码来源:IndexedNestedRingTester.java
注:本文中的com.vividsolutions.jts.index.strtree.STRtree类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论