Skip to content
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

Adjust scaling with parameter #14

Closed
jywarren opened this issue May 28, 2019 · 19 comments
Closed

Adjust scaling with parameter #14

jywarren opened this issue May 28, 2019 · 19 comments

Comments

@jywarren
Copy link
Member

We scale the output image with a provided cm per pixel value called scale or sometimes resolution -- here is the relevant segment -- but also search for scale or pxperm in this file!

https://github.com/publiclab/mapknitter-exporter/blob/c767780392342c109b26a887971b3ab6bcd98c94/lib/mapknitterExporter.rb#L125-L126

It's not super complex, it's just a scaling factor because we know the real-world dimensions of the images, and we know the pixel dimensions as well.

cc @tech4GT !

@tech4GT
Copy link
Member

tech4GT commented May 28, 2019

Awesome! I'll ad this part in tomorrow as well! This is coming together rather quickly!! Exciting!!

@jywarren
Copy link
Member Author

jywarren commented May 28, 2019 via email

@tech4GT
Copy link
Member

tech4GT commented May 28, 2019

Okay I tried running this with node v10 to export a 11904x8928 Image and it is taking somewhere in the neighborhood of about 4-5 minutes on my machine!

@jywarren
Copy link
Member Author

jywarren commented May 28, 2019 via email

@tech4GT
Copy link
Member

tech4GT commented May 28, 2019

Yes! I better sleep now but I think I can push everything we talked about tomorrow itself! 😄

@jywarren
Copy link
Member Author

jywarren commented May 28, 2019 via email

@jywarren
Copy link
Member Author

jywarren commented Jun 9, 2019

Hi @tech4GT did the scaling code get added in and would you mind adding some brief docs? Thanks!!

@tech4GT
Copy link
Member

tech4GT commented Jun 9, 2019

@jywarren The scaling part was still giving me trouble. I'll add the details in a couple of hours.

@tech4GT
Copy link
Member

tech4GT commented Jun 10, 2019

Okay, here is the detailed explanation of the problem:

  • We use a converter function to convert the lat/long coordinates to overlay coordinates of warped images.
  • While the coordinates generated are distorting the image correctly they are getting scaled incorrectly which results in improper overlay of images.
  • We need to fix the converter in a way that it consumes a scale query and converts the coordinates into correct overlay coordinates for every value of the scale and not just a particular value.

@jywarren jywarren mentioned this issue Jun 10, 2019
5 tasks
@jywarren
Copy link
Member Author

jywarren commented Jul 6, 2019

We may need to use the haversine formula if we're not already doing so to correctly scale: https://www.npmjs.com/package/haversine-distance

@jywarren
Copy link
Member Author

jywarren commented Jul 6, 2019

Hmm here are the sections where scaling might be needed. We probably need a scale coefficient.

vals.steps = `canvas-resize{width:${2 * width}|height:${2 * height}|x:${lMins[0].x}|y:${lMins[0].y}}`;
for (let i in rv) {
if (i == 0) continue;
vals.steps += `,import-image{url:output>${rv[i].id}},overlay{x:${lMins[i].x}|y:${lMins[i].y}}`;

I couldn't find a commit referencing scale, or code referencing a scale parameter. Is this in a feature branch somewhere? Can you open a PR? Thanks!

We can refer to the matching section of code in mapknitter-exporter, which does the same thing but in Ruby and ImageMagick:

https://github.com/publiclab/mapknitter-exporter/blob/main/lib/mapknitterExporter.rb#L251

@tech4GT
Copy link
Member

tech4GT commented Jul 6, 2019

Yeah, I was kind of trying this stuff out when we decided to circle back later. I couldn't really figure out how to convert the parameters using scale though, by looking at the ruby code!
I'll try this out tomorrow, and add the code I wrote for consuming the scale parameter(It's on my local machine right now, sorry). That wan't really working perfectly though!

@tech4GT
Copy link
Member

tech4GT commented Jul 6, 2019

The npm module looks great! It might just make the job easier for us!!

@tech4GT
Copy link
Member

tech4GT commented Jul 6, 2019

And now since the deployment stuff is figured out, this is all that remains I guess 😄

@tech4GT
Copy link
Member

tech4GT commented Jul 7, 2019

@jywarren Is there someone I can talk to maybe? Someone who worked on the ruby version, maybe they'll be able to better explain this part of the logic to me. I still can't really wrap my head around this!

@jywarren
Copy link
Member Author

jywarren commented Jul 8, 2019 via email

@tech4GT
Copy link
Member

tech4GT commented Jul 8, 2019

It’s in the evening, I think I can make it! Thanks!

@jywarren
Copy link
Member Author

jywarren commented Jul 9, 2019

OK so placement is incorrect - but rotation and distortion are good. Let's then look at this segment of code:

https://github.com/publiclab/mapknitter-exporter/blob/main/lib/mapknitterExporter.rb#L250-L282

@tech4GT
Copy link
Member

tech4GT commented Jul 10, 2019

#23

@tech4GT tech4GT closed this as completed Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants