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

Far nodes with OTT are chosen for URL over near nodes without OTT #907

Open
davidebbo opened this issue Nov 18, 2024 · 4 comments
Open

Far nodes with OTT are chosen for URL over near nodes without OTT #907

davidebbo opened this issue Nov 18, 2024 · 4 comments
Labels

Comments

@davidebbo
Copy link
Collaborator

Normally, zooming in on a node or searching for it results in the URL changing to that node (e.g. @Panthera_leo=563151), allowing it to be shared. This does not happen when there is no OTT.

@lentinj
Copy link
Collaborator

lentinj commented Nov 18, 2024

There's 2 related problems to this:

Firstly, there's the problem of deciding what you're looking at. The current algorithm isn't great, and could do with replacing (#547). We fudge around this by selecting any with an OTT, assuming you're more likely to be looking at a node with an OTT.

Secondly, we'd need to decide how to represent them in the URL. Presumably there is no latin name or OTT in your case, and this falls through, because we can't make a URL for it:

export function node_to_pinpoint(node) {
if (!node.ott && !node.latin_name) return null;
return [
"@",
node.latin_name ? tidy_latin(node.latin_name) : '',
node.ott ? "=" + node.ott : "",
].join("")
}

It could generate an OZid / metacode URL instead (the primary key in the leaf/node table), but these aren't going to be permanent anyway. Do we have anything to use in the URL?

The current pinpoint forms we support are documented here, if that's useful:

/**
* Convert a pinpoint (or list of pinpoints) into a list of leaf/node OZids
*
* A pinpoint is a string representing a location on the tree, most obviously used in URLs, it can be of the form:
* ``12345``: Where 12345 is an OTT
* ``@name``: Where name is a latin name
* ``@name=12345``: Where name is a latin name, 12345 an OTT
* ``@=12345``: Where 12345 is an OTT
* ``@_ancestor=1234=6789``: Where 1234, 6789 are OTTs
* ``@_ozid=123456``: Where 123456 is an OZid / metacode
* If required, API lookups will be made to fill in an gaps in local knowledge.
*
* Extra metadata can be requested by setting items in the (extra_metadata) object:
* * ``sciname``: Anything truthy will add a ``sciname`` field to the pinpoint objects.
* * ``vn``: Add a ``vn`` field to the pinpoint object output. See ``controllers/API/pinpoints`` for possible values.
*
* @param pinpoint_or_pinpoints A pinpoint string or list of pinpoint strings
* @return {Promise} Resolves to a pinpoint dict or list of pinpoint dicts, depending on what was handed in
*/

@davidebbo
Copy link
Collaborator Author

Presumably there is no latin name or OTT in your case

There is no OTT, but there is definitely a latin name (taxon name). Doing some quick debugging, I never see node_to_pinpoint getting called for the node at stake. It always gets called for a neighbor node.

If it worked with a taxon name and no OTT, we wouldn't have a problem at all, since they all have that (at least in the extinct tree).

@lentinj
Copy link
Collaborator

lentinj commented Nov 18, 2024

Ah, in that case I'm pretty sure the problem is here:

// Choose one with an OTT by preference
let node = controller.largest_visible_node((node) => !!node.ott) || controller.largest_visible_node();
// NB: Still possible to find nothing, e.g. with a manually tampered URL that positions xp/wp/ws at an empty point in the tree
if (!node) return {};

We really need a replacement for largest_visible_node with more DWIM, but a half-way house might be to impose a penalty on node/leaves without an OTT, rather than considering any node first.

@davidebbo
Copy link
Collaborator Author

Ah, I see, thanks for tracking it down!

I think we need to carefully evaluate all the options in OneZoom/tree-build#103 before investing too much time in fixing all the various issues when there are no OTTs. If we go with an alternative approach, it becomes a much lower pri issue.

@lentinj lentinj changed the title Nodes without OTT can't have permalinks Far nodes with OTT are chosen for URL over near nodes without OTT Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants