-
Notifications
You must be signed in to change notification settings - Fork 285
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
Detect & accept array-only JSON files from legacy MapKnitter #1350
Comments
If we develop this, then we can enable people to open old MapKnitter maps, by adding https://gist.github.com/jywarren/8cc1ee8f68a46e227eeb86ca068fdf0c In the format:
example for raw response: https://web.archive.org/web/20220726175911id_/https://mapknitter.org/maps/ceres--2/warpables.json# That'll be pretty cool. |
With about 7000 maps there, we could even allow a mini search engine -- maybe something like https://twitter.github.io/typeahead.js/examples/, but we don't have to think about that yet. |
Sounds interesting, I will be happy to work on this once PR #1345 is given final landing. |
Hi @jywarren, I will now begin work to convert this to PR. Many thanks. |
Once we get this working, we can really enjoy looking at a lot of old maps, complex ones, and we can use that to write up a nice post showing off all your new work! |
I see that this code results in a CORS error!
Hmm. I think we need another API endpoint... |
We could just fetch every map with |
Yeah, I ran into CORS errors while trying to fix PR #1358 (as this task is part of this PR as I planned it). IA does not seem to provide such endpoint, I combed almost everywhere but haven't found any such endpoint. |
I guess those are good candidate solutions. I was planning to tell you about the CORS errors, the error led me into focusing on DnD first. |
Great, yes, this kind of makes sense on the CORS stuff. But we can think on it a bit - yes, i agree this is a great first step forward! |
On a second thought, I'm wondering how this will work. Does web.archive.org support programmatic download of the images? It works if the images are saved in a location of this URL format |
It's true, I'm not sure. Right now I believe all the images are actually in an Amazon S3 bucket -- see the URLS like: https://s3.amazonaws.com/grassrootsmapping/warpables/306184/DJI_1204_medium.JPG (From https://web.archive.org/web/20220726175911id_/https://mapknitter.org/maps/ceres--2/warpables.json) So they will load fine. But the images are also all present in the archive.org, like: It looks like those are also CORS limited. I tweeted about this to see if anyone knows, and I have a contact at archive.org I can ask if we don't hear anything: https://twitter.com/jywarren/status/1625984206869348352 |
Okay... I'd wait for any feedback from IA to enable next move. |
Well, if we don't hear soon, we can also create a copy of all the JSON files at a CORS-enabled location, for the short term. |
Absolutely... many possible alternatives. No problem! |
Reopening for follow-ups! |
So, I tried this - with this JSON file: https://web.archive.org/web/20220726175911id_/https://mapknitter.org/maps/ceres--2/warpables.json Which should look like this: https://web.archive.org/web/20220726175945/https://mapknitter.org/maps/ceres--2/edit But it didn't quite work... it's close! Here's what it's supposed to look like: Actually only 3 images are placed, and the remainder we don't have to display on the map at all. I thought I saw there was a check for whether corners exist, so I was surprised to see that more images were placed. This is so exciting though! @segun-codes what do you think might be happening? |
Oh! interesting so:
|
Yes that's right, in old map knitter maps the JSON file recorded images that were uploaded but not yet used. |
Ok, so great! I'd give this a shot. By the way, any feedback from twitter or IA team? Many thanks! |
Nothing yet. I think we should assume though that CORS access for a JSON
file would be unlikely. Thanks!
…On Thu, Feb 16, 2023 at 6:53 AM Segun ***@***.***> wrote:
Ok, so great! I'd give this a shot. By the way, any feedback from twitter
or IA team? Many thanks!
—
Reply to this email directly, view it on GitHub
<#1350 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6JZ6QGYYKAFXYFHOMITWXYIKRANCNFSM6AAAAAAUVPHXSM>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
I'm also now generating a list of all the JSON files from all MapKnitter legacy maps, with this URL schema: https://archive.publiclab.org/mk-json/--10.json We can also filter through those and prefix all the image URLs with |
Okay, does it mean you are manually saving all the json files to archive.org now? |
I'm saving them to a public lab server right now but we can try to figure out where to put them next! Yes, I guess we could put them into an archive.org collection... Good idea! |
I filtered out image objects without coordinates but the issue with the weird looking image persists. Can't see the effect of |
Can you figure out which image it is and log it's coordinates?
…On Thu, Feb 16, 2023, 5:30 PM Segun ***@***.***> wrote:
I filtered out image objects without coordinates but the issue with the
weird looking image persists. Can't see the effect of map.fitBounds()
this time.
—
Reply to this email directly, view it on GitHub
<#1350 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J3WHS6STDAYVBWUY33WX2S7XANCNFSM6AAAAAAUVPHXSM>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
I noticed the longitude values are about 144degrees. Then, the JSON files we have experimented with successfully in the past have low order magnitude of longitude (e.g., see sample corner set below). Now, given the view area restriction here Sample Corner Set Then I observed, the longitude data is not written to json file when button 'save' is clicked. I'd do some more checks now. |
Just to mention, |
Oh excellent. Great idea.
…On Fri, Feb 17, 2023, 12:31 PM Segun ***@***.***> wrote:
Just to mention, generateJson() can now handle longitude written as lng
or lon.
—
Reply to this email directly, view it on GitHub
<#1350 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J6I7AZVHGKP56HHXULWX6YYPANCNFSM6AAAAAAUVPHXSM>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
I'm thinking the longitude values must undergo some form of transformation into lower order values like -0.2xxx before we pass it to |
Hmm, strange. I'm trying to explicitly set these, but it's still not changing the distorted display: function placeImage (imageURL, options, newImage = false) {
let image;
if (newImage) { // Construct new map
image = L.distortableImageOverlay(
imageURL,
{tooltipText: options.tooltipText}
);
} else if (options.corners) { // Reconstruct map to previous saved state
image = L.distortableImageOverlay(
imageURL,
{
tooltipText: options.tooltipText,
corners: [
L.latLng(options.corners[0], options.corners[0]),
L.latLng(options.corners[1], options.corners[1]),
L.latLng(options.corners[2], options.corners[2]),
L.latLng(options.corners[3], options.corners[3])
]
}
);
console.log('corners',image.getCorners())
}
if (image) map.imgGroup.addLayer(image);
}; $ map._layers[184].getCorners()
=>
[
{
"lat": -37.7664063648,
"lng": 144.9828654528
},
{
"lat": -37.7650239004,
"lng": 144.9831980467
},
{
"lat": -37.7652020107,
"lng": 144.9844533205
},
{
"lat": -37.7665844718,
"lng": 144.9841207266
}
] |
I also tried manually running: i = L.distortableImageOverlay(
"https://s3.amazonaws.com/grassrootsmapping/warpables/306187/DJI_1207.JPG",
{
corners: [
{
"lat": -37.7664063648,
"lng": 144.9828654528
},
{
"lat": -37.7650239004,
"lng": 144.9831980467
},
{
"lat": -37.7652020107,
"lng": 144.9844533205
},
{
"lat": -37.7665844718,
"lng": 144.9841207266
}
]}).addTo(map); And saw the same thing... so strange!! |
OK, so it's still not quite right. But the corner order is important. We should compare to the image = L.distortableImageOverlay(
imageURL,
{
tooltipText: options.tooltipText,
corners: [
L.latLng(options.corners[1], options.corners[1]),
L.latLng(options.corners[2], options.corners[2]),
L.latLng(options.corners[0], options.corners[0]),
L.latLng(options.corners[3], options.corners[3])
]
}
);
console.log('corners',image.getCorners()) MapKnitter had accounted for this, with order 0,1,3,2: Yes, that's correct!! image = L.distortableImageOverlay(
imageURL,
{
tooltipText: options.tooltipText,
corners: [
L.latLng(options.corners[0], options.corners[0]),
L.latLng(options.corners[1], options.corners[1]),
L.latLng(options.corners[3], options.corners[3]),
L.latLng(options.corners[2], options.corners[2])
]
}
); OK, so actually we need to standardize everything to that. We should follow the previous convention, including our own JSON exporting. That will mean we won't have to have 2 different logics to do this. Phew, that was a tough one!!! |
Also, I'm uploading ALL of the JSON files to: https://archive.org/details/mapknitter so we can try using that! But for now, all of them are available at: https://archive.publiclab.org/mk-json/ For example: https://archive.publiclab.org/mk-json/ceres--2.json Later, we'll be able to follow this pattern: |
Waoh! very good observation, well done @jywarren. All along, I had thought the order of coordinates in MK were consistent with the order in MK Lite. |
Okay, so I see the coordinates must be passed in this order NW, NE, SW, SE order (in a "Z" shape).
Let's see how all these will pan out. |
Great. I'll just note that https://archive.org/download/mapknitter is now all online and present, all 7824 maps. |
This is now working, and we could think about the best way to display a list of all the maps in https://archive.org/download/mapknitter/, but they all work now! Great work!!!! |
I just realized also - the cached JSON files from legacy MapKnitter use the plain
[...]
array format 😭https://web.archive.org/web/20220726175911/https://mapknitter.org/maps/ceres--2/warpables.json
This doesn't have to be a problem for us, certainly not now. The format we've chosen is definitely better:
We can add a feature which can detect if the JSON is just an array, and accept that format too, for backwards compatibility. We can work on it later!
The text was updated successfully, but these errors were encountered: