Skip to content

Commit

Permalink
add yasgui timeline
Browse files Browse the repository at this point in the history
  • Loading branch information
joschne committed Apr 12, 2024
1 parent 9b2a855 commit ee5a1f5
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 16 deletions.
44 changes: 43 additions & 1 deletion lib/projectParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ LIMIT 10`,
headOgImage: '/socialimage/maritime-history.jpg',
sparqlQueryTabs: [
{
name: 'Ship Voyages',
name: 'Ship Voyages Map',
sparqlEndpoint: 'https://sparql.geovistory.org/api_v1_project_84760',
selectedPlugin: 'mapCircles',
query: `PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
Expand Down Expand Up @@ -257,6 +257,48 @@ WHERE {
GROUP BY ?label ?long ?lat ?type ?link
}
}`
},
{
name: 'Ship Voyages Timeline',
sparqlEndpoint: 'https://sparql.geovistory.org/api_v1_project_84760',
selectedPlugin: 'timeline',
query: `PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX time: <http://www.w3.org/2006/time#>
PREFIX ontome: <https://ontome.net/ontology/>
PREFIX geov: <http://geovistory.org/resource/>
SELECT (concat(str(?e), "?p=84760") as ?entityLink) (MIN(?date) as ?startDate) (MAX(?date) as ?endDate) (SAMPLE(?l) as ?entityLabel) ?entityClassLabel
WHERE {
### Definition of the events we want to display on a timeline
# Geo-Place "Texel NL" -> is departure place of -> ship voyage
geov:i209502 ^ontome:p1335 ?e .
# event -> is a -> ship voyages
?e a ontome:c523 .
# Ship voyage -> class label
ontome:c523 rdfs:label ?entityClassLabel .
### Join temproal information for the time line ###
# event -> has -> time span
?e ontome:p4 ?timespan.
# time span -> timeprop -> date time description
?timespan ontome:p71|ontome:p72|ontome:p150|ontome:p151|ontome:p152|ontome:p153 ?dtd.
# date time description -> year;month;day
?dtd time:year ?y ; time:month ?m ; time:day ?d .
FILTER regex(str(?y), '^-') # necessary because of https://github.com/geovistory/toolbox-streams/issues/124
# parse to xsd:date
bind(xsd:date(concat(replace(str(?y), "^-", "" ), replace(str(?m), "^-", "" ),replace(str(?d), "^--", "" ))) as ?date)
# event -> has -> label
?e rdfs:label ?l .
}
GROUP BY ?e ?entityClassLabel
LIMIT 10`
},
{
name: 'Selection of triples',
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"copy:icons": "node .build/copy-icons.js"
},
"dependencies": {
"@geovistory/design-system-web": "1.21.1-pr-122.1",
"@geovistory/design-system-web": "1.23.0",
"@ionic/core": "^6.1.13",
"@triply/yasgui": "^4.2.26",
"dlv": "^1.1.3",
Expand Down
58 changes: 50 additions & 8 deletions pages/project/[geov_id]/sparql.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
projectsParams,
} from '../../../lib/projectParams';
import styles from './sparql.module.css';
import { QueryTab } from '@geovistory/design-system-web/loader';
import { CustomPlugin, QueryTab } from '@geovistory/design-system-web/loader';

export interface ProjectSparqlProps {
params: ProjectParams;
Expand All @@ -33,17 +33,19 @@ const ProjectSparqlPage: NextPage<ProjectSparqlProps> = (props) => {
default-plugin="table"
collapse="false"
ref={(el: HTMLGeovYasguiElement) => {
el.plugins = new Set<'mapCircles'>(['mapCircles']);
el.plugins = new Set<CustomPlugin>(['mapCircles', 'timeline']);
el.queryTabs = props.queryTabs ?? [
{
name: 'Geographical Places',
name: 'Map example',
sparqlEndpoint: `https://sparql.geovistory.org/api_v1_project_${props.params.geovID}`,
selectedPlugin: 'mapCircles',
query: `PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ontome: <https://ontome.net/ontology/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?label ?long ?lat ?link ("Geographical Place" as ?type) ${props.params.geovID ? "(count(?label) as ?radius)" : ""}
SELECT ?label ?long ?lat ?link ("Geographical Place" as ?type) ${
props.params.geovID ? '(count(?label) as ?radius)' : ''
}
WHERE {
# Geographical Place -had presence-> Presence -was at-> Place (lat/long)
Expand All @@ -60,14 +62,54 @@ WHERE {
# Append the project query param to the URI
bind(concat(str(?geoplace), "?p=${props.params.geovID}") as ?link )
${props.params.geovID == 153 ?
`# Find how much event are linked
${
props.params.geovID == 153
? `# Find how many events are linked
?event ontome:p7 ?geoplace`
: ""}
: ''
}
}
GROUP BY ?label ?long ?lat ?type ?link
`
`,
},
{
name: 'Timeline example',
sparqlEndpoint: `https://sparql.geovistory.org/api_v1_project_${props.params.geovID}`,
selectedPlugin: 'timeline',
query: `PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX time: <http://www.w3.org/2006/time#>
PREFIX ontome: <https://ontome.net/ontology/>
PREFIX geov: <http://geovistory.org/resource/>
SELECT
(concat(str(?e), "?p=${props.params.geovID}") as ?entityLink)
(MIN(?date) as ?startDate) (MAX(?date) as ?endDate) (SAMPLE(?l) as ?entityLabel) (SAMPLE(?classLabel) as ?entityClassLabel)
WHERE {
# event -> is a -> birth
?e a ontome:c61 .
# event class label
ontome:c61 rdfs:label ?classLabel .
# birth -> brought into life -> person -> has label -> label
?e ontome:p86/rdfs:label ?l .
# event -> has -> time span
?e ontome:p4 ?timespan.
# time span -> timeprop -> date time description
?timespan ontome:p71|ontome:p72|ontome:p150|ontome:p151|ontome:p152|ontome:p153 ?dtd.
# date time description -> year;month;day
?dtd time:year ?y ; time:month ?m ; time:day ?d .
FILTER regex(str(?y), '^-') # necessary because of https://github.com/geovistory/toolbox-streams/issues/124
# parse to xsd:date
bind(xsd:date(concat(replace(str(?y), "^-", "" ), replace(str(?m), "^-", "" ),replace(str(?d), "^--", "" ))) as ?date)
}
GROUP BY ?e ?classLabel
LIMIT 10
`,
},
{
name: 'Selection of triples',
Expand Down
104 changes: 102 additions & 2 deletions pages/sparql.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CustomPlugin } from '@geovistory/design-system-web/loader';
import type { GetStaticProps, NextPage } from 'next';
import { CCLicense } from '../components/elements/CCLicense.component';
import { Yasgui } from '../components/elements/Yasgui.component';
import {
DefaultPage,
DefaultPageProps,
Expand All @@ -16,7 +16,107 @@ const Sparql: NextPage<SparqlProps> = (props) => {
<h1 className={styles.title}>
Access Geovistory Community Data via SPARQL
</h1>
<Yasgui endpoint="https://sparql.geovistory.org/api_v1_community_data" />
<geov-yasgui
id="el-1"
default-plugin="table"
collapse="false"
ref={(el: HTMLGeovYasguiElement) => {
el.plugins = new Set<CustomPlugin>(['mapCircles', 'timeline']);
el.queryTabs = [
{
name: 'Selection of triples',
sparqlEndpoint: `https://sparql.geovistory.org/api_v1_community_data`,
selectedPlugin: 'table',
query: `PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX time: <http://www.w3.org/2006/time#>
PREFIX ontome: <https://ontome.net/ontology/>
PREFIX geov: <http://geovistory.org/resource/>
SELECT ?subject ?predicate ?object
WHERE {
?subject ?predicate ?object .
}
LIMIT 10`,
},
{
name: 'Map example',
sparqlEndpoint: `https://sparql.geovistory.org/api_v1_community_data`,
selectedPlugin: 'mapCircles',
query: `PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ontome: <https://ontome.net/ontology/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?label ?long ?lat ?link ("Geographical Place" as ?type)
WHERE {
# Geographical Place -had presence-> Presence -was at-> Place (lat/long)
?geoplace ontome:p147i/ontome:p148 ?place.
# Geographical Place -label-> label
?geoplace rdfs:label ?label.
# Extract lat and long from WKT
bind(replace(str(?place), '<http://www.opengis.net/def/crs/EPSG/0/4326>', "", "i") as ?rep)
bind(xsd:float(replace(str(?rep), "^[^0-9\\\\.-]*([-]?[0-9\\\\.]+) .*$", "$1" )) as ?long )
bind(xsd:float(replace( str(?rep), "^.* ([-]?[0-9\\\\.]+)[^0-9\\\\.]*$", "$1" )) as ?lat )
# Append the project query param to the URI
bind(concat(str(?geoplace)) as ?link )
}
GROUP BY ?label ?long ?lat ?type ?link
`
},
{
name: 'Timeline example',
sparqlEndpoint: 'https://sparql.geovistory.org/api_v1_community_data',
selectedPlugin: 'timeline',
query: `PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xml: <http://www.w3.org/XML/1998/namespace>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX geo: <http://www.opengis.net/ont/geosparql#>
PREFIX time: <http://www.w3.org/2006/time#>
PREFIX ontome: <https://ontome.net/ontology/>
PREFIX geov: <http://geovistory.org/resource/>
SELECT (str(?e) as ?entityLink) (MIN(?date) as ?startDate) (MAX(?date) as ?endDate) (SAMPLE(?l) as ?entityLabel) ?entityClassLabel
WHERE {
### Definition of the events we want to display on a timeline
# Geo-Place "Texel NL" -> is departure place of -> ship voyage
geov:i209502 ^ontome:p1335 ?e .
# event -> is a -> ship voyages
?e a ontome:c523 .
# Ship voyage -> class label
ontome:c523 rdfs:label ?entityClassLabel .
### Join temproal information for the time line ###
# event -> has -> time span
?e ontome:p4 ?timespan.
# time span -> timeprop -> date time description
?timespan ontome:p71|ontome:p72|ontome:p150|ontome:p151|ontome:p152|ontome:p153 ?dtd.
# date time description -> year;month;day
?dtd time:year ?y ; time:month ?m ; time:day ?d .
# parse to xsd:date
bind(xsd:date(concat(replace(str(?y), "^-", "" ), replace(str(?m), "^-", "" ),replace(str(?d), "^--", "" ))) as ?date)
# event -> has -> label
?e rdfs:label ?l .
}
GROUP BY ?e ?entityClassLabel
LIMIT 10`,
},
];
}}
></geov-yasgui>{' '}
<CCLicense />
</DefaultPage>
);
Expand Down

0 comments on commit ee5a1f5

Please sign in to comment.