Commit 9ca788f7 authored by Sebastian Bruch's avatar Sebastian Bruch

verbindungen

parent 50cc5b54
......@@ -70,15 +70,13 @@ export class OsmNode {
}
}
if(data['type']){
this.osmType = this.osmType.toLowerCase();
console.log("Type: "+this.osmType);
}
if(data['tags']){
for(let key in data['tags']){
if(data['tags'][key]['key']){
this.tags.push(new Tag(data['tags'][key]['key'],data['tags'][key]['value'] ));
this.tags.push(new Tag(data['tags'][key]['key'],data['tags'][key]['value']));
}else{
this.osmtags.push(new Tag(key,data['tags'][key]));
}
......
......@@ -32,6 +32,7 @@ export class OpenlayerComponent implements OnInit {
nodes.push(OsmNodeFactory.create(data));
}
this.mapService.showNodes(nodes);
this.mapService.showConnections();
},
(error)=>{
console.log("error: "+JSON.stringify(error));
......
......@@ -5,7 +5,7 @@
<div class="tabContent">
<div class="form-group">
<!--<ngx-spinner bdColor="rgba(51, 51, 51, 0.8)" size="large" color="#fff" type="ball-spin-clockwise"></ngx-spinner>-->
<form [formGroup]="searchForm" (ngSubmit)="login()" class="searchForm">
<form [formGroup]="searchForm" class="searchForm">
<div class="">
<input type="text" formControlName="searchPattern"
class="form-control searchinput"
......@@ -168,7 +168,7 @@
</div>
<div *ngFor="let dimension of nodeService.detailView.dimensions"
class="list-group">
<div class="list-group-item list-group-item-action">{{dimension.name}}</div>
<div class="list-group-item list-group-item-action" title="{{dimension.description}}">{{dimension.name}}</div>
</div>
</div>
<div class="elementpartner">
......@@ -180,7 +180,7 @@
class="list-group">
<div class="list-group-item list-group-item-action">
<i class="fa fa-map-marker" aria-hidden="true"></i>{{partner.name}}<label
class="switch"><input type="checkbox" (change)="togglePeerVisibility(nodeService.detailView,partner)"><span
class="switch"><input type="checkbox" (change)="togglePeerVisibility(partner)"><span
class="slider round"></span></label>
</div>
</div>
......
This diff is collapsed.
......@@ -51,8 +51,6 @@ export class SearchComponent implements OnInit {
}
show(element: OsmNode){
this.logger.debug("Showing ");
this.logger.debug(JSON.stringify(element,null,3));
this.nodeService.showDetails(element);
this.mapService.show(element);
}
......@@ -99,12 +97,10 @@ export class SearchComponent implements OnInit {
}
}
}
parseSearchResult(result){
this.searched=true;
this.logger.debug("Search result.");
this.logger.debug(JSON.stringify(result,null,3));
if(result){
if(result['dataGroups']){
this.dataGroups = new Array<DataGroup>();
......@@ -118,14 +114,12 @@ export class SearchComponent implements OnInit {
for(let data of result['geoElements']){
let node = new OsmNode(data);
this.nodeService.fillBliDimensions(node);
this.logger.debug("SiD: "+this.searchForm.value.searchInDescription);
this.logger.debug("processing node: "+node.name);
node.osmId = data['osmId'];
if(this.searchForm.value.searchInDescription){
this.logger.debug("Pushing anyway.");
this.osmNodes.push(node);
}else{
this.logger.debug("Searching "+node.name)
this.logger.debug(" for " + this.searchForm.value.searchPattern);
if(node.name.toLowerCase().indexOf(this.searchForm.value.searchPattern.toLowerCase()) > -1){
this.osmNodes.push(node);
......@@ -175,9 +169,9 @@ export class SearchComponent implements OnInit {
this.state="hidden";
}
}
togglePeerVisibility(node: OsmNode,peer: OsmNode){
togglePeerVisibility(peer: OsmNode){
this.logger.debug("toggling visibility of peer "+peer.name);
this.mapService.togglePeerVisibility(node,peer);
this.mapService.togglePeerVisibility(this.nodeService.detailView,peer);
}
isCurrentElement(node:OsmNode){
......
......@@ -24,8 +24,8 @@ export class GeoportalApiService {
};
//private apiURL = 'http://10.0.8.29:8080/geoportal';
private apiURL = 'http://94.130.8.94:18080/geoportal';
//private apiURL = 'http://127.0.0.1:8080/geoportal';
//private apiURL = 'http://94.130.8.94:18080/geoportal';
private apiURL = 'http://127.0.0.1:8080/geoportal';
private endpoints: GeoportalApiEndpoint[];
private defaultEndpoint: GeoportalApiEndpoint;
private bearer: string;
......@@ -121,7 +121,6 @@ export class GeoportalApiService {
}
getGeoportalElementByOsmId(id:number){
return this.http.get(this.apiURL+"/GeoElements/byOsmId/"+id+"/",this.httpOptions);
}
......
......@@ -6,19 +6,22 @@
import OlTileLayer from 'ol/layer/tile';
import OlView from 'ol/view';
import OlProj from 'ol/proj';
import OlProjection from 'ol/proj/projection';
import OlExtent from 'ol/extent';
import OlFeature from 'ol/Feature';
import { OlVectorFeature } from 'ol/Feature';
import { Icon as OlIcon, Style as OlStyle } from 'ol/style';
import { Stroke as OlStroke, Fill as OlFill } from 'ol/style';
import OlVectorLayer from 'ol/layer/vector';
import { fromLonLat } from 'ol/proj';
import { transformExtent } from 'ol/proj';
import OlPoint from 'ol/geom/Point';
import { Stroke as OlStroke, Fill as OlFill } from 'ol/style';
import OlLineString from 'ol/geom/LineString';
import { LogService } from './log.service';
import { OsmNode } from '../models/OsmNode';
import { defaults as OlDefaultControls } from 'ol/control.js';
import { OlMapBrowserEvent } from 'ol/events';
import { Rectangle } from '../models/Rectangle';
import { OsmNodeService } from './osm-node.service';
//OlTransforms.transformExtent(extent,'EPSG:3857','EPSG:4326');
@Injectable({
......@@ -34,6 +37,8 @@
coordinates: [ number,number ];
mapLayer: OlTileLayer;
iconLayer: OlVectorLayer;
connectionLayer: OlVectorLayer;
connections: Array<OlFeature>;
icons: Array<OlFeature>;
layers: Array<any>;
text:string;
......@@ -48,6 +53,7 @@
this.layers=new Array<any>();
this.currentNodeSet=new Array<OsmNode>();
this.icons = new Array<OlFeature>();
this.connections = new Array<OlFeature>();
this.coordinates = [7.147,51.26];
this.changeText();
this.zoom = 12;
......@@ -59,6 +65,13 @@
},
source: new OlVectorSource({features: this.icons})
});
this.connectionLayer = new OlVectorLayer({
style: function(feature) {
return feature.get('style');
},
source: new OlVectorSource({features: this.connections})
});
this.source = new OlXYZ({
//url: 'http://tile.osm.org/{z}/{x}/{y}.png'
......@@ -74,7 +87,8 @@
zoom: this.zoom
});
}
createElement(coords,node){
if(node.mapId== -1){
node.mapId = parseInt(node.osmId)+""+(Math.floor(Math.random()*100000)+1);
......@@ -112,10 +126,14 @@
}))
});
}
fitView(){
this.map.getView().fit(this.iconLayer.getSource().getExtent());
}
addNode(node:OsmNode){
this.icons.push(this.createElement([(node.lon),(node.lat)],node));
this.map.removeLayer(this.iconLayer);
......@@ -129,6 +147,25 @@
this.map.addLayer(this.iconLayer);
this.currentNodeSet.push(node);
}
showConnections(){
this.connections.length = 0;
for( let node of this.currentNodeSet){
for( let peer of node.peers){
// wenn das element schon angezeigt wird.
if(this.currentNodeSet.indexOf(peer)>-1){
this.connections.push(this.createLine(node,peer));
}
}
}
this.map.removeLayer(this.connectionLayer);
this.connectionLayer = new OlVectorLayer({
source: new OlVectorSource({features: this.connections}),
});
this.map.addLayer(this.connectionLayer);
}
showNodes(nodes: Array<OsmNode>){
this.currentNodeSet = nodes;
let center = {'lon':0,'lat':0};
......@@ -165,6 +202,8 @@
for(let node of nodes){
this.icons.push(this.createElement([(node.lon),(node.lat)],node));
}
this.connections.length = 0;
this.map.removeLayer(this.connectionLayer);
this.map.removeLayer(this.iconLayer);
this.iconLayer = new OlVectorLayer({
style: function(feature) {
......@@ -174,6 +213,7 @@
});
this.map.getView().fit(this.iconLayer.getSource().getExtent());
this.map.addLayer(this.iconLayer);
this.showConnections();
}
show(node: OsmNode){
......@@ -198,39 +238,13 @@
this.map.addLayer(this.iconLayer);
}
showConnection(lhs:OsmNode,rhs:OsmNode){
}
removeConnection(lhs:OsmNode,rhs:OsmNode){
}
removeNode(node:OsmNode){
let nodeIdx:any;
let iconIdx:any;
if(node.mapId==-1){
this.logger.debug("cannot remove from map: mapId not set.");
}
for(let idx in this.currentNodeSet){
if(this.currentNodeSet[idx].mapId == node.mapId){
nodeIdx=idx;
}
}
for(let idx in this.icons){
if(this.icons[idx].getId() == node.mapId){
iconIdx=idx;
}
}
if(nodeIdx !== -1){
delete this.currentNodeSet[nodeIdx];
}
if(iconIdx !== -1){
delete this.icons[iconIdx];
}
this.map.removeLayer(this.iconLayer);
this.iconLayer = new OlVectorLayer({
......@@ -247,7 +261,7 @@
if(peer.mapId == -1){
this.addNode(peer);
this.showConnection(parent,peer);
this.showConnections();
this.fitView();
this.logger.debug("Showing peer "+peer.name);
return;
......@@ -264,7 +278,7 @@
this.logger.debug("Hiding peer "+peer.name);
}else{
this.addNode(peer);
this.showConnection(parent,peer);
this.showConnections();
this.fitView();
this.logger.debug("Showing peer "+peer.name);
}
......@@ -281,9 +295,42 @@
let coords = transformExtent(extent,'EPSG:3857',format);
return coords;
}
createLineStyle(){
return new OlStyle({
stroke: new OlStroke({color: '#cdcdcd',width: 3})
});
}
createLine(lhs: OsmNode, rhs:OsmNode){
let lhsCoords = fromLonLat( [lhs.lon,lhs.lat] );
let rhsCoords = fromLonLat( [rhs.lon,rhs.lat] );
let lineString = new OlLineString([lhsCoords,rhsCoords]);
let feature = new OlFeature( {geometry: lineString});
feature.set('style',this.createLineStyle());
return feature;
//;
//feature.set('style', this.createStyle('assets/img/map-marker.png', undefined));
//feature.set('style', this.createLineStyle());
}
showLine(lhs: OsmNode, rhs:OsmNode){
let feature = this.createLine(lhs,rhs);
this.connections.push(feature);
this.map.removeLayer(this.connectionLayer);
this.connectionLayer = new OlVectorLayer({
source: new OlVectorSource({features: this.connections}),
});
this.map.addLayer(this.connectionLayer);
}
initMap(){
this.layers.push(this.mapLayer);
this.layers.push(this.iconLayer);
this.layers.push(this.connectionLayer);
this.map = new OlMap({
target: 'map',
layers: this.layers,
......@@ -291,25 +338,28 @@
controls:null
});
//this.createElement([7.15,51.30]);
let handler = this.clickHandler;
this.map.on('click', this.clickHandler);
}
internalClickHandler(ev: OlMapBrowserEvent){
//let map=ev.map;
let map=this.map;
let pixel = ev.pixel;
let features = map.getFeaturesAtPixel(pixel);
let data=features;
if(data && data.length > 0){
console.log("first feature"+JSON.stringify(data[0].getId()));
for(let node of this.currentNodeSet){
if(node.mapId == data[0].getId()){
this.osmNodeService.showDetails(node);
for(let dataItem of data){
if(dataItem.getId() != undefined){
for(let node of this.currentNodeSet){
if(node.mapId == dataItem.getId()){
this.osmNodeService.showDetails(node);
}
}
}
}
}else{
console.log("no feature there..");
}
......
This diff is collapsed.
......@@ -78,8 +78,6 @@ export class OsmNodeService {
fillBliDimensions(node: OsmNode){
this.logger.debug("Showing ");
this.logger.debug(JSON.stringify(node));
for(let bli of node.dimensions){
for(let dim of this.bliService.dimensions){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment