Skip to content

Commit

Permalink
Merge pull request #5 from dhlab-basel/wip/integrate-ui-2
Browse files Browse the repository at this point in the history
Add map & location component
  • Loading branch information
Vijeinath committed Jan 25, 2024
2 parents 604a95a + 1fc4dd9 commit f8ec3fa
Show file tree
Hide file tree
Showing 25 changed files with 642 additions and 92 deletions.
1 change: 1 addition & 0 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
],
"styles": [
"src/styles.scss",
"node_modules/leaflet/dist/leaflet.css",
"src/assets/style/main.scss",
"src/assets/style/material-theme.scss"
],
Expand Down
77 changes: 77 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
"core-js": "^3.6.5",
"jdnconvertiblecalendar": "^0.0.7",
"jdnconvertiblecalendardateadapter": "^1.0.1",
"leaflet": "^1.9.4",
"leaflet-arrowheads": "^1.4.0",
"ngx-color-picker": "^13.0.0",
"openseadragon": "^2.4.2",
"rxjs": "~6.5.5",
Expand All @@ -51,6 +53,7 @@
"@angular/language-service": "^15.2.10",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3",
"@types/leaflet": "^1.9.8",
"@types/node": "^12.11.1",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.43.0",
Expand Down
6 changes: 5 additions & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ import { PageTranscriptionComponent } from './resource/page-transcription/page-t
import { ArkUrlDialogComponent } from './dialog/ark-url-dialog.component';
import { ReisbuechleinUriPipe } from './pipes/reisbuechlein-uri.pipe';
import { OnlyTranscriptionComponent } from './resource/page-transcription/only-transcription/only-transcription.component';
import { LocationComponent } from './resource/location/location.component';
import { MapComponent } from './map/map.component';

@NgModule({
declarations: [
Expand Down Expand Up @@ -110,7 +112,9 @@ import { OnlyTranscriptionComponent } from './resource/page-transcription/only-t
PageTranscriptionComponent,
ArkUrlDialogComponent,
ReisbuechleinUriPipe,
OnlyTranscriptionComponent
OnlyTranscriptionComponent,
LocationComponent,
MapComponent
],
imports: [
AppRouting,
Expand Down
5 changes: 5 additions & 0 deletions src/app/app.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { CommentComponent } from './resource/comment/comment.component';
import { BiographyComponent } from './biography/biography.component';
import { LeceLeooComponent } from './lece-leoo/lece-leoo.component';
import { PageTranscriptionComponent } from './resource/page-transcription/page-transcription.component';
import { LocationComponent } from './resource/location/location.component';


const appRoutes: Routes = [
Expand Down Expand Up @@ -53,6 +54,10 @@ const appRoutes: Routes = [
path: 'resource/:id',
component: ResourceComponent
},
{
path: 'location/:id',
component: LocationComponent
},
{
path: 'simpleResource/:id',
component: SimpleResourceComponent
Expand Down
2 changes: 1 addition & 1 deletion src/app/biography/biography.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ <h2>Biography</h2>
made significant contributions to almost all areas of mathematics and physics: the areas he
deeply influenced include, to cite just a few, analysis—a field that he virtually founded—number
theory, geometry, the emerging area of topology, dynamics, and optics. Euler's vast impact on
science also extends to the introduction, in his textbooks, of many elements of modern mathematical terminology and notation. </p>
science also extends to the introduction, in his textbooks, of many elements of modern mathematical terminology and notation.</p>
</section>

<mat-divider></mat-divider>
Expand Down
9 changes: 4 additions & 5 deletions src/app/landing-page/landing-page.component.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<div class="full-size scroll-y-only">
<div class="sidebar">

<a href="/about">About</a>
</div>
<div class="main-content">

<section>
<h1 style="font-size:50px; font-family: 'Times New Roman'">Bernoulli Euler Digital</h1>
<h1>Bernoulli Euler Digital</h1>
<p>
The Bernoulli-Euler Digital represents a notable expansion of the
<a target="_blank" href="https://app.dasch.swiss/project/yTerZGyxjZVqFMNNKXCDPF">Bernoulli-Euler Online (BEOL)</a> project.
Expand Down Expand Up @@ -72,7 +71,7 @@ <h4>Nicolaus <br>Fuss</h4>
<mat-divider></mat-divider>

<section class="third-party-projects">
<h3 style="font-size:35px; font-family: 'Times New Roman'">Third Party Projects</h3>
<h3>Third Party Projects</h3>
<p>
Bernoulli-Euler Digital is connected to the repositories of <a href="http://www.newtonproject.ox.ac.uk/">The Newton Project</a>
and the <a href="http://leibniz-briefportal.adw-goe.de/start">Briefportal Leibniz</a> initiating the formation
Expand All @@ -92,8 +91,8 @@ <h4>{{leibniz.description}}</h4>

<mat-divider></mat-divider>

<section>
<h3 style="font-size:35px; font-family: 'Times New Roman'">Visualizations</h3>
<section class="visualizations">
<h3>Visualizations</h3>
<p>The correspondence data included in this platform are visualized as interactive 3D force-directed graphs which
are also available in WebVR format. You can explore the correspondence network interactively
<a target="_blank" href="https://vis.beol.dasch.swiss/">here</a>.
Expand Down
10 changes: 10 additions & 0 deletions src/app/landing-page/landing-page.component.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
section {
padding: 24px 0 48px 0;

h1 {
font-size: 50px;
font-family: 'Times New Roman';
}
}

.third-party-projects h3, .visualizations h3 {
font-size:35px;
font-family: 'Times New Roman';
}

.biographies {
Expand Down
4 changes: 4 additions & 0 deletions src/app/map/map.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="map-frame">
<div id="map"></div>
</div>

10 changes: 10 additions & 0 deletions src/app/map/map.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.map-frame {
border: 2px solid black;
height: 100%;
margin: 2rem 0;
}

#map {
height: 700px;
}

23 changes: 23 additions & 0 deletions src/app/map/map.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { MapComponent } from './map.component';

describe('MapComponent', () => {
let component: MapComponent;
let fixture: ComponentFixture<MapComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ MapComponent ]
})
.compileComponents();

fixture = TestBed.createComponent(MapComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
93 changes: 93 additions & 0 deletions src/app/map/map.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { DataGraphDB } from '../services/beol.service';
import * as L from 'leaflet';
import 'leaflet-arrowheads';
import { environment } from '../../environments/environment';

@Component({
selector: 'app-map',
templateUrl: './map.component.html',
styleUrls: ['./map.component.scss']
})
export class MapComponent implements OnChanges {
@Input() mapData: DataGraphDB;
map: any;
constructor() {
}

ngOnChanges(changes: SimpleChanges): void {
this.initMap();
}

private initMap() {
const origin = this.get_origin()
const destination = this.get_destination()
const centroid = this.calculate_center(origin, destination)
this.loadMap(centroid);
this.addMarkers(origin, destination);
this.addLines();
}

private get_origin(): L.LatLng {
const latitude = this.mapData.results.bindings[0].startLat.value
const longitude = this.mapData.results.bindings[0].startLong.value
return new L.LatLng(latitude, longitude)
}

private get_destination(): L.LatLng {
const length = this.mapData.results.bindings.length
const lastObject = this.mapData.results.bindings[length-1]
const latitude = lastObject.endLat.value
const longitude = lastObject.endLong.value
return new L.LatLng(latitude, longitude)
}
private calculate_center(origin: L.LatLng, destination: L.LatLng): L.LatLng {
const middle_point_lat = (origin.lat + destination.lat)/2
const middle_point_lng = (origin.lng + destination.lng)/2
return new L.LatLng(middle_point_lat, middle_point_lng)
}

private loadMap(centroid: L.LatLngExpression): void {
this.map = L.map('map', {center: centroid, zoom: 8.4});
const tiles = L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
accessToken: environment.mapbox.accessToken,
})
tiles.addTo(this.map);
}

private addMarkers(origin_coord: L.LatLng, destination_coord: L.LatLng): void {
const origin = L.marker(origin_coord, {
icon: new L.Icon({
iconSize: new L.Point(40, 40),
iconAnchor: [13, 41],
iconUrl: 'assets/images/red_marker.svg',
}), title: 'Workspace'
} as L.MarkerOptions);
origin.addTo(this.map);

const destination = L.marker(destination_coord, {
icon: new L.Icon({
iconSize: new L.Point(40, 40),
iconAnchor: [13, 41],
iconUrl: 'assets/images/blue_marker.svg',
}), title: 'Workspace'
} as L.MarkerOptions);
destination.addTo(this.map);
}

private addLines(): void {
this.mapData.results.bindings.forEach((obj, index) => {
const start = new L.LatLng(obj.startLat.value, obj.startLong.value)
const end = new L.LatLng(obj.endLat.value, obj.endLong.value)
const line = L.polyline([start, end], {
color: '#800080'
} as L.PolylineOptions).arrowheads({size: '15%'});
line.addTo(this.map)
})
}
}
Loading

0 comments on commit f8ec3fa

Please sign in to comment.