publiclab / Leaflet.DistortableImage

A Leaflet extension to distort or "rubber sheet" images
https://publiclab.github.io/Leaflet.DistortableImage/examples/
BSD 2-Clause "Simplified" License
265 stars 284 forks source link

Correct rendering of images reconstructed from Legacy JSON #1359

Closed segun-codes closed 1 year ago

segun-codes commented 1 year ago

Fixes #1358

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!

If tests do fail, click on the red X to learn why by reading the logs.

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software

Thanks!

jywarren commented 1 year ago

Ah apologies is this ready for review/merge?

segun-codes commented 1 year ago

Ah apologies is this ready for review/merge?

No, not at the time you sent this message, the subsequent messages too.

segun-codes commented 1 year ago

Hi @jywarren, this is ready for your review and advice. The code supports proper reconstruction of maps from legacy json files using DnD or URL features.

Illustration 1: Reconstruct legacy map using DnD Feature illustration-1

Illustration 2: Reconstruct legacy map using URL

  1. http://localhost:8081/examples/archive.html?json=https://archive.org/download/mapknitter/--10.json
  2. http://localhost:8081/examples/archive.html?json=https://archive.org/download/mapknitter/041114flcwetlandsjv.json
  3. http://localhost:8081/examples/archive.html?json=https://archive.org/download/mapknitter/07172013-blue-ocean.json illustration-2
jywarren commented 1 year ago

Exciting!! This is working really well for old maps. I noticed this map doesn't work anymore, but that's because it's saved in the wrong order (which we did for a while before we found this issue) -- does that sound right to you?

https://archive.org/details/empire-st-chinatown-providence

I can then re-save that JSON and re-upload it.

jywarren commented 1 year ago

I tried re-ordering the corner points from https://archive.org/details/empire-st-chinatown-providence, so it's 0,1,3,2, as we had figured out. So:

{"avg_cm_per_pixel":22.023384694097306,"collection":[{"id":515,"src":"https://archive.org/download/empire-st-chinatown-providence/service-gmd-gmd377m-g3774m-g3774pm-g3774pm_g08099189901-08099_01_1899-0010.jpg","tooltipText":"service-gmd-gmd377m-g3774m-g3774pm-g3774pm_g08099189901-08099_01_1899-0010","image_file_name":"service-gmd-gmd377m-g3774m-g3774pm-g3774pm_g08099189901-08099_01_1899-0010.jpg","nodes":[{"lat":41.823035603473315,"lon":-71.41519904136659},{"lat":41.82091283895551,"lon":-71.41239881515504},{"lat":41.818462177715475,"lon":-71.41576230525972},{"lat":41.820585023472844,"lon":-71.41857326030733}],"cm_per_pixel":22.023384694097306}]}

But now I get Image object has no nodes and can't be loaded as an error.

So before merging, what do you think happened? I think we're there, i just want to be sure we still have the edit-download-upload-recover cycle still working!

Thanks @segun-codes !!

segun-codes commented 1 year ago

Interesting! Okay, I'd take a look. Many thanks!

segun-codes commented 1 year ago

Exciting!! This is working really well for old maps. I noticed this map doesn't work anymore, but that's because it's saved in the wrong order (which we did for a while before we found this issue) -- does that sound right to you?

https://archive.org/details/empire-st-chinatown-providence

I can then re-save that JSON and re-upload it.

Hi @jywarren, everything seems to work now (see illustrations below). I think you want to re-fetch from https://archive.org/details/empire-st-chinatown-providence, download its json file from mk-lite and then attempt to reconstruct the same map (either by DnD or URL).

Illustration 3A Illustration 3a

Illustration 3B Illustration 3b

jywarren commented 1 year ago

Indeed it works! Merging now! Great work, @segun-codes.