-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d5f4839
commit cde4e57
Showing
9 changed files
with
103 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/java/com/seoultech/sanEseo/public_api/CoordinateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.seoultech.sanEseo.public_api; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@AllArgsConstructor | ||
@Getter | ||
public class CoordinateRequest { | ||
|
||
private String name; | ||
private String type; | ||
|
||
private List<List<Double>> coordinates; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/java/com/seoultech/sanEseo/public_api/CoordinatesDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.seoultech.sanEseo.public_api; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CoordinatesDeserializer extends JsonDeserializer<List<List<Double>>> { | ||
@Override | ||
public List<List<Double>> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { | ||
List<List<Double>> coordinates = new ArrayList<>(); | ||
while (p.nextToken() != JsonToken.END_ARRAY) { | ||
JsonNode node = p.getCodec().readTree(p); | ||
double lat = node.get("lat").asDouble(); | ||
double lng = node.get("lng").asDouble(); | ||
List<Double> coordPair = new ArrayList<>(); | ||
coordPair.add(lat); | ||
coordPair.add(lng); | ||
coordinates.add(coordPair); | ||
} | ||
return coordinates; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/seoultech/sanEseo/public_api/CoordinatesSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.seoultech.sanEseo.public_api; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.JsonSerializer; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public class CoordinatesSerializer extends JsonSerializer<List<List<Double>>> { | ||
@Override | ||
public void serialize(List<List<Double>> value, JsonGenerator gen, SerializerProvider serializers) throws IOException { | ||
gen.writeStartArray(); | ||
for (List<Double> coord : value) { | ||
gen.writeStartObject(); | ||
gen.writeNumberField("lat", coord.get(0)); | ||
gen.writeNumberField("lng", coord.get(1)); | ||
gen.writeEndObject(); | ||
} | ||
gen.writeEndArray(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters