-
Notifications
You must be signed in to change notification settings - Fork 283
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
auto-detect json from response #1346
Conversation
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: So I pivoted to construct the URL and pass it to the 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! 😅 |
By download, do you mean we should load it on the tile layer? I'm not sure I understand.
Alright, I understand this
Okay, so do you mean if there's no Json file named mapknitter.json it should load whatever Json file is available? |
😅😅 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
<#1346 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J4OHTKKEIFBX4PD3ULWV7EM3ANCNFSM6AAAAAAUR2AG4I>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Sounds good to me. 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
<#1346 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6JYNOFMZM5V7ECTKDCTWV7FR7ANCNFSM6AAAAAAUR2AG4I>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
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 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 Testing your code out now! |
|
||
function showImages(getUrl) { | ||
const url = getUrl.replace('details', 'metadata'); | ||
|
||
axios.get(url) | ||
.then((response) => { | ||
.then((response) => { | ||
loadJSONfromResponse(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, but I'm seeing this error when entering the url https://archive.org/details/sanborn-1885
DistortableCollection.js:226 err TypeError: Cannot read properties of undefined (reading 'length')
The JSON in this is mapknitter.json
and the contents are:
[{"id":1504,"src":"https://archive.org/download/sanborn-1885/sanborn-1885.jpg",
"width":7573,
"height":6396,
"image_file_name":"sanborn-1885.jpg",
"nodes":[
{"lat":39.32869582897733,"lon":-120.187548995018},
{"lat":39.32982863334289,"lon":-120.18338084220888},
{"lat":39.3270941035765,"lon":-120.182141661644},
{"lat":39.32596125491416,"lon":-120.18630981445314}
],"cm_per_pixel":10.875006010132818}]
What do you think is happening? Ah, look:
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'avg_cm_per_pixel') at reconstructMapFromJson (archive.js:254:53)
Maybe we have to check for that first, in case it doesn't exist?
Great work so far!!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh alright, I'll add that check
Although I have an idea, I'd explore it and get back to you
@jywarren I've added the check for the |
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?
|
Alright, I will give it a shot @jywarren |
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: Leaflet.DistortableImage/src/DistortableCollection.js Lines 209 to 210 in 8cca752
I propose we stick to a single format of saving JSON files, our choices are :
or
What do you think @jywarren? |
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 |
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
<#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
<#1346 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J5ACTKSUJXV2MIJ6Z3WWTSM7ANCNFSM6AAAAAAUR2AG4I>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
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)