Skip to content

Commit

Permalink
If @id is present save json for @ref in PointReader
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpoole committed Feb 19, 2019
1 parent 1d6fa60 commit 7f0e701
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/main/java/de/komoot/photon/elasticsearch/Replicatior.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void run() {
InputStream in = new BufferedInputStream(new GZIPInputStream(urlConnection.getInputStream()));
JsonReader reader = new JsonReader(in);
reader.addReader(com.vividsolutions.jts.geom.Point.class, new PointReader());

List<PhotonAction> actions = (List<PhotonAction>) reader.readObject();
int deletions = 0;
int updates = 0;
Expand Down Expand Up @@ -166,7 +167,14 @@ public Point read(Object jOb, Deque<JsonObject<String, Object>> stack, Map<Strin
} else { // crash and burn
throw new IllegalArgumentException("PointReader unknown serialisation " + c.getClass().getCanonicalName() + " " + c.toString());
}
return factory.createPoint(new Coordinate(coords[0], coords[1]));
if (coords[0] != null && coords[1] != null) {
if (((JsonObject) jOb).hasId()) {
// this isn't done automatically
Support.getReader(args).getObjectsRead().put(((JsonObject) jOb).getId(), coordinates);
}
return factory.createPoint(new Coordinate(coords[0], coords[1]));
}
throw new IllegalArgumentException("PointReader invlaid coordinates " + c.getClass().getCanonicalName() + " " + c.toString());
}
}
}

0 comments on commit 7f0e701

Please sign in to comment.