diff --git a/src/app/analyze/analyze.component.html b/src/app/analyze/analyze.component.html
index e69de29..d612469 100644
--- a/src/app/analyze/analyze.component.html
+++ b/src/app/analyze/analyze.component.html
@@ -0,0 +1,4 @@
+
+ {{ osmAnalysis.publicTransportAccessability.isBusAccessible }}
+
+
diff --git a/src/app/analyze/analyze.component.ts b/src/app/analyze/analyze.component.ts
index 6154dd6..805bab1 100644
--- a/src/app/analyze/analyze.component.ts
+++ b/src/app/analyze/analyze.component.ts
@@ -1,5 +1,10 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router'
+import { OverpassApiService } from '../services/overpass-api.service';
+import { OsmAnalysis } from '../interfaces/osmAnalysis';
+import { OsmService } from '../services/osm.service';
+import { OSM } from '../interfaces/osm';
+import { OsmAnalysisService } from '../services/osm-analysis.service';
@Component({
selector: 'app-analyze',
@@ -9,13 +14,32 @@ import { ActivatedRoute } from '@angular/router'
export class AnalyzeComponent implements OnInit {
lon!: string | null;
lat!: string | null;
+
+ osmAnalysis?: OsmAnalysis;
+
constructor(
private route: ActivatedRoute,
+ private overpassApiService: OverpassApiService,
+ private osmService: OsmService,
+ private osmAnalysisService: OsmAnalysisService
) { }
ngOnInit() {
this.lon = this.route.snapshot.paramMap.get('lon');
this.lat = this.route.snapshot.paramMap.get('lat');
+
+ let minLon: number = parseFloat(this.lon!) - 0.1;
+ let maxLon: number = parseFloat(this.lon!) + 0.1;
+ let minLat: number = parseFloat(this.lat!) - 0.13;
+ let maxLat: number = parseFloat(this.lat!) + 0.13;
+
+
+ this.overpassApiService.sendQueryRequest(`${minLon},${minLat},${maxLon},${maxLat}`).subscribe(data => {
+ console.log(data);
+ let osm: OSM = this.osmService.parseOsmContent(data);
+ // Analyze the OSM data
+ this.osmAnalysis = this.osmAnalysisService.getOsmAnalysis(osm);
+ });
}
}
diff --git a/src/app/interfaces/osm.ts b/src/app/interfaces/osm.ts
new file mode 100644
index 0000000..f54e536
--- /dev/null
+++ b/src/app/interfaces/osm.ts
@@ -0,0 +1,93 @@
+
+export interface OSMContact{
+ phone?: string;
+ fax?: string;
+ email?: string;
+ website?: string;
+ mobile?: string;
+ vk?: string;
+ facebook?: string;
+ instagram?: string;
+ twitter?: string;
+ youtube?: string;
+ ok?: string;
+ webcam?: string;
+ telegram?: string;
+ whatsapp?: string;
+ linkedin?: string;
+ pinterest?: string;
+ viper?: string;
+ foursquare?: string;
+ skype?: string;
+ xing?: string;
+ vhf?: string;
+ flickr?: string;
+ mastodon?: string;
+ sip?: string;
+ diaspora?: string;
+ gnusocial?: string;
+}
+
+export interface OSMAddress{
+ housenumber?: string;
+ street?: string;
+ place?: string;
+ city?: string;
+ postcode?: string;
+ country?: string;
+ suburb?: string;
+ state?: string;
+ province?: string;
+}
+
+
+export interface OSMPlace{
+ nodeIds?: Array;
+ type?: string;
+ name?: string;
+ address?: OSMAddress;
+ contact?: OSMContact;
+ openingHours?: string;
+}
+
+export interface OSMNode{
+ id?: string;
+ lon?: string;
+ lat?: string;
+ version?: string;
+ timestamp?: string;
+ changeset?: string;
+ uid?: string;
+ user?: string;
+}
+
+export interface OSMNodeTag{
+ id?: string;
+ nodeId?: string;
+ key?: string;
+ value?: string;
+}
+
+export interface OSMWay{
+ id?: string;
+ version?: string;
+ timestamp?: string;
+ changeset?: string;
+ uid?: string;
+ user?: string;
+}
+
+export interface OSMWayTag{
+ id?: string;
+ wayId?: string;
+ key?: string;
+ value?: string;
+}
+
+export interface OSM{
+ nodes?: Array;
+ nodeTags?: Array;
+ ways?: Array;
+ wayTags?: Array;
+ places?: Array;
+}
diff --git a/src/app/interfaces/osmAnalysis.ts b/src/app/interfaces/osmAnalysis.ts
new file mode 100644
index 0000000..7d81ec2
--- /dev/null
+++ b/src/app/interfaces/osmAnalysis.ts
@@ -0,0 +1,14 @@
+
+export interface PublicTransportAccessability {
+ isBusAccessible: boolean;
+ isTramAccessible: boolean;
+ isTrainAccessible: boolean;
+ isLightRailAccessible: boolean;
+ isMonorailAccessible: boolean;
+ isSubwayAccessible: boolean;
+}
+
+
+export interface OsmAnalysis {
+ publicTransportAccessability: PublicTransportAccessability;
+}
diff --git a/src/app/services/osm-analysis.service.spec.ts b/src/app/services/osm-analysis.service.spec.ts
new file mode 100644
index 0000000..f999d40
--- /dev/null
+++ b/src/app/services/osm-analysis.service.spec.ts
@@ -0,0 +1,16 @@
+/* tslint:disable:no-unused-variable */
+
+import { TestBed, async, inject } from '@angular/core/testing';
+import { OsmAnalysisService } from './osm-analysis.service';
+
+describe('Service: OsmAnalysis', () => {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [OsmAnalysisService]
+ });
+ });
+
+ it('should ...', inject([OsmAnalysisService], (service: OsmAnalysisService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/src/app/services/osm-analysis.service.ts b/src/app/services/osm-analysis.service.ts
new file mode 100644
index 0000000..242626d
--- /dev/null
+++ b/src/app/services/osm-analysis.service.ts
@@ -0,0 +1,47 @@
+import { Injectable } from '@angular/core';
+import { OSM } from '../interfaces/osm';
+import { OsmAnalysis, PublicTransportAccessability } from '../interfaces/osmAnalysis';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class OsmAnalysisService {
+
+constructor() { }
+ getPublicTransportAccessability(osm: OSM): PublicTransportAccessability {
+ let publicTransportAccessability: PublicTransportAccessability = {
+ isBusAccessible: false,
+ isTramAccessible: false,
+ isTrainAccessible: false,
+ isLightRailAccessible: false,
+ isMonorailAccessible: false,
+ isSubwayAccessible: false
+ };
+
+ for(let nodeTag of osm.nodeTags!){
+ if(nodeTag.key === "highway" && nodeTag.value === "bus_stop"){
+ publicTransportAccessability.isBusAccessible = true;
+ }else if(nodeTag.key === "railway" && nodeTag.value === "tram_stop"){
+ publicTransportAccessability.isTramAccessible = true;
+ }else if(nodeTag.key === "railway" && nodeTag.value === "station"){
+ publicTransportAccessability.isTrainAccessible = true;
+ }else if(nodeTag.key === "station" && nodeTag.value === "light_rail"){
+ publicTransportAccessability.isLightRailAccessible = true;
+ }else if(nodeTag.key === "station" && nodeTag.value === "monorail"){
+ publicTransportAccessability.isMonorailAccessible = true;
+ }else if(nodeTag.key === "station" && nodeTag.value === "subway"){
+ publicTransportAccessability.isSubwayAccessible = true;
+ }
+ }
+
+ return publicTransportAccessability;
+ }
+
+ getOsmAnalysis(osm: OSM): OsmAnalysis {
+ let osmAnalysis: OsmAnalysis = {
+ publicTransportAccessability: this.getPublicTransportAccessability(osm)
+ };
+
+ return osmAnalysis;
+ }
+}
diff --git a/src/app/services/osm.service.ts b/src/app/services/osm.service.ts
index e325837..d009c7a 100644
--- a/src/app/services/osm.service.ts
+++ b/src/app/services/osm.service.ts
@@ -1,10 +1,236 @@
import { Injectable } from '@angular/core';
+import { OsmAnalysis } from '../interfaces/osmAnalysis';
+import { OSMNode, OSMNodeTag, OSMWay, OSMWayTag, OSMPlace, OSMContact, OSMAddress, OSM } from '../interfaces/osm';
+
@Injectable({
providedIn: 'root'
})
export class OsmService {
+nodeList: OSMNode[] = [];
+nodeTagList: OSMNodeTag[] = [];
+wayList: OSMWay[] = [];
+wayTagList: OSMWayTag[] = [];
+placeList: OSMPlace[] = [];
+
constructor() { }
+ parseOsmContent(osmData: string): OSM{
+ this.nodeList = [];
+ this.nodeTagList = [];
+ this.wayList = [];
+ this.wayTagList = [];
+ this.placeList = [];
+
+ let lines = osmData.split('\n');
+ let nodeLines: string[] = [];
+ let wayLines: string[] = [];
+
+ for(let line of lines){
+ if(line.includes("")){
+ this.createNode([line]);
+ nodeLines = [];
+ }else{
+ nodeLines.push(line);
+ }
+ }else if(line.includes("")){
+ this.createNode(nodeLines);
+ nodeLines = [];
+ }else if(nodeLines.length > 0){
+ nodeLines.push(line);
+ }else if(line.includes("")){
+ this.createWay(wayLines);
+ wayLines = [];
+ }else if(wayLines.length > 0){
+ wayLines.push(line);
+ }
+ }
+
+ let osm: OSM = {
+ nodes: this.nodeList,
+ nodeTags: this.nodeTagList,
+ ways: this.wayList,
+ wayTags: this.wayTagList,
+ places: this.placeList
+ };
+
+ return osm;
+ }
+
+ createContact(lines: string[]): OSMContact{
+ let contact: OSMContact = {};
+
+ for(let line of lines){
+ if(line.includes(" {
+ beforeEach(() => {
+ TestBed.configureTestingModule({
+ providers: [OverpassApiService]
+ });
+ });
+
+ it('should ...', inject([OverpassApiService], (service: OverpassApiService) => {
+ expect(service).toBeTruthy();
+ }));
+});
diff --git a/src/app/services/overpass-api.service.ts b/src/app/services/overpass-api.service.ts
new file mode 100644
index 0000000..310ea96
--- /dev/null
+++ b/src/app/services/overpass-api.service.ts
@@ -0,0 +1,16 @@
+import { Injectable } from '@angular/core';
+import { HttpClient } from '@angular/common/http';
+import { Observable } from 'rxjs';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class OverpassApiService {
+
+constructor(private http: HttpClient) { }
+
+ sendQueryRequest(queryString: string){
+ console.log("queryString: " + queryString);
+ return this.http.get("https://overpass-api.de/api/map?bbox=" + queryString, { observe: 'body', responseType: 'text'});
+ }
+}