diff --git a/class.png b/class.png index 91134d7..b8eaa52 100644 --- a/class.png +++ b/class.png Binary files differ diff --git a/class.pu b/class.pu index f49cf1a..5f3c42e 100644 --- a/class.pu +++ b/class.pu @@ -19,7 +19,7 @@ username :VARCHAR 20 } - entity task { + entity CITYMESH { + citycode : VARCHAR 255 + meshcode : VARCHAR 255 version :VARCHAR 255 @@ -27,7 +27,7 @@ line : VARCHAR 255 point :VARCHAR 255 } - task }|- city : citycode + CITYMESH }|- city : citycode } note bottom of db : spring.datasource.url=jdbc:h2:./taskdb\nspring.jpa.hibernate.ddl-auto=update @@ -124,18 +124,18 @@ } CityController ..> CityRepository -class TaskController <> { - - repository : TaskRepository +class CitymeshController <> { + - repository : CitymeshRepository + showList(citycode, model) } -TaskController ..> TaskRepository +CitymeshController ..> CitymeshRepository -interface TaskRepository <> { - findByCitycode() : List +interface CitymeshRepository <> { + findByCitycode() : List } -TaskRepository <|-- Task +CitymeshRepository <|-- Citymesh -class Task <> { +class Citymesh <> { + id : Long - citycode : String@NumberFormat - meshcode : String @@ -146,7 +146,7 @@ + setPoint(Point) + setLine(JsonLine) } -Task .. task +Citymesh .. CITYMESH interface CommandLineRunner @@ -159,4 +159,3 @@ CommandLineRunner <|-- DataLoader @enduml - diff --git a/controller.png b/controller.png index 5960b16..419d522 100644 --- a/controller.png +++ b/controller.png Binary files differ diff --git a/controller.pu b/controller.pu index cdce74f..b5851bf 100644 --- a/controller.pu +++ b/controller.pu @@ -58,10 +58,10 @@ } cities --> cities : /city/delete/{citycode} cities --> form : /city/edit/{citycode} -cities --> tasks : /task/{citycode} +cities --> meshes : /mesh/{citycode} -state tasks { - state task_list +state meshes { + state mesh_list } state form { diff --git a/src/main/java/osm/surveyor/task/city/CitymeshController.java b/src/main/java/osm/surveyor/task/city/CitymeshController.java new file mode 100644 index 0000000..8e7f036 --- /dev/null +++ b/src/main/java/osm/surveyor/task/city/CitymeshController.java @@ -0,0 +1,28 @@ +package osm.surveyor.task.city; + +import java.util.List; + +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +import lombok.RequiredArgsConstructor; +import osm.surveyor.task.city.model.City; +import osm.surveyor.task.city.model.Citymesh; + +@RequiredArgsConstructor +@Controller +public class CitymeshController { + private final CitymeshRepository meshRepository; + private final CityRepository cityRepository; + + @GetMapping("/mesh/{citycode}") + public String showList(@PathVariable String citycode, Model model) { + City city = cityRepository.findByCitycode(citycode); + List tasks = meshRepository.findByCitycode(citycode); + model.addAttribute("city", city); + model.addAttribute("meshes", tasks); + return "meshes"; + } +} diff --git a/src/main/java/osm/surveyor/task/city/CitymeshRepository.java b/src/main/java/osm/surveyor/task/city/CitymeshRepository.java new file mode 100644 index 0000000..1faa3b9 --- /dev/null +++ b/src/main/java/osm/surveyor/task/city/CitymeshRepository.java @@ -0,0 +1,12 @@ +package osm.surveyor.task.city; + +import java.util.List; + +import org.springframework.data.jpa.repository.JpaRepository; + +import osm.surveyor.task.city.model.Citymesh; + +public interface CitymeshRepository extends JpaRepository { + + List findByCitycode(String citycode); +} diff --git a/src/main/java/osm/surveyor/task/city/DataLoader.java b/src/main/java/osm/surveyor/task/city/DataLoader.java index c205002..feba2cc 100644 --- a/src/main/java/osm/surveyor/task/city/DataLoader.java +++ b/src/main/java/osm/surveyor/task/city/DataLoader.java @@ -15,7 +15,7 @@ import osm.surveyor.task.city.model.CitiesJson; import osm.surveyor.task.city.model.City; import osm.surveyor.task.city.model.CityJson; -import osm.surveyor.task.city.model.Task; +import osm.surveyor.task.city.model.Citymesh; import osm.surveyor.task.util.Geojson; import osm.surveyor.task.util.JsonFeature; import osm.surveyor.task.util.JsonGeometryPoint; @@ -26,7 +26,7 @@ @Component public class DataLoader implements CommandLineRunner { private final CityRepository repository; - private final TaskRepository taskRepository; + private final CitymeshRepository taskRepository; @Override public void run(String... args) throws Exception { @@ -70,7 +70,7 @@ if (prop != null) { String meshcode = prop.getId(); if (meshcode != null) { - Task task = new Task(); + Citymesh task = new Citymesh(); task.setCitycode(city.getCitycode()); task.setMeshcode(meshcode); task.setVersion(prop.getVersion()); diff --git a/src/main/java/osm/surveyor/task/city/TaskController.java b/src/main/java/osm/surveyor/task/city/TaskController.java deleted file mode 100644 index 057e8b2..0000000 --- a/src/main/java/osm/surveyor/task/city/TaskController.java +++ /dev/null @@ -1,28 +0,0 @@ -package osm.surveyor.task.city; - -import java.util.List; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; - -import lombok.RequiredArgsConstructor; -import osm.surveyor.task.city.model.City; -import osm.surveyor.task.city.model.Task; - -@RequiredArgsConstructor -@Controller -public class TaskController { - private final TaskRepository taskRepository; - private final CityRepository cityRepository; - - @GetMapping("/task/{citycode}") - public String showList(@PathVariable String citycode, Model model) { - City city = cityRepository.findByCitycode(citycode); - List tasks = taskRepository.findByCitycode(citycode); - model.addAttribute("city", city); - model.addAttribute("tasks", tasks); - return "tasks"; - } -} diff --git a/src/main/java/osm/surveyor/task/city/TaskRepository.java b/src/main/java/osm/surveyor/task/city/TaskRepository.java deleted file mode 100644 index d9112cb..0000000 --- a/src/main/java/osm/surveyor/task/city/TaskRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package osm.surveyor.task.city; - -import java.util.List; - -import org.springframework.data.jpa.repository.JpaRepository; - -import osm.surveyor.task.city.model.Task; - -public interface TaskRepository extends JpaRepository { - - List findByCitycode(String citycode); -} diff --git a/src/main/java/osm/surveyor/task/city/model/Citymesh.java b/src/main/java/osm/surveyor/task/city/model/Citymesh.java new file mode 100644 index 0000000..1a742a7 --- /dev/null +++ b/src/main/java/osm/surveyor/task/city/model/Citymesh.java @@ -0,0 +1,46 @@ +package osm.surveyor.task.city.model; + +import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; +import javax.persistence.Id; +import javax.persistence.IdClass; + +import org.springframework.format.annotation.NumberFormat; + +import lombok.Getter; +import lombok.Setter; +import osm.surveyor.task.util.JsonGeometryLine; + +@Getter +@Setter +@Entity +@IdClass(CitymeshPK.class) +public class Citymesh { + + @Id + @NumberFormat(pattern="#####") + private String citycode; // CitymeshPK.citycode + + @Id + @NumberFormat + private String meshcode; // CitymeshPK.meshcode + + private String version; + + private String path; + + private String point; + + private String line; + + public void setLine(JsonGeometryLine p) { + this.line = p.toString(); + } + + /** + * ステータス + */ + @Enumerated(EnumType.ORDINAL) + private Status status = Status.PREPARATION; +} diff --git a/src/main/java/osm/surveyor/task/city/model/CitymeshPK.java b/src/main/java/osm/surveyor/task/city/model/CitymeshPK.java new file mode 100644 index 0000000..2fde21d --- /dev/null +++ b/src/main/java/osm/surveyor/task/city/model/CitymeshPK.java @@ -0,0 +1,36 @@ +package osm.surveyor.task.city.model; + +import java.io.Serializable; + +import javax.persistence.Embeddable; + +import lombok.Getter; +import lombok.Setter; + +@SuppressWarnings("serial") +@Getter +@Setter +@Embeddable +public class CitymeshPK implements Serializable { + private String citycode; + private String meshcode; + + public CitymeshPK() { + } + + public boolean equals(Object obj) { + if (obj instanceof CitymeshPK) { + if (((CitymeshPK)obj).getCitycode().equals(this.citycode)) { + if (((CitymeshPK)obj).getMeshcode().equals(this.meshcode)) { + return true; + } + } + } + return false; + } + + public int hashCode() { + String s = this.citycode + this.meshcode; + return s.hashCode(); + } +} diff --git a/src/main/java/osm/surveyor/task/city/model/Task.java b/src/main/java/osm/surveyor/task/city/model/Task.java deleted file mode 100644 index 862829c..0000000 --- a/src/main/java/osm/surveyor/task/city/model/Task.java +++ /dev/null @@ -1,46 +0,0 @@ -package osm.surveyor.task.city.model; - -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.Id; -import javax.persistence.IdClass; - -import org.springframework.format.annotation.NumberFormat; - -import lombok.Getter; -import lombok.Setter; -import osm.surveyor.task.util.JsonGeometryLine; - -@Getter -@Setter -@Entity -@IdClass(TaskPK.class) -public class Task { - - @Id - @NumberFormat(pattern="#####") - private String citycode; // TaskPK.citycode - - @Id - @NumberFormat - private String meshcode; // TaskPK.meshcode - - private String version; - - private String path; - - private String point; - - private String line; - - public void setLine(JsonGeometryLine p) { - this.line = p.toString(); - } - - /** - * ステータス - */ - @Enumerated(EnumType.ORDINAL) - private Status status = Status.PREPARATION; -} diff --git a/src/main/java/osm/surveyor/task/city/model/TaskPK.java b/src/main/java/osm/surveyor/task/city/model/TaskPK.java deleted file mode 100644 index edd32cd..0000000 --- a/src/main/java/osm/surveyor/task/city/model/TaskPK.java +++ /dev/null @@ -1,36 +0,0 @@ -package osm.surveyor.task.city.model; - -import java.io.Serializable; - -import javax.persistence.Embeddable; - -import lombok.Getter; -import lombok.Setter; - -@SuppressWarnings("serial") -@Getter -@Setter -@Embeddable -public class TaskPK implements Serializable { - private String citycode; - private String meshcode; - - public TaskPK() { - } - - public boolean equals(Object obj) { - if (obj instanceof TaskPK) { - if (((TaskPK)obj).getCitycode().equals(this.citycode)) { - if (((TaskPK)obj).getMeshcode().equals(this.meshcode)) { - return true; - } - } - } - return false; - } - - public int hashCode() { - String s = this.citycode + this.meshcode; - return s.hashCode(); - } -} diff --git a/src/main/resources/static/custom/cities.js b/src/main/resources/static/custom/cities.js index a85da32..9d0b816 100644 --- a/src/main/resources/static/custom/cities.js +++ b/src/main/resources/static/custom/cities.js @@ -79,7 +79,7 @@ var descriptionHTML = "
" + info.code + "
" + "
" + info.name + "
" + - ""; + ""; element.innerHTML = descriptionHTML; __overlay.setPosition(coordinates); __map.addOverlay(__overlay); diff --git a/src/main/resources/static/custom/meshes.js b/src/main/resources/static/custom/meshes.js new file mode 100644 index 0000000..00f9178 --- /dev/null +++ b/src/main/resources/static/custom/meshes.js @@ -0,0 +1,147 @@ +const geojson = "index.geojson"; + +var __map = null; +var __markerLayer = null; +var __lineLayer = null; + +var citycode = "00000"; +var dir = "./"; +var cityname = ""; +var lonlat = [139.7637,35.6808]; + +var queryString = window.location.pathname; +if(queryString){ + queryString = queryString.substring(1); + var parameters = queryString.split('/'); + for (var i = 0; i < parameters.length; i++) { + citycode = parameters[i]; + } +} + +function loadMap() { + $.when( + // マップ表示のための中心位置を読み取る + $.getJSON("/city/index.json") + ).done(function(data1) { + site = data1.site; + style = new ol.style.Style({ + image: new ol.style.Icon({ + src: '/img/osm_200x200.png', + anchor: [0.5, 0.5], + scale: 0.2 + }), + stroke: new ol.style.Stroke({color: '#ff33ff', width: 10}) + }); + + $(data1.list).each(function() { + if (this.code == citycode) { + lonlat = this.coordinates; // 中心位置 + dir = this.path + "/bldg/"; + cityname = this.name; + } + }); + + // マップの作成 + __map = new ol.Map({ + target: 'map', + layers: [ + new ol.layer.Tile({ + source: new ol.source.OSM() + }) + ], + view: new ol.View({ + center: ol.proj.fromLonLat(lonlat), + zoom: 12 + }) + }); + + var title = document.getElementById("title"); + title.innerHTML = "PLATEAU OSMデータ : " + citycode + " " + cityname; + + // 表示するためのレイヤーを作成する + __markerLayer = new ol.layer.Vector({ + source: new ol.source.Vector() + }); + __map.addLayer(__markerLayer); + + // ポップアップを表示するためのオーバーレイを作成する + __overlay = new ol.Overlay({ + element: document.getElementById('popup'), + positioning: 'bottom-center' + }); + + $.when( + $.getJSON("/city/"+ dir + geojson) + ).done(function(data2) { + features = data2.features; + $(features).each(function() { + if (this.geometry != null) { + if (this.geometry.type == "Point") { + var feature = new ol.Feature({ + geometry: new ol.geom.Point(ol.proj.fromLonLat(this.geometry.coordinates)) + }); + feature.information = this; + feature.setStyle(style); + __markerLayer.getSource().addFeature(feature); + } + if (this.geometry.type == "LineString") { + drawPolygon([this.geometry.coordinates]); + } + } + }); + + // 地図のクリックイベントを設定 + __map.on('click', function (evt) { + var feature = __map.forEachFeatureAtPixel( + evt.pixel, + function (feature) { + return feature; + } + ); + if (feature) { + var coordinates = feature.getGeometry().getCoordinates(); + var info = feature.information; + var element = __overlay.getElement(); + var descriptionHTML = + "
code: " + info.properties.id + "
" + + "
version: " + info.properties.version + "
" + + ""; + element.innerHTML = descriptionHTML; + __overlay.setPosition(coordinates); + __map.addOverlay(__overlay); + } else { + __map.removeOverlay(__overlay); + } + }); + }); + }); +} + +/** + * ポリゴンを描画する + */ +function drawPolygon(coordinates) { + // ジオメトリの作成 + var polygon = new ol.geom.Polygon([]); + polygon.setCoordinates(coordinates); + + // 地物オブジェクトの作成 〜 レイヤーの作成 + var feature = new ol.Feature( + polygon.transform('EPSG:4326', 'EPSG:3857') + ); + feature.setId('tokyotower'); + + var vector = new ol.source.Vector({ + features: [feature] + }); + var routeLayer = new ol.layer.Vector({ + source: vector, + style: new ol.style.Style({ + stroke: new ol.style.Stroke({ color: '#000000', width: 2 }) + //fill: new ol.style.Fill({ color: [0, 0, 0, 0.2] }) + }) + }); + + // 作成したポリゴンをレイヤーにのせる + __map.addLayer(routeLayer); +} diff --git a/src/main/resources/static/custom/tasks.js b/src/main/resources/static/custom/tasks.js deleted file mode 100644 index 00f9178..0000000 --- a/src/main/resources/static/custom/tasks.js +++ /dev/null @@ -1,147 +0,0 @@ -const geojson = "index.geojson"; - -var __map = null; -var __markerLayer = null; -var __lineLayer = null; - -var citycode = "00000"; -var dir = "./"; -var cityname = ""; -var lonlat = [139.7637,35.6808]; - -var queryString = window.location.pathname; -if(queryString){ - queryString = queryString.substring(1); - var parameters = queryString.split('/'); - for (var i = 0; i < parameters.length; i++) { - citycode = parameters[i]; - } -} - -function loadMap() { - $.when( - // マップ表示のための中心位置を読み取る - $.getJSON("/city/index.json") - ).done(function(data1) { - site = data1.site; - style = new ol.style.Style({ - image: new ol.style.Icon({ - src: '/img/osm_200x200.png', - anchor: [0.5, 0.5], - scale: 0.2 - }), - stroke: new ol.style.Stroke({color: '#ff33ff', width: 10}) - }); - - $(data1.list).each(function() { - if (this.code == citycode) { - lonlat = this.coordinates; // 中心位置 - dir = this.path + "/bldg/"; - cityname = this.name; - } - }); - - // マップの作成 - __map = new ol.Map({ - target: 'map', - layers: [ - new ol.layer.Tile({ - source: new ol.source.OSM() - }) - ], - view: new ol.View({ - center: ol.proj.fromLonLat(lonlat), - zoom: 12 - }) - }); - - var title = document.getElementById("title"); - title.innerHTML = "PLATEAU OSMデータ : " + citycode + " " + cityname; - - // 表示するためのレイヤーを作成する - __markerLayer = new ol.layer.Vector({ - source: new ol.source.Vector() - }); - __map.addLayer(__markerLayer); - - // ポップアップを表示するためのオーバーレイを作成する - __overlay = new ol.Overlay({ - element: document.getElementById('popup'), - positioning: 'bottom-center' - }); - - $.when( - $.getJSON("/city/"+ dir + geojson) - ).done(function(data2) { - features = data2.features; - $(features).each(function() { - if (this.geometry != null) { - if (this.geometry.type == "Point") { - var feature = new ol.Feature({ - geometry: new ol.geom.Point(ol.proj.fromLonLat(this.geometry.coordinates)) - }); - feature.information = this; - feature.setStyle(style); - __markerLayer.getSource().addFeature(feature); - } - if (this.geometry.type == "LineString") { - drawPolygon([this.geometry.coordinates]); - } - } - }); - - // 地図のクリックイベントを設定 - __map.on('click', function (evt) { - var feature = __map.forEachFeatureAtPixel( - evt.pixel, - function (feature) { - return feature; - } - ); - if (feature) { - var coordinates = feature.getGeometry().getCoordinates(); - var info = feature.information; - var element = __overlay.getElement(); - var descriptionHTML = - "
code: " + info.properties.id + "
" + - "
version: " + info.properties.version + "
" + - ""; - element.innerHTML = descriptionHTML; - __overlay.setPosition(coordinates); - __map.addOverlay(__overlay); - } else { - __map.removeOverlay(__overlay); - } - }); - }); - }); -} - -/** - * ポリゴンを描画する - */ -function drawPolygon(coordinates) { - // ジオメトリの作成 - var polygon = new ol.geom.Polygon([]); - polygon.setCoordinates(coordinates); - - // 地物オブジェクトの作成 〜 レイヤーの作成 - var feature = new ol.Feature( - polygon.transform('EPSG:4326', 'EPSG:3857') - ); - feature.setId('tokyotower'); - - var vector = new ol.source.Vector({ - features: [feature] - }); - var routeLayer = new ol.layer.Vector({ - source: vector, - style: new ol.style.Style({ - stroke: new ol.style.Stroke({ color: '#000000', width: 2 }) - //fill: new ol.style.Fill({ color: [0, 0, 0, 0.2] }) - }) - }); - - // 作成したポリゴンをレイヤーにのせる - __map.addLayer(routeLayer); -} diff --git a/src/main/resources/templates/cities.html b/src/main/resources/templates/cities.html index 9978258..7373f42 100644 --- a/src/main/resources/templates/cities.html +++ b/src/main/resources/templates/cities.html @@ -66,7 +66,7 @@ - + タスク diff --git a/src/main/resources/templates/meshes.html b/src/main/resources/templates/meshes.html new file mode 100644 index 0000000..1e74871 --- /dev/null +++ b/src/main/resources/templates/meshes.html @@ -0,0 +1,92 @@ + + + + + + + + + + +
+
+ + +
+
+
+ +
+
+ +
+
+ +
+
+
Plateau 3D都市データ
+
+
+ + +
+
+
+
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + +
ステータス地域メッシュversionfileoperation
+ + + タスク + + + + + 編集 + + + + + 削除 + +
+ +
+
+
+
+
+
+
+ + + diff --git a/src/main/resources/templates/tasks.html b/src/main/resources/templates/tasks.html deleted file mode 100644 index e1ae7c8..0000000 --- a/src/main/resources/templates/tasks.html +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - -
-
- - - -
-
-
- -
-
- -
-
- -
-
-
Plateau 3D都市データ
-
-
- - -
-
-
-
-
- - - -
- - - - - - - - - - - - - - - - - - - - -
ステータス地域メッシュversionfileoperation
- - - タスク - - - - - 編集 - - - - - 削除 - -
- -
-
-
-
-
-
-
- - -