/** * Converts meters to pixels at latitude for zoom-level. * * @param meters the meters to convert * @param latitude the latitude for the conversion. * @param mapSize precomputed size of map. * @return pixels that represent the meters at the given zoom-level and latitude. */ public static double metersToPixels(float meters, double latitude, long mapSize) { return meters / MercatorProjection.calculateGroundResolution(latitude, mapSize); }
double southPerPixel = MercatorProjection.calculateGroundResolution(fileInfo.southLat(), axisLength * 170); double northPerPixel = MercatorProjection.calculateGroundResolution(fileInfo.northLat(), axisLength * 170);
/** * Calculates the required length and value of the scalebar * * @param unitAdapter the DistanceUnitAdapter to calculate for * @return a {@link ScaleBarLengthAndValue} object containing the required scaleBarLength and scaleBarValue */ protected ScaleBarLengthAndValue calculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter) { this.prevMapPosition = this.mapViewPosition.getMapPosition(); double groundResolution = MercatorProjection.calculateGroundResolution(this.prevMapPosition.latLong.latitude, MercatorProjection.getMapSize(this.prevMapPosition.zoomLevel, this.displayModel.getTileSize())); groundResolution = groundResolution / unitAdapter.getMeterRatio(); int[] scaleBarValues = unitAdapter.getScaleBarValues(); int scaleBarLength = 0; int mapScaleValue = 0; for (int scaleBarValue : scaleBarValues) { mapScaleValue = scaleBarValue; scaleBarLength = (int) (mapScaleValue / groundResolution); if (scaleBarLength < (this.mapScaleBitmap.getWidth() - 10)) { break; } } return new ScaleBarLengthAndValue(scaleBarLength, mapScaleValue); }
/** * Converts meters to pixels at latitude for zoom-level. * * @param meters the meters to convert * @param latitude the latitude for the conversion. * @param mapSize precomputed size of map. * @return pixels that represent the meters at the given zoom-level and latitude. */ public static double metersToPixels(float meters, double latitude, long mapSize) { return meters / MercatorProjection.calculateGroundResolution(latitude, mapSize); }
private double getThresholdForPixel(LatLong latLong) { long mapSize = getMapSize(mapView.getModel().mapViewPosition.getZoomLevel(), getTileSize()); double metersPerPixel = calculateGroundResolution(latLong.latitude, mapSize); return metersPerPixel * SELECTION_CIRCLE_IN_PIXEL; }
double southPerPixel = MercatorProjection.calculateGroundResolution(fileInfo.southLat(), axisLength * 170); double northPerPixel = MercatorProjection.calculateGroundResolution(fileInfo.northLat(), axisLength * 170);
/** * Calculates the required length and value of the scalebar * * @param unitAdapter the DistanceUnitAdapter to calculate for * @return a {@link ScaleBarLengthAndValue} object containing the required scaleBarLength and scaleBarValue */ protected ScaleBarLengthAndValue calculateScaleBarLengthAndValue(DistanceUnitAdapter unitAdapter) { this.prevMapPosition = this.mapViewPosition.getMapPosition(); double groundResolution = MercatorProjection.calculateGroundResolution(this.prevMapPosition.latLong.latitude, MercatorProjection.getMapSize(this.prevMapPosition.zoomLevel, this.displayModel.getTileSize())); groundResolution = groundResolution / unitAdapter.getMeterRatio(); int[] scaleBarValues = unitAdapter.getScaleBarValues(); int scaleBarLength = 0; int mapScaleValue = 0; for (int scaleBarValue : scaleBarValues) { mapScaleValue = scaleBarValue; scaleBarLength = (int) (mapScaleValue / groundResolution); if (scaleBarLength < (this.mapScaleBitmap.getWidth() - 10)) { break; } } return new ScaleBarLengthAndValue(scaleBarLength, mapScaleValue); }