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
74fceb6c
Commit
74fceb6c
authored
5 years ago
by
Davit Gogshelidze
Committed by
Xiao Gui
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
add spatial search filter (remove cache spatial search)
parent
d058dfff
No related branches found
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
+30
-8
30 additions, 8 deletions
deploy/datasets/query.js
with
30 additions
and
8 deletions
deploy/datasets/query.js
+
30
−
8
View file @
74fceb6c
...
...
@@ -196,10 +196,10 @@ exports.getPreview = ({ datasetName }) => getPreviewFile({ datasetName })
* change to real spatial query
*/
const
cachedMap
=
new
Map
()
const
fetchSpatialDataFromKg
=
async
({
templateName
})
=>
{
const
cachedResult
=
cachedMap
.
get
(
templateName
)
if
(
cachedResult
)
return
cachedResult
const
fetchSpatialDataFromKg
=
async
({
templateName
,
queryArg
})
=>
{
//
const cachedResult = cachedMap.get(templateName)
//
if (cachedResult)
//
return cachedResult
try
{
const
filename
=
path
.
join
(
STORAGE_PATH
,
templateName
+
'
.json
'
)
...
...
@@ -210,8 +210,14 @@ const fetchSpatialDataFromKg = async ({ templateName }) => {
const
data
=
fs
.
readFileSync
(
filename
,
'
utf-8
'
)
const
json
=
JSON
.
parse
(
data
)
cachedMap
.
set
(
templateName
,
json
)
return
json
var
splitQueryArg
=
queryArg
.
split
(
'
__
'
);
const
cubeDots
=
[]
splitQueryArg
.
forEach
(
element
=>
{
cubeDots
.
push
(
element
.
split
(
'
_
'
))
});
// cachedMap.set(templateName, json.filter(filterByqueryArg(cubeDots)))
return
json
.
filter
(
filterByqueryArg
(
cubeDots
))
}
catch
(
e
)
{
console
.
log
(
'
datasets#query.js#fetchSpatialDataFromKg
'
,
'
read file and parse json failed
'
,
e
)
return
[]
...
...
@@ -219,5 +225,21 @@ const fetchSpatialDataFromKg = async ({ templateName }) => {
}
exports
.
getSpatialDatasets
=
async
({
templateName
,
queryGeometry
,
queryArg
})
=>
{
return
await
fetchSpatialDataFromKg
({
templateName
})
}
\ No newline at end of file
return
await
fetchSpatialDataFromKg
({
templateName
,
queryArg
})
}
function
filterByqueryArg
(
cubeDots
)
{
return
function
(
item
)
{
const
px
=
item
.
geometry
.
position
[
0
]
const
py
=
item
.
geometry
.
position
[
1
]
const
pz
=
item
.
geometry
.
position
[
2
]
if
(
cubeDots
[
0
][
0
]
<=
px
&&
px
<=
cubeDots
[
1
][
0
]
&&
cubeDots
[
0
][
1
]
<=
py
&&
py
<=
cubeDots
[
1
][
1
]
&&
cubeDots
[
0
][
2
]
<=
pz
&&
pz
<=
cubeDots
[
1
][
2
])
{
return
true
;
}
}
return
false
;
}
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