List of usage examples for com.google.common.geometry S2Loop S2Loop
public S2Loop(S2Loop src)
From source file:org.esa.beam.occci.S2IEoProduct.java
static S2Polygon createS2Polygon(double[] poygonData) { List<S2Point> vertices = new ArrayList<S2Point>(poygonData.length / 3); for (int i = 0; i < poygonData.length;) { double x = poygonData[i++]; double y = poygonData[i++]; double z = poygonData[i++]; S2Point s2Point = new S2Point(x, y, z); vertices.add(s2Point);/* w w w . j av a 2s . co m*/ } return new S2Polygon(new S2Loop(vertices)); }
From source file:com.bc.fiduceo.geometry.s2.BcS2GeometryFactory.java
@Override public Polygon createPolygon(List<Point> points) { final List<S2Point> loopPoints = extractS2Points(points); final S2Point first = loopPoints.get(0); final int lastIndex = loopPoints.size() - 1; final S2Point last = loopPoints.get(lastIndex); if (first.equals(last)) { loopPoints.remove(lastIndex);//from w w w .ja v a2s .co m } final S2Loop s2Loop = new S2Loop(loopPoints); final S2Polygon googlePolygon = new S2Polygon(s2Loop); return new BcS2Polygon(googlePolygon); }
From source file:org.geosde.cassandra.GeometryTestCase.java
static S2Loop makeLoop(String str) { List<S2Point> vertices = Lists.newArrayList(); parseVertices(str, vertices); return new S2Loop(vertices); }
From source file:org.esa.beam.occci.S2IEoProduct.java
private static S2Polygon createS2Polygon(String loopPoints) { StringTokenizer stPoints = new StringTokenizer(loopPoints, ";"); List<S2Point> vertices = new ArrayList<S2Point>(); while (stPoints.hasMoreTokens()) { String point = stPoints.nextToken(); String substring = point.substring(1, point.length() - 1); StringTokenizer stXYZ = new StringTokenizer(substring, ","); S2Point s2Point = new S2Point(Double.parseDouble(stXYZ.nextToken()), Double.parseDouble(stXYZ.nextToken()), Double.parseDouble(stXYZ.nextToken())); vertices.add(s2Point);//ww w .jav a2 s . co m } S2Loop s2Loop = new S2Loop(vertices); return new S2Polygon(s2Loop); }
From source file:com.bc.geometry.s2.S2WKTReader.java
/** * Creates a <code>LinearRing</code> using the next token in the stream. * * @return a <code>LinearRing</code> specified by the next * token in the stream//from w ww .j av a 2s .c om * @throws IOException if an I/O error occurs * @throws IllegalArgumentException if the coordinates used to create the <code>LinearRing</code> * do not form a closed linestring, or if an unexpected token was * encountered */ private S2Loop readLinearRingText() throws IOException, IllegalArgumentException { List<S2Point> points = getPoints(); if (points.size() > 1 && points.get(0).equals(points.get(points.size() - 1))) { points.remove(points.size() - 1); } return new S2Loop(points); }
From source file:com.bc.geometry.s2.S2WKTReader.java
private List<S2Polygon> readMultiPolygonText() throws IOException, IllegalArgumentException { List<S2Polygon> s2PolygonList = new ArrayList<>(); while (true) { int i = tokenizer.nextToken(); if (StreamTokenizer.TT_WORD == i) { tokenizer.pushBack();/*from w w w . ja v a2 s. co m*/ List<S2Point> points = getMultiPolygonPoints(); S2Loop s2Loop = new S2Loop(points); s2Loop.normalize(); s2PolygonList.add(new S2Polygon(s2Loop)); } if (i == ')') { int i1 = tokenizer.nextToken(); if (i1 == StreamTokenizer.TT_EOF) { break; } tokenizer.pushBack(); } } return s2PolygonList; }