diff --git a/src/app/pages/tecnalia-module/bike-analysis_AMS/bike-analysis_AMS.component.html b/src/app/pages/tecnalia-module/bike-analysis_AMS/bike-analysis_AMS.component.html index 1b63497a6625f2f0fab4bc6377609d0c90f466bc..a49091d6e8d8f01ff5528c6ff5ff77ea3c7d2ec5 100644 --- a/src/app/pages/tecnalia-module/bike-analysis_AMS/bike-analysis_AMS.component.html +++ b/src/app/pages/tecnalia-module/bike-analysis_AMS/bike-analysis_AMS.component.html @@ -29,8 +29,9 @@ <div class="control_box button_box" id="control_help" style='width:300px;'> <button (click)="openInstructions()"> Help</button> - <button id="download_run_btn1" (click)="download_geojson();">Download GEOJSON</button> - <button id="download_run_btn2" (click)="download_matrix();">Download OD Matrix</button> + <button id="upload_geojson_btn" (click)="upload_geojson();">Upload GEOJSON</button> + <button id="download_run_btn1" (click)="download_geojson();">Download GEOJSON</button> + <button id="download_run_btn2" (click)="download_matrix();">Download OD Matrix</button> </div> </div> diff --git a/src/app/pages/tecnalia-module/bike-analysis_AMS/bike-analysis_AMS.component.ts b/src/app/pages/tecnalia-module/bike-analysis_AMS/bike-analysis_AMS.component.ts index 39408407e94b8d0085fb55af6b7e695a68fced4b..e4d9d6126beb44b7820e92c788f873e2083f202b 100644 --- a/src/app/pages/tecnalia-module/bike-analysis_AMS/bike-analysis_AMS.component.ts +++ b/src/app/pages/tecnalia-module/bike-analysis_AMS/bike-analysis_AMS.component.ts @@ -3,6 +3,7 @@ import * as L from 'leaflet'; import { ConfigService } from '@ngx-config/core'; import { Options, LabelType } from '@angular-slider/ngx-slider'; import { BikeAnalysisAMSService } from '../services/bike-analysis_AMS.service'; +import { PutGeoJsonService } from '../services/put-geojson.service'; import { LeafletLayerDirective } from '@asymmetrik/ngx-leaflet'; @Component({ selector: 'ngx-od-from-counts', @@ -13,6 +14,7 @@ export class BikeAnalysisAMSComponent implements OnInit { constructor( private configService: ConfigService, + private putGeoJSONService: PutGeoJsonService, private bikeAnalysisAMSService: BikeAnalysisAMSService) { } public R_EARTH: number = 6371e3; @@ -603,4 +605,23 @@ export class BikeAnalysisAMSComponent implements OnInit { link.dispatchEvent(evt); link.remove(); } + + upload_geojson(){ + console.log("upload_geojson::: clicked"); + var fg = L.featureGroup(); + this.map.eachLayer((layer)=>{ + if(layer instanceof L.Path || layer instanceof L.Marker){ + fg.addLayer(layer); + } + }); + console.log(fg.toGeoJSON()); + let geojson = fg.toGeoJSON(); + let dt = new Date(); + let name = "test_IOP_"+dt.getTime(); + console.log("upload_geojson::: name="+name); + this.putGeoJSONService.putGeoJSON(geojson,name).subscribe( + res => {alert('geojson '+name+' added to storage.'); console.log("putGeoJSONService: SUCESS::: res="+JSON.stringify(res))}, + err => {alert('ERROR!!!\ngeojson '+name+' NOT added to storage.');console.log("putGeoJSONService: ERROR::: err="+JSON.stringify(err));} + ); + } }