private static double[] bufferInDegrees(long tileY, byte zoom, int enlargementInMeter) { if (enlargementInMeter == 0) { return EPSILON_ZERO; } double[] epsilons = new double[2]; double lat = MercatorProjection.tileYToLatitude(tileY, zoom); epsilons[0] = LatLongUtils.latitudeDistance(enlargementInMeter); epsilons[1] = LatLongUtils.longitudeDistance(enlargementInMeter, lat); return epsilons; }
public PolylineContainer(Way way, Tile upperLeft, Tile lowerRight) { this.coordinatesAbsolute = null; this.coordinatesRelativeToTile = null; this.tags = way.tags; this.upperLeft = upperLeft; this.lowerRight = lowerRight; this.layer = way.layer; this.way = way; this.isClosedWay = LatLongUtils.isClosedWay(way.latLongs[0]); if (this.way.labelPosition != null) { this.center = MercatorProjection.getPixelAbsolute(this.way.labelPosition, this.upperLeft.mapSize); } }
private static double[] computeTileEnlargement(double lat, int enlargementInMeter) { if (enlargementInMeter == 0) { return EPSILON_ZERO; } double[] epsilons = new double[2]; epsilons[0] = LatLongUtils.latitudeDistance(enlargementInMeter); epsilons[1] = LatLongUtils.longitudeDistance(enlargementInMeter, lat); return epsilons; }
/** * Converts a tile Y number at a certain zoom level to a latitude coordinate. * * @param tileY the tile Y number that should be converted. * @param zoomLevel the zoom level at which the number should be converted. * @return the latitude value of the tile Y number. */ public static double tileYToLatitude(long tileY, byte zoomLevel) { return pixelYToLatitude(tileY * DUMMY_TILE_SIZE, getMapSize(zoomLevel, DUMMY_TILE_SIZE)); }
/** * Converts a tile X number at a certain zoom level to a longitude coordinate. * * @param tileX the tile X number that should be converted. * @param zoomLevel the zoom level at which the number should be converted. * @return the longitude value of the tile X number. */ public static double tileXToLongitude(long tileX, byte zoomLevel) { return pixelXToLongitude(tileX * DUMMY_TILE_SIZE, getMapSize(zoomLevel, DUMMY_TILE_SIZE)); }
/** * Converts a longitude coordinate (in degrees) to the tile X number at a certain zoom level. * * @param longitude the longitude coordinate that should be converted. * @param zoomLevel the zoom level at which the coordinate should be converted. * @return the tile X number of the longitude value. */ public static int longitudeToTileX(double longitude, byte zoomLevel) { return pixelXToTileX(longitudeToPixelX(longitude, zoomLevel, DUMMY_TILE_SIZE), zoomLevel, DUMMY_TILE_SIZE); }
/** * Constructs a new LatLong with the given latitude and longitude values, measured in * degrees. * * @param latitude the latitude value in degrees. * @param longitude the longitude value in degrees. * @throws IllegalArgumentException if the latitude or longitude value is invalid. */ public LatLong(double latitude, double longitude) throws IllegalArgumentException { this.latitude = LatLongUtils.validateLatitude(latitude); this.longitude = LatLongUtils.validateLongitude(longitude); }
/** * Converts a longitude coordinate (in degrees) to the tile X number at a certain scale factor. * * @param longitude the longitude coordinate that should be converted. * @param scaleFactor the scale factor at which the coordinate should be converted. * @return the tile X number of the longitude value. */ public static int longitudeToTileXWithScaleFactor(double longitude, double scaleFactor) { return pixelXToTileXWithScaleFactor(longitudeToPixelXWithScaleFactor(longitude, scaleFactor, DUMMY_TILE_SIZE), scaleFactor, DUMMY_TILE_SIZE); }
/** * Returns the longitude value in microdegrees of this coordinate. * * @return the longitude value in microdegrees of this coordinate. */ public int getLongitudeE6() { return LatLongUtils.degreesToMicrodegrees(this.longitude); }
/** * @param inputChannel the map file from which the index should be read and cached. * @param capacity the maximum number of entries in the cache. * @throws IllegalArgumentException if the capacity is negative. */ IndexCache(FileChannel inputChannel, int capacity) { this.fileChannel = inputChannel; this.map = new LRUCache<IndexCacheEntryKey, byte[]>(capacity); }
/** * 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); }
/** * Converts a longitude coordinate (in degrees) to a pixel X coordinate at a certain scale factor. * * @param longitude the longitude coordinate that should be converted. * @param scaleFactor the scale factor at which the coordinate should be converted. * @return the pixel X coordinate of the longitude value. */ public static double longitudeToPixelXWithScaleFactor(double longitude, double scaleFactor, int tileSize) { long mapSize = getMapSizeWithScaleFactor(scaleFactor, tileSize); return (longitude + 180) / 360 * mapSize; }
/** * Calculate the spherical distance from this LatLong to another. * <p/> * Use "distance" for faster computation with less accuracy. * * @param other The LatLong to calculate the distance to * @return the distance in meters as a double */ public double vincentyDistance(LatLong other) { return LatLongUtils.vincentyDistance(this, other); } }
/** * Converts a tile X number at a certain scale to a longitude coordinate. * * @param tileX the tile X number that should be converted. * @param scaleFactor the scale factor at which the number should be converted. * @return the longitude value of the tile X number. */ public static double tileXToLongitudeWithScaleFactor(long tileX, double scaleFactor) { return pixelXToLongitudeWithScaleFactor(tileX * DUMMY_TILE_SIZE, scaleFactor, DUMMY_TILE_SIZE); }
/** * Calculate the spherical distance from this LatLong to another. * <p/> * Use vincentyDistance for more accuracy but less performance. * * @param other The LatLong to calculate the distance to * @return the distance in meters as a double */ public double sphericalDistance(LatLong other) { return LatLongUtils.sphericalDistance(this, other); }
/** * Calculates the absolute pixel position for a map size and tile size relative to origin * * @param latLong the geographic position. * @param mapSize precomputed size of map. * @return the relative pixel position to the origin values (e.g. for a tile) */ public static Point getPixelRelative(LatLong latLong, long mapSize, Point origin) { return getPixelRelative(latLong, mapSize, origin.x, origin.y); }
@Override protected boolean removeEldestEntry(Map.Entry<K, V> eldest) { return size() > this.capacity; } }
/** * Converts meters to pixels at latitude for zoom-level. * * @param meters the meters to convert * @param latitude the latitude for the conversion. * @param scaleFactor the scale factor for the conversion. * @return pixels that represent the meters at the given zoom-level and latitude. */ public static double metersToPixelsWithScaleFactor(float meters, double latitude, double scaleFactor, int tileSize) { return meters / MercatorProjection.calculateGroundResolutionWithScaleFactor(latitude, scaleFactor, tileSize); }
/** * Returns the destination point from this point having travelled the given distance on the * given initial bearing (bearing normally varies around path followed). * * @param distance the distance travelled, in same units as earth radius (default: meters) * @param bearing the initial bearing in degrees from north * @return the destination point * @see <a href="http://www.movable-type.co.uk/scripts/latlon.js">latlon.js</a> */ public LatLong destinationPoint(double distance, float bearing) { return LatLongUtils.destinationPoint(this, distance, bearing); }
public MockTDNode(double lat, double lon) { super(0, LatLongUtils.degreesToMicrodegrees(lat), LatLongUtils.degreesToMicrodegrees(lon), (short) 0, (byte) 0, null, null); } }