- Timestamp:
- May 1, 2019, 3:55:35 PM (8 years ago)
- Branches:
- debian/bullseye, master
- Children:
- 1e7f556
- Parents:
- be25db1
- Location:
- src
- Files:
-
- 7 added
- 1 deleted
- 30 edited
-
mapservice-webclient/package-lock.json (modified) (2 diffs)
-
mapservice-webclient/package.json (modified) (1 diff)
-
mapservice-webclient/src-gen/gnuboat-mapservice/model/models.ts (modified) (1 diff)
-
mapservice-webclient/src-gen/gnuboat-mapservice/model/osmType.ts (added)
-
mapservice-webclient/src-gen/gnuboat-mapservice/model/water.ts (modified) (2 diffs)
-
mapservice-webclient/src-gen/gnuboat-mapservice/model/waterCreation.ts (modified) (2 diffs)
-
mapservice-webclient/src/app/app.component.html (modified) (1 diff)
-
mapservice-webclient/src/app/app.module.ts (modified) (2 diffs)
-
mapservice-webclient/src/app/app.routing.ts (modified) (2 diffs)
-
mapservice-webclient/src/app/home/home.component.html (modified) (1 diff)
-
mapservice-webclient/src/app/home/home.component.ts (modified) (1 diff)
-
mapservice-webclient/src/app/mygnuboat/index.ts (modified) (1 diff)
-
mapservice-webclient/src/app/mygnuboat/map.component.html (modified) (1 diff)
-
mapservice-webclient/src/app/mygnuboat/map.component.ts (modified) (6 diffs)
-
mapservice-webclient/src/app/mygnuboat/user.component.html (modified) (2 diffs)
-
mapservice-webclient/src/app/mygnuboat/water.component.html (added)
-
mapservice-webclient/src/app/mygnuboat/water.component.ts (added)
-
mapservice-webclient/src/app/mygnuboat/wateradd.component.html (modified) (2 diffs)
-
mapservice-webclient/src/app/mygnuboat/wateradd.component.ts (modified) (7 diffs)
-
mapservice-webclient/src/app/mygnuboat/wateredit.component.css (added)
-
mapservice-webclient/src/app/mygnuboat/wateredit.component.html (added)
-
mapservice-webclient/src/app/mygnuboat/wateredit.component.ts (added)
-
mapservice-webclient/src/app/services/alert.service.ts (modified) (1 diff)
-
mapservice-webclient/src/app/services/index.ts (modified) (1 diff)
-
mapservice-webclient/src/app/services/osmoverpass.service.ts (added)
-
mapservice-webclient/src/app/user/login.component.html (modified) (1 diff)
-
mapservice-webclient/src/app/user/login.component.ts (modified) (1 diff)
-
mapservice-webclient/src/app/user/register.component.html (modified) (1 diff)
-
mapservice-webclient/src/css/GnuBoat.Mapservice.Webclient.css (modified) (3 diffs)
-
mapservice/openapi.yaml (modified) (8 diffs)
-
mapservice/src-gen/openapi_server/models/__init__.py (modified) (1 diff)
-
mapservice/src-gen/openapi_server/models/water.py (modified) (8 diffs)
-
mapservice/src-gen/openapi_server/models/water_creation.py (modified) (4 diffs)
-
mapservice/src-gen/openapi_server/openapi/openapi.yaml (modified) (11 diffs)
-
mapservice/src-gen/openapi_server/test/test_default_controller.py (deleted)
-
mapservice/src/server_impl/controllers/WatersController.py (modified) (3 diffs)
-
mapservice/src/server_impl/database/Model.py (modified) (4 diffs)
-
mapservice/src/server_impl/tests/test_waters.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/mapservice-webclient/package-lock.json
rbe25db1 r041e464 2890 2890 "dev": true 2891 2891 }, 2892 "d3-queue": { 2893 "version": "2.0.3", 2894 "resolved": "https://registry.npmjs.org/d3-queue/-/d3-queue-2.0.3.tgz", 2895 "integrity": "sha1-B/vaOsrlNYqcUpmq+ICt8JU+0sI=" 2896 }, 2892 2897 "dashdash": { 2893 2898 "version": "1.14.1", … … 6381 6386 } 6382 6387 }, 6388 "leaflet-image": { 6389 "version": "0.4.0", 6390 "resolved": "https://registry.npmjs.org/leaflet-image/-/leaflet-image-0.4.0.tgz", 6391 "integrity": "sha1-6E8i/2KI8JubDi9RpIUKnweWjME=", 6392 "requires": { 6393 "d3-queue": "2.0.3" 6394 } 6395 }, 6383 6396 "less": { 6384 6397 "version": "3.9.0", -
src/mapservice-webclient/package.json
rbe25db1 r041e464 23 23 "@angular/router": "~7.2.0", 24 24 "core-js": "^2.5.4", 25 "leaflet-image": "^0.4.0", 25 26 "osmtogeojson": "^3.0.0-beta.3", 26 27 "rxjs": "~6.3.3", -
src/mapservice-webclient/src-gen/gnuboat-mapservice/model/models.ts
rbe25db1 r041e464 1 1 export * from './httpError'; 2 2 export * from './order'; 3 export * from './osmType'; 3 4 export * from './user'; 4 5 export * from './userCreation'; -
src/mapservice-webclient/src-gen/gnuboat-mapservice/model/water.ts
rbe25db1 r041e464 10 10 * Do not edit the class manually. 11 11 */ 12 import { OsmType } from './osmType'; 12 13 13 14 … … 17 18 manager?: string; 18 19 osmId?: number; 19 osmType?: string; 20 osmClass?: string; 20 osmType?: OsmType; 21 21 } 22 22 -
src/mapservice-webclient/src-gen/gnuboat-mapservice/model/waterCreation.ts
rbe25db1 r041e464 10 10 * Do not edit the class manually. 11 11 */ 12 import { OsmType } from './osmType'; 12 13 13 14 … … 15 16 name: string; 16 17 osmId?: number; 17 osmType?: string;18 osmType?: OsmType; 18 19 } 19 20 -
src/mapservice-webclient/src/app/app.component.html
rbe25db1 r041e464 17 17 </nav> 18 18 <div class="main"> 19 <alert></alert>20 19 <router-outlet></router-outlet> 21 20 </div> -
src/mapservice-webclient/src/app/app.module.ts
rbe25db1 r041e464 14 14 import { HomeComponent } from './home/'; 15 15 import { LoginComponent, RegisterComponent } from './user'; 16 import { UserComponent, Water AddComponent, MapComponent } from './mygnuboat';16 import { UserComponent, WaterComponent, WaterAddComponent, WaterEditComponent, MapComponent } from './mygnuboat'; 17 17 18 18 … … 32 32 RegisterComponent, 33 33 UserComponent, 34 WaterComponent, 34 35 WaterAddComponent, 36 WaterEditComponent, 35 37 MapComponent, 36 38 ], -
src/mapservice-webclient/src/app/app.routing.ts
rbe25db1 r041e464 3 3 import { AuthGuard } from './guards'; 4 4 import { LoginComponent, RegisterComponent } from './user'; 5 import { UserComponent, WaterAddComponent } from './mygnuboat';5 import { UserComponent, WaterAddComponent, WaterEditComponent } from './mygnuboat'; 6 6 import { HomeComponent } from './home'; 7 7 … … 11 11 { path: 'mygnuboat', component: UserComponent, canActivate: [AuthGuard] }, 12 12 { path: 'mygnuboat/water/add', component: WaterAddComponent, canActivate: [AuthGuard] }, 13 { path: 'mygnuboat/water/:id', component: WaterEditComponent, canActivate: [AuthGuard] }, 13 14 { path: 'register', component: RegisterComponent }, 14 15 -
src/mapservice-webclient/src/app/home/home.component.html
rbe25db1 r041e464 1 <gnuboat-map [ mapViewportStyleClass]='mapViewportStyleClass'></gnuboat-map>1 <gnuboat-map [viewportStyleClass]='mapViewportStyleClass'></gnuboat-map> -
src/mapservice-webclient/src/app/home/home.component.ts
rbe25db1 r041e464 5 5 @Component({ templateUrl: 'home.component.html' }) 6 6 export class HomeComponent implements OnInit, OnDestroy { 7 mapViewportStyleClass:string = ' viewport-geometry';7 mapViewportStyleClass:string = 'home-map'; 8 8 constructor() { 9 9 } -
src/mapservice-webclient/src/app/mygnuboat/index.ts
rbe25db1 r041e464 1 1 export * from './user.component'; 2 export * from './water.component'; 2 3 export * from './wateradd.component'; 4 export * from './wateredit.component'; 3 5 export * from './map.component'; -
src/mapservice-webclient/src/app/mygnuboat/map.component.html
rbe25db1 r041e464 1 <div id="mapViewport" [ngClass]="_mapViewportStyleClass">1 <div #mapElement [ngClass]='_mapViewportStyleClass'> 2 2 <div class="leaflet-top map-middle"> 3 3 <div class="leaflet-control"> 4 <img id="logo" src="resources/gnuboat-256-256-transparent.png" />4 <img *ngIf="gnuboat" id="logo" src="resources/gnuboat-256-256-transparent.png" /> 5 5 </div> 6 6 </div> -
src/mapservice-webclient/src/app/mygnuboat/map.component.ts
rbe25db1 r041e464 1 import { Component, OnInit, OnDestroy, Input } from '@angular/core';1 import { Component, OnInit, OnDestroy, Input, ViewChild } from '@angular/core'; 2 2 3 3 declare let L; 4 4 5 import { OsmType } from '../../../src-gen/gnuboat-mapservice'; 6 import { OsmOverpassService } from '../services'; 7 5 8 @Component({ 6 9 selector: 'gnuboat-map', 7 templateUrl: 'map.component.html' 10 templateUrl: 'map.component.html', 11 providers: [OsmOverpassService], 8 12 }) 9 13 export class MapComponent implements OnInit, OnDestroy { … … 11 15 private map; 12 16 private mapControl; 17 private geoJsonLayer; 18 @Input() controlsShow = true; 19 @ViewChild('mapElement') mapElement; 13 20 14 constructor( ) {21 constructor(private osmOverpassService: OsmOverpassService) { 15 22 } 16 23 … … 27 34 28 35 @Input() 29 set mapViewportStyleClass(styleClass: string){36 set viewportStyleClass(styleClass: string){ 30 37 this._mapViewportStyleClass = styleClass; 31 38 if(!this.map){ … … 36 43 37 44 mapSetup(){ 38 this.map = L.map('mapViewport').setView([48.43, 10.04], 17); 45 this.map = L.map(this.mapElement.nativeElement, { 46 center: [48.43, 10.04], 47 zoom: 17, 48 zoomControl: this.controlsShow, 49 }); 39 50 40 51 var layer_openstreetmap = L.tileLayer( … … 47 58 ).addTo(this.map); 48 59 60 var baselayers = { 61 "Map": layer_openstreetmap, 62 }; 63 var overlays = {"Seamarks": layer_openseamap}; 64 65 49 66 // add GNUBoat layers 50 67 var layer_gnuboat_accuracy_low = L.tileLayer( … … 56 73 {tms: true, opacity: 0.5, zIndex: 98, attribute: '© <a href="http://gnuboat.engsas.de">GNUBoat</a> contributors'} 57 74 ).addTo(this.map); 75 overlays["GNUBoat Low Accuracy"] = layer_gnuboat_accuracy_low; 76 overlays["GNUBoat High Accuracy"] = layer_gnuboat_accuracy_high; 58 77 59 // add layer control 60 var baselayers = { 61 "Map": layer_openstreetmap, 62 }; 63 // overlays 64 var overlays = {"Seamarks": layer_openseamap, 65 "GNUBoat Low Accuracy": layer_gnuboat_accuracy_low, 66 "GNUBoat High Accuracy": layer_gnuboat_accuracy_high, 67 }; 68 this.mapControl = L.control.layers( 69 baselayers, overlays, 70 {hideSingleBase: true, sortLayers: true, } 71 ).addTo(this.map); 78 if(this.controlsShow){ 79 // add layer control 80 this.mapControl = L.control.layers( 81 baselayers, overlays, 82 {hideSingleBase: true, sortLayers: true, } 83 ).addTo(this.map); 72 84 73 // add scale 74 L.control.scale().addTo(this.map); 85 // add scale 86 L.control.scale().addTo(this.map); 87 } 88 } 89 90 addOsmElement(id: number, osmType: OsmType){ 91 if(!this.geoJsonLayer){ 92 this.geoJsonLayer = L.geoJSON().addTo(this.map); 93 } 94 this.osmOverpassService.getElement(id, osmType).subscribe(res => { 95 this.geoJsonLayer.addData(res); 96 this.map.fitBounds(this.geoJsonLayer.getBounds()); 97 }); 75 98 } 76 99 } -
src/mapservice-webclient/src/app/mygnuboat/user.component.html
rbe25db1 r041e464 1 <div class="header"> 2 <h1>Welcome to {{currentUser.firstName}}'s GNUBoat!</h1> 3 <alert></alert> 4 </div> 1 5 <div class="content"> 2 <h1>Welcome to {{currentUser.firstName}}'s GNUBoat!</h1>3 6 <h2 class="content-subhead">Logfiles</h2> 4 7 <div> … … 8 11 <div> 9 12 <a name="waters"></a> 10 <div><a class="pure-button button-add" routerLink="water/add">Add Water</a></div> 11 <div class="pure-u-1 pure-u-md-1-3"> 12 <div class="water" *ngFor="let water of waters"> 13 <div> 14 <h2>{{water.name}}</h2> 15 </div> 16 <ul> 17 <li>Coordinates</li> 18 <li>Managed by </li> 19 </ul> 20 <div class="water-button"><button class="button-add pure-button">Upload Logfile</button></div> 21 <div class="water-button" *ngIf="water.manager==currentUser.username"><a class="pure-button" routerLink="water/edit">Edit</a></div> 13 <p><a class="pure-button button-add" routerLink="water/add">Add Water</a></p> 14 <div class="pure-g"> 15 <div class="pure-u-1 pure-u-md-1-3" *ngFor="let water of waters"> 16 <gnuboat-water [water]="water" [user]="currentUser"></gnuboat-water> 22 17 </div> 23 18 </div> -
src/mapservice-webclient/src/app/mygnuboat/wateradd.component.html
rbe25db1 r041e464 1 <div class="header"> 2 <h1>Add a new Water to GNUBoat</h1> 3 <alert></alert> 4 </div> 1 5 <div class="content"> 2 <h1>Add a new Water to GNUBoat</h1>3 6 <div class="pure-g"> 4 7 <div class="pure-u-2-3"> 5 <form class="pure-form pure-form-aligned" [formGroup]='watersForm' >8 <form class="pure-form pure-form-aligned" [formGroup]='watersForm' (ngSubmit)="addWater()"> 6 9 <fieldset> 7 10 <div class="pure-control-group"> 8 11 <label for="name">Name:</label> 9 <input #waterNameInput id="waterNameAutocomplete" formControlName='name' type="text" placeholder="Name of Water" list="watersAutocomplete" required> 12 <input #waterNameInput id="waterNameAutocomplete" formControlName='name' type="text" placeholder="Name of Water" required> 13 <img *ngIf="isProcessingGnuBoat || isProcessingOverpass" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" /> 14 <span *ngIf="submitted && watersForm.name.errors" class="pure-form-message-inline">Watername is required.</span> 15 </div> 16 <div class="pure-controls"> 17 <button [disabled]="!waterChoosen || !currentUser" *ngIf="!waterChoosen || waterChoosen.origin!=Origin.GNUBOAT" class="pure-button pure-button-primary">Add</button> 18 <button [disabled]="!waterChoosen || !currentUser" *ngIf="waterChoosen && waterChoosen.origin==Origin.GNUBOAT" class="pure-button pure-button-primary">Choose</button> 10 19 </div> 11 20 </fieldset> … … 13 22 </div> 14 23 <div class="pure-u-1-3"> 15 <gnuboat-map #mapComponent [mapViewportStyleClass]='mapViewportStyleClass'></gnuboat-map> 24 <img *ngIf="isProcessingRelation" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/ jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" /> 25 <gnuboat-map #mapComponent [viewportStyleClass]='mapViewportStyleClass' [controlsShow]='mapControlsShow'></gnuboat-map> 16 26 </div> 17 27 </div> -
src/mapservice-webclient/src/app/mygnuboat/wateradd.component.ts
rbe25db1 r041e464 1 1 import { Component, OnInit, OnDestroy, ViewChild, AfterViewInit } from '@angular/core'; 2 import { Observable } from 'rxjs';3 import { HttpClient, HttpHeaders } from '@angular/common/http';2 import { Observable, Subscription } from 'rxjs'; 3 import { first } from 'rxjs/operators'; 4 4 import {switchMap, debounceTime, tap, finalize, filter} from 'rxjs/operators'; 5 5 import {FormBuilder, FormGroup, Validators} from '@angular/forms'; 6 7 var osmtogeojson = require('osmtogeojson'); 6 import { Router, ActivatedRoute } from '@angular/router'; 7 8 declare var jQuery: any; 8 9 declare let L; 9 10 10 import { environment } from '../../environments/environment'; 11 import { Water, WatersService } from '../../../src-gen/gnuboat-mapservice'; 12 import { AuthenticationService } from '../services'; 11 import { User, OsmType, Water, WaterCreation, WatersService } from '../../../src-gen/gnuboat-mapservice'; 12 import { AlertService, AuthenticationService, OsmOverpassService } from '../services'; 13 13 import { MapComponent } from './'; 14 15 declare var jQuery: any;16 // declare let L;17 14 18 15 enum Origin { … … 22 19 23 20 interface WaterCompletion { 24 name: string,25 21 label: string, 22 value: string, 26 23 origin: Origin, 27 id: string 24 id: number, 25 osmType: OsmType, 26 osmId: number, 28 27 } 29 28 30 @Component({ templateUrl: 'wateradd.component.html' }) 29 @Component({ 30 templateUrl: 'wateradd.component.html', 31 providers: [OsmOverpassService], 32 }) 31 33 export class WaterAddComponent implements OnInit, OnDestroy, AfterViewInit { 32 34 mapViewportStyleClass:string = 'water-add-map'; 35 mapControlsShow:boolean = false; 33 36 @ViewChild('mapComponent') mapComponent: MapComponent; 34 35 private filteredWatersGnuBoat = new Map<string, WaterCompletion>(); 36 private filteredWatersOverpass = new Map<string, WaterCompletion>(); 37 private watersOverpass = new Map<string, Object>(); 37 @ViewChild('waterNameInput') waterNameInput; 38 public Origin = Origin; 39 public waterChoosen:WaterCompletion = undefined; 40 public currentUser:User; 41 public isProcessingGnuBoat = false; 42 public isProcessingOverpass = false; 43 public isProcessingRelation = false; 44 45 private filteredWatersGnuBoat = new Map<number, WaterCompletion>(); 46 private filteredWatersOverpass = new Map<number, WaterCompletion>(); 38 47 private map; 39 48 private geoJsonLayer = undefined; 40 49 private watersForm: FormGroup; 41 private isProcessingGnuBoat = false; 42 private isProcessingOverpass = false; 50 private currentUserSubscription: Subscription; 43 51 44 52 constructor( 45 53 private formBuilder: FormBuilder, 46 54 private watersService: WatersService, 47 private http: HttpClient 55 private osmOverpassService: OsmOverpassService, 56 private alertService: AlertService, 57 private authenticationService: AuthenticationService, 58 private router: Router, 59 private route: ActivatedRoute, 48 60 ) { 61 this.currentUserSubscription = this.authenticationService.currentUser.subscribe(user => { 62 this.currentUser = user; 63 this.watersService.configuration.username = user.username; 64 this.watersService.configuration.password = this.authenticationService.currentUserPassword; 65 }); 49 66 } 50 67 … … 81 98 tap(() => this.isProcessingOverpass = true), 82 99 switchMap( 83 value => this. queryOverpass(value).pipe(100 value => this.osmOverpassService.findWaters(value).pipe( 84 101 finalize(() => this.isProcessingOverpass = false), 85 102 ) 86 103 ) 87 104 ).subscribe(res => { 88 // converting to XML object, so that osmtogeojson detects it as XML content 89 var data = jQuery.parseXML(res.body); 90 this.getOverpassWaters(osmtogeojson(data)); 105 this.getOverpassWaters(res); 91 106 }); 92 107 } … … 98 113 this.map = this.mapComponent.getMap(); 99 114 this.geoJsonLayer = L.geoJSON().addTo(this.map); 100 }101 102 queryOverpass(name: string){103 var query = '[timeout:25];( rel[name~"'+ name +'"][natural="water"]; rel[name~"'+ name +'"][type="waterway"]; ); out center;'104 const headers = new HttpHeaders({ 'Content-Type': 'text/xml' }).set('Accept', 'text/xml');105 return this.http.get(environment.OVERPASS_API_PATH +"?data="+ query, {observe: 'response', responseType: 'text', headers: headers});106 115 } 107 116 … … 110 119 for(var i = 0; i < waters.length; i++){ 111 120 var water = {} as WaterCompletion; 112 water. name = waters[i].name;113 water.label = water. name + " (GNUBoat)";121 water.value = waters[i].name; 122 water.label = water.value + " (GNUBoat)"; 114 123 water.origin = Origin.GNUBOAT; 115 124 water.id = waters[i].waterId; 125 water.osmId = waters[i].osmId; 126 water.osmType = waters[i].osmType; 116 127 this.filteredWatersGnuBoat.set(water.id, water); 117 128 } … … 120 131 121 132 getOverpassWaters(geojson) { 122 console.log(geojson);123 this.watersOverpass.clear();124 133 this.filteredWatersOverpass.clear(); 125 134 if('features' in geojson){ 126 135 geojson.features.forEach(feature => { 127 136 var water = {} as WaterCompletion; 128 water. name = feature.properties.name;129 water.label = water. name + " (OSM)";;137 water.value = feature.properties.name; 138 water.label = water.value + " (OSM)";; 130 139 water.origin = Origin.OSM; 131 water.id = feature.properties.id; 140 water.id = Number(feature.properties.id.replace(/\D/g, '')); 141 water.osmId = water.id; 142 if(feature.properties.id.replace(/\/\d+/g, '').toLowerCase() == "relation"){ 143 water.osmType = OsmType.Relation; 144 } 145 else{ 146 console.log(["Unidentified OSM Type", feature.properties.id.replace(/\/\d+/g, '')]); 147 } 132 148 this.filteredWatersOverpass.set(water.id, water); 133 this.watersOverpass.set(water.id, feature);134 149 }); 135 150 } 136 151 this.buildAutoCompletor(); 152 } 153 154 getOverpassRelation(id: number, osmType: OsmType){ 155 this.geoJsonLayer.clearLayers(); 156 this.isProcessingRelation = true; 157 this.osmOverpassService.getElement(id, osmType).subscribe(res => { 158 this.isProcessingRelation = false; 159 this.geoJsonLayer.addData(res); 160 this.map.fitBounds(this.geoJsonLayer.getBounds()); 161 }); 137 162 } 138 163 … … 145 170 waterCompletion.push(value); 146 171 }); 147 jQuery('#waterNameAutocomplete').autocomplete({ source: waterCompletion}); 172 // set the elements to the autocompletion list 173 jQuery('#waterNameAutocomplete').autocomplete("option", "source", waterCompletion); 174 // open the autocompletion list 175 jQuery('#waterNameAutocomplete').autocomplete("search", jQuery('#waterNameAutocomplete').val()); 148 176 } 149 177 150 178 waterSelected(event, ui) { 151 if(ui.item.origin == Origin.OSM){ 152 this.watersOverpass.forEach((value, key) => { 153 if(value["id"] == ui.item.id){ 154 this.geoJsonLayer.addData(value); 155 this.map.fitBounds(this.geoJsonLayer.getBounds()); 156 console.log(value); 157 return; 179 this.waterChoosen = ui.item; 180 if(!ui.item.osmId || !ui.item.osmType){ 181 return; 182 } 183 this.getOverpassRelation(ui.item.osmId, ui.item.osmType); 184 } 185 186 addWater() { 187 // stop here if form is invalid 188 if (this.watersForm.invalid) { 189 this.alertService.error("Please enter all necessary data"); 190 return; 191 } 192 193 if(!this.waterChoosen){ 194 this.alertService.error("No water selected!"); 195 return; 196 } 197 198 if(this.waterChoosen.value != this.waterNameInput.nativeElement.value){ 199 this.alertService.error("Water selected has different name than entered in name field!"); 200 return; 201 } 202 203 var id = undefined; 204 if(this.waterChoosen.origin == Origin.GNUBOAT){ 205 id = this.waterChoosen.id; 206 } 207 if(this.waterChoosen.origin == Origin.OSM){ 208 console.log("GNUBOAT --> OSM"); 209 var water = {} as WaterCreation; 210 water.name = this.waterChoosen.value; 211 water.osmId = this.waterChoosen.id; 212 water.osmType = this.waterChoosen.osmType; 213 this.watersService.watersCreate(water).pipe(first()).subscribe(result => { 214 if(water.name == result.name){ 215 id = result.waterId; 216 } 217 else{ 218 console.log(result); 219 // do some error handling here! 220 this.alertService.error("Could not add water!"); 158 221 } 159 222 }); 160 } 223 return; 224 } 225 226 if(id === undefined){ 227 this.alertService.error("Unable to handle selected Water!"); 228 return; 229 } 230 this.router.navigate(['../', id], {relativeTo: this.route}); 161 231 } 162 232 } -
src/mapservice-webclient/src/app/services/alert.service.ts
rbe25db1 r041e464 33 33 error(message: string, keepAfterNavigationChange = false) { 34 34 this.keepAfterNavigationChange = keepAfterNavigationChange; 35 this.subject.next({ type: 'error', text: message });35 this.subject.next({ type: 'error', text: message}); 36 36 } 37 37 -
src/mapservice-webclient/src/app/services/index.ts
rbe25db1 r041e464 1 1 export * from './alert.service'; 2 2 export * from './authentication.service'; 3 export * from './osmoverpass.service'; -
src/mapservice-webclient/src/app/user/login.component.html
rbe25db1 r041e464 1 1 <!-- s. http://jasonwatmore.com/post/2018/10/29/angular-7-user-registration-and-login-example-tutorial --> 2 <div class="header"> 3 <h1>Login</h1> 4 <alert></alert> 5 </div> 2 6 <div class="content"> 3 <h2>Login</h2>4 7 <form [formGroup]="loginForm" (ngSubmit)="onSubmit()" class="pure-form pure-form-aligned"> 5 8 <fieldset> 6 <div class="pure-control-group"> 7 <label for="username">Username:</label> 8 <input type="text" formControlName="username" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.username.errors }" /> 9 <div *ngIf="submitted && f.username.errors" class="invalid-feedback"> 10 <div *ngIf="f.username.errors.required">Username is required</div> 11 </div> 12 </div> 13 <div class="pure-control-group"> 14 <label for="password">Password:</label> 15 <input type="password" formControlName="password" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.password.errors }" /> 16 <div *ngIf="submitted && f.password.errors" class="invalid-feedback"> 17 <div *ngIf="f.password.errors.required">Password is required</div> 18 </div> 19 </div> 20 <button [disabled]="loading" class="pure-button pure-button-primary">Login</button> 21 <img *ngIf="loading" class="pl-3" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" /> 22 <button routerLink="/register" class="pure-button">Register</button> 23 </fieldset> 9 <div class="pure-control-group"> 10 <label for="username">Username:</label> 11 <input type="text" formControlName="username" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.username.errors }" /> 12 <span *ngIf="submitted && f.username.errors" class="pure-form-message-inline">Username is required.</span> 13 </div> 14 <div class="pure-control-group"> 15 <label for="password">Password:</label> 16 <input type="password" formControlName="password" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.password.errors }" /> 17 <span *ngIf="submitted && f.password.errors" class="pure-form-message-inline">Password is required.</span> 18 </div> 19 <div class="pure-controls"> 20 <button [disabled]="loading" class="pure-button pure-button-primary">Login</button> 21 <img *ngIf="loading" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" /> 22 <button routerLink="/register" class="pure-button">Register</button> 23 </div> 24 </fieldset> 24 25 </form> 25 26 </div> -
src/mapservice-webclient/src/app/user/login.component.ts
rbe25db1 r041e464 60 60 // stop here if form is invalid 61 61 if (this.loginForm.invalid) { 62 this.alertService.error("Please enter all necessary data"); 62 63 return; 63 64 } -
src/mapservice-webclient/src/app/user/register.component.html
rbe25db1 r041e464 1 1 <!-- s. http://jasonwatmore.com/post/2018/10/29/angular-7-user-registration-and-login-example-tutorial --> 2 <h2>Register</h2> 3 <form [formGroup]="registerForm" (ngSubmit)="onSubmit()"> 4 <div class="form-group"> 5 <label for="firstName">First Name</label> 6 <input type="text" formControlName="firstName" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.firstName.errors }" /> 7 <div *ngIf="submitted && f.firstName.errors" class="invalid-feedback"> 8 <div *ngIf="f.firstName.errors.required">First Name is required</div> 9 </div> 10 </div> 11 <div class="form-group"> 12 <label for="lastName">Last Name</label> 13 <input type="text" formControlName="lastName" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.lastName.errors }" /> 14 <div *ngIf="submitted && f.lastName.errors" class="invalid-feedback"> 15 <div *ngIf="f.lastName.errors.required">Last Name is required</div> 16 </div> 17 </div> 18 <div class="form-group"> 19 <label for="username">Username</label> 20 <input type="text" formControlName="username" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.username.errors }" /> 21 <div *ngIf="submitted && f.username.errors" class="invalid-feedback"> 22 <div *ngIf="f.username.errors.required">Username is required</div> 23 </div> 24 </div> 25 <div class="form-group"> 26 <label for="password">Password</label> 27 <input type="password" formControlName="password" class="form-control" [ngClass]="{ 'is-invalid': submitted && f.password.errors }" /> 28 <div *ngIf="submitted && f.password.errors" class="invalid-feedback"> 29 <div *ngIf="f.password.errors.required">Password is required</div> 30 <div *ngIf="f.password.errors.minlength">Password must be at least 6 characters</div> 31 </div> 32 </div> 33 <div class="form-group"> 34 <button [disabled]="loading" class="btn btn-primary">Register</button> 35 <img *ngIf="loading" class="pl-3" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" /> 36 <a routerLink="/login" class="btn btn-link">Cancel</a> 37 </div> 38 </form> 2 <div class="header"> 3 <h1>Register</h1> 4 </div> 5 <div class="content"> 6 <form [formGroup]="registerForm" (ngSubmit)="onSubmit()" class="pure-form pure-form-aligned"> 7 <fieldset> 8 <div class="pure-control-group"> 9 <label for="firstName">First Name</label> 10 <input type="text" formControlName="firstName" [ngClass]="{ 'is-invalid': submitted && f.firstName.errors }" /> 11 <div *ngIf="submitted && f.firstName.errors" class="invalid-feedback"> 12 <div *ngIf="f.firstName.errors.required">First Name is required</div> 13 </div> 14 </div> 15 <div class="pure-control-group"> 16 <label for="lastName">Last Name</label> 17 <input type="text" formControlName="lastName" [ngClass]="{ 'is-invalid': submitted && f.lastName.errors }" /> 18 <div *ngIf="submitted && f.lastName.errors" class="invalid-feedback"> 19 <div *ngIf="f.lastName.errors.required">Last Name is required</div> 20 </div> 21 </div> 22 <div class="pure-control-group"> 23 <label for="username">Username</label> 24 <input type="text" formControlName="username" [ngClass]="{ 'is-invalid': submitted && f.username.errors }" /> 25 <div *ngIf="submitted && f.username.errors" class="invalid-feedback"> 26 <div *ngIf="f.username.errors.required">Username is required</div> 27 </div> 28 </div> 29 <div class="pure-control-group"> 30 <label for="password">Password</label> 31 <input type="password" formControlName="password" [ngClass]="{ 'is-invalid': submitted && f.password.errors }" /> 32 <div *ngIf="submitted && f.password.errors" class="invalid-feedback"> 33 <div *ngIf="f.password.errors.required">Password is required</div> 34 <div *ngIf="f.password.errors.minlength">Password must be at least 6 characters</div> 35 </div> 36 </div> 37 <div class="pure-controls"> 38 <button [disabled]="loading" class="pure-button pure-button-primary">Register</button> 39 <img *ngIf="loading" class="pl-3" src="data:image/gif;base64,R0lGODlhEAAQAPIAAP///wAAAMLCwkJCQgAAAGJiYoKCgpKSkiH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAEAAQAAADMwi63P4wyklrE2MIOggZnAdOmGYJRbExwroUmcG2LmDEwnHQLVsYOd2mBzkYDAdKa+dIAAAh+QQJCgAAACwAAAAAEAAQAAADNAi63P5OjCEgG4QMu7DmikRxQlFUYDEZIGBMRVsaqHwctXXf7WEYB4Ag1xjihkMZsiUkKhIAIfkECQoAAAAsAAAAABAAEAAAAzYIujIjK8pByJDMlFYvBoVjHA70GU7xSUJhmKtwHPAKzLO9HMaoKwJZ7Rf8AYPDDzKpZBqfvwQAIfkECQoAAAAsAAAAABAAEAAAAzMIumIlK8oyhpHsnFZfhYumCYUhDAQxRIdhHBGqRoKw0R8DYlJd8z0fMDgsGo/IpHI5TAAAIfkECQoAAAAsAAAAABAAEAAAAzIIunInK0rnZBTwGPNMgQwmdsNgXGJUlIWEuR5oWUIpz8pAEAMe6TwfwyYsGo/IpFKSAAAh+QQJCgAAACwAAAAAEAAQAAADMwi6IMKQORfjdOe82p4wGccc4CEuQradylesojEMBgsUc2G7sDX3lQGBMLAJibufbSlKAAAh+QQJCgAAACwAAAAAEAAQAAADMgi63P7wCRHZnFVdmgHu2nFwlWCI3WGc3TSWhUFGxTAUkGCbtgENBMJAEJsxgMLWzpEAACH5BAkKAAAALAAAAAAQABAAAAMyCLrc/jDKSatlQtScKdceCAjDII7HcQ4EMTCpyrCuUBjCYRgHVtqlAiB1YhiCnlsRkAAAOwAAAAAAAAAAAA==" /> 40 <a routerLink="/login" class="pure-button">Cancel</a> 41 </div> 42 </fieldset> 43 </form> 44 </div> -
src/mapservice-webclient/src/css/GnuBoat.Mapservice.Webclient.css
rbe25db1 r041e464 45 45 } 46 46 47 . viewport-geometry{47 .home-map { 48 48 width: -webkit-calc(100vw - 3em); 49 49 width: -moz-calc(100vw - 3em); … … 52 52 height: -moz-calc(100vh - 3em); 53 53 height: calc(100vh - 3em); 54 } 55 56 #mapViewport { 57 border: 1px solid var(--gnuboat-primary-light); 54 border: 1px solid var(--gnuboat-primary-light); 58 55 margin-top: 1.5em; 59 56 margin-left: 1.5em; … … 90 87 91 88 .water { 89 position: relative; 92 90 color: white; 93 background: var(--gnuboat-primary-dark);91 /** background: var(--gnuboat-primary-dark); **/ 94 92 text-align: center; 93 height: 24em; 94 padding: 0; 95 margin: 0.5em 0.5em 0.5em 0; 96 } 97 98 .water-map { 99 width: 100%; 100 height: 100%; 101 } 102 103 .water-background{ 104 color: #999999; 105 position: absolute; 106 top: 0; 107 left: 0; 108 z-index: -100; 109 width: 100%; 110 height: 100%; 111 margin: 0; 112 padding: 0; 113 } 114 115 .water-content { 116 position: relative; 117 z-index: 100; 118 width: 100%; 119 height: 100%; 120 margin: 0; 121 display: flex; 122 flex-direction: column; 95 123 } 96 124 97 125 .water h2 { 98 padding: 0.8em; 126 padding: 0.8em; 127 margin: 0; 128 background: var(--gnuboat-primary-light) 99 129 } 100 130 101 131 .water ul { 102 132 list-style-type: none; 103 margin: 0;133 margin: auto 0 0 0; 104 134 padding: 0; 105 135 text-align: center; 136 width: 100%; 106 137 } 107 138 108 139 .water ul li { 109 padding: 0. 8em 0;140 padding: 0.5em 0; 110 141 background: var(--gnuboat-primary-light); 142 opacity: 0.8; 111 143 border-bottom: 1px solid var(--gnuboat-primary-middle); 112 144 } 113 145 114 146 .water-button { 115 padding: 0.8em; 147 padding: 0.5em; 148 } 149 150 .water-edit { 151 color: white; 152 background: var(--gnuboat-primary-dark); 116 153 } 117 154 118 155 .water-add-map { 119 height: 40em;156 height: 24em; 120 157 } 158 159 .water-edit-map { 160 height: 40em; 161 } -
src/mapservice/openapi.yaml
rbe25db1 r041e464 168 168 in: query 169 169 schema: 170 $ref: '#/components/schemas/item _name'170 $ref: '#/components/schemas/itemName' 171 171 example: 'Missi' 172 172 - name: manager … … 202 202 schema: 203 203 $ref: '#/components/schemas/WaterCreation' 204 examples: 205 Water: 206 $ref: '#/components/examples/WaterCreation' 204 example: 205 name: Rhein 206 osmId: 1756854 207 osmType: 'Relation' 207 208 responses: 208 209 '201': … … 232 233 required: true 233 234 schema: 234 $ref: '#/components/schemas/item _id'235 $ref: '#/components/schemas/itemId' 235 236 responses: 236 237 '200': … … 271 272 title: Activation code for a User 272 273 type: string 273 item _id:274 itemId: 274 275 title: Item ID 275 276 type: integer 276 277 format: int32 277 item _name:278 itemName: 278 279 title: Item Name 279 280 type: string 280 281 osmType: 281 maxLength: 1 282 minLength: 1 283 type: string 282 title: OSM type of item (N|W|R) 283 type: string 284 enum: 285 - Node 286 - Way 287 - Relation 284 288 User: 285 289 title: User … … 323 327 properties: 324 328 waterId: 325 $ref: '#/components/schemas/item _id'329 $ref: '#/components/schemas/itemId' 326 330 name: 327 $ref: '#/components/schemas/item _name'331 $ref: '#/components/schemas/itemName' 328 332 manager: 329 333 $ref: '#/components/schemas/username' 330 334 osmId: 331 $ref: '#/components/schemas/item _id'335 $ref: '#/components/schemas/itemId' 332 336 osmType: 333 $ref: '#/components/schemas/osmType'334 osm_class:335 337 $ref: '#/components/schemas/osmType' 336 338 required: … … 342 344 properties: 343 345 name: 344 $ref: '#/components/schemas/item _name'346 $ref: '#/components/schemas/itemName' 345 347 osmId: 346 $ref: '#/components/schemas/item _id'348 $ref: '#/components/schemas/itemId' 347 349 osmType: 348 350 $ref: '#/components/schemas/osmType' … … 438 440 osmId: 1756854 439 441 osmType: R 440 link: 'http://gnuboat.engsas.com/mapservice/v1/waters/1'441 442 summary: A water example object 442 443 WaterCreation: … … 444 445 name: Mississippi 445 446 osmId: 1756854 446 osmType: R447 osmType: 'Relation' 447 448 summary: A water example object for creation of a water 448 449 waters: 449 450 value: 450 451 - waterId: 1 451 name: Mississippi452 name: 'Mississippi' 452 453 osmId: 1756854 453 osmType: R 454 link: 'http://gnuboat.engsas.com/mapservice/v1/waters/1' 454 osmType: 'Relation' 455 455 - waterId: 2 456 name: Bodensee 457 link: 'http://gnuboat.engsas.com/mapservice/v1/waters/2' 456 name: 'Bodensee' 458 457 summary: A sample list with waters 459 458 HttpError: -
src/mapservice/src-gen/openapi_server/models/__init__.py
rbe25db1 r041e464 6 6 from openapi_server.models.http_error import HttpError 7 7 from openapi_server.models.order import Order 8 from openapi_server.models.osm_type import OsmType 8 9 from openapi_server.models.user import User 9 10 from openapi_server.models.user_creation import UserCreation -
src/mapservice/src-gen/openapi_server/models/water.py
rbe25db1 r041e464 9 9 from openapi_server import util 10 10 11 from openapi_server.models.osm_type import OsmType # noqa: E501 11 12 12 13 class Water(Model): … … 16 17 """ 17 18 18 def __init__(self, water_id=None, name=None, manager=None, osm_id=None, osm_type=None , osm_class=None): # noqa: E50119 def __init__(self, water_id=None, name=None, manager=None, osm_id=None, osm_type=None): # noqa: E501 19 20 """Water - a model defined in OpenAPI 20 21 … … 28 29 :type osm_id: int 29 30 :param osm_type: The osm_type of this Water. # noqa: E501 30 :type osm_type: str 31 :param osm_class: The osm_class of this Water. # noqa: E501 32 :type osm_class: str 31 :type osm_type: OsmType 33 32 """ 34 33 self.openapi_types = { … … 37 36 'manager': str, 38 37 'osm_id': int, 39 'osm_type': str, 40 'osm_class': str 38 'osm_type': OsmType 41 39 } 42 40 … … 46 44 'manager': 'manager', 47 45 'osm_id': 'osmId', 48 'osm_type': 'osmType', 49 'osm_class': 'osm_class' 46 'osm_type': 'osmType' 50 47 } 51 48 … … 55 52 self._osm_id = osm_id 56 53 self._osm_type = osm_type 57 self._osm_class = osm_class58 54 59 55 @classmethod … … 162 158 163 159 :return: The osm_type of this Water. 164 :rtype: str160 :rtype: OsmType 165 161 """ 166 162 return self._osm_type … … 172 168 173 169 :param osm_type: The osm_type of this Water. 174 :type osm_type: str170 :type osm_type: OsmType 175 171 """ 176 if osm_type is not None and len(osm_type) > 1:177 raise ValueError("Invalid value for `osm_type`, length must be less than or equal to `1`") # noqa: E501178 if osm_type is not None and len(osm_type) < 1:179 raise ValueError("Invalid value for `osm_type`, length must be greater than or equal to `1`") # noqa: E501180 172 181 173 self._osm_type = osm_type 182 183 @property184 def osm_class(self):185 """Gets the osm_class of this Water.186 187 188 :return: The osm_class of this Water.189 :rtype: str190 """191 return self._osm_class192 193 @osm_class.setter194 def osm_class(self, osm_class):195 """Sets the osm_class of this Water.196 197 198 :param osm_class: The osm_class of this Water.199 :type osm_class: str200 """201 if osm_class is not None and len(osm_class) > 1:202 raise ValueError("Invalid value for `osm_class`, length must be less than or equal to `1`") # noqa: E501203 if osm_class is not None and len(osm_class) < 1:204 raise ValueError("Invalid value for `osm_class`, length must be greater than or equal to `1`") # noqa: E501205 206 self._osm_class = osm_class -
src/mapservice/src-gen/openapi_server/models/water_creation.py
rbe25db1 r041e464 9 9 from openapi_server import util 10 10 11 from openapi_server.models.osm_type import OsmType # noqa: E501 11 12 12 13 class WaterCreation(Model): … … 24 25 :type osm_id: int 25 26 :param osm_type: The osm_type of this WaterCreation. # noqa: E501 26 :type osm_type: str27 :type osm_type: OsmType 27 28 """ 28 29 self.openapi_types = { 29 30 'name': str, 30 31 'osm_id': int, 31 'osm_type': str32 'osm_type': OsmType 32 33 } 33 34 … … 103 104 104 105 :return: The osm_type of this WaterCreation. 105 :rtype: str106 :rtype: OsmType 106 107 """ 107 108 return self._osm_type … … 113 114 114 115 :param osm_type: The osm_type of this WaterCreation. 115 :type osm_type: str116 :type osm_type: OsmType 116 117 """ 117 if osm_type is not None and len(osm_type) > 1:118 raise ValueError("Invalid value for `osm_type`, length must be less than or equal to `1`") # noqa: E501119 if osm_type is not None and len(osm_type) < 1:120 raise ValueError("Invalid value for `osm_type`, length must be greater than or equal to `1`") # noqa: E501121 118 122 119 self._osm_type = osm_type -
src/mapservice/src-gen/openapi_server/openapi/openapi.yaml
rbe25db1 r041e464 235 235 required: false 236 236 schema: 237 $ref: '#/components/schemas/item _name'237 $ref: '#/components/schemas/itemName' 238 238 style: form 239 239 - example: jane … … 297 297 content: 298 298 application/json: 299 examples: 300 Water: 301 $ref: '#/components/examples/WaterCreation' 299 example: 300 name: Rhein 301 osmId: 1756854 302 osmType: Relation 302 303 schema: 303 304 $ref: '#/components/schemas/WaterCreation' … … 348 349 required: true 349 350 schema: 350 $ref: '#/components/schemas/item _id'351 $ref: '#/components/schemas/itemId' 351 352 style: simple 352 353 responses: … … 398 399 osmId: 1756854 399 400 osmType: R 400 link: http://gnuboat.engsas.com/mapservice/v1/waters/1401 401 WaterCreation: 402 402 summary: A water example object for creation of a water … … 404 404 name: Mississippi 405 405 osmId: 1756854 406 osmType: R 406 osmType: Relation 407 407 waters: 408 408 summary: A sample list with waters … … 411 411 name: Mississippi 412 412 osmId: 1756854 413 osmType: R 414 link: http://gnuboat.engsas.com/mapservice/v1/waters/1 413 osmType: Relation 415 414 - waterId: 2 416 415 name: Bodensee 417 link: http://gnuboat.engsas.com/mapservice/v1/waters/2418 416 HttpError: 419 417 value: … … 508 506 title: Activation code for a User 509 507 type: string 510 item _id:508 itemId: 511 509 format: int32 512 510 title: Item ID 513 511 type: integer 514 item _name:512 itemName: 515 513 title: Item Name 516 514 type: string 517 515 osmType: 518 maxLength: 1 519 minLength: 1 516 enum: 517 - Node 518 - Way 519 - Relation 520 title: OSM type of item (N|W|R) 520 521 type: string 521 522 User: … … 580 581 osmId: 6 581 582 name: name 582 osmType: osmType583 osm_class: osm_class584 583 waterId: 0 585 584 properties: … … 599 598 type: integer 600 599 osmType: 601 maxLength: 1 602 minLength: 1 603 type: string 604 osm_class: 605 maxLength: 1 606 minLength: 1 607 type: string 600 $ref: '#/components/schemas/osmType' 608 601 required: 609 602 - name … … 615 608 osmId: 0 616 609 name: name 617 osmType: osmType618 610 properties: 619 611 name: … … 625 617 type: integer 626 618 osmType: 627 maxLength: 1 628 minLength: 1 629 type: string 619 $ref: '#/components/schemas/osmType' 630 620 required: 631 621 - name -
src/mapservice/src/server_impl/controllers/WatersController.py
rbe25db1 r041e464 17 17 import connexion 18 18 19 from ..database.Model import User, Water 19 from ..database.Model import User, Water, db 20 20 from ..HttpErrors import BadRequest, Unauthorized, NotFound 21 from .UsersController import loggedin_user 21 22 22 23 def waters_get(name=None, manager=None, order_by=None, offset=None, limit=None): … … 39 40 40 41 if query is None: 41 print("5")42 42 query = Water.query 43 43 … … 48 48 49 49 def water_get_by_id(id): 50 return {51 'water_id': id,52 'name': 'Mississippi'53 }50 water = Water.query.filter_by(id=id).all() 51 if len(water) != 1: 52 return NotFound 53 return water[0].to_dict() 54 54 55 def waters_post(water): 56 print(connexion.context['user']) 57 return water 55 def waters_create(water_creation): 56 user = loggedin_user() 57 if user is None: 58 return Unauthorized 59 60 water = Water(name=water_creation.name, manager=user, osm_id=water_creation.osm_id, osm_type=water_creation.osm_type) 61 db.session.add(water) 62 db.session.commit() 63 return water.to_dict() -
src/mapservice/src/server_impl/database/Model.py
rbe25db1 r041e464 17 17 import flask 18 18 from flask_sqlalchemy import SQLAlchemy 19 from sqlalchemy import inspect, text 19 from sqlalchemy import inspect, text, Enum 20 20 import hashlib 21 21 import datetime 22 import enum 22 23 23 24 db = SQLAlchemy() 25 26 class OsmType(enum.Enum): 27 Node = 1 28 Way = 2 29 Relation = 3 24 30 25 31 class User(db.Model): … … 81 87 name = db.Column(db.String(255), nullable=False) 82 88 manager_id = db.Column(db.Integer, db.ForeignKey('users.id')) 83 osm_id = db.Column(db.BigInteger) 84 osm_type = db.Column(db.String(255)) 85 osm_class = db.Column(db.String(255)) 89 osm_id = db.Column(db.Integer) 90 osm_type = db.Column(Enum(OsmType)) 86 91 manager = db.relationship("User", backref=db.backref("waters", uselist=False), lazy=True) 87 92 … … 93 98 result['osmId'] = obj.osm_id 94 99 if obj.osm_type: 95 result['osmType'] = obj.osm_type 96 if obj.osm_class: 97 result['osmClass'] = obj.osm_class 100 result['osmType'] = obj.osm_type.name 98 101 return result 99 102 … … 136 139 db.session.add(test_key) 137 140 if len(Water.query.filter_by(name='Mississippi').all()) < 1: 138 mississippi = Water(name='Mississippi', manager=test_user_jane )141 mississippi = Water(name='Mississippi', manager=test_user_jane, osm_id=1756854, osm_type=OsmType.Relation) 139 142 db.session.add(mississippi) 143 if len(Water.query.filter_by(name='Forggensee').all()) < 1: 144 mississippi = Water(name='Forggensee', manager=test_user_john, osm_id=897899, osm_type=OsmType.Relation) 145 db.session.add(mississippi) 140 146 db.session.commit() 141 147 -
src/mapservice/src/server_impl/tests/test_waters.py
rbe25db1 r041e464 39 39 assert "name" in data[0] 40 40 assert data[0]["name"] == "Mississippi" 41 assert "water_id" in data[0] 42 assert data[0]["waterId"] == "1" 41 assert "waterId" in data[0] 42 assert data[0]["waterId"] == 1 43 assert "osmId" in data[0] 44 assert data[0]["osmId"] == 1756854 45 assert "osmType" in data[0] 46 assert data[0]["osmType"] == "Relation" 47 43 48 def get_by_name(self): 44 49 headers = {} … … 61 66 assert "name" in data[0] 62 67 assert data[0]["name"] == "Mississippi" 63 assert "water_id" in data[0] 64 assert data[0]["waterId"] == "1" 68 assert "waterId" in data[0] 69 assert data[0]["waterId"] == 1 70 assert "osmId" in data[0] 71 assert data[0]["osmId"] == 1756854 72 assert "osmType" in data[0] 73 assert data[0]["osmType"] == "Relation" 65 74 66 75 def get_by_manager(self): … … 84 93 assert "name" in data[0] 85 94 assert data[0]["name"] == "Mississippi" 86 assert "water_id" in data[0] 87 assert data[0]["waterId"] == "1" 95 assert "waterId" in data[0] 96 assert data[0]["waterId"] == 1 97 assert "osmId" in data[0] 98 assert data[0]["osmId"] == 1756854 99 assert "osmType" in data[0] 100 assert data[0]["osmType"] == "Relation" 88 101 89 102 def get_by_name_manager(self): … … 113 126 assert "name" in data[0] 114 127 assert data[0]["name"] == "Mississippi" 115 assert "water_id" in data[0] 116 assert data[0]["waterId"] == "1" 128 assert "waterId" in data[0] 129 assert data[0]["waterId"] == 1 130 assert "osmId" in data[0] 131 assert data[0]["osmId"] == 1756854 132 assert "osmType" in data[0] 133 assert data[0]["osmType"] == "Relation" 117 134 118 135 if __name__ == '__main__':
Note:
See TracChangeset
for help on using the changeset viewer.
