/** * Constructs a new LatLong with the given latitude and longitude values, measured in * microdegrees. * * @param latitudeE6 the latitude value in microdegrees. * @param longitudeE6 the longitude value in microdegrees. * @return the LatLong * @throws IllegalArgumentException if the latitudeE6 or longitudeE6 value is invalid. */ public static LatLong fromMicroDegrees(int latitudeE6, int longitudeE6) { return new LatLong(LatLongUtils.microdegreesToDegrees(latitudeE6), LatLongUtils.microdegreesToDegrees(longitudeE6)); }
private static Coordinate toCoordinate(int latitude, int longitude) { return new Coordinate(LatLongUtils.microdegreesToDegrees(longitude), LatLongUtils.microdegreesToDegrees(latitude)); }
static void readBoundingBox(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) { double minLatitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); double minLongitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); double maxLatitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); double maxLongitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); try { mapFileInfoBuilder.boundingBox = new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude); } catch (IllegalArgumentException e) { throw new MapFileException(e.getMessage()); } }
private void readMapStartPosition(ReadBuffer readBuffer) { if (this.hasStartPosition) { double mapStartLatitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); double mapStartLongitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); try { this.startPosition = new LatLong(mapStartLatitude, mapStartLongitude); } catch (IllegalArgumentException e) { throw new MapFileException(e.getMessage()); } } }
private void decodeWayNodesSingleDelta(LatLong[] waySegment, double tileLatitude, double tileLongitude, ReadBuffer readBuffer) { // get the first way node latitude single-delta offset (VBE-S) double wayNodeLatitude = tileLatitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); // get the first way node longitude single-delta offset (VBE-S) double wayNodeLongitude = tileLongitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); // store the first way node waySegment[0] = new LatLong(wayNodeLatitude, wayNodeLongitude); for (int wayNodesIndex = 1; wayNodesIndex < waySegment.length; ++wayNodesIndex) { // get the way node latitude offset (VBE-S) wayNodeLatitude = wayNodeLatitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); // get the way node longitude offset (VBE-S) wayNodeLongitude = wayNodeLongitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); // Decoding near international date line can return values slightly outside valid [-180°, 180°] due to calculation precision if (wayNodeLongitude < LatLongUtils.LONGITUDE_MIN && (LatLongUtils.LONGITUDE_MIN - wayNodeLongitude) < 0.001) { wayNodeLongitude = LatLongUtils.LONGITUDE_MIN; } else if (wayNodeLongitude > LatLongUtils.LONGITUDE_MAX && (wayNodeLongitude - LatLongUtils.LONGITUDE_MAX) < 0.001) { wayNodeLongitude = LatLongUtils.LONGITUDE_MAX; } waySegment[wayNodesIndex] = new LatLong(wayNodeLatitude, wayNodeLongitude); } }
private void decodeWayNodesDoubleDelta(LatLong[] waySegment, double tileLatitude, double tileLongitude, ReadBuffer readBuffer) { + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); double doubleDeltaLatitude = LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); double doubleDeltaLongitude = LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt());
private static TileCoordinate[] getWayBoundingBox(final TDWay way, byte zoomlevel, int enlargementInMeter) { double maxx = Double.NEGATIVE_INFINITY, maxy = Double.NEGATIVE_INFINITY, minx = Double.POSITIVE_INFINITY, miny = Double.POSITIVE_INFINITY; for (TDNode coordinate : way.getWayNodes()) { maxy = Math.max(maxy, LatLongUtils.microdegreesToDegrees(coordinate.getLatitude())); miny = Math.min(miny, LatLongUtils.microdegreesToDegrees(coordinate.getLatitude())); maxx = Math.max(maxx, LatLongUtils.microdegreesToDegrees(coordinate.getLongitude())); minx = Math.min(minx, LatLongUtils.microdegreesToDegrees(coordinate.getLongitude())); } double[] epsilonsTopLeft = computeTileEnlargement(maxy, enlargementInMeter); double[] epsilonsBottomRight = computeTileEnlargement(miny, enlargementInMeter); TileCoordinate[] bbox = new TileCoordinate[2]; bbox[0] = new TileCoordinate((int) MercatorProjection.longitudeToTileX(minx - epsilonsTopLeft[1], zoomlevel), (int) MercatorProjection.latitudeToTileY(maxy + epsilonsTopLeft[0], zoomlevel), zoomlevel); bbox[1] = new TileCoordinate( (int) MercatorProjection.longitudeToTileX(maxx + epsilonsBottomRight[1], zoomlevel), (int) MercatorProjection.latitudeToTileY(miny - epsilonsBottomRight[0], zoomlevel), zoomlevel); return bbox; }
/** * @param way the TDWay * @return the boundary of way */ public static BoundingBox mapWayToBoundingBox(TDWay way) { TDNode[] wayNodes = way.getWayNodes(); if (wayNodes.length < 3) { return null; } try { double lat = LatLongUtils.microdegreesToDegrees(wayNodes[0].getLatitude()); double lon = LatLongUtils.microdegreesToDegrees(wayNodes[0].getLongitude()); BoundingBox bb = new BoundingBox(lat, lon, lat, lon); for (int i = 1; i < wayNodes.length; i++) { bb = bb.extendCoordinates( LatLongUtils.microdegreesToDegrees(wayNodes[i].getLatitude()), LatLongUtils.microdegreesToDegrees(wayNodes[i].getLongitude())); } return bb; } catch (IllegalArgumentException ex) { LOGGER.warning("wrong coordinates on way: " + way.toString() + "\nLat: " + wayNodes[0].getLatitude() + " Lon: " + wayNodes[0].getLongitude()); } return null; }
@Test public void intToDoubleTest() { double degrees = LatLongUtils.microdegreesToDegrees(MICRO_DEGREES); Assert.assertEquals(DEGREES, degrees, 0); }
double latitude = tileLatitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); double longitude = tileLongitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt());
continue; if (!rBox.contains(LatLongUtils.microdegreesToDegrees(pElem.getWayNodes()[0].getLatitude()), LatLongUtils.microdegreesToDegrees(pElem.getWayNodes()[0].getLongitude()))) { continue;
protected void addPOI(TDNode poi) { if (!poi.isPOI()) { return; } byte minZoomLevel = poi.getZoomAppear(); for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) { // is POI seen in a zoom interval? if (minZoomLevel <= this.zoomIntervalConfiguration.getMaxZoom(i)) { long tileCoordinateX = MercatorProjection.longitudeToTileX( LatLongUtils.microdegreesToDegrees(poi.getLongitude()), this.zoomIntervalConfiguration.getBaseZoom(i)); long tileCoordinateY = MercatorProjection.latitudeToTileY( LatLongUtils.microdegreesToDegrees(poi.getLatitude()), this.zoomIntervalConfiguration.getBaseZoom(i)); TileData tileData = getTileImpl(i, (int) tileCoordinateX, (int) tileCoordinateY); if (tileData != null) { tileData.addPOI(poi); countPoiTags(poi); } } } }
LatLong labelLatLong = null; if (labelPosition != null) { labelLatLong = new LatLong(wayNodes[0][0].latitude + LatLongUtils.microdegreesToDegrees(labelPosition[1]), wayNodes[0][0].longitude + LatLongUtils.microdegreesToDegrees(labelPosition[0]));
/** * Constructs a new LatLong with the given latitude and longitude values, measured in * microdegrees. * * @param latitudeE6 the latitude value in microdegrees. * @param longitudeE6 the longitude value in microdegrees. * @return the LatLong * @throws IllegalArgumentException if the latitudeE6 or longitudeE6 value is invalid. */ public static LatLong fromMicroDegrees(int latitudeE6, int longitudeE6) { return new LatLong(LatLongUtils.microdegreesToDegrees(latitudeE6), LatLongUtils.microdegreesToDegrees(longitudeE6)); }
static void readBoundingBox(ReadBuffer readBuffer, MapFileInfoBuilder mapFileInfoBuilder) { double minLatitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); double minLongitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); double maxLatitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); double maxLongitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); try { mapFileInfoBuilder.boundingBox = new BoundingBox(minLatitude, minLongitude, maxLatitude, maxLongitude); } catch (IllegalArgumentException e) { throw new MapFileException(e.getMessage()); } }
private void readMapStartPosition(ReadBuffer readBuffer) { if (this.hasStartPosition) { double mapStartLatitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); double mapStartLongitude = LatLongUtils.microdegreesToDegrees(readBuffer.readInt()); try { this.startPosition = new LatLong(mapStartLatitude, mapStartLongitude); } catch (IllegalArgumentException e) { throw new MapFileException(e.getMessage()); } } }
private void decodeWayNodesSingleDelta(LatLong[] waySegment, double tileLatitude, double tileLongitude, ReadBuffer readBuffer) { // get the first way node latitude single-delta offset (VBE-S) double wayNodeLatitude = tileLatitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); // get the first way node longitude single-delta offset (VBE-S) double wayNodeLongitude = tileLongitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); // store the first way node waySegment[0] = new LatLong(wayNodeLatitude, wayNodeLongitude); for (int wayNodesIndex = 1; wayNodesIndex < waySegment.length; ++wayNodesIndex) { // get the way node latitude offset (VBE-S) wayNodeLatitude = wayNodeLatitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); // get the way node longitude offset (VBE-S) wayNodeLongitude = wayNodeLongitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); // Decoding near international date line can return values slightly outside valid [-180°, 180°] due to calculation precision if (wayNodeLongitude < LatLongUtils.LONGITUDE_MIN && (LatLongUtils.LONGITUDE_MIN - wayNodeLongitude) < 0.001) { wayNodeLongitude = LatLongUtils.LONGITUDE_MIN; } else if (wayNodeLongitude > LatLongUtils.LONGITUDE_MAX && (wayNodeLongitude - LatLongUtils.LONGITUDE_MAX) < 0.001) { wayNodeLongitude = LatLongUtils.LONGITUDE_MAX; } waySegment[wayNodesIndex] = new LatLong(wayNodeLatitude, wayNodeLongitude); } }
private void decodeWayNodesDoubleDelta(LatLong[] waySegment, double tileLatitude, double tileLongitude, ReadBuffer readBuffer) { + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); double doubleDeltaLatitude = LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); double doubleDeltaLongitude = LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt());
double latitude = tileLatitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt()); double longitude = tileLongitude + LatLongUtils.microdegreesToDegrees(readBuffer.readSignedInt());
LatLong labelLatLong = null; if (labelPosition != null) { labelLatLong = new LatLong(wayNodes[0][0].latitude + LatLongUtils.microdegreesToDegrees(labelPosition[1]), wayNodes[0][0].longitude + LatLongUtils.microdegreesToDegrees(labelPosition[0]));