Example usage for com.google.common.geometry S2Loop normalize

List of usage examples for com.google.common.geometry S2Loop normalize

Introduction

In this page you can find the example usage for com.google.common.geometry S2Loop normalize.

Prototype

public void normalize() 

Source Link

Document

Invert the loop if necessary so that the area enclosed by the loop is at most 2*Pi.

Usage

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);
        loop.normalize();
        loops.add(loop);/*www.j  a va  2s . com*/
    }

    return new S2Polygon(loops);
}

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 w  w  . ja  va2s .c o  m
 * @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);
}

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();//ww w .  j av a2s . 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;
}