/** * Create a Point from the given coordinates. * * @param lon The x axis value. Longitude in a geographic projection. * @param lat The y axis value. Latitude in a geographic projection. * @param alt The z axis value. Altitude in a geographic projection. * @return Point instance. */ public static Point from(double lon, double lat, double alt) { return new Point(new SinglePosition(lon, lat, alt)); }
@Override public LinearPositions build() { Boolean isClosed = size >= 4 && first.equals(last); return new LinearPositions(singlePositions, isClosed); }
/** * The x-axis coordinate in map units (degree, kilometer, meter, mile, foot * and inch). If your map is in a geographic projection, this will be the * Longitude. Otherwise, it will be the x coordinate of the map location in * your map units. * * @return the x-axis value of this point. */ public double lon() { return positions().lon(); }
/** * The y-axis coordinate in map units (degree, kilometer, meter, mile, foot * and inch). If your map is in a geographic projection, this will be the * Latitude. Otherwise, it will be the y coordinate of the map location in * your map units. * * @return the y-axis value of this point. */ public double lat() { return positions().lat(); }
/** * The z-axis coordinate in map units (degree, kilometer, meter, mile, foot * and inch). If your map is in a geographic projection, this will be the * Altitude. Otherwise, it will be the z coordinate of the map location in * your map units. * * @return the z-axis value of this point. */ public double alt() { return positions().alt(); }
private static Boolean isPointInside(Feature feature, Coordinates location) { Polygon polygon = (Polygon) feature.geometry(); List<SinglePosition> positions = Lists.newArrayList(polygon.perimeter().positions().children()); if ((positions == null) || (location == null)) { return false; } int wn = 0; for (int i = 0; i < positions.size() - 1; i++) { if (positions.get(i).coordinates().getLat() <= location.getLat()) { if (positions.get(i + 1).coordinates().getLat() > location.getLat()) { if (isLeft(positions.get(i).coordinates(), positions.get(i + 1).coordinates(), location) > 0.0) { ++wn; } } } else { if (positions.get(i + 1).coordinates().getLat() <= location.getLat()) { if (isLeft(positions.get(i).coordinates(), positions.get(i + 1).coordinates(), location) < 0.0) { --wn; } } } } return (wn != 0); }
/** * The x-axis coordinate in map units (degree, kilometer, meter, mile, foot * and inch). If your map is in a geographic projection, this will be the * Longitude. Otherwise, it will be the x coordinate of the map location in * your map units. * * @return the x-axis value of this point. */ public double lon() { return positions().lon(); }
/** * The y-axis coordinate in map units (degree, kilometer, meter, mile, foot * and inch). If your map is in a geographic projection, this will be the * Latitude. Otherwise, it will be the y coordinate of the map location in * your map units. * * @return the y-axis value of this point. */ public double lat() { return positions().lat(); }
/** * The z-axis coordinate in map units (degree, kilometer, meter, mile, foot * and inch). If your map is in a geographic projection, this will be the * Altitude. Otherwise, it will be the z coordinate of the map location in * your map units. * * @return the z-axis value of this point. */ public double alt() { return positions().alt(); }
/** * Create a Point from the given coordinates. * * @param lon The x axis value. Longitude in a geographic projection. * @param lat The y axis value. Latitude in a geographic projection. * @param alt The z axis value. Altitude in a geographic projection. * @return Point instance. */ public static Point from(double lon, double lat, double alt) { return new Point(new SinglePosition(lon, lat, alt)); }
@Override public LinearPositions build() { Boolean isClosed = size >= 4 && first.equals(last); return new LinearPositions(singlePositions, isClosed); }
@Override public Positions positions() { Positions positions = new SinglePosition(Double.NaN, Double.NaN, Double.NaN); for (Geometry<?> geometry : this.geometries) { positions.merge(geometry.positions()); } return positions; }
@Override public Positions positions() { Positions positions = new SinglePosition(Double.NaN, Double.NaN, Double.NaN); for (Geometry<?> geometry : this.geometries) { positions.merge(geometry.positions()); } return positions; }
private static Positions parseSinglePosition(JsonReader in) throws IOException { double lon = in.nextDouble(); double lat = in.nextDouble(); double alt = Double.NaN; if (in.hasNext()) { alt = in.nextDouble(); } // Skip eventual other dimensions while (in.peek() != JsonToken.END_ARRAY) { in.skipValue(); } return new SinglePosition(lon, lat, alt); }