List of usage examples for com.google.common.geometry S2Polygon S2Polygon
public S2Polygon()
From source file:com.bc.fiduceo.geometry.s2.BcS2Polygon.java
@SuppressWarnings("unchecked") @Override/*from w ww .j av a2 s . c o m*/ public Geometry getIntersection(Geometry other) { if (other instanceof BcS2Polygon) { final S2Polygon intersection = new S2Polygon(); intersection.initToIntersection(googlePolygon, (S2Polygon) other.getInner()); return new BcS2Polygon(intersection); } else if (other instanceof BcS2MultiLineString) { List<S2Polyline> s2PolylineList = (List<S2Polyline>) other.getInner(); List<S2Polyline> intersectionResult = new ArrayList<>(); for (final S2Polyline s2Polyline : s2PolylineList) { intersectionResult.addAll(googlePolygon.intersectWithPolyLine(s2Polyline)); } return new BcS2MultiLineString(intersectionResult); } else if (other instanceof BcS2Point) { final S2LatLng inner = (S2LatLng) other.getInner(); if (googlePolygon.contains(inner.toPoint())) { return other; } else { return new BcS2Point(null); // "empty point" tb 2016-11-07 } } throw new RuntimeException("intersection type not implemented"); }
From source file:com.bc.fiduceo.geometry.s2.BcS2Polygon.java
@Override public Polygon getDifference(Polygon polygon) { final S2Polygon difference = new S2Polygon(); difference.initToDifference(googlePolygon, (S2Polygon) polygon.getInner()); return new BcS2Polygon(difference); }
From source file:com.bc.fiduceo.geometry.s2.BcS2Polygon.java
@Override public Polygon getUnion(Polygon polygon) { final S2Polygon union = new S2Polygon(); union.initToUnion(googlePolygon, (S2Polygon) polygon.getInner()); return new BcS2Polygon(union); }
From source file:com.bc.geometry.s2.S2WKTReader.java
/** * Creates a <code>Polygon</code> using the next token in the stream. * * @return a <code>Polygon</code> specified by the next token * in the stream// w ww. ja va 2s.c om * @throws IOException if an I/O error occurs */ private S2Polygon readPolygonText() throws IOException { String nextToken = getNextEmptyOrOpener(); if (EMPTY.equals(nextToken)) { return new S2Polygon(); } ArrayList<S2Loop> loops = new ArrayList<>(); S2Loop shell = readLinearRingText(); shell.normalize(); loops.add(shell); nextToken = getNextCloserOrComma(); while (COMMA.equals(nextToken)) { S2Loop e = readLinearRingText(); loops.add(e); // if (!loops.contains(e)) { // loops.add(e); // } nextToken = getNextCloserOrComma(); } return new S2Polygon(loops); }