Closed 7malikk closed 1 year ago
Hello @jywarren, in trying to address the solution using the method in #1343, I came across a small disparity.
IA returns JSON files like so:
With this, I could not verify if the JSON file contains images or not.
So I pivoted to construct the URL and pass it to the reconstructMapFromURL()
function here
What are your thoughts?
Ah I see, that makes sense, we don't see the contents. We could try two things:
What do you prefer? We could also have it search for mapknitter.json first but if it doesn't find it, try all other JSON files?
Or we could let people choose one from a list, but that's a lot of extra UI to design! 😅
- Download and test each JSON file (could be a lot of requests but probably won't be, people don't store a lot of JSON files in IA!)
By download, do you mean we should load it on the tile layer? I'm not sure I understand.
- Have a consistent name for the JSON file, kind of like package.json or something. We could call it mapknitter.json?
Alright, I understand this
What do you prefer? We could also have it search for mapknitter.json first but if it doesn't find it, try all other JSON files?
Okay, so do you mean if there's no Json file named mapknitter.json it should load whatever Json file is available?
Or we could let people choose one from a list, but that's a lot of extra UI to design! 😅
😅😅 That's right.
So what's your final say, I'm still trying to wrap my head around the previous comment
I'm not sure! Maybe the easiest way for now is to standardize the name. Then we can add full auto detection later?
On Sun, Feb 5, 2023, 10:54 AM Malik @.***> wrote:
Or we could let people choose one from a list, but that's a lot of extra UI to design! 😅
😅😅 That's right.
So what's your final say, I'm still trying to wrap my head around the previous comment
— Reply to this email directly, view it on GitHub https://github.com/publiclab/Leaflet.DistortableImage/pull/1346#issuecomment-1418076156, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF6J4OHTKKEIFBX4PD3ULWV7EM3ANCNFSM6AAAAAAUR2AG4I . You are receiving this because you were mentioned.Message ID: @.***>
I'm not sure! Maybe the easiest way for now is to standardize the name. Then we can add full auto detection later?
Sounds good to me. What of cases of multiple files?
Also should standardization remove the need to prompt the user for a file name?
And I believe this will affect the download button too, so the naming should be standardized for now
What if it just has to start with "mapknitter" but could also contain later characters like date, a more specific label. So mapknitter-__.json. And we just use the first one we find, for now.
On Sun, Feb 5, 2023, 11:04 AM Malik @.***> wrote:
I'm not sure! Maybe the easiest way for now is to standardize the name. Then we can add full auto detection later?
Sounds good to me. What of cases of multiple files?
Also should standardization remove the need to prompt the user for a file name?
And I believe this will affect the download button too, so the naming should be standardized for now
— Reply to this email directly, view it on GitHub https://github.com/publiclab/Leaflet.DistortableImage/pull/1346#issuecomment-1418088599, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF6JYNOFMZM5V7ECTKDCTWV7FR7ANCNFSM6AAAAAAUR2AG4I . You are receiving this because you were mentioned.Message ID: @.***>
What if it just has to start with "mapknitter" but could also contain later characters like date, a more specific label. So mapknitter-__.json. And we just use the first one we find, for now.
Okay, I think that makes sense
So the first match for the search of "mapknitter" should be loaded.
@jywarren I made the changes to have a standardized name of mapknitter
with a unique ID generated from the time it was downloaded resulting in a filename of: mapknitter-1293929493
like so:
I also updated the JSON filter to check for files that start with "mapknitter" and are in JSON format and prompt the user. If the user confirms to load it, it is then loaded on the map like so:
This sounds great. What if the random number is a timestamp? Or a date time formatted string like 20:00-01-04-2023
or something?
Testing your code out now!
@jywarren I've added the check for the avg_cm_per_pixel
though it looks a tad hacky, what do you think?
Hmm, can't we still reconstruct without this value? Where are we depending on it?
Hmm, can't we still reconstruct without this value? Where are we depending on it?
I wondered the same thing we do make use of it here, but I am yet to answer the question if the reconstruction from JSON is dependent on that value
I want to say we are providing it optionally. Instead of rejecting if we don't have the value, shall we make the change in the following area to only include that value in the output if it exists, otherwise we don't set that property on line 215?
I want to say we are providing it optionally. Instead of rejecting if we don't have the value, shall we make the change in the following area to only include that value in the output if it exists, otherwise we don't set that property on line 215?
Alright, I will give it a shot @jywarren
I want to say we are providing it optionally. Instead of rejecting if we don't have the value, shall we make the change in the following area to only include that value in the output if it exists, otherwise we don't set that property on line 215?
While attempting to do this, I noticed that the format which the JSON file I saved is integral to how it would be reconstructed based on the setup here:
I propose we stick to a single format of saving JSON files, our choices are :
{"avg_cm_per_pixel":7.291666666666667,
"images":[{image1}, {image2}]
}
[{image1}, {image2}]
What do you think @jywarren?
I want to say we are providing it optionally. Instead of rejecting if we don't have the value, shall we make the change in the following area to only include that value in the output if it exists, otherwise we don't set that property on line 215?
While attempting to do this, I noticed that the format which the JSON file I saved is integral to how it would be reconstructed based on the setup here:
I propose we stick to a single format of saving JSON files, our choices are :
{"avg_cm_per_pixel":7.291666666666667, "images":[{image1}, {image2}] }
or
[{image1}, {image2}]
What do you think @jywarren?
Oh! @7malikk, good observation. Your question is similar to what we are discussing here https://github.com/publiclab/Leaflet.DistortableImage/pull/1345
Oh! @7malikk, good observation. Your question is similar to what we are discussing here #1345
Really? @segun-codes, let me go give it a read through
Hello, @jywarren I've made avg_cm_per_pixel an optional property in reconstructing the map from JSON URL. I took into consideration changes from #1345 which upon final works, this PR would be ready for merge after some conflict resolutions
Ok great! Let me know and I'll test and merge!
On Thu, Feb 9, 2023, 7:55 AM Malik @.***> wrote:
Hello, @jywarren https://github.com/jywarren I've made avg_cm_per_pixel an optional property in reconstructing the map from JSON URL. I took into consideration changes from #1345 https://github.com/publiclab/Leaflet.DistortableImage/pull/1345 which upon final works, this PR would be ready for merge after some conflict resolutions
— Reply to this email directly, view it on GitHub https://github.com/publiclab/Leaflet.DistortableImage/pull/1346#issuecomment-1424150858, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAF6J5ACTKSUJXV2MIJ6Z3WWTSM7ANCNFSM6AAAAAAUR2AG4I . You are receiving this because you were mentioned.Message ID: @.***>
@jywarren this PR is refactored at #1351, I'll be closing this one
Fixes #1343
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
grunt test
UI changes:
When there are multiple JSON files in URL response![loadJSON-t2](https://user-images.githubusercontent.com/75104021/216825813-a0ac507b-e6ce-47c1-9177-54df29d9a4cb.gif)
When there is just one JSON file in URL response![loadJSON-t1](https://user-images.githubusercontent.com/75104021/216826011-c67935fb-9977-4e84-a861-da1a9ac15ed1.gif)