IsraelHikingMap / Site

Israel Hiking Map has maps, route planning, and travel information for Israel. This repository holds the files needed for running the Israel Hiking Map site and apps.
https://israelhiking.osm.org.il/
Other
79 stars 32 forks source link

Posting tracks to Facebook #156

Closed valleyofdawn closed 7 years ago

valleyofdawn commented 8 years ago

An automatic thumbnail of tracks would be nice to have when posting to facebook.

HarelM commented 7 years ago

Here is the algorithm in pseudo code:

  1. Get all the points from all routes to get the bounding box.
  2. Find the zoom level that can contain the above bounding box using 4 tiles horizontal and 4 tiles vertical (less if the route is very short and fits in one zoom 16 tile for example).
  3. Combine the tiles to a single image and draw the routes on that image.
  4. Resize the image to 600x315 and return it to FB crawler.

The above algorithm is symmetric in terms of x and y meaning it doesn't matter if the route is horizontal or vertical it will always (in the happy flow) combine 16 tiles to create the image. It relays on tiles without cropping them (just resize at the end), which make it very stupid and very simple. Adding margin and cropping it in 1:2 ratio might prove hard to write, of course it is possible but the incentive here is very low, I agree that the outcome is not perfect and may not be polished like other features.

valleyofdawn commented 7 years ago

Maybe find a zoom that can contain the track in 4 horizontal by 2 vertical tiles and combine these 8?

HarelM commented 7 years ago

Sound like a good idea, I'll see if I can easily write it, but it won't be 1:1.91 ratio, there will still be resize to do (although minimal in comparison to current resize) and this will not help with your margins issue... If it'll work I'll locally I'll upload it to the server since unfortunately I can't create a test site for this kind of change.

HarelM commented 7 years ago

Turned out to be a relatively easy fix :-) most of the code was general enough to support adding the Y axis as parameter. Your route now looks better (the margins are pure luck), thanks for the advise! image I'm not sure if the FB post image will get updated, probably not... P.S. Sharing using the site on maps that are configured by the user will create an image on those tiles which is a great feature assuming it works (haven't really tested it, but you can see that it works with the MTB tiles). I'm not sure overlays and POI are worth the time... Empty routes (route with no points) will generate an image of the visible area using the closest tiles (image creation will take a rectangle route of the currently shared bounding box but will not draw the route, hard to explain, all you need to know is that sharing a map with an empty route will generate an image as well).

HarelM commented 7 years ago

@valleyofdawn can we close this issue? I think the sharing is in a good state and high quality.

valleyofdawn commented 7 years ago

Just the issue with the crumpled up start and end point and we're done.

בתאריך 13 בנוב׳ 2016 14:49,‏ "Harel M" notifications@github.com כתב:

@valleyofdawn https://github.com/valleyofdawn can we close this issue? I think the sharing is in a good state and high quality.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/IsraelHikingMap/Site/issues/156#issuecomment-260184338, or mute the thread https://github.com/notifications/unsubscribe-auth/AAqEMV28BObaRbPl3h-XQbQFasAmnyEgks5q9wc_gaJpZM4H74zS .

HarelM commented 7 years ago

After changes, added white outline, bigger start and end point and thicker line. image

valleyofdawn commented 7 years ago

Strangely, it is not just the circles that are compressed, it's the line as well. Like some floating pen script.

HarelM commented 7 years ago

Guy, leave it be. I'm done playing with it...