List of usage examples for com.google.common.geometry S2Polygon S2Polygon
public S2Polygon(S2Polygon 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);//from ww w . j a va 2 s. 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 ww .ja v a2 s . 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 S2Polygon makePolygon(String str) { List<S2Loop> loops = Lists.newArrayList(); for (String token : Splitter.on(';').omitEmptyStrings().split(str)) { S2Loop loop = makeLoop(token);//from w w w . jav a2 s . c o m loop.normalize(); loops.add(loop); } return new S2Polygon(loops); }
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);/* w w w . j a v a 2 s . c o m*/ } S2Loop s2Loop = new S2Loop(vertices); return new S2Polygon(s2Loop); }
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. j a v a 2s . c o 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; }