diff --git a/docs/releases/v2.11.3.md b/docs/releases/v2.11.3.md index 1070a19f20c6584b287244c0328a322a5b9aae07..834f0c7dd7677e5066e85cd999927a59c1aa3d20 100644 --- a/docs/releases/v2.11.3.md +++ b/docs/releases/v2.11.3.md @@ -2,4 +2,8 @@ ## Bugfixes -- Fixed point assignment for maps that do not have statistical maps. Also fixed error messages. \ No newline at end of file +- Fixed point assignment for maps that do not have statistical maps. Also fixed error messages. + +## Behind the scenes + +- Using hashed region name to encode selected region, rather than the archaic ngId & label index diff --git a/src/routerModule/routeStateTransform.service.ts b/src/routerModule/routeStateTransform.service.ts index 1032448ec67ea1c9bf80d3f18f82f901bf7c6057..b01ac54beb7085b01ea548ac2de69b4d0a103fff 100644 --- a/src/routerModule/routeStateTransform.service.ts +++ b/src/routerModule/routeStateTransform.service.ts @@ -9,6 +9,7 @@ import { getParcNgId } from "src/viewerModule/nehuba/config.service"; import { decodeToNumber, encodeNumber, encodeURIFull, separator } from "./cipher"; import { TUrlAtlas, TUrlPathObj, TUrlStandaloneVolume } from "./type"; import { decodePath, encodeId, decodeId, encodePath } from "./util"; +import { QuickHash } from "src/util/fn"; @Injectable() export class RouteStateTransformSvc { @@ -26,6 +27,7 @@ export class RouteStateTransformSvc { const selectedTemplateId = decodeId( RouteStateTransformSvc.GetOneAndOnlyOne(obj.t) ) const selectedParcellationId = decodeId( RouteStateTransformSvc.GetOneAndOnlyOne(obj.p) ) const selectedRegionIds = obj.r + const selectedRegionNames = obj.rn if (!selectedAtlasId || !selectedTemplateId || !selectedParcellationId) { return {} @@ -60,7 +62,11 @@ export class RouteStateTransformSvc { const userViewer = await this.sapi.useViewer(selectedTemplate).toPromise() const selectedRegions = await (async () => { - if (!selectedRegionIds) return [] + if (!selectedRegionIds && !selectedRegionNames) return [] + + if (selectedRegionNames && selectedRegionNames.length > 0) { + return allParcellationRegions.filter(region => selectedRegionNames.includes(QuickHash.GetHash(region.name))) + } /** * should account for @@ -268,16 +274,7 @@ export class RouteStateTransformSvc { } } - // encoding selected regions - let selectedRegionsString: string - if (selectedRegions.length === 1) { - const region = selectedRegions[0] - const labelIndex = await this.sapi.getRegionLabelIndices(selectedTemplate, selectedParcellation, region) - - const ngId = getParcNgId(selectedAtlas, selectedTemplate, selectedParcellation, region) - selectedRegionsString = `${ngId}::${encodeNumber(labelIndex, { float: false })}` - } - let routes: TUrlPathObj<string, TUrlAtlas<string>> | TUrlPathObj<string, TUrlStandaloneVolume<string>> + let routes: TUrlPathObj<string|string[], TUrlAtlas<string|string[]>> | TUrlPathObj<string, TUrlStandaloneVolume<string>> routes = { // for atlas @@ -287,7 +284,8 @@ export class RouteStateTransformSvc { // for parcellation p: selectedParcellation && encodeId(selectedParcellation.id), // for regions - r: selectedRegionsString && encodeURIFull(selectedRegionsString), + // r: selectedRegionsString && encodeURIFull(selectedRegionsString), + rn: selectedRegions[0] && selectedRegions.map(r => QuickHash.GetHash(r.name)), // nav ['@']: cNavString, // showing dataset diff --git a/src/routerModule/type.ts b/src/routerModule/type.ts index 13205ad3e09e0969a8c419a5d9803b2883bc2de3..284b5e7a9441fd52be9281ad3dec5c749e390993 100644 --- a/src/routerModule/type.ts +++ b/src/routerModule/type.ts @@ -7,6 +7,7 @@ export type TUrlAtlas<T> = { t: T // template p: T // parcellation r?: T // region selected + rn?: T } export type TUrlPlugin<T> = { diff --git a/src/util/fn.ts b/src/util/fn.ts index 9c1d188f7aea4e807406b45dfb82491f23d9543b..6457ccf78a80061da34734ae0c3b2e20b0ffe238 100644 --- a/src/util/fn.ts +++ b/src/util/fn.ts @@ -134,7 +134,7 @@ export const CachedFunction = (config?: TCacheFunctionArg) => { } } -// A quick, non security hash function +// A quick, non secure hash function export class QuickHash { private length = 6 constructor(opts?: any){