Skip to content
Snippets Groups Projects
Commit 020a52ef authored by esikkala's avatar esikkala
Browse files

Add initial config for choropleth map

parent 4791ac7c
No related branches found
No related tags found
No related merge requests found
...@@ -204,6 +204,28 @@ const Perspective1 = props => { ...@@ -204,6 +204,28 @@ const Perspective1 = props => {
layoutConfig={props.layoutConfig} layoutConfig={props.layoutConfig}
/>} />}
/> />
<Route
path={`${rootUrl}/${perspective.id}/faceted-search/choropleth_map`}
render={() =>
<Deck
center={props.perspectiveState.maps.placesMsMigrations.center}
zoom={props.perspectiveState.maps.placesMsMigrations.zoom}
results={props.perspectiveState.results}
facetUpdateID={props.facetState.facetUpdateID}
instanceAnalysisData={props.perspectiveState.instanceAnalysisData}
instanceAnalysisDataUpdateID={props.perspectiveState.instanceAnalysisDataUpdateID}
resultClass='choropleth'
facetClass='perspective1'
fetchResults={props.fetchResults}
fetchInstanceAnalysis={props.fetchInstanceAnalysis}
fetching={props.perspectiveState.fetching}
fetchingInstanceAnalysisData={props.perspectiveState.fetchingInstanceAnalysisData}
layerType='arcLayer'
mapBoxAccessToken={MAPBOX_ACCESS_TOKEN}
mapBoxStyle={MAPBOX_STYLE}
layoutConfig={props.layoutConfig}
/>}
/>
<Route <Route
path={`${rootUrl}/${perspective.id}/faceted-search/production_dates`} path={`${rootUrl}/${perspective.id}/faceted-search/production_dates`}
render={() => render={() =>
......
...@@ -171,13 +171,14 @@ export const mapPieChart = sparqlBindings => { ...@@ -171,13 +171,14 @@ export const mapPieChart = sparqlBindings => {
export const linearScale = ({ data, config }) => { export const linearScale = ({ data, config }) => {
const { variable, minAllowed, maxAllowed } = config const { variable, minAllowed, maxAllowed } = config
const length = data.length const length = data.length
const min = data[length - 1][variable] const min = Number(data[length - 1][variable])
const max = data[0][variable] const max = Number(data[0][variable])
data.forEach(item => { data.forEach(item => {
if (item[variable]) { if (item[variable]) {
const unscaledNum = item[variable] const unscaledNum = Number(item[variable])
// https://stackoverflow.com/a/31687097 // https://stackoverflow.com/a/31687097
item[`${variable}Scaled`] = (maxAllowed - minAllowed) * (unscaledNum - min) / (max - min) + minAllowed const scaled = (maxAllowed - minAllowed) * (unscaledNum - min) / (max - min) + minAllowed
item[`${variable}Scaled`] = scaled.toFixed(2)
} }
}) })
return data return data
......
...@@ -5,6 +5,7 @@ import { findsConfig } from './perspective_configs/FindsConfig' ...@@ -5,6 +5,7 @@ import { findsConfig } from './perspective_configs/FindsConfig'
import { actorsConfig } from './perspective_configs/EmloActorsConfig' import { actorsConfig } from './perspective_configs/EmloActorsConfig'
import { hellerauConfig } from './perspective_configs/HellerauConfig' import { hellerauConfig } from './perspective_configs/HellerauConfig'
import { speechesConfig } from './perspective_configs/SemparlSpeechesConfig' import { speechesConfig } from './perspective_configs/SemparlSpeechesConfig'
import { warsaConfig } from './perspective_configs/WarsaConfig'
import { import {
productionPlacesQuery, productionPlacesQuery,
lastKnownLocationsQuery, lastKnownLocationsQuery,
...@@ -19,7 +20,8 @@ import { ...@@ -19,7 +20,8 @@ import {
manuscriptInstancePageNetworkLinksQuery, manuscriptInstancePageNetworkLinksQuery,
manuscriptFacetResultsNetworkLinksQuery, manuscriptFacetResultsNetworkLinksQuery,
manuscriptNetworkNodesQuery, manuscriptNetworkNodesQuery,
knowledgeGraphMetadataQuery knowledgeGraphMetadataQuery,
choroplethQuery
} from './sparql_queries/SparqlQueriesPerspective1' } from './sparql_queries/SparqlQueriesPerspective1'
import { import {
workProperties workProperties
...@@ -75,6 +77,7 @@ export const backendSearchConfig = { ...@@ -75,6 +77,7 @@ export const backendSearchConfig = {
emloActors: actorsConfig, emloActors: actorsConfig,
hellerau: hellerauConfig, hellerau: hellerauConfig,
semparlSpeeches: speechesConfig, semparlSpeeches: speechesConfig,
warsa: warsaConfig,
manuscripts: { manuscripts: {
perspectiveID: 'perspective1', // get rest of the config from 'perspective1' perspectiveID: 'perspective1', // get rest of the config from 'perspective1'
instance: { instance: {
...@@ -166,6 +169,19 @@ export const backendSearchConfig = { ...@@ -166,6 +169,19 @@ export const backendSearchConfig = {
} }
} }
}, },
choropleth: {
perspectiveID: 'warsa',
q: choroplethQuery,
resultMapper: makeObjectList,
postprocess: {
func: linearScale,
config: {
variable: 'instanceCount',
minAllowed: 0,
maxAllowed: 1
}
}
},
placesMsMigrationsDialog: { placesMsMigrationsDialog: {
perspectiveID: 'perspective1', perspectiveID: 'perspective1',
q: migrationsDialogQuery, q: migrationsDialogQuery,
......
import { prefixes } from '../sparql_queries/SparqlQueriesPrefixes'
export const warsaConfig = {
endpoint: {
url: 'http://ldf.fi/warsa/sparql',
prefixes,
useAuth: false
}
}
...@@ -596,3 +596,16 @@ export const knowledgeGraphMetadataQuery = ` ...@@ -596,3 +596,16 @@ export const knowledgeGraphMetadataQuery = `
dct:modified ?databaseDump__modified . dct:modified ?databaseDump__modified .
} }
` `
export const choroplethQuery = `
SELECT ?id ?prefLabel ?polygon (count(?death) as ?instanceCount)
WHERE {
?id a <http://www.yso.fi/onto/suo/kunta> ;
skos:prefLabel ?prefLabel .
# sch:polygon ?polygon
?death crm-org:P7_took_place_at ?id .
}
GROUP BY ?id ?prefLabel ?polygon
ORDER BY desc(?instanceCount)
LIMIT 10
`
...@@ -3,6 +3,7 @@ export const prefixes = ` ...@@ -3,6 +3,7 @@ export const prefixes = `
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX crm: <http://erlangen-crm.org/current/> PREFIX crm: <http://erlangen-crm.org/current/>
PREFIX crm-org: <http://www.cidoc-crm.org/cidoc-crm/>
PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX text: <http://jena.apache.org/text#> PREFIX text: <http://jena.apache.org/text#>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment