diff --git a/src/app/pages/tecnalia-module/noise-comp/noise-comp.component.html b/src/app/pages/tecnalia-module/noise-comp/noise-comp.component.html index c8cc1bf38de9f56e0ebe53e24ca02d19a9023984..481b61daea89be3044d3704a7bf58efd4afb7849 100644 --- a/src/app/pages/tecnalia-module/noise-comp/noise-comp.component.html +++ b/src/app/pages/tecnalia-module/noise-comp/noise-comp.component.html @@ -154,7 +154,7 @@ <div class="modal" id="newNewGeoJSONModal" style='display:none;z-index:2000'> <div class="modal-content" style="width:80%;height:170px"> - <button type="button" class="close" data-dismiss="modal" aria-label="Close" (click)="closenewNewGeoJSONModal();"> + <button type="button" class="close" data-dismiss="modal" style="z-index: 1000;"aria-label="Close" (click)="closenewNewGeoJSONModal();"> <span aria-hidden="true">×</span> </button> <div class="modal-header"> diff --git a/src/app/pages/tecnalia-module/noise-comp/noise-comp.component.ts b/src/app/pages/tecnalia-module/noise-comp/noise-comp.component.ts index f6ac20b3bd6d11f28648de6dc5636e7afb4e4d1a..ced1f4228dd5919b112316980d850f86d5461cc0 100644 --- a/src/app/pages/tecnalia-module/noise-comp/noise-comp.component.ts +++ b/src/app/pages/tecnalia-module/noise-comp/noise-comp.component.ts @@ -65,7 +65,7 @@ export class NoiseCompComponent implements OnInit { public model_names = []; public traffic_names = []; public static newSquareLayer; - + public geojson = {}; ngOnInit(): void { let pilotName = this.configService.getSettings("default_pilot"); if (pilotName === "BILBAO" || pilotName === "URBANITE") { this.city = "0"; } @@ -298,7 +298,7 @@ export class NoiseCompComponent implements OnInit { console.log("getNewGeoJSONS0::: data["+i+"]="+JSON.stringify(data[i])); var opt = data[i]; var el = document.createElement("option"); - el.textContent = i+": "+opt["name"]; + el.textContent = i+": "+opt["name"]; this.newgeojson_names.push(opt["name"]); this.newgeojsons.push(opt); el.value = i+""; @@ -474,10 +474,17 @@ export class NoiseCompComponent implements OnInit { ddiv.innerHTML = ''; this.legend.remove; } - this.marks =[]; + this.marks = []; if ( ps != null ){ for(let j=0;j<ps.length;j++){ - let mark = L.circle(ps[j], {radius: 2, color: this.getClr2(vl,j,qs), opacity:.5}).addTo(this.map); + let mark = new L.CircleMarker(ps[j], {radius: 2, color: this.getClr2(vl,j,qs), opacity:.5}); + mark['value'] = vl[j]; + //mark['options']['value'] = vl[j]; + //mark['properties'] = {}; + //mark['properties']['value'] = vl[j]; + //mark['feature']['properties']['value'] = vl[j] + //console.log(mark); + mark.addTo(this.map); this.marks.push(mark); } } @@ -537,8 +544,8 @@ export class NoiseCompComponent implements OnInit { this.marks =[]; if ( ps != null ){ for(let j=0;j<ps.length;j++){ - let mark = L.circle(ps[j], {radius: 2, color: this.getClr2(vl,j,qs), opacity:.5}).addTo(this.map); - this.marks.push(mark); + let mark = L.circle(ps[j], {radius: 2, color: this.getClr2(vl,j,qs), opacity:.5}).addTo(this.map); + this.marks.push(mark); } } this.legend = new L.Control({position: 'bottomleft'}); @@ -714,22 +721,40 @@ export class NoiseCompComponent implements OnInit { this.formData.append("thumbnail", file); } } - + generate_geojson(){ + this.geojson = {}; + this.geojson['type'] = 'FeatureCollection'; + this.geojson['features'] = []; + for (let j=0;j<this.marks.length;j++){ + let mark:L.CircleMarker = <L.CircleMarker>this.marks[j]; + let feature = {}; + feature['type'] = 'Feature'; + feature['properties'] = {'value': mark['value']}; + feature['geometry'] = {}; + feature['geometry']['type'] = 'Point'; + console.log(mark.getLatLng()); + feature['geometry']['coordinates'] = [mark.getLatLng()['lng'],mark.getLatLng()['lat']]; + this.geojson['features'].push(feature); + } + } upload_geojson(){ console.log("upload_geojson::: clicked"); + /* var fg = L.featureGroup(); this.map.eachLayer((layer)=>{ - if(layer instanceof L.Path || layer instanceof L.Marker){ + if( layer instanceof L.Path || layer instanceof L.Marker){ fg.addLayer(layer); } }); - console.log(fg.toGeoJSON()); - let geojson = fg.toGeoJSON(); + console.log(fg.toGeoJSON());*/ + this.generate_geojson(); + //console.log(JSON.stringify(this.marks)); let dt = new Date(); let sel = document.getElementById('comps_combo') as HTMLSelectElement; let name = "noise_computation_"+sel.value+"_"+dt.getTime(); console.log("upload_geojson::: name="+name); - this.putGeoJSONService.putGeoJSON(geojson,name,this.city).subscribe( + console.log("upload_geojson::: this.geojson="+JSON.stringify(this.geojson)); + this.putGeoJSONService.putGeoJSON(this.geojson,name,this.city).subscribe( res => { document.getElementById('nameNGJ').innerHTML = name; document.getElementById('newNewGeoJSONModal').style.display = "block"; @@ -758,10 +783,16 @@ export class NoiseCompComponent implements OnInit { let filename = document.getElementById('nameNGJ').innerHTML; console.log("process_newgeojson::: filename="+filename); console.log("process_newgeojson::: should call to end point"); + let conf = {}; + conf["layer_id"] = 0; + conf["title_layer_predicted"] = filename; + conf["description_layer_predicted"] = filename; + conf["geojson_layer_predicted"] = this.geojson; document.getElementById("newNewGeoJSONModal").style.display = "none"; } closenewNewGeoJSONModal(){ + console.log('closenewNewGeoJSONModal::: in routine...'); document.getElementById("newNewGeoJSONModal").style.display = "none"; } }