Closed matthias-mueller closed 8 years ago
Hi there,
while making myself familiar with this great library I was trying to convert an S2Cell into a WKT Polygon using its four vertices. As it turned out, the values of all four vertices are identical with any of my test cells. Here is an example:
S2Cell
1011111111100000000000000000000000000000000000000000000000000000 [Lo=(-1.5707963267948966, -3.141592653589793), Hi=(-0.6154797086703869, 3.141592653589793)] V0: (-35.264389682754654, -135.0) V1: (-35.264389682754654, -135.0) V2: (-35.264389682754654, -135.0) V3: (-35.264389682754654, -135.0)
This is the code I am using:
private static String toWKTPolygon(final S2Cell cell){ String wkt = new String("POLYGON(("); S2LatLng point; System.out.println(cell.toString()); System.out.println(toBinaryString(cell.id().id())); System.out.println(cell.getRectBound().toString()); // vertex order in S2LatLng is CCW, thus compliant with vertex order in WKT for (int i=0; i<4; i++){ System.out.println("V" + i + ": " + cell.getVertex(i).toDegreesString()); point = new S2LatLng(cell.getVertex(i)); wkt = wkt.concat(point.lngDegrees() + " " + point.latDegrees() + ","); } // close the poly loop point = new S2LatLng(cell.getVertex(0)); wkt = wkt.concat(point.lngDegrees() + " " + point.latDegrees() + "))"); return wkt; }
If this is not a bug, how would I obtain the "natural" vertices of an S2Cell?
I am sorry, this is a non-issue. A bit-shift error in my code led to invalid cellIDs.
Hi there,
while making myself familiar with this great library I was trying to convert an
S2Cell
into a WKT Polygon using its four vertices. As it turned out, the values of all four vertices are identical with any of my test cells. Here is an example:This is the code I am using:
If this is not a bug, how would I obtain the "natural" vertices of an
S2Cell
?