markoteittinen / custom-maps

Automatically exported from code.google.com/p/custom-maps
Apache License 2.0
29 stars 8 forks source link

Point wrong when close to edge of image #14

Closed mganss closed 2 years ago

mganss commented 4 years ago

If you pick a reference point that is very close to the edge of the image (say, in a corner) it is shown in a different location on the Google Maps overlay, i.e. the little circle is suddenly at a different point than what you had picked.

If you continue to create the map using the overlay with the circle in the wrong location, the resulting map is off.

This can be worked around somewhat during selection of the reference point by zooming in so that the edge of the image is not visible.

mganss commented 4 years ago

An easy way to repro is to place the reference point in any corner or directly at the edge about halfway between corners. In the latter case you'll notice that the "snippet" is not a square.

I believe the culprits are here:

https://github.com/markoteittinen/custom-maps/blob/cdf963567c0b9923084da696dbaa3002a79cad51/app/src/main/java/com/custommapsapp/android/create/BitmapPointActivity.java#L219-L220

and here

https://github.com/markoteittinen/custom-maps/blob/cdf963567c0b9923084da696dbaa3002a79cad51/app/src/main/java/com/custommapsapp/android/ImageHelper.java#L211-L215

markoteittinen commented 4 years ago

Thanks for reporting your problem.

Actually, the tiepoints selected near the edge of the map image seem to work correctly. I just created a perfectly aligned map with two points selected so close to the edge that both samples were clipped vertically, almost in half.

But I don't doubt that you are seeing a problem. My guess is that the point that is giving you trouble is not one of the first 4 tiepoints (alignment points). Custom Maps actually ignores all but the first 4 tiepoints, since it computes a linear matrix that converts the map image x,y coordinates to geo latitude,longitude coordinates.

Custom Maps allows adding more than 4 tiepoints, because I originally thought I'd either try to come up with a clever algorithm to pick the 4 tiepoints that get the best alignment, or I'd always use the 3 closest tiepoints to user's location, but both of these approaches have significant issues. Selecting the best group of 4 tiepoints from a large number of tiepoints fails due to the number of unique 4 point combinations that can be created. And if the conversion is based on the closest 3 tiepoints to user's current location, it becomes excessively complex to draw the map image over Google map for preview (verification) purposes.

If your problematic point near the edge is one of the first 4 points in your map, I would like to see your map file (can you attach it to this issue?) and investigate what is going wrong. Also, let me know whether you are using the release version, or the beta, or if you are using a version you built yourself from the open source.

Thanks, and apologies for lack of documentation about the limit on the tiepoints.

mganss commented 4 years ago

I'm seeing this for all points, so even for the very first point. Here's an example map: https://www.giovis.com/maps/massa2013web1.pdf

I'm using v1.5.2 from the Play Store.

Steps to repro:

Another test case:

mganss commented 4 years ago

The problem seems to only occur with rotated images. Using a non-rotated image the tiepoints are correct but the snippet size is still only half width and/or height if the tiepoint is along an edge or in a corner.

markoteittinen commented 4 years ago

Thank you for the clarification. I can now reproduce the issue with the PDF file you shared. I will definitely fix this one before I release the next non-beta version.

The snippets are not full size when a tiepoint is selected close to the edge, as there are no more pixels to grab from the map image. But I guess I probably should add empty transparent borders to those snippets so that all snippets are the same size even if some parts of the snippets are transparent.

mganss commented 4 years ago

Another option would be to show the tiepoint in the corner of the snippet and provide more context from the rest of the image. For example, if you choose the lower left corner of the image as a tiepoint then choose the snippet so that its lower left corner is at this point, too. In other words, the snippet will always have the same size but will always stay within the bounds of the image.

markoteittinen commented 4 years ago

Sorry, but I didn't have the time to fix this issue in version 1.6 beta 4 (available in Play Store if you join beta), but I will fix this issue for the next beta release. Your translation improvements are already in 1.6 beta 4.

markoteittinen commented 4 years ago

I have fixed this issue now on my dev system. The fix will be included in the next beta release (1.6 beta 5). Thank you for discovering and reporting this one.