Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this fixes (papers over) issue #547. #608

Merged
merged 2 commits into from
Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/components/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { MAP_ANIMATION_PLAY_PAUSE_BUTTON } from "../../actions/types";
// import { incommingMapPNG } from "../download/helperFunctions";
import { timerStart, timerEnd } from "../../util/perf";
import { lightGrey, goColor, pauseColor } from "../../globalStyles";
import { errorNotification } from "../../actions/notifications";

/* global L */
// L is global in scope and placed by leaflet()
Expand Down Expand Up @@ -181,7 +182,8 @@ class Map extends React.Component {
demeData,
transmissionData,
demeIndices,
transmissionIndices
transmissionIndices,
demesMissingLatLongs
} = createDemeAndTransmissionData(
this.props.nodes,
this.props.visibility,
Expand All @@ -191,6 +193,12 @@ class Map extends React.Component {
this.props.metadata,
this.state.map
);
if (demesMissingLatLongs.size) {
this.props.dispatch(errorNotification({
message: "The following demes are missing lat/long information",
details: [...demesMissingLatLongs].join(", ")
}));
}

// const latLongs = this.latLongs(demeData, transmissionData); /* no reference stored, we recompute this for now rather than updating in place */
const d3elems = drawDemesAndTransmissions(
Expand Down
34 changes: 21 additions & 13 deletions src/components/map/mapHelpersLatLong.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,26 @@ const maybeConstructTransmissionEvent = (
visibility,
map,
offsetOrig,
offsetDest
offsetDest,
demesMissingLatLongs
) => {

let latOrig, longOrig, latDest, longDest;
let transmission;

/* checking metadata for lat longs name match - ie., does the metadata list a latlong for Thailand? */
try {
// node.attr[geoResolution] is the node's location, we're looking that up in the metadata lookup table
latOrig = metadataGeoLookupTable[geoResolution][node.attr[geoResolution]].latitude;
longOrig = metadataGeoLookupTable[geoResolution][node.attr[geoResolution]].longitude;
} catch (e) {
// console.warn("No transmission lat/longs for ", node.attr[geoResolution], " -> ",child.attr[geoResolution], "If this wasn't fired in the context of a dataset change, it's probably a bug.")
demesMissingLatLongs.add(node.attr[geoResolution]);
}
try {
// node.attr[geoResolution] is the node's location, we're looking that up in the metadata lookup table
latDest = metadataGeoLookupTable[geoResolution][child.attr[geoResolution]].latitude;
longDest = metadataGeoLookupTable[geoResolution][child.attr[geoResolution]].longitude;
} catch (e) {
// console.warn("No transmission lat/longs for ", countries[0], " -> ", countries[1], "If this wasn't fired in the context of a dataset change, it's probably a bug.")
console.warn("No transmission lat/longs for ", node.attr[geoResolution], " -> ", child.attr[geoResolution], "If this wasn't fired in the context of a dataset change, it's probably a bug.");
return undefined;
}

Expand Down Expand Up @@ -211,10 +216,10 @@ const maybeGetClosestTransmissionEvent = (
nodeColors,
visibility,
map,
offsetOrig
offsetOrig,
demesMissingLatLongs
) => {
const possibleEvents = [];

// iterate over offsets applied to transmission destination
// even if map is not tripled - ie., don't let a line go across the whole world
[-360, 0, 360].forEach((offsetDest) => {
Expand All @@ -227,7 +232,8 @@ const maybeGetClosestTransmissionEvent = (
visibility,
map,
offsetOrig,
offsetDest
offsetDest,
demesMissingLatLongs
);
if (t) { possibleEvents.push(t); }
});
Expand Down Expand Up @@ -259,7 +265,7 @@ const setupTransmissionData = (
const metadataGeoLookupTable = metadata.geo;
const transmissionData = []; /* edges, animation paths */
const transmissionIndices = {}; /* map of transmission id to array of indices */

const demesMissingLatLongs = new Set();
nodes.forEach((n) => {
if (n.children) {
n.children.forEach((child) => {
Expand All @@ -278,7 +284,8 @@ const setupTransmissionData = (
nodeColors,
visibility,
map,
offsetOrig
offsetOrig,
demesMissingLatLongs
);
if (t) { transmissionData.push(t); }
});
Expand All @@ -296,7 +303,8 @@ const setupTransmissionData = (
});
return {
transmissionData: transmissionData,
transmissionIndices: transmissionIndices
transmissionIndices: transmissionIndices,
demesMissingLatLongs
};
};

Expand Down Expand Up @@ -324,7 +332,7 @@ export const createDemeAndTransmissionData = (
} = setupDemeData(nodes, visibility, geoResolution, nodeColors, triplicate, metadata, map);

/* second time so that we can get Bezier */
const { transmissionData, transmissionIndices } = setupTransmissionData(
const { transmissionData, transmissionIndices, demesMissingLatLongs } = setupTransmissionData(
nodes,
visibility,
geoResolution,
Expand All @@ -338,7 +346,8 @@ export const createDemeAndTransmissionData = (
demeData: demeData,
transmissionData: transmissionData,
demeIndices: demeIndices,
transmissionIndices: transmissionIndices
transmissionIndices: transmissionIndices,
demesMissingLatLongs
};
};

Expand Down Expand Up @@ -381,7 +390,6 @@ const updateDemeDataColAndVis = (demeData, demeIndices, nodes, visibility, geoRe
};

const updateTransmissionDataColAndVis = (transmissionData, transmissionIndices, nodes, visibility, geoResolution, nodeColors) => {

const transmissionDataCopy = transmissionData.slice(); /* basically, instead of _.map() since we're not mapping over the data we're mutating */
nodes.forEach((node) => {
if (node.children) {
Expand Down