Fix shape using y instead of z coordinates
This commit is contained in:
parent
745192e232
commit
1838ebbc93
|
@ -134,7 +134,7 @@ public final class MarkerGson {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ShapeAdapter extends TypeAdapter<Shape> {
|
static class ShapeAdapter extends TypeAdapter<Shape> {
|
||||||
private static final Vector2dAdapter VEC2D_ADAPTER = new Vector2dAdapter();
|
private static final Vector2dAdapter VEC2D_ADAPTER = new Vector2dAdapter(true);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(JsonWriter out, Shape value) throws IOException {
|
public void write(JsonWriter out, Shape value) throws IOException {
|
||||||
|
@ -217,6 +217,16 @@ public final class MarkerGson {
|
||||||
|
|
||||||
static class Vector2dAdapter extends TypeAdapter<Vector2d> {
|
static class Vector2dAdapter extends TypeAdapter<Vector2d> {
|
||||||
|
|
||||||
|
private final boolean useZ;
|
||||||
|
|
||||||
|
public Vector2dAdapter() {
|
||||||
|
this.useZ = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector2dAdapter(boolean useZ) {
|
||||||
|
this.useZ = useZ;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(JsonWriter out, Vector2d value) throws IOException {
|
public void write(JsonWriter out, Vector2d value) throws IOException {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
|
@ -226,7 +236,7 @@ public final class MarkerGson {
|
||||||
|
|
||||||
out.beginObject();
|
out.beginObject();
|
||||||
out.name("x"); out.value(value.getX());
|
out.name("x"); out.value(value.getX());
|
||||||
out.name("y"); out.value(value.getY());
|
out.name(useZ ? "z" : "y"); out.value(value.getY());
|
||||||
out.endObject();
|
out.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +252,8 @@ public final class MarkerGson {
|
||||||
while (in.peek() != JsonToken.END_OBJECT) {
|
while (in.peek() != JsonToken.END_OBJECT) {
|
||||||
switch (in.nextName()) {
|
switch (in.nextName()) {
|
||||||
case "x" : x = in.nextDouble(); break;
|
case "x" : x = in.nextDouble(); break;
|
||||||
case "y" : y = in.nextDouble(); break;
|
case "y" : if (!useZ) y = in.nextDouble(); else in.skipValue(); break;
|
||||||
|
case "z" : if (useZ) y = in.nextDouble(); else in.skipValue(); break;
|
||||||
default : in.skipValue(); break;
|
default : in.skipValue(); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue