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


Java STRtree.query方法代码示例

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


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

示例1: 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

示例2: queryIndex

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
private List queryIndex(SpatialIndex index, Envelope envelope){
    if(index instanceof Quadtree){
        Quadtree quadtree = (Quadtree) index;
        if(envelope == null){
            return quadtree.queryAll();
        }else return quadtree.query(envelope);
    }else if(index instanceof STRtree){
        STRtree strtree = (STRtree) index;
        if(envelope == null){
            envelope = new Envelope(-180, 180, -90, 90);
        }
        return strtree.query(envelope);
    }else throw new UnsupportedOperationException("unsupport index type");
}
 
开发者ID:DataSystemsLab,项目名称:GeoSpark,代码行数:15,代码来源:SpatialIndexSerdeTest.java

示例3: testEmptyTreeUsingItemVisitorQuery

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
public void testEmptyTreeUsingItemVisitorQuery()  
{
  STRtree tree = new STRtree();
  tree.query(new Envelope(0,0,1,1), new ItemVisitor() {
    public void visitItem(Object item) {
      assertTrue("Should never reach here", true);
    }
  });  
}
 
开发者ID:Semantive,项目名称:jts,代码行数:10,代码来源:STRtreeTest.java

示例4: 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

示例5: runFinalFilter

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
private void runFinalFilter( final STRtree leftOverCoordsTree, List<Coordinate> newLeftOverCoordinateList,
        final Geometry triangle, double pFinalCleanupDist, AtomicInteger removedCount ) {

    Coordinate[] tinCoords = triangle.getCoordinates();

    // get left coords around triangle
    List triangleCoordinates = null;
    monitor.readLock().lock();
    try {
        triangleCoordinates = leftOverCoordsTree.query(triangle.getEnvelopeInternal());
    } finally {
        monitor.readLock().unlock();
    }

    /*
     * now sort the points in the triangle in distance order
     * from the triangle centroid, nearest first
     */
    int count = 0;
    for( Object coordinateObj : triangleCoordinates ) {
        Coordinate c = (Coordinate) coordinateObj;
        int loc = SimplePointInAreaLocator.locate(c, triangle);
        if (loc == Location.INTERIOR) {
            Coordinate c1 = new Coordinate(c.x, c.y, 1E6);
            Coordinate c2 = new Coordinate(c.x, c.y, -1E6);
            Coordinate intersection = getLineWithPlaneIntersection(c1, c2, tinCoords[0], tinCoords[1], tinCoords[2]);
            double distance = distance3d(intersection, c, null);
            if (distance > pFinalCleanupDist) {
                count++;
                synchronized (newLeftOverCoordinateList) {
                    newLeftOverCoordinateList.add(c);
                }
            }
        }
    }
    removedCount.addAndGet(count);
    pm.worked(1);
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:39,代码来源:TinHandler.java

示例6: queryPoint

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
/**
 * Endpoint for finding the fences a certain point is in.
 */@ApiMethod(name = "point", httpMethod = "get", path = "point")
public ArrayList < MyFence > queryPoint(@Named("group") String group, @Named("lng") double lng, @Named("lat") double lat) {
    ArrayList < MyFence > fences = new ArrayList < MyFence > ();

    //Get the Index from Memcache.
    MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
    GeometryFactory gf = new GeometryFactory();
    STRtree index = (STRtree) syncCache.get(group); // read from cache
    if (index != null) {
        Coordinate coord = new Coordinate(lng, lat);
        Point point = gf.createPoint(coord);
        List < MyPolygon > items = index.query(point.getEnvelopeInternal());
        if (!items.isEmpty()) {
            for (MyPolygon poly: items) {
                if (poly.contains(point)) {
                    long id = poly.getID();
                    MyFence newFence = new MyFence();
                    newFence.setId(id);
                    fences.add(newFence);
                }
            }
        }
    } else {
        try {
            MyIndex.buildIndex(group);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return fences;
}
 
开发者ID:tschaeff,项目名称:google-geoEngine,代码行数:34,代码来源:GeoFencingAPI.java

示例7: testEmptyTreeUsingListQuery

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
public void testEmptyTreeUsingListQuery()  
{
  STRtree tree = new STRtree();
  List list = tree.query(new Envelope(0, 0, 1, 1));
  assertTrue(list.isEmpty());
}
 
开发者ID:Semantive,项目名称:jts,代码行数:7,代码来源:STRtreeTest.java

示例8: process

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Execute
public void process() throws Exception {
    checkNull(inVector, pMaxOverlap, inRaster);

    RandomIter rasterIter = CoverageUtilities.getRandomIterator(inRaster);
    GridGeometry2D gridGeometry = inRaster.getGridGeometry();
    double[] tm_utm_tac = new double[3];

    STRtree circlesTree = FeatureUtilities.featureCollectionToSTRtree(inVector);
    List<SimpleFeature> circlesList = FeatureUtilities.featureCollectionToList(inVector);

    DefaultFeatureCollection outFC = new DefaultFeatureCollection();

    for( SimpleFeature circleFeature : circlesList ) {
        Geometry geometry = (Geometry) circleFeature.getDefaultGeometry();
        Polygon circle = (Polygon) geometry.getGeometryN(0);
        PreparedGeometry preparedCircle = PreparedGeometryFactory.prepare(circle);

        List<SimpleFeature> circlesAround = circlesTree.query(circle.getEnvelopeInternal());
        List<Geometry> intersectedCircles = new ArrayList<Geometry>();
        for( SimpleFeature circleAround : circlesAround ) {
            if (circleAround.equals(circleFeature)) {
                continue;
            }
            Geometry circleAroundGeometry = (Geometry) circleAround.getDefaultGeometry();
            if (preparedCircle.intersects(circleAroundGeometry)) {
                intersectedCircles.add(circleAroundGeometry);
            }
        }

        Point centroid = circle.getCentroid();
        int intersectionsCount = intersectedCircles.size();
        if (intersectionsCount != 0) {
            // check how many circles overlapped
            if (intersectionsCount > pMaxOverlapCount) {
                continue;
            }
            // check if the circles overlap too much, i.e. cover their baricenter
            boolean intersected = false;
            for( Geometry intersectedCircle : intersectedCircles ) {
                if (intersectedCircle.intersects(centroid)) {
                    intersected = true;
                    break;
                }
            }
            if (intersected) {
                continue;
            }
        }
        // check if the center has a raster value, i.e. is not empty
        double value = CoverageUtilities.getValue(inRaster, centroid.getCoordinate());
        if (!HMConstants.isNovalue(value)) {
            continue;
        }

        // check if the inner part of the circle is indeed rather empty

        // min, max, mean, var, sdev, activeCellCount, passiveCellCount
        double[] stats = OmsZonalStats.polygonStats(circle, gridGeometry, rasterIter, false, tm_utm_tac, 0, pm);
        // if we have many more active cells than passive cells, that is not a circle
        double activeCells = stats[5];
        double novalues = stats[6];
        if (activeCells * 1.5 > novalues) {
            continue;
        }

        // take it as valid circle
        outFC.add(circleFeature);
    }
    outCircles = outFC;

    rasterIter.done();
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:75,代码来源:OmsHoughCirclesRasterCleaner.java

示例9: processing

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
private void processing( final int cols, final STRtree tree, final WritableRandomIter interpolatedIter, final double[] eval,
        final int row ) {
    try {
        for( int c = 0; c < cols; c++ ) {
            final DirectPosition gridToWorld = gridGeometry.gridToWorld(new GridCoordinates2D(c, row));
            // System.out.println(row + "/" + c);
            boolean doProcess = true;
            if (inMask != null) {
                inMask.evaluate(gridToWorld, eval);
                if (isNovalue(eval[0])) {
                    doProcess = false;
                }
            }

            if (doProcess) {
                final Coordinate currentCoord = new Coordinate();
                final double[] coord = gridToWorld.getCoordinate();
                currentCoord.x = coord[0];
                currentCoord.y = coord[1];

                final Envelope env = new Envelope(currentCoord.x - pBuffer, currentCoord.x + pBuffer, currentCoord.y
                        - pBuffer, currentCoord.y + pBuffer);

                @SuppressWarnings("unchecked")
                final List<Coordinate> result = tree.query(env);
                // System.out.println(row + "/" + c + "  = " + result.size());

                // we need at least 3 points
                if (result.size() < 4) {
                    continue;
                }

                final double value = interpolator.getValue(result.toArray(new Coordinate[0]), currentCoord);
                synchronized (interpolatedIter) {
                    interpolatedIter.setSample(c, row, 0, value);
                }
            }

        }
        pm.worked(1);
    } catch (TransformException e) {
        e.printStackTrace();
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:45,代码来源:OmsSurfaceInterpolator.java

示例10: makeRow

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
private void makeRow( STRtree tree, int newRows, GridGeometry2D newGridGeometry2D, WritableRaster newWR, int c )
        throws TransformException {
    for( int r = 0; r < newRows; r++ ) {
        DirectPosition worldPosition = newGridGeometry2D.gridToWorld(new GridCoordinates2D(c, r));
        double[] wpCoords = worldPosition.getCoordinate();
        Coordinate coordinate = new Coordinate(wpCoords[0], wpCoords[1]);
        Point point = gf.createPoint(coordinate);
        Envelope e = new Envelope(coordinate);
        List interceptedTriangles = tree.query(e);
        if (interceptedTriangles.size() == 0) {
            continue;
        }
        double newElev = -9999.0;
        for( Object object : interceptedTriangles ) {
            if (object instanceof Geometry) {
                Geometry triangle = (Geometry) object;
                if (!triangle.intersects(point)) {
                    continue;
                }
                Coordinate[] triangleCoords = triangle.getCoordinates();
                Coordinate c1 = new Coordinate(coordinate.x, coordinate.y, 1E4);
                Coordinate c2 = new Coordinate(coordinate.x, coordinate.y, -1E4);
                Coordinate intersection = GeometryUtilities.getLineWithPlaneIntersection(c1, c2, triangleCoords[0],
                        triangleCoords[1], triangleCoords[2]);
                double maxZ = max(triangleCoords[0].z, triangleCoords[1].z);
                maxZ = max(maxZ, triangleCoords[2].z);
                if (intersection.z > maxZ) {
                    boolean equals = NumericsUtilities.dEq(intersection.z, maxZ, 0.0001);
                    if (!equals) {
                        pm.errorMessage(triangle.toText());
                        pm.errorMessage(gf.createPoint(intersection).toText());
                        throw new RuntimeException("Intersection can't be  > than the triangle.");
                    }
                }
                if (intersection.z > newElev) {
                    newElev = intersection.z;
                }
            }
        }
        synchronized (newWR) {
            newWR.setSample(c, r, 0, newElev);
        }
    }
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:45,代码来源:LasTriangulation2Dsm.java

示例11: queryPolyLine

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
/**
 * Endpoint for finding the fences that intersect with a polyline.
 */@ApiMethod(name = "polyline", httpMethod = "post", path = "polyline")
public ArrayList < MyFence > queryPolyLine(@Named("group") String group, MyPolyLine polyline) {
    ArrayList < MyFence > fences = new ArrayList < MyFence > ();

    //Get the index from Memcache.
    MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
    GeometryFactory gf = new GeometryFactory();
    STRtree index = (STRtree) syncCache.get(group); // read from cache
    if (index != null) {
        //Create coordinate array.
        double[][] points = polyline.getCoordinates();
        Coordinate[] coordinates = new Coordinate[points.length];
        int i = 0;
        for (double[] point: points) {
            Coordinate coordinate = new Coordinate(point[0], point[1]);
            coordinates[i++] = coordinate;
        }
        //Create polyline.
        GeometryFactory fact = new GeometryFactory();
        LineString linestring = new GeometryFactory().createLineString(coordinates);

        List < MyPolygon > items = index.query(linestring.getEnvelopeInternal());
        if (!items.isEmpty()) {
            for (MyPolygon poly: items) {
                if (linestring.crosses(poly) || poly.contains(linestring)) {
                    long id = poly.getID();
                    MyFence newFence = new MyFence();
                    newFence.setId(id);
                    fences.add(newFence);
                }
            }
        }
    } else {
        try {
            MyIndex.buildIndex(group);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    return fences;
}
 
开发者ID:tschaeff,项目名称:google-geoEngine,代码行数:45,代码来源:GeoFencingAPI.java

示例12: queryPolygon

import com.vividsolutions.jts.index.strtree.STRtree; //导入方法依赖的package包/类
/**
 * Endpoint for finding the fences that intersect with a polygon.
 */@ApiMethod(name = "polygon", httpMethod = "post", path = "polygon")
public ArrayList < MyFence > queryPolygon(@Named("group") String group, MyPolyLine polyline) {
    ArrayList < MyFence > fences = new ArrayList < MyFence > ();

    //Get index from Memcache
    MemcacheService syncCache = MemcacheServiceFactory.getMemcacheService();
    STRtree index = (STRtree) syncCache.get(group); // read from cache
    if (index != null) {
        //Create coordinate array.
        double[][] points = polyline.getCoordinates();
        Coordinate[] coordinates = new Coordinate[points.length];
        int i = 0;
        for (double[] point: points) {
            Coordinate coordinate = new Coordinate(point[0], point[1]);
            coordinates[i++] = coordinate;
        }
        //Create polygon.
        GeometryFactory fact = new GeometryFactory();
        LinearRing linear = new GeometryFactory().createLinearRing(coordinates);
        Polygon polygon = new Polygon(linear, null, fact);

        List < MyPolygon > items = index.query(polygon.getEnvelopeInternal());
        if (!items.isEmpty()) {
            for (MyPolygon poly: items) {
                if (polygon.contains(poly) || !polygon.disjoint(poly)) {
                    long id = poly.getID();
                    MyFence newFence = new MyFence();
                    newFence.setId(id);
                    fences.add(newFence);
                }
            }
        }
    } else {
        try {
            MyIndex.buildIndex(group);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    return fences;
}
 
开发者ID:tschaeff,项目名称:google-geoEngine,代码行数:45,代码来源:GeoFencingAPI.java


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