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

Downloaded JSON has only lat, no lon #1353

Open jywarren opened 1 year ago

jywarren commented 1 year ago

Hi, all, not sure when this happened, but I created and downloaded a JSON file and it was this:

{"avg_cm_per_pixel":9.765205126141716,"collection":
[
{"id":246,"src":"https://archive.org/download/texas-barnraising//IMG_0137.JPG","tooltipText":"IMG_0137","image_file_name":"IMG_0137.JPG","nodes":[{"lat":30.24656835091466},{"lat":30.24669606967037},{"lat":30.246681528559265},{"lat":30.246802763541005}],"cm_per_pixel":8.844274048278852},
{"id":244,"src":"https://archive.org/download/texas-barnraising//IMG_0128.JPG","tooltipText":"IMG_0128","image_file_name":"IMG_0128.JPG","nodes":[{"lat":30.24661665249983},{"lat":30.24664503656851},{"lat":30.246701804681287},{"lat":30.246730188725383}],"cm_per_pixel":5.5115729012365255},
{"id":232,"src":"https://archive.org/download/texas-barnraising//IMG_0807%20(2).JPG","tooltipText":"IMG_0807%20(2)","image_file_name":"IMG_0807%20(2).JPG","nodes":[{"lat":30.24684989876675,"lon":-97.74413697207335},{"lat":30.247082694639825,"lon":-97.74389014505901},{"lat":30.246596047697814,"lon":-97.74386020327914},{"lat":30.24687811716672,"lon":-97.74360684083737}
],"cm_per_pixel":14.939768428909769}]}

Notice none of the first two image's coordinates have longitudes. How do you think this happened? Let's dig in and investigate! Thanks!!

segun-codes commented 1 year ago

Interesting.. I will look into this or well, @7malikk do you want to do this? Thanks!

7malikk commented 1 year ago

@segun-codes You can go ahead, I did some findings though, after resolving issue #1352 I tried the following:

Trial 1

latLng

Result of Trial 1

image

Trial 2

t-2latLng

Result of Trial 2

image

Trial 3

t-3latLng

Result of Trial 3

image

As seen in these trials, there are consistent lon values, @jywarren @segun-codes Give it a try as well

jywarren commented 1 year ago

(Oops moving this comment to this PR, i had meant to comment there - https://github.com/publiclab/Leaflet.DistortableImage/pull/1354)

jywarren commented 1 year ago

Sorry for commenting in the wrong place!

jywarren commented 1 year ago

OK, not sure if this is related at all - 2 observations:

image

I found that in this collection: https://archive.org/details/sanborn-1885

See the individual files here: https://archive.org/download/sanborn-1885

one of the longitudes was recorded as "lng" not "lon" -- different libraries use lng or lon, so maybe there's an issue there? But so strange that it was just one corner!!!

I also uploaded a new mapknitter.json file there (just generated), so I'm not sure when the "lng" was introduced. But I had moved one corner so maybe that one was converted to "lng"?

I think we should double check everywhere we're using "lng" vs "lon" and maybe that's somewhere the cause of the issue!

jywarren commented 1 year ago

And you can try it out live at https://publiclab.github.io/Leaflet.DistortableImage/examples/archive - it's running the latest code!

segun-codes commented 1 year ago

Hi @7malikk, @jywarren, I just observed that layer.getCorners() in generateExportJson() does not return corners for some images e.g., IMG_0807 and IMG_0725 from https://archive.org/details/texas-barnraising/. You may want to try them out too.

IMG_0807 IMG_0807

IMG_0725 IMG_0725

segun-codes commented 1 year ago

Oh! @7malikk, @jywarren, I tried the same images again and layer.getCorners() returned corners. I can't seem to reproduce same error again. Very strange!!!

segun-codes commented 1 year ago

OK, not sure if this is related at all - 2 observations:

image

I found that in this collection: https://archive.org/details/sanborn-1885

See the individual files here: https://archive.org/download/sanborn-1885

one of the longitudes was recorded as "lng" not "lon" -- different libraries use lng or lon, so maybe there's an issue there? But so strange that it was just one corner!!!

I also uploaded a new mapknitter.json file there (just generated), so I'm not sure when the "lng" was introduced. But I had moved one corner so maybe that one was converted to "lng"?

I think we should double check everywhere we're using "lng" vs "lon" and maybe that's somewhere the cause of the issue!

Hi @jywarren, I fetched the two images from https://archive.org/details/sanborn-1885 and there was no inconsistency in the naming for longitude, see section highlighted yellow: 3

jywarren commented 1 year ago

Well, I think it's a clue even if this specific issue isn't reproducible. Did you try moving one corner of the image, then checking again?

The layer.getCorners() thing is also a clue! We should look in the core library code to see where it's assembled!

I did that, printed the corners shortly after assembly in distortableImageOverlay.js. Corners were printed on each occasion, no miss. See the underlined: 2

4

5

segun-codes commented 1 year ago

I think I might have addressed this issue in PR #1359 already.

jywarren commented 1 year ago

Ok, we can test after merging that. Thanks!

On Sat, Feb 18, 2023, 7:34 AM Segun @.***> wrote:

I think I might have addressed this issue in PR #1359 https://github.com/publiclab/Leaflet.DistortableImage/pull/1359 already.

— Reply to this email directly, view it on GitHub https://github.com/publiclab/Leaflet.DistortableImage/issues/1353#issuecomment-1435660080, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF6J26BYR2XWKNEDM65OTWYC6ULANCNFSM6AAAAAAU2YSGNY . You are receiving this because you were mentioned.Message ID: @.***>

jywarren commented 1 year ago

Could this also be related somehow to the corner ordering in https://github.com/publiclab/Leaflet.DistortableImage/issues/1350 ? Hard to see how, but good to bear in mind as a possible complicating factor.

segun-codes commented 1 year ago

Could this also be related somehow to the corner ordering in #1350 ? Hard to see how, but good to bear in mind as a possible complicating factor.

Possibly...