diff options
| -rw-r--r-- | client/map/index.js | 17 | ||||
| -rw-r--r-- | scraper/s2-final-report.py | 4 |
2 files changed, 11 insertions, 10 deletions
diff --git a/client/map/index.js b/client/map/index.js index 4e6db2de..b35ffddb 100644 --- a/client/map/index.js +++ b/client/map/index.js @@ -37,7 +37,7 @@ const redDot = L.icon({ popupAnchor: [0, -5] // point from which the popup should open relative to the iconAnchor }) -function addMarker(map, latlng, title, subtext, year, pdf) { +function addMarker(map, latlng, title, addresses, year, pdf) { const marker = L.marker(latlng, { icon: redDot }).addTo(map) let message = [ "<b>", title, "</b>", @@ -47,9 +47,10 @@ function addMarker(map, latlng, title, subtext, year, pdf) { message.push("</a>") } + const addressString = addresses.map(addr => addr.name).join('<br/>') message = message.concat([ "<br>", - subtext, + addressString, ]) if (year) { message.push(" (" + year + ")") @@ -72,7 +73,7 @@ function addArc(map, src, dest, arcStyle) { export default function append(el, payload) { const { data } = payload if (!data) return - let { paper, address, citations } = data + let { paper, addresses, citations } = data let source = [0, 0] let map = L.map(el).setView([25, 0], 2) @@ -86,13 +87,14 @@ export default function append(el, payload) { accessToken: 'pk.eyJ1IjoiZmFuc2FsY3kiLCJhIjoiY2pvN3I1czJwMHF5NDNrbWRoMWpteHlrdCJ9.kMpM5syQUhVjKkn1iVx9fg' }).addTo(map) - if (address) { - source = [address.lat, address.lng].map(n => (parseFloat(n) || 0)) + if (addresses && addresses.length) { + source = [address[0].lat, address[0].lng].map(n => (parseFloat(n) || 0)) } else { console.error("No address found for root paper") // console.log(data) } + // group papers by address citations.forEach(citation => { console.log(citation) if (!citation.addresses) { @@ -102,14 +104,13 @@ export default function append(el, payload) { const citationAddress = citation.addresses[0] const latlng = [citationAddress.lat, citationAddress.lng].map(n => parseFloat(n)) if (Number.isNaN(latlng[0]) || Number.isNaN(latlng[1])) return - const addressString = citation.addresses.map(addr => addr.name).join('<br/>') - addMarker(map, latlng, citation.title, addressString, citation.year, citation.pdf) + addMarker(map, latlng, citation.title, citation.addresses, citation.year, citation.pdf) addArc(map, source, latlng, arcStyles[citationAddress.type]) }) console.log(paper) - const rootMarker = addMarker(map, source, paper.title, address.name, paper.year) + const rootMarker = addMarker(map, source, paper.title, addresses, paper.year) rootMarker.openPopup() // a transparent div to cover the map, so normal scroll events will not be eaten by leaflet diff --git a/scraper/s2-final-report.py b/scraper/s2-final-report.py index 0cc762af..cd77182a 100644 --- a/scraper/s2-final-report.py +++ b/scraper/s2-final-report.py @@ -85,8 +85,8 @@ def process_paper(row, verified_lookup): 'name': row['name'], 'title': paper['title'], 'year': paper['year'], + 'addresses': address_list, }, - 'addresses': address_list, 'citations': [aggregate_citations[key] for key in aggregate_citations.keys()], }, f) with open('{}/{}.json'.format(DIR_VERIFIED_CITATIONS, row['key']), 'w') as f: @@ -97,8 +97,8 @@ def process_paper(row, verified_lookup): 'name': row['name'], 'title': paper['title'], 'year': paper['year'], + 'addresses': address_list, }, - 'addresses': address_list, 'citations': [aggregate_citations[key] for key in verified_lookup.keys() if key in aggregate_citations], }, f) |
