Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
siibra-explorer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiao Gui
siibra-explorer
Commits
d2a6ab56
Commit
d2a6ab56
authored
5 years ago
by
Daviti Gogshelidze
Browse files
Options
Downloads
Patches
Plain Diff
spatial search corrections
parent
c185a397
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
deploy/datasets/query.js
+18
-27
18 additions, 27 deletions
deploy/datasets/query.js
with
18 additions
and
27 deletions
deploy/datasets/query.js
+
18
−
27
View file @
d2a6ab56
...
@@ -17,7 +17,7 @@ let getPublicAccessToken
...
@@ -17,7 +17,7 @@ let getPublicAccessToken
const
fetchDatasetFromKg
=
async
(
arg
)
=>
{
const
fetchDatasetFromKg
=
async
(
arg
)
=>
{
const
userState
=
getUser
Token
(
arg
)
const
userState
=
await
getUser
KGRequestInfo
(
arg
)
return
await
new
Promise
((
resolve
,
reject
)
=>
{
return
await
new
Promise
((
resolve
,
reject
)
=>
{
request
(
`
${
queryUrl
}${
userState
.
releasedOnly
?
'
&databaseScope=RELEASED
'
:
''
}
`
,
userState
.
option
,
(
err
,
resp
,
body
)
=>
{
request
(
`
${
queryUrl
}${
userState
.
releasedOnly
?
'
&databaseScope=RELEASED
'
:
''
}
`
,
userState
.
option
,
(
err
,
resp
,
body
)
=>
{
...
@@ -187,8 +187,7 @@ exports.getPreview = ({ datasetName, templateSelected }) => getPreviewFile({ dat
...
@@ -187,8 +187,7 @@ exports.getPreview = ({ datasetName, templateSelected }) => getPreviewFile({ dat
const
cachedMap
=
new
Map
()
const
cachedMap
=
new
Map
()
const
fetchSpatialDataFromKg
=
async
({
templateName
,
queryArg
,
req
})
=>
{
const
fetchSpatialDataFromKg
=
async
({
templateName
,
queryArg
,
req
})
=>
{
try
{
try
{
// const filename = path.join(STORAGE_PATH, templateName + '.json')
const
filename
=
path
.
join
(
STORAGE_PATH
,
templateName
+
'
.json
'
)
const
filename
=
path
.
join
(
__dirname
+
'
/data/waxholm-hbp-00937-transformed.json
'
)
const
exists
=
fs
.
existsSync
(
filename
)
const
exists
=
fs
.
existsSync
(
filename
)
if
(
!
exists
)
if
(
!
exists
)
...
@@ -207,26 +206,20 @@ const fetchSpatialDataFromKg = async ({ templateName, queryArg, req }) => {
...
@@ -207,26 +206,20 @@ const fetchSpatialDataFromKg = async ({ templateName, queryArg, req }) => {
if
(
templateName
!==
'
Waxholm Space rat brain atlas v.2.0
'
)
{
if
(
templateName
!==
'
Waxholm Space rat brain atlas v.2.0
'
)
{
return
json
.
filter
(
filterByqueryArg
(
cubeDots
))
return
json
.
filter
(
filterByqueryArg
(
cubeDots
))
}
else
{
}
else
{
if
(
user
&&
user
.
req
)
{
const
centerDifference
=
[
-
9.550781
,
-
24.355468
,
-
9.707031
]
const
centerDifference
=
[
-
9.550781
,
-
24.355468
,
-
9.707031
]
let
calculatedCubeDots
=
[]
let
calculatedCubeDots
=
[]
cubeDots
.
forEach
((
dots
,
index
)
=>
{
cubeDots
.
forEach
((
dots
,
index
)
=>
{
calculatedCubeDots
[
index
]
=
cubeDots
[
index
].
map
((
num
,
idx
)
=>
{
calculatedCubeDots
[
index
]
=
cubeDots
[
index
].
map
((
num
,
idx
)
=>
{
return
+
num
-
centerDifference
[
idx
]
return
+
num
-
centerDifference
[
idx
]
})
})
})
})
calculatedCubeDots
=
calculatedCubeDots
.
map
(
x
=>
transformToWoxel
(
x
))
calculatedCubeDots
=
calculatedCubeDots
.
map
(
x
=>
transformToWoxel
(
x
))
const
resultFromKG
=
await
getSpatialSearchOk
({
calculatedCubeDots
,
req
})
const
resultFromKG
=
await
getSpatialSearchOk
({
calculatedCubeDots
,
req
})
if
(
resultFromKG
&&
resultFromKG
[
'
total
'
]
&&
resultFromKG
[
'
total
'
]
>
0
)
{
return
json
.
filter
(
filterByqueryArg
(
cubeDots
))
if
(
resultFromKG
&&
resultFromKG
[
'
total
'
]
&&
resultFromKG
[
'
total
'
]
>
0
)
{
}
else
{
return
json
.
filter
(
filterByqueryArg
(
cubeDots
))
return
[]
}
else
{
return
[]
}
}
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
'
datasets#query.js#fetchSpatialDataFromKg
'
,
'
read file and parse json failed
'
,
e
)
console
.
log
(
'
datasets#query.js#fetchSpatialDataFromKg
'
,
'
read file and parse json failed
'
,
e
)
...
@@ -256,14 +249,14 @@ function filterByqueryArg(cubeDots) {
...
@@ -256,14 +249,14 @@ function filterByqueryArg(cubeDots) {
async
function
getSpatialSearchOk
(
arg
)
{
async
function
getSpatialSearchOk
(
arg
)
{
const
userState
=
getUser
Token
(
arg
.
req
)
const
userState
=
await
getUser
KGRequestInfo
(
arg
.
req
)
const
option
=
{
const
option
=
{
headers
:
{
headers
:
{
'
Authorization
'
:
userState
.
token
'
Authorization
'
:
userState
.
token
}
}
}
}
const
spatialQuery
=
'
https://kg.humanbrainproject.org/query/minds/core/dataset/v1.0.0/spatialSimple/instances?size=10
&boundingBox=waxholmV2:180,750,390,200,780,400
'
const
spatialQuery
=
'
https://kg.humanbrainproject.org/query/minds/core/dataset/v1.0.0/spatialSimple/instances?size=10
'
return
await
new
Promise
((
resolve
,
reject
)
=>
{
return
await
new
Promise
((
resolve
,
reject
)
=>
{
request
(
`
${
spatialQuery
}${
'
&boundingBox=waxholmV2:
'
+
arg
.
calculatedCubeDots
[
0
].
concat
(
arg
.
calculatedCubeDots
[
1
])}${
userState
.
releasedOnly
?
'
&databaseScope=RELEASED
'
:
''
}
`
,
option
,
(
err
,
resp
,
body
)
=>
{
request
(
`
${
spatialQuery
}${
'
&boundingBox=waxholmV2:
'
+
arg
.
calculatedCubeDots
[
0
].
concat
(
arg
.
calculatedCubeDots
[
1
])}${
userState
.
releasedOnly
?
'
&databaseScope=RELEASED
'
:
''
}
`
,
option
,
(
err
,
resp
,
body
)
=>
{
...
@@ -277,14 +270,12 @@ async function getSpatialSearchOk(arg) {
...
@@ -277,14 +270,12 @@ async function getSpatialSearchOk(arg) {
})
})
}
}
function
getUser
Token
(
arg
)
{
async
function
getUser
KGRequestInfo
(
arg
)
{
const
accessToken
=
arg
&&
arg
.
user
&&
arg
.
user
.
tokenset
&&
arg
.
user
.
tokenset
.
access_token
const
accessToken
=
arg
&&
arg
.
user
&&
arg
.
user
.
tokenset
&&
arg
.
user
.
tokenset
.
access_token
const
releasedOnly
=
!
accessToken
const
releasedOnly
=
!
accessToken
let
publicAccessToken
let
publicAccessToken
if
(
!
accessToken
&&
getPublicAccessToken
)
{
if
(
!
accessToken
&&
getPublicAccessToken
)
{
// ToDo Here was await but I removed it because of error
publicAccessToken
=
await
getPublicAccessToken
()
// publicAccessToken = await getPublicAccessToken()
publicAccessToken
=
getPublicAccessToken
()
}
}
const
option
=
accessToken
||
publicAccessToken
||
process
.
env
.
ACCESS_TOKEN
const
option
=
accessToken
||
publicAccessToken
||
process
.
env
.
ACCESS_TOKEN
?
{
?
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment