@@ -47,8 +47,9 @@ class ObservationPointsOverlay extends Overlay {
47
47
private final int mSize3px ;
48
48
49
49
LinkedHashMap <Integer , ObservationPoint > mHashedGrid ;
50
+ private Point mHashedGridAnchorPoint = new Point (0 ,0 );
50
51
51
- ObservationPointsOverlay (Context ctx , MapView mapView ) {
52
+ ObservationPointsOverlay (Context ctx ) {
52
53
super (ctx );
53
54
mConvertPx = new DevicePixelConverter (ctx );
54
55
@@ -91,7 +92,7 @@ void update(ObservationPoint obsPoint, MapView mapView, boolean isMlsPointUpdate
91
92
92
93
if (!isMlsPointUpdate ) {
93
94
// add to hashed grid
94
- addToGridHash (obsPoint , point );
95
+ addToGridHash (obsPoint , point , new Point ( mapView . getScrollX (), mapView . getScrollY ()) );
95
96
}
96
97
97
98
mapView .postInvalidate ();
@@ -113,8 +114,8 @@ private void drawWifiScan(Canvas c, Point p) {
113
114
c .drawCircle (p .x , p .y , size , mWifiPaint );
114
115
}
115
116
116
- private void addToGridHash (ObservationPoint obsPoint , Point screenPoint ) {
117
- int hash = toGridPoint (screenPoint .x , screenPoint .y );
117
+ private void addToGridHash (ObservationPoint obsPoint , Point screenPoint , Point currentScroll ) {
118
+ int hash = hashedGridPoint (screenPoint .x , screenPoint . y , currentScroll . x , currentScroll .y );
118
119
ObservationPoint gp = mHashedGrid .get (hash );
119
120
if (gp == null || toTypeBitField (obsPoint ) > toTypeBitField (gp )) {
120
121
mHashedGrid .put (hash , obsPoint );
@@ -123,21 +124,23 @@ private void addToGridHash(ObservationPoint obsPoint, Point screenPoint) {
123
124
124
125
public void zoomChanged (MapView mapView ) {
125
126
mHashedGrid = new LinkedHashMap <Integer , ObservationPoint >();
127
+ mHashedGridAnchorPoint = new Point (mapView .getScrollX (), mapView .getScrollY ());
126
128
final Projection pj = mapView .getProjection ();
127
129
LinkedList <ObservationPoint > points = ObservedLocationsReceiver .getInstance ().getObservationPoints ();
128
130
final Iterator <ObservationPoint > i = points .iterator ();
129
131
final Point gps = new Point ();
130
132
ObservationPoint point ;
133
+ Point zero = new Point (0 , 0 );
131
134
while (i .hasNext ()) {
132
135
point = i .next ();
133
136
pj .toPixels (point .pointGPS , gps );
134
- addToGridHash (point , gps );
137
+ addToGridHash (point , gps , zero );
135
138
}
136
139
}
137
140
138
- private int toGridPoint (int x , int y ) {
139
- x = (int ) Math .round (x / (mSize3px * 2.0 ));
140
- y = (int ) Math .round (y / (mSize3px * 2.0 ));
141
+ private int hashedGridPoint (int x , int y , int scrollX , int scrollY ) {
142
+ x = (int ) Math .round (( x - mHashedGridAnchorPoint . x + scrollX ) / (mSize3px * 2.0 ));
143
+ y = (int ) Math .round (( y - mHashedGridAnchorPoint . y + scrollY ) / (mSize3px * 2.0 ));
141
144
return x * 10000 + y ;
142
145
}
143
146
0 commit comments