biodiv / anycluster

Server-side clustering of map markers for (Geo)Django

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panning

lmorroni opened this issue · comments

Hi,
I noticed both in my tests and on your demo at https://www.anymals.org/nx/bigmap/ that the certain clusters do not get rendered when you pan. Here's how you can reproduce on your demo:

  • Make your browser window small enough so that when you refresh your map, you only see Europe/Africa. Then pan the window over to where the US is centered. You will notice that not all the clusters show for the US.

biodev

  • Now refresh the window again and move over so the US is in the bottom left portion of the window. The clusters will render.

I am attaching my screenshot. Not sure what is going on here. I tried turning debugging on in clusterer.py but it started complaining about line 804
print('pins after phase2: %s' %cellpins)

Thanks a lot for finding this. I will look into this issue at the end of the week or during the weekend and try to fix it. I think this has to with panning below -180 degrees and for some reason it then clusters "the other half of the world" from the right edge as a start and the left edge as the end, but this is only my first guess.

This might help you. Below are the URL GETs that are triggered when I
zomme from the highest level down to level 3.

[10/Feb/2014 15:16:58] "GET
/anycluster/kmeans/0/128/?left=-180&top=89.98887490038717&right=180&bottom=-89.94387742356028&layer_id=list_5%2C7
HTTP/1.1" 200 111
[10/Feb/2014 15:17:01] "GET
/anycluster/kmeans/1/128/?left=-180&top=89.38471355964259&right=180&bottom=-85.34892541556992&layer_id=list_5%2C7
HTTP/1.1" 200 221
[10/Feb/2014 15:17:03] "GET
/anycluster/kmeans/2/128/?left=-180&top=85.42659514936709&right=180&bottom=-49.41125786935332&layer_id=list_5%2C7
HTTP/1.1" 200 637
[10/Feb/2014 15:17:05] "GET
/anycluster/kmeans/3/128/?left=136.078125&top=76.75037266166416&right=107.42578125&bottom=2.5914519003430008&layer_id=list_5%2C7
HTTP/1.1" 200 2

The first three of these work fine. The fourth where the left and right
are < 180, I get no results back. This is just for zooming but maybe it
is related to your panning issue too?
Larry

Sorry for taking so long. Both the zooming and the panning issues are now fixed. The error was in MapTools calculating maximum/minimum of cellIDs in a bad, unreliable way

I appreciate all your work. I noticed that you updated
gmap_clusterer.js as well. Is this required? I have had to modify my
local copy of gmap_clusterer.js to reflect my map styles and some path
changes. I also had to fix a minor issue I found relating to icon and
MarkerImage at about line 242. The latest version of Google Maps had
issues with the way you had it defined. Also, for whatever it's worth,
the clusters were appearing stuck together when I used the latest
experimental version of Google maps. I had to explicitly set it to 3.15
to get it to behave properly.
Larry

On 3/9/14, 7:19 AM, biodiv wrote:

Sorry for taking so long. Both the zooming and the panning issues are
now fixed. The error was in MapTools calculating maximum/minimum of
cellIDs in a bad, unreliable way


Reply to this email directly or view it on GitHub
#6 (comment).

the new gmap_clusterer.js contains a temporary workaround for the problem with the latest google maps api - but it does not display exact counts anymore and should be replaced with a better solution. I will try to replace the markerWithLabel (external code), which is the problem with the new api. The MarkerWithLabel javascript also was/is a performance hit. Until there is something better you either can explicitly set the google api to 3.15 as you described, or use the workaround provided in my gmap_clusterer.js

I have updated to all of the latest code. I am forcing v 3.15 on maps.
I am using the older version of gmap_clusterer.js that shows accurate
counts on the cluster. I am still experiencing the panning and zooming
issues. I am wondering if you have any suggestions on how I can
troubleshoot this issue? I don't think I am doing anything out of the
ordinary in how instantiate the clusterer from my javascript.
Larry

On 3/9/14, 7:19 AM, biodiv wrote:

Sorry for taking so long. Both the zooming and the panning issues are
now fixed. The error was in MapTools calculating maximum/minimum of
cellIDs in a bad, unreliable way


Reply to this email directly or view it on GitHub
#6 (comment).

Larry Morroni
610.862.0920
http://morroni.com

Before I reopen this bug, please try the following:
First, delete all .pyc files in the anycluster folder. For some odd reason, I had to do this to get the MapClusterer class use the updated MapTools.

Troubleshoot if python really is using the new files:
In python code of MapClusterer.py set

DEBUG = True

In a python shell:

    c = MapClusterer()
    c.zoom = 3
    c.gridSize = 128
    cells = c.getClusterCells(viewport3)

You should get the following in the last line:

CELLID: toprightCell: [12, 13]  |  bottomleftCell: [14, 8]

Now print the cells:

>>> print cells
['12,8', '12,9', '12,10', '12,11', '12,12', '12,13', '13,8', '13,9', '13,10', '13,11', '13,12', '13,13', '14,8', '14,9', '14,10', '14,11', '14,12', '14,13']

viewport3 together with zoom 3 and gridSize 128 is your query URL from a few posts earlier that did not work. In the previous version, this returned the empty list

[]

Don't forget to turn DEBUG off after this.

I am baffled. I just cloned your latest version. I cleaned out all the
pyc files. I turned on debugging in MapClusterer.py. Here's my output:
(bayz)lmorroni@tuck : ~/Documents/workspace/bayz ( master ✔✖) $ python
manage.py shell
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)

from anycluster import MapClusterer
c = MapClusterer.MapClusterer()
c.zoom = 3
c.gridSize = 128
viewport3 = {'left':-175.78124999999775, 'top':84.67351256610502,
'right':175.78124999999775, 'bottom':-84.67351256610502}
cells = c.getClusterCells(viewport3)
4326, longlat: topright: (175.78125,84.6735125661) | bottomleft:
(-175.78125,-84.6735125661)
MERCATOR: topright: (19567879.241,19567879.241) | bottomleft:
(-19567879.241,-19567879.241)
WORLD: topright: (39605387.5838,39605387.584) | bottomleft:
(469629.101784,469629.102034)
PIXELS: topright: (2024.0,2024.00000001) | bottomleft: (24.0,24.0000000128)
CELLID: toprightCell: [15, 15] | bottomleftCell: [0, 0]

I'm not getting the same CELLID as you.
Larry

On 3/10/14, 4:58 AM, biodiv wrote:

Before I reopen this bug, please try the following:
First, delete all .pyc files in the anycluster folder. For some odd
reason, I had to do this to get the MapClusterer class use the updated
MapTools.

Troubleshoot if python really is using the new files:
In python code of MapClusterer.py set

|DEBUG = True
|

In a python shell:

| c = MapClusterer()
c.zoom = 3
c.gridSize = 128
cells = c.getClusterCells(viewport3)
|

You should get the following in the last line:

|CELLID: toprightCell: [12, 13] | bottomleftCell: [14, 8]
|

Now print the cells:

|>>> print cells
['12,8', '12,9', '12,10', '12,11', '12,12', '12,13', '13,8', '13,9', '13,10', '13,11', '13,12', '13,13', '14,8', '14,9', '14,10', '14,11', '14,12', '14,13']
|

viewport3 together with zoom 3 and gridSize 128 is your query URL from
a few posts earlier that did not work. In the previous version, this
returned the empty list

|[]
|


Reply to this email directly or view it on GitHub
#6 (comment).

Larry Morroni
610.862.0920
http://morroni.com

I was a bit unexact, sorry. Please try this viewport:

viewport3 = {'left':136.078125, 'top':76.75037266166416, 'right':107.42578125, 'bottom':2.5914519003430008}

from your earlier post:

/anycluster/kmeans/3/128/?left=136.078125&top=76.75037266166416&right=107.42578125&bottom=2.5914519003430008&layer_id=list_5%2C7 HTTP/1.1" 200 

This request did not return any cells in the last version, and should return cells in the new version, when you use

print cells

after calling getClusterCells method