List of usage examples for com.google.common.geometry S2Polygon intersects
public boolean intersects(S2Polygon b)
From source file:org.esa.beam.occci.S2EoProduct.java
@Override public boolean overlaps() { S2Polygon poly = getPolygon(); if (poly != null) { return poly.intersects(THE_PRODUCT); }//from ww w . ja v a 2 s . c om return false; }
From source file:org.esa.beam.occci.ReverseMatcher.java
public Set<Integer> matchProduct(String testWKT, long windowStartTime, long windowEndTime) { S2Region testRegion = new S2WKTReader().read(testWKT); S2Polygon testPoly = (S2Polygon) testRegion; S2RegionCoverer coverer = new S2RegionCoverer(); coverer.setMinLevel(3);//from w w w .j a v a 2 s. c o m coverer.setMaxLevel(3); coverer.setMaxCells(500); S2CellUnion covering = coverer.getCovering(testRegion); S2ReverseIndexCreatorMain.S2IntCoverage s2IntCoverage = new S2ReverseIndexCreatorMain.S2IntCoverage( covering); Set<Integer> candidatesSet = new HashSet<>(); for (int cellId : s2IntCoverage.intIds) { candidatesSet.addAll(reverseProductDB.findInsitu(cellId, windowStartTime, windowEndTime)); } System.out.println("candidatesSet = " + candidatesSet.size()); List<Integer> uniqueProductList = new ArrayList<>(candidatesSet); Set<Integer> matches = new HashSet<>(); try (StopWatch sw = new StopWatch(" >>load and test polygons")) { Collections.sort(uniqueProductList); try (DataInputStream dis = new DataInputStream( new BufferedInputStream(new FileInputStream(polygonFile)))) { int streamPID = 0; for (Integer productID : uniqueProductList) { while (streamPID < productID) { int numLoopPoints = dis.readInt(); dis.skipBytes(numLoopPoints * 3 * 8); streamPID++; } final int numLoopPoints = dis.readInt(); final double[] pointData = new double[numLoopPoints * 3]; for (int i = 0; i < pointData.length; i++) { pointData[i] = dis.readDouble(); } streamPID++; S2Polygon s2Polygon = S2IEoProduct.createS2Polygon(pointData); if (testPoly.intersects(s2Polygon)) { matches.add(productID); } } } catch (IOException e) { e.printStackTrace(); return null; } } return matches; }