nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit ebb0e4fd39203ace9e8cfb48929892f0758f79bd
parent 52aebab08b324462220bdfef5ab4ed9545807d82
Author: Sergey Orlov <wladimirych@gmail.com>
Date:   Sun, 14 Nov 2021 21:45:37 +0100

wikimedia photos: update results filter according to coverage layer

Additionally filter out
- images with non-earth coordinates
- images with both coordinates having less then 2 digits
  after decimal point (remove NASA photos)
- images with either coordinate equal to 0
- images with equal lat and lon
- images whose filename contains "View of Earth" (remove NASA photos)

Diffstat:
Msrc/lib/leaflet.control.panoramas/lib/wikimedia/index.js | 22+++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/src/lib/leaflet.control.panoramas/lib/wikimedia/index.js b/src/lib/leaflet.control.panoramas/lib/wikimedia/index.js @@ -13,11 +13,27 @@ function getCoverageLayer(options) { ]); } +function isCoordLikeArtificial(x) { + // check if number has less then 2 non-zero digits after decimal point + return Number.isInteger(x * 10); +} + function parseSearchResponse(resp) { // eslint-disable-line complexity const images = []; if (resp && resp.query && resp.query.pages && resp.query.pages) { for (let page of Object.values(resp.query.pages)) { - if (!page.coordinates || page.title.slice(-4).toLowerCase() !== '.jpg') { + const coordinates = page.coordinates?.[0]; + const [baseName, extension] = (page.title ?? '').split('.', 2); + if ( + !coordinates || + coordinates.globe !== 'earth' || + (isCoordLikeArtificial(coordinates.lat) && isCoordLikeArtificial(coordinates.lon)) || + coordinates.lat === 0 || + coordinates.lon === 0 || + coordinates.lat === coordinates.lon || + (baseName ?? '').includes('View of Earth') || + (extension ?? '').toLowerCase() !== 'jpg' + ) { continue; } @@ -73,8 +89,8 @@ function parseSearchResponse(resp) { // eslint-disable-line complexity url, width: iinfo.width, height: iinfo.height, - lat: page.coordinates[0].lat, - lng: page.coordinates[0].lon, + lat: coordinates.lat, + lng: coordinates.lon, author: author, timeOriginal: iinfo.extmetadata.DateTimeOriginal ? iinfo.extmetadata.DateTimeOriginal.value : null, time: iinfo.extmetadata.DateTime ? iinfo.extmetadata.DateTime.value : null,