use of com.google.maps.android.projection.SphericalMercatorProjection in project android-maps-utils by googlemaps.
the class GridBasedAlgorithm method getClusters.
@Override
public Set<? extends Cluster<T>> getClusters(double zoom) {
long numCells = (long) Math.ceil(256 * Math.pow(2, zoom) / GRID_SIZE);
SphericalMercatorProjection proj = new SphericalMercatorProjection(numCells);
HashSet<Cluster<T>> clusters = new HashSet<Cluster<T>>();
LongSparseArray<StaticCluster<T>> sparseArray = new LongSparseArray<StaticCluster<T>>();
synchronized (mItems) {
for (T item : mItems) {
Point p = proj.toPoint(item.getPosition());
long coord = getCoord(numCells, p.x, p.y);
StaticCluster<T> cluster = sparseArray.get(coord);
if (cluster == null) {
cluster = new StaticCluster<T>(proj.toLatLng(new Point(Math.floor(p.x) + .5, Math.floor(p.y) + .5)));
sparseArray.put(coord, cluster);
clusters.add(cluster);
}
cluster.add(item);
}
}
return clusters;
}
use of com.google.maps.android.projection.SphericalMercatorProjection in project android-maps-utils by googlemaps.
the class GridBasedAlgorithm method getClusters.
@Override
public Set<? extends Cluster<T>> getClusters(float zoom) {
long numCells = (long) Math.ceil(256 * Math.pow(2, zoom) / mGridSize);
SphericalMercatorProjection proj = new SphericalMercatorProjection(numCells);
HashSet<Cluster<T>> clusters = new HashSet<Cluster<T>>();
LongSparseArray<StaticCluster<T>> sparseArray = new LongSparseArray<StaticCluster<T>>();
synchronized (mItems) {
for (T item : mItems) {
Point p = proj.toPoint(item.getPosition());
long coord = getCoord(numCells, p.x, p.y);
StaticCluster<T> cluster = sparseArray.get(coord);
if (cluster == null) {
cluster = new StaticCluster<T>(proj.toLatLng(new Point(Math.floor(p.x) + .5, Math.floor(p.y) + .5)));
sparseArray.put(coord, cluster);
clusters.add(cluster);
}
cluster.add(item);
}
}
return clusters;
}
use of com.google.maps.android.projection.SphericalMercatorProjection in project wigle-wifi-wardriving by wiglenet.
the class GridBasedAlgorithm method getClusters.
@Override
public Set<? extends Cluster<T>> getClusters(double zoom) {
long numCells = (long) Math.ceil(256 * Math.pow(2, zoom) / GRID_SIZE);
SphericalMercatorProjection proj = new SphericalMercatorProjection(numCells);
HashSet<Cluster<T>> clusters = new HashSet<Cluster<T>>();
LongSparseArray<StaticCluster<T>> sparseArray = new LongSparseArray<StaticCluster<T>>();
synchronized (mItems) {
for (T item : mItems) {
Point p = proj.toPoint(item.getPosition());
long coord = getCoord(numCells, p.x, p.y);
StaticCluster<T> cluster = sparseArray.get(coord);
if (cluster == null) {
cluster = new StaticCluster<T>(proj.toLatLng(new Point(Math.floor(p.x) + .5, Math.floor(p.y) + .5)));
sparseArray.put(coord, cluster);
clusters.add(cluster);
}
cluster.add(item);
}
}
return clusters;
}
Aggregations