/** * @return A dm7 latitude and dm7 longitude concatenated in a long. The first 32 bits are for * the dm7 latitude, and the last 32 bits are for the dm7 longitude. */ public long asConcatenation() { long result = this.latitude.asDm7(); result <<= INT_SIZE; result |= this.longitude.asDm7() & INT_FULL_MASK_AS_LONG; return result; }
protected Point2D asAwtPoint() { return new Point((int) getLongitude().asDm7(), (int) getLatitude().asDm7()); } }
/** * @return The surface of this polygon. Not valid if the polygon self-intersects, and/or * overlaps itself * @see "http://www.mathopenref.com/coordpolygonarea2.html" */ @Override public Surface surface() { long dm7Squared = 0L; final Iterator<Location> loopOnItself = loopOnItself().iterator(); if (!loopOnItself.hasNext()) { return Surface.forDm7Squared(0); } Location current = loopOnItself.next(); Location next = null; while (loopOnItself.hasNext()) { next = loopOnItself.next(); dm7Squared += (current.getLongitude().asDm7() + next.getLongitude().asDm7()) * (current.getLatitude().asDm7() - next.getLatitude().asDm7()); current = next; } return Surface.forDm7Squared(Math.abs(Math.round(dm7Squared / 2.0))); }
private java.awt.Polygon awtPolygon() { if (this.awtPolygon == null) { final int size = size(); final int[] xArray = new int[size]; final int[] yArray = new int[size]; int index = 0; for (final Location location : this) { xArray[index] = (int) location.getLongitude().asDm7(); yArray[index] = (int) location.getLatitude().asDm7(); index++; } this.awtPolygon = new java.awt.Polygon(xArray, yArray, size); } return this.awtPolygon; }
for (final Location location : polyLine) final int latitude = (int) location.getLatitude().asDm7(); final int longitude = (int) location.getLongitude().asDm7(); final int deltaLatitude = latitude - formerLatitude;
@Override public ProtoLocation backwardConvert(final Location location) { final ProtoLocation.Builder protoLocationBuilder = ProtoLocation.newBuilder(); protoLocationBuilder.setLatitude(Math.toIntExact(location.getLatitude().asDm7())); protoLocationBuilder.setLongitude(Math.toIntExact(location.getLongitude().asDm7())); return protoLocationBuilder.build(); }
/** * @return True if this {@link Polygon} is arranged clockwise, false otherwise. * @see <a href="http://stackoverflow.com/questions/1165647"></a> */ public boolean isClockwise() { long sum = 0; long lastLatitude = Long.MIN_VALUE; long lastLongitude = Long.MIN_VALUE; for (final Location point : this) { if (lastLongitude != Long.MIN_VALUE) { sum += (point.getLongitude().asDm7() - lastLongitude) * (point.getLatitude().asDm7() + lastLatitude); } lastLongitude = point.getLongitude().asDm7(); lastLatitude = point.getLatitude().asDm7(); } return sum >= 0; }
protected Rectangle2D asAwtRectangle() { final int xAxis = (int) this.upperLeft().getLongitude().asDm7(); final int yAxis = (int) this.upperLeft().getLatitude().asDm7(); final int width = (int) (this.upperRight().getLongitude().asDm7() - this.upperLeft().getLongitude().asDm7()); final int height = (int) (this.upperLeft().getLatitude().asDm7() - this.lowerLeft().getLatitude().asDm7()); return new java.awt.Rectangle(xAxis, yAxis, width, height); } }
tags.put("latitude", String.valueOf(location.getLatitude().asDm7())); tags.put("longitude", String.valueOf(location.getLongitude().asDm7()));
/** * @param bounds * Bounds to constrain the result * @return A random location within the bounds */ public static Location random(final Rectangle bounds) { final int latitude = RANDOM.ints((int) bounds.lowerLeft().getLatitude().asDm7(), (int) bounds.upperRight().getLatitude().asDm7()).iterator().next(); final int longitude = RANDOM.ints((int) bounds.lowerLeft().getLongitude().asDm7(), (int) bounds.upperRight().getLongitude().asDm7()).iterator().next(); return new Location(Latitude.dm7(latitude), Longitude.dm7(longitude)); }
final double latitudeAsDm7 = shape.start().getLatitude().asDm7() + offsetDistance / shape.dotProductLength() * shape.latitudeSpan(); final double longitudeAsDm7 = shape.start().getLongitude().asDm7()