Fix 'nearby images'

This commit is contained in:
Pieter Vander Vennet 2023-01-30 01:19:37 +01:00
parent 9757b5fc35
commit 97bf454d38
5 changed files with 74 additions and 16 deletions

View file

@ -87,27 +87,33 @@ export class NearbyImageVis implements SpecialVisualization {
const nearby = new Lazy(() => {
const towardsCenter = new CheckBox(t.onlyTowards, false)
const radiusValue =
state?.osmConnection?.GetPreference("nearby-images-radius", "300").sync(
const maxSearchRadius = 100
const stepSize = 10
const defaultValue = Math.floor(maxSearchRadius / (2 * stepSize)) * stepSize
const fromOsmPreferences = state?.osmConnection
?.GetPreference("nearby-images-radius", "" + defaultValue)
.sync(
(s) => Number(s),
[],
(i) => "" + i
) ?? new UIEventSource(300)
)
const radiusValue = new UIEventSource(fromOsmPreferences.data)
radiusValue.addCallbackAndRunD((v) => fromOsmPreferences.setData(v))
const radius = new Slider(25, 500, {
const radius = new Slider(stepSize, maxSearchRadius, {
value: radiusValue,
step: 25,
step: 10,
})
const alreadyInTheImage = AllImageProviders.LoadImagesFor(tagSource)
const options: NearbyImageOptions & { value } = {
lon,
lat,
searchRadius: 500,
searchRadius: maxSearchRadius,
shownRadius: radius.GetValue(),
value: selectedImage,
blacklist: alreadyInTheImage,
towardscenter: towardsCenter.GetValue(),
maxDaysOld: 365 * 5,
maxDaysOld: 365 * 3,
}
const slideshow = canBeEdited
? new SelectOneNearbyImage(options, state)

View file

@ -15,7 +15,7 @@ import { SubtleButton } from "../Base/SubtleButton"
import { GeoOperations } from "../../Logic/GeoOperations"
import { ElementStorage } from "../../Logic/ElementStorage"
import Lazy from "../Base/Lazy"
import P4C from "pic4carto"
export interface P4CPicture {
pictureUrl: string
date?: number
@ -175,7 +175,6 @@ export default class NearbyImages extends Lazy {
options: NearbyImageOptions,
state?: { allElements: ElementStorage }
) {
const P4C = require("../../vendor/P4C.min")
const picManager = new P4C.PicturesManager({})
const searchRadius = options.searchRadius ?? 500

59
package-lock.json generated
View file

@ -39,6 +39,7 @@
"osm-auth": "^1.0.2",
"osmtogeojson": "^3.0.0-beta.5",
"papaparse": "^5.3.1",
"pic4carto": "^2.1.15",
"prompt-sync": "^4.2.0",
"showdown": "^2.1.0",
"svg-path-parser": "^1.1.0",
@ -2035,6 +2036,17 @@
"geojson-rewind": "geojson-rewind"
}
},
"node_modules/@mapbox/sphericalmercator": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@mapbox/sphericalmercator/-/sphericalmercator-1.2.0.tgz",
"integrity": "sha512-ZTOuuwGuMOJN+HEmG/68bSEw15HHaMWmQ5gdTsWdWsjDe56K1kGvLOK6bOSC8gWgIvEO0w6un/2Gvv1q5hJSkQ==",
"bin": {
"bbox": "bin/bbox.js",
"to4326": "bin/to4326.js",
"to900913": "bin/to900913.js",
"xyz": "bin/xyz.js"
}
},
"node_modules/@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -6684,6 +6696,11 @@
"xmldom": "^0.1.21"
}
},
"node_modules/kdbush": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/kdbush/-/kdbush-1.0.1.tgz",
"integrity": "sha512-Y75c18KdvLKRmqHc0u2WUYud1vEj54i+8SNBxsowr6LJJsnNUJ8KK8cH7uHDpC5U66NNlieEzVxeWipZaYfN0w=="
},
"node_modules/latlon2country": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/latlon2country/-/latlon2country-1.2.6.tgz",
@ -7573,6 +7590,21 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="
},
"node_modules/pic4carto": {
"version": "2.1.15",
"resolved": "https://registry.npmjs.org/pic4carto/-/pic4carto-2.1.15.tgz",
"integrity": "sha512-A1jvSWeX7siZbmY1wr7rGk6ElWeulaP+WQR3/Rpkqe7rnCKYPErc+jtp7lDOGw4TzMp57wARoA47TVleL/70ZA==",
"dependencies": {
"@mapbox/sphericalmercator": "^1.1.0",
"csv-parse": "^1.2.3",
"kdbush": "^1.0.1"
}
},
"node_modules/pic4carto/node_modules/csv-parse": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-1.3.3.tgz",
"integrity": "sha512-byxnDBxM1AVF3YfmsK7Smop9/usNz7gAZYSo9eYp61TGcNXraJby1rAiLyJSt1/8Iho2qaxZOtZCOvQMXogPtg=="
},
"node_modules/picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
@ -11972,6 +12004,11 @@
"minimist": "^1.2.6"
}
},
"@mapbox/sphericalmercator": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@mapbox/sphericalmercator/-/sphericalmercator-1.2.0.tgz",
"integrity": "sha512-ZTOuuwGuMOJN+HEmG/68bSEw15HHaMWmQ5gdTsWdWsjDe56K1kGvLOK6bOSC8gWgIvEO0w6un/2Gvv1q5hJSkQ=="
},
"@nodelib/fs.scandir": {
"version": "2.1.5",
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
@ -15557,6 +15594,11 @@
"xmldom": "^0.1.21"
}
},
"kdbush": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/kdbush/-/kdbush-1.0.1.tgz",
"integrity": "sha512-Y75c18KdvLKRmqHc0u2WUYud1vEj54i+8SNBxsowr6LJJsnNUJ8KK8cH7uHDpC5U66NNlieEzVxeWipZaYfN0w=="
},
"latlon2country": {
"version": "1.2.6",
"resolved": "https://registry.npmjs.org/latlon2country/-/latlon2country-1.2.6.tgz",
@ -16229,6 +16271,23 @@
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
"integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow=="
},
"pic4carto": {
"version": "2.1.15",
"resolved": "https://registry.npmjs.org/pic4carto/-/pic4carto-2.1.15.tgz",
"integrity": "sha512-A1jvSWeX7siZbmY1wr7rGk6ElWeulaP+WQR3/Rpkqe7rnCKYPErc+jtp7lDOGw4TzMp57wARoA47TVleL/70ZA==",
"requires": {
"@mapbox/sphericalmercator": "^1.1.0",
"csv-parse": "^1.2.3",
"kdbush": "^1.0.1"
},
"dependencies": {
"csv-parse": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/csv-parse/-/csv-parse-1.3.3.tgz",
"integrity": "sha512-byxnDBxM1AVF3YfmsK7Smop9/usNz7gAZYSo9eYp61TGcNXraJby1rAiLyJSt1/8Iho2qaxZOtZCOvQMXogPtg=="
}
}
},
"picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",

View file

@ -94,6 +94,7 @@
"osm-auth": "^1.0.2",
"osmtogeojson": "^3.0.0-beta.5",
"papaparse": "^5.3.1",
"pic4carto": "^2.1.15",
"prompt-sync": "^4.2.0",
"showdown": "^2.1.0",
"svg-path-parser": "^1.1.0",

File diff suppressed because one or more lines are too long