/species/suggest - higherClassificationMap question
Hi API gurus,
I assume, the search box functionality in the species page of gbif homepage (e.g.: https://www.gbif.org/species/5298708) is based on "suggest". There each result contains the scientific name and the full taxonomic hierarchy e.g. "Iris pumila subsp. attica (Boiss. & Heldr.) K.Richt. Subspecies | Plantae > Tracheophyta > Liliopsida > Asparagales
Iridaceae > Iris > Iris pumila".
My question: how is the hierarchy implemented? Is it based on "higherClassificationMap"? How?
When I play with the suggest api, the XMLHttpRequest responseText in raw text format contains the taxonomic hierarchy correctly (i.e. the physical order of the entries in "higherClassificationMap" is correct). Unfortunately after JSON.parse the resulting javascript object does not hold any information about the physical order of the key/value pairs.
Is there any smart way to overcome this, or shall I hardcode the hierarchy manually?
Thanks in advance.
József Szlamka
Hi József
I am no guru or web developer but looking at the code [1] I think it is pulling out distinct the ranks in order from the suggest response [2]. I see the code has this:
<span ng-repeat="taxa in ['kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species']" ng-if="match.model[taxa] && taxa != match.model.rank.toLowerCase()"> {{match.model[taxa]}} </span>
Someone may correct me if I’m wrong, but since it’s the weekend here now it may be some time – I hope this helps for starters…
Thanks, Tim
[1] https://github.com/gbif/portal16/blob/80aa008dcd9442c47e6d9ee5894f4e19de4000... [2] https://api.gbif.org/v1/species/suggest?datasetKey=d7dddbf4-2cf0-4f39-9b2a-b...
From: API-users api-users-bounces@lists.gbif.org on behalf of Szlamka József szlajozs@gmail.com Date: Friday, 11 March 2022 at 18.44 To: api-users@lists.gbif.org api-users@lists.gbif.org Subject: [API-users] /species/suggest - higherClassificationMap question Hi API gurus,
I assume, the search box functionality in the species page of gbif homepage (e.g.: https://www.gbif.org/species/5298708) is based on "suggest". There each result contains the scientific name and the full taxonomic hierarchy e.g. "Iris pumila subsp. attica (Boiss. & Heldr.) K.Richt. Subspecies | Plantae > Tracheophyta > Liliopsida > Asparagales > Iridaceae > Iris > Iris pumila".
My question: how is the hierarchy implemented? Is it based on "higherClassificationMap"? How?
When I play with the suggest api, the XMLHttpRequest responseText in raw text format contains the taxonomic hierarchy correctly (i.e. the physical order of the entries in "higherClassificationMap" is correct). Unfortunately after JSON.parse the resulting javascript object does not hold any information about the physical order of the key/value pairs.
Is there any smart way to overcome this, or shall I hardcode the hierarchy manually?
Thanks in advance.
József Szlamka
Hi Tim,
Many thanks for your answer. I didn't know that the portal code was available at Github. Though I don't speak Angular, I could understand the logic and created a similar solution in pure js. With your guidance my problem is solved now.
Thanks again and have a nice weekend, József
----------------------------------------------------------------------- 2022. 03. 11. 19:33 keltezéssel, Tim Robertson írta:
Hi József
I am no guru or web developer but looking at the code [1] I /think/ it is pulling out distinct the ranks in order from the suggest response [2]. I see the code has this:
<span ng-repeat="taxa in ['kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species']"
ng-if="match.model[taxa] && taxa != match.model.rank.toLowerCase()">
{{match.model[taxa]}}
</span>
Someone may correct me if I’m wrong, but since it’s the weekend here now it may be some time – I hope this helps for starters…
Thanks,
Tim
[1] https://github.com/gbif/portal16/blob/80aa008dcd9442c47e6d9ee5894f4e19de4000...
[2] https://api.gbif.org/v1/species/suggest?datasetKey=d7dddbf4-2cf0-4f39-9b2a-b... https://api.gbif.org/v1/species/suggest?datasetKey=d7dddbf4-2cf0-4f39-9b2a-bb099caae36c&limit=10&q=Iris%20pumila
participants (2)
-
Szlamka József
-
Tim Robertson