my_data = {
var result = []
birthdeath.forEach(person => {
var cleanedOccupations = []
var personOccupations = occupation.filter(d => d.URI == person.URI)
var searchLocations = locations.filter(d => d.URI == person.URI)
var personLocations = []
if (searchLocations.length > 0)
searchLocations.forEach(loc => {
var locationLabel = loc.event_label.split(":")
var simpleLocationLabel = locationLabel[locationLabel.length-1].trim()
personLocations.push({
placeLabel: loc.placeLabel,
locationType: loc.locationType.replace("http://id.lincsproject.ca/cwrc/", ""),
latitude: loc.latitude.replace(",", "."),
longitude: loc.longitude.replace(",", "."),
eventLabel: simpleLocationLabel
})
})
var searchDeath = causedeath.filter(d => d.URI == person.URI)
var causeDeath = []
if ( searchDeath.length == 0)
causeDeath.push("unknown causes")
else if (searchDeath.length == 1)
causeDeath.push(searchDeath[0].cause_label)
else {
causeDeath = []
searchDeath.forEach(d => causeDeath.push(d.cause_label))
}
personOccupations.forEach(occ => {
cleanedOccupations.push({
job: occ.job_title,
type: occ.type_of_employment
})
})
result.push({
name: person.name,
firstName: person.name.split(",")[1] ? person.name.split(",")[1].trim() : "",
lastName: person.name.split(",")[0] ? person.name.split(",")[0].trim() : "",
birth: person.birth_Year,
death: person.death_Year,
ageAtDeath: person.death_Year - person.birth_Year,
uri: person.URI,
occupation: cleanedOccupations,
causeDeath : causeDeath,
locations: personLocations
})
})
return result
}