Skip to content
Snippets Groups Projects
Unverified Commit 8a1913e7 authored by xgui3783's avatar xgui3783 Committed by GitHub
Browse files

Merge pull request #331 from HumanBrainProject/bugfix/uriComponent

bugfix: more robust spatial query ev stream
parents d4a074fd 0bcdccb0
No related branches found
No related tags found
No related merge requests found
......@@ -115,12 +115,12 @@ export class DatabrowserService implements OnDestroy{
select('navigation'),
distinctUntilChanged(),
debounceTime(SPATIAL_SEARCH_DEBOUNCE),
filter(v => !!v),
map(navigation => {
filter(v => !!v && !!v.position && !!v.zoom),
map(({ position, zoom }) => {
// in mm
const center = navigation.position.map(n=>n/1e6)
const searchWidth = this.constantService.spatialWidth / 4 * navigation.zoom / 1e6
const center = position.map(n=>n/1e6)
const searchWidth = this.constantService.spatialWidth / 4 * zoom / 1e6
const pt1 = center.map(v => (v - searchWidth)) as [number, number, number]
const pt2 = center.map(v => (v + searchWidth)) as [number, number, number]
......@@ -142,10 +142,11 @@ export class DatabrowserService implements OnDestroy{
* templateSelected and templateSelected.name must be defined for spatial search
*/
if (!templateSelected || !templateSelected.name) return from(Promise.reject('templateSelected must not be empty'))
const encodedTemplateName = encodeURI(templateSelected.name)
return from(fetch(`${this.constantService.backendUrl}datasets/spatialSearch/templateName/${encodedTemplateName}/bbox/${_bbox[0].join('_')}__${_bbox[1].join("_")}`).then(res => res.json()))
const encodedTemplateName = encodeURIComponent(templateSelected.name)
return this.http.get(`${this.constantService.backendUrl}datasets/spatialSearch/templateName/${encodedTemplateName}/bbox/${_bbox[0].join('_')}__${_bbox[1].join("_")}`).pipe(
catchError((err) => (console.log(err), of([])))
)
}),
catchError((err) => (console.log(err), of([])))
)
this.fetchDataObservable$ = combineLatest(
......@@ -227,7 +228,7 @@ export class DatabrowserService implements OnDestroy{
}
public fetchPreviewData(datasetName: string){
const encodedDatasetName = encodeURI(datasetName)
const encodedDatasetName = encodeURIComponent(datasetName)
return new Promise((resolve, reject) => {
fetch(`${this.constantService.backendUrl}datasets/preview/${encodedDatasetName}`)
.then(res => res.json())
......@@ -249,8 +250,8 @@ export class DatabrowserService implements OnDestroy{
private mostRecentFetchToken: any
private lowLevelQuery(templateName: string, parcellationName: string){
const encodedTemplateName = encodeURI(templateName)
const encodedParcellationName = encodeURI(parcellationName)
const encodedTemplateName = encodeURIComponent(templateName)
const encodedParcellationName = encodeURIComponent(parcellationName)
return Promise.all([
fetch(`${this.constantService.backendUrl}datasets/templateName/${encodedTemplateName}`)
.then(res => res.json()),
......
......@@ -51,10 +51,6 @@ export class DataBrowser implements OnChanges, OnDestroy,OnInit{
public favDataentries$: Observable<DataEntry[]>
get darktheme(){
return this.dbService.darktheme
}
/**
* TODO
* viewport
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment