Skip to content

Commit

Permalink
Remove point shifter so that it is not part of 4.1.0 release (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
osana authored Nov 12, 2018
1 parent d67f1e9 commit 083b490
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 315 deletions.
18 changes: 9 additions & 9 deletions services-geojson/src/main/java/com/mapbox/geojson/Point.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
import com.mapbox.geojson.gson.BoundingBoxSerializer;
import com.mapbox.geojson.gson.CoordinateTypeAdapter;
import com.mapbox.geojson.gson.GeoJsonAdapterFactory;
import com.mapbox.geojson.shifter.CoordinateShifterManager;

import java.io.Serializable;
import java.util.Arrays;
import java.util.List;

/**
Expand Down Expand Up @@ -97,8 +97,7 @@ public static Point fromLngLat(
@FloatRange(from = MIN_LONGITUDE, to = MAX_LONGITUDE) double longitude,
@FloatRange(from = MIN_LATITUDE, to = MAX_LATITUDE) double latitude) {

List<Double> coordinates =
CoordinateShifterManager.getCoordinateShifter().shiftLonLat(longitude, latitude);
List<Double> coordinates = Arrays.asList(longitude, latitude);
return new AutoValue_Point(TYPE, null, coordinates);
}

Expand All @@ -122,8 +121,7 @@ public static Point fromLngLat(
@FloatRange(from = MIN_LATITUDE, to = MAX_LATITUDE) double latitude,
@Nullable BoundingBox bbox) {

List<Double> coordinates =
CoordinateShifterManager.getCoordinateShifter().shiftLonLat(longitude, latitude);
List<Double> coordinates = Arrays.asList(longitude, latitude);
return new AutoValue_Point(TYPE, bbox, coordinates);
}

Expand All @@ -148,8 +146,9 @@ public static Point fromLngLat(
@FloatRange(from = MIN_LATITUDE, to = MAX_LATITUDE) double latitude,
double altitude) {

List<Double> coordinates =
CoordinateShifterManager.getCoordinateShifter().shiftLonLatAlt(longitude, latitude, altitude);
List<Double> coordinates = Double.isNaN(altitude)
? Arrays.asList(longitude, latitude) :
Arrays.asList(longitude, latitude, altitude);
return new AutoValue_Point(TYPE, null, coordinates);
}

Expand All @@ -175,8 +174,9 @@ public static Point fromLngLat(
@FloatRange(from = MIN_LATITUDE, to = MAX_LATITUDE) double latitude,
double altitude, @Nullable BoundingBox bbox) {

List<Double> coordinates =
CoordinateShifterManager.getCoordinateShifter().shiftLonLatAlt(longitude, latitude, altitude);
List<Double> coordinates = Double.isNaN(altitude)
? Arrays.asList(longitude, latitude) :
Arrays.asList(longitude, latitude, altitude);
return new AutoValue_Point(TYPE, bbox, coordinates);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
import com.google.gson.JsonSerializer;
import com.mapbox.geojson.BoundingBox;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.shifter.CoordinateShifterManager;

import java.lang.reflect.Type;
import java.util.List;

/**
* Serializer used for converting the {@link BoundingBox} object inside a GeoJson object to a JSON
Expand Down Expand Up @@ -45,24 +43,20 @@ public JsonElement serialize(BoundingBox src, Type typeOfSrc, JsonSerializationC

// Southwest
Point point = src.southwest();
List<Double> unshiftedCoordinates =
CoordinateShifterManager.getCoordinateShifter().unshiftPoint(point);

bbox.add(new JsonPrimitive(unshiftedCoordinates.get(0)));
bbox.add(new JsonPrimitive(unshiftedCoordinates.get(1)));
bbox.add(new JsonPrimitive(point.longitude()));
bbox.add(new JsonPrimitive(point.latitude()));
if (point.hasAltitude()) {
bbox.add(new JsonPrimitive(unshiftedCoordinates.get(2)));
bbox.add(new JsonPrimitive(point.altitude()));
}

// Northeast
point = src.northeast();
unshiftedCoordinates =
CoordinateShifterManager.getCoordinateShifter().unshiftPoint(point);
bbox.add(new JsonPrimitive(unshiftedCoordinates.get(0)));
bbox.add(new JsonPrimitive(unshiftedCoordinates.get(1)));
bbox.add(new JsonPrimitive(point.longitude()));
bbox.add(new JsonPrimitive(point.latitude()));
if (point.hasAltitude()) {
bbox.add(new JsonPrimitive(unshiftedCoordinates.get(2)));
bbox.add(new JsonPrimitive(point.altitude()));
}

return bbox;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.mapbox.geojson.shifter.CoordinateShifterManager;

import java.io.IOException;
import java.math.BigDecimal;
Expand All @@ -22,15 +21,11 @@ public void write(JsonWriter out, List<Double> value) throws IOException {

out.beginArray();

// Unshift coordinates
List<Double> unshiftedCoordinates =
CoordinateShifterManager.getCoordinateShifter().unshiftPoint(value);

BigDecimal lon = BigDecimal.valueOf(unshiftedCoordinates.get(0));
BigDecimal lon = BigDecimal.valueOf(value.get(0));
String lonString = lon.setScale(7, RoundingMode.HALF_UP)
.stripTrailingZeros().toPlainString();

BigDecimal lat = BigDecimal.valueOf(unshiftedCoordinates.get(1));
BigDecimal lat = BigDecimal.valueOf(value.get(1));
String latString = lat.setScale(7, RoundingMode.HALF_UP)
.stripTrailingZeros().toPlainString();

Expand All @@ -39,7 +34,7 @@ public void write(JsonWriter out, List<Double> value) throws IOException {

// Includes altitude
if (value.size() > 2) {
out.value(unshiftedCoordinates.get(2));
out.value(value.get(2));
}
out.endArray();
}
Expand All @@ -53,11 +48,6 @@ public List<Double> read(JsonReader in) throws IOException {
}
in.endArray();

if (coordinates.size() > 2) {
return CoordinateShifterManager.getCoordinateShifter()
.shiftLonLatAlt(coordinates.get(0), coordinates.get(1), coordinates.get(2));
}
return CoordinateShifterManager.getCoordinateShifter()
.shiftLonLat(coordinates.get(0), coordinates.get(1));
return coordinates;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.mapbox.geojson.Point;
import com.mapbox.geojson.shifter.CoordinateShifterManager;

import java.lang.reflect.Type;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;

/**
* Required to handle the special case where the altitude might be a Double.NaN, which isn't a valid
Expand Down Expand Up @@ -46,15 +44,11 @@ public PointSerializer() {
public JsonElement serialize(Point src, Type typeOfSrc, JsonSerializationContext context) {
JsonArray rawCoordinates = new JsonArray();

// Unshift coordinates
List<Double> unshiftedCoordinates =
CoordinateShifterManager.getCoordinateShifter().unshiftPoint(src);

BigDecimal lon = BigDecimal.valueOf(unshiftedCoordinates.get(0));
BigDecimal lon = BigDecimal.valueOf(src.longitude());
String lonString = lon.setScale(7, RoundingMode.HALF_UP)
.stripTrailingZeros().toPlainString();

BigDecimal lat = BigDecimal.valueOf(unshiftedCoordinates.get(1));
BigDecimal lat = BigDecimal.valueOf(src.latitude());
String latString = lat.setScale(7, RoundingMode.HALF_UP)
.stripTrailingZeros().toPlainString();

Expand All @@ -63,7 +57,7 @@ public JsonElement serialize(Point src, Type typeOfSrc, JsonSerializationContext

// Includes altitude
if (src.hasAltitude()) {
rawCoordinates.add(new JsonPrimitive(unshiftedCoordinates.get(3)));
rawCoordinates.add(new JsonPrimitive(src.altitude()));
}

return rawCoordinates;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 083b490

Please sign in to comment.