Newer
Older
task-bldg / src / test / java / osm / surveyor / task / util / GeojsonTest.java
  1. package osm.surveyor.task.util;
  2.  
  3. import java.io.IOException;
  4. import java.io.InputStream;
  5.  
  6. import org.junit.jupiter.api.AfterAll;
  7. import org.junit.jupiter.api.AfterEach;
  8. import org.junit.jupiter.api.BeforeAll;
  9. import org.junit.jupiter.api.BeforeEach;
  10. import org.junit.jupiter.api.DisplayName;
  11. import org.junit.jupiter.api.Test;
  12. import org.springframework.core.io.ClassPathResource;
  13.  
  14. import com.fasterxml.jackson.databind.JsonNode;
  15. import com.fasterxml.jackson.databind.ObjectMapper;
  16.  
  17. class GeojsonTest {
  18.  
  19. @BeforeAll
  20. static void setUpBeforeClass() throws Exception {
  21. }
  22.  
  23. @AfterAll
  24. static void tearDownAfterClass() throws Exception {
  25. }
  26.  
  27. @BeforeEach
  28. void setUp() throws Exception {
  29. }
  30.  
  31. @AfterEach
  32. void tearDown() throws Exception {
  33. }
  34.  
  35. @Test
  36. @DisplayName("'Sapporo'のGeojsonをパース")
  37. void readSapporo() throws IOException {
  38. String path = "static/city/01100_sapporo-shi_2020/bldg/index.geojson";
  39. try (InputStream is = new ClassPathResource(path).getInputStream()) {
  40. ObjectMapper mapper = new ObjectMapper();
  41. JsonNode node = mapper.readTree(is);
  42. Geojson geojson = new Geojson();
  43. geojson.parse(node);
  44. System.out.println(geojson.toString());
  45. }
  46. }
  47.  
  48. }