Re: Percision of champlain_view_get_coords_at



Ooops, accidentally took this off-list. Sorry.

On Tue, Nov 30, 2010 at 10:28 AM, Quikee <quikee gmail com> wrote:
> I investigated more about this and found that get_coords_at is working
> as expected. The problem is elsewhere - probably in marker placement
> code or something like this. I don't know why but setting a marker (in
> my scenario) at a specific coordinate is only accurate at the current
> center of the map.

I think this is actually related to the bug I was having with the
notify signal not firing often enough.

It seems to me if you've moved the map by a distance short enough as
to not trigger the notify signal, get_coords_at gives stale results as
if the map view has not moved since the last time the notify signal
was fired.

This bug bit me hard when I was trying to implement keyboard
navigation of the map (the method would determine the pixel
coordinates of the map center, and then choose a location that was n
pixels away from the center, either up down left or right depending on
which key was pressed). If n was too small, the notify signal would
not fire, and the method would only work once. That is, the method
would successfully move the map once, but if you tried to do it again
in the same direction, it wouldn't move the map view at all because
the results from get_coords_at were stale.

Also, if you tried to go in a different direction from the first time,
you would snap back to the starting location each time, and then
always move relative to there. So for example, let's say n = 10
pixels, and you pressed 'left' arrow key, the map would successfully
move 10 pixels left, but if you then pressed 'up' arrow key, the map
would go 10 pixels back to the right, then 10 pixels up. and you would
always be 'pinned' to the starting location, never able to get more
than 10px away from it in any direction (until you used mouse
navigation to break free).

My workaround was to just set n large enough that it caused 'notify'
signal to fire, and then things began to work as expected. I didn't
test very thoroughly exactly what the threshold was, but I ended up
making n be "1/5 of total map view size" and haven't had any problems
with that (although I would like it to be smaller/more precise).

--
http://exolucere.ca



-- 
http://exolucere.ca


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]