Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

take external images into gallery #306

Open
ralfhauser opened this issue Oct 30, 2019 · 6 comments
Open

take external images into gallery #306

ralfhauser opened this issue Oct 30, 2019 · 6 comments

Comments

@ralfhauser
Copy link
Member

include external images (e.g. from Basel)
water-fountains/import2wikidata#12 (comment)

(although those from google user-content apparently do not have a stable URL)

@ralfhauser
Copy link
Member Author

  1. Flickr might be an other candidate (via creativeCommon-search)

@ralfhauser
Copy link
Member Author

ralfhauser commented Nov 10, 2019

@ralfhauser
Copy link
Member Author

ralfhauser commented Dec 2, 2019

or https://www.flickr.com/photos/76225195@N07/14072865167 for https://www.openstreetmap.org/node/259576441 i.e. https://h2o.do/Q76941085

To have less menu around, rather use

https://www.flickr.com/photos/76225195@N07/14072865167/lightbox/

The real images then are then
https://live.staticflickr.com/5555/14072865167_a3aa00c693.jpg
and with lower resolution:
https://live.staticflickr.com/5555/14072865167_a3aa00c693_n.jpg

seems that .+_n.jpg = "normal"
_m.jpg = "medium"
_s.jpg = "small" ==> squared thumbnail
_t = thumbnail
_b.jpg = "big"
_o = orig
s < m < n < b see https://www.flickr.com/services/api/flickr.photos.getSizes.html

TODO: how do we lookup the jpg ?
https://www.flickr.com/services/api/ is overwhelming but probably has it

@ralfhauser
Copy link
Member Author

see also #138

@EuropeanWaterProject
Copy link

EuropeanWaterProject commented Feb 24, 2020

I found with the flickr API searching around with a radius of 5 meters. The process to add available photo links to OSM may be manual and tedious, but might be achievable on a limited scale ...

https://www.openstreetmap.org/node/4401114206#map=14/59.3219/18.0809  

https://www.flickr.com/photos/53866652@N08/48776688947

https://www.flickr.com/services/rest/?method=flickr.photos.search&api_key=<api_ID>&has_geo=&lat=59.3249769&lon=18.0708824&radius=.005&per_page=1000&format=json&nojsoncallback=1

@EuropeanWaterProject
Copy link

EuropeanWaterProject commented Mar 1, 2020

Hi Ralf,
Here is a snippet .. that you might use. Although when I spot checked many of the flickr images in OSM, the license level was not 4 and above. Not sure we will use flickr images.

BR,s

Stuart

function getUrlJson(url) {
 //  console.log(url); //for debugging
    return new Promise(function (resolve, reject) {
        // run api query
        axios_1.default.get(url)
            .then(function (res) {
            if (res.status !== 200) {
                var error = new Error("Request to flickr Failed. Status Code: " + res.status + ". Data: " + res + ". Url: " + url);
                return reject(error);
            }
            else {
                resolve(res.data);
            }
        }).catch(function (error) {console.log(error);});
    });
}

//get flickr small url from different url tags. Put blanks in flickrUrl3
flickrUrl1 = "https://farm9.staticflickr.com/8059/8176155093_830e0e02eb_m.jpg";
flickrUrl2 = "https://www.flickr.com/photos/151135260@N07/36780940861";
flickrUrl3 = "https://www.flickr.com/photos/134902422@N04/map?&fLat=41.9559&fLon=19.4337&zl=11&order_by=recent";
flickrUrl4 ="https://www.flickr.com/photos/150827403@N06/albums/72157683048121684",

apikey = "api - key";
function getFlickrJson (flickr)
{
    newFlickrJson =
    {
        "author" : "",
        "url" : ""
    }
    //case 1 album
    if (flickr.search('albums') != -1)
        {   flickrArray = flickr.split('/');
            var userId = flickrArray[4];
            var albumId = flickrArray[6];
            flickrGetAlbumUrl =  "https://www.flickr.com/services/rest/?method=flickr.photosets.getPhotos&api_key=" + apikey + "&photoset_id="+ albumId + "&user_id="+ userId  + "&format=json&nojsoncallback=1";
            return new Promise(function (resolve, reject) {
            getUrlJson(flickrGetAlbumUrl).then(data =>{
                //console.log(data.photoset.owner);
                newFlickrJson.url = "https://farm"+data.photoset.photo[0].farm+".staticflickr.com/"+data.photoset.photo[0].server+"/"+data.photoset.photo[0].id+"_"+data.photoset.photo[0].secret+"_m.jpg";
                newFlickrJson.author = data.photoset.owner;
                resolve (newFlickrJson);
            }).catch(function (error) {console.log(error);})
            }  
        )} else
        if (flickr.search('farm') != -1)
        {      
            flickrArray = flickr.split('_')[0].split('/');
            var userId = flickrArray[4];
            var photoId = flickrArray[4];
            flickrPhotoInfoUrl =  "https://www.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=" + apikey + "&photo_id=" + photoId + "&format=json&nojsoncallback=1";
       //     console.log("b flickrArray" + flickrArray);
            return new Promise(function (resolve, reject) {
                getUrlJson(flickrPhotoInfoUrl).then(data =>{
                  //  console.log(data);
                 newFlickrJson.url =  "https://farm"+data.photo.farm+".staticflickr.com/"+data.photo.server+"/"+data.photo.id+"_"+data.photo.secret+"_m.jpg";
                 newFlickrJson.author = data.photo.owner.nsid;
                    resolve (newFlickrJson);
                }).catch(function (error) {console.log(error);})  
        } )}
        
        else if (flickr.search('photos') != -1)
        {      
            flickrArray = flickr.split('/');
            var userId = flickrArray[4];
            var photoId = flickrArray[5];
            if (isNaN(photoId))
            {
                return new Promise(function (resolve, reject) {
                    {
                        //console.log(data.photoset.photo[0]);
                        resolve (newFlickrJson);
                    }
                        })
            }
           flickrPhotoInfoUrl =  "https://www.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key=" + apikey + "&photo_id=" + photoId + "&format=json&nojsoncallback=1";
           return new Promise(function (resolve, reject) {
            getUrlJson(flickrPhotoInfoUrl).then(data =>{
             newFlickrJson.url =  "https://farm"+data.photo.farm+".staticflickr.com/"+data.photo.server+"/"+data.photo.id+"_"+data.photo.secret+"_m.jpg";    
             newFlickrJson.author = data.photo.owner.nsid;
             resolve (newFlickrJson);
            }).catch(function (error) {console.log(error);})
            }  
        )}
}

//example call to function to test. 
getFlickrJson(flickrUrl2).then(data =>{
    console.log(data);
}
    )
module.exports.getFlickrJson  = getFlickrJson ;

ralfhauser pushed a commit to water-fountains/datablue that referenced this issue Apr 6, 2020
make category from osm more robust
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants