/** Constructor. *@param planetModel is the planet model. */ public GeoWorld(final PlanetModel planetModel) { super(planetModel); originPoint = new GeoPoint(planetModel.ab, 1.0, 0.0, 0.0); }
@SuppressWarnings("unchecked") @Override public T pointXY(double x, double y) { GeoPoint point = new GeoPoint(planetModel, y * DistanceUtils.DEGREES_TO_RADIANS, x * DistanceUtils.DEGREES_TO_RADIANS); points.add(point); return (T) this; }
/** Add a point to the path. *@param lat is the latitude of the point. *@param lon is the longitude of the point. */ public void addPoint(final double lat, final double lon) { if (isDone) throw new IllegalStateException("Can't call addPoint() if done() already called"); points.add(new GeoPoint(planetModel, lat, lon)); }
@SuppressWarnings("unchecked") @Override public T pointXYZ(double x, double y, double z) { GeoPoint point = new GeoPoint(x, y, z); if (!points.contains(point)) { points.add(point); } return (T) this; } }
/** Add a point to the path. *@param lat is the latitude of the point. *@param lon is the longitude of the point. */ public void addPoint(final double lat, final double lon) { if (isDone) throw new IllegalStateException("Can't call addPoint() if done() already called"); points.add(new GeoPoint(planetModel, lat, lon)); }
/** Compute a GeoPoint that's based on (x,y,z) values, but is scaled to actually be on the planet surface. * @param x is the x value. * @param y is the y value. * @param z is the z value. * @return the scaled point. */ public GeoPoint createSurfacePoint(final double x, final double y, final double z) { // The equation of the surface is: // (x^2 / a^2 + y^2 / b^2 + z^2 / c^2) = 1 // We will need to scale the passed-in x, y, z values: // ((tx)^2 / a^2 + (ty)^2 / b^2 + (tz)^2 / c^2) = 1 // t^2 * (x^2 / a^2 + y^2 / b^2 + z^2 / c^2) = 1 // t = sqrt ( 1 / (x^2 / a^2 + y^2 / b^2 + z^2 / c^2)) final double t = Math.sqrt(1.0 / (x*x*inverseAbSquared + y*y*inverseAbSquared + z*z*inverseCSquared)); return new GeoPoint(t*x, t*y, t*z); }
/** Compute a GeoPoint that's a bisection between two other GeoPoints. * @param pt1 is the first point. * @param pt2 is the second point. * @return the bisection point, or null if a unique one cannot be found. */ public GeoPoint bisection(final GeoPoint pt1, final GeoPoint pt2) { final double A0 = (pt1.x + pt2.x) * 0.5; final double B0 = (pt1.y + pt2.y) * 0.5; final double C0 = (pt1.z + pt2.z) * 0.5; final double denom = inverseAbSquared * A0 * A0 + inverseAbSquared * B0 * B0 + inverseCSquared * C0 * C0; if(denom < Vector.MINIMUM_RESOLUTION) { // Bisection is undefined return null; } final double t = Math.sqrt(1.0 / denom); return new GeoPoint(t * A0, t * B0, t * C0); }
/** * Add a point to the polygon. * Accepts only values in the following ranges: lat: {@code -PI/2 -> PI/2}, lon: {@code -PI -> PI} * * @param latitude is the latitude of the next point. * @param longitude is the longitude of the next point. * @param isInternalEdge is true if the edge just added with this point should be considered "internal", and not * intersected as part of the intersects() operation. */ public void addPoint(final double latitude, final double longitude, final boolean isInternalEdge) { if (isDone) throw new IllegalStateException("Can't call addPoint() if done() already called"); if (isInternalEdge) isInternalEdges.set(points.size() - 1); points.add(new GeoPoint(planetModel, latitude, longitude)); }
/** * Add a point to the polygon. * Accepts only values in the following ranges: lat: {@code -PI/2 -> PI/2}, lon: {@code -PI -> PI} * * @param latitude is the latitude of the next point. * @param longitude is the longitude of the next point. * @param isInternalEdge is true if the edge just added with this point should be considered "internal", and not * intersected as part of the intersects() operation. */ public void addPoint(final double latitude, final double longitude, final boolean isInternalEdge) { if (isDone) throw new IllegalStateException("Can't call addPoint() if done() already called"); if (isInternalEdge) isInternalEdges.set(points.size() - 1); points.add(new GeoPoint(planetModel, latitude, longitude)); }
/** Constructor. *@param planetModel is the planet model. *@param topLat is the top latitude of the zone. */ public GeoSouthLatitudeZone(final PlanetModel planetModel, final double topLat) { super(planetModel); this.topLat = topLat; final double sinTopLat = Math.sin(topLat); this.cosTopLat = Math.cos(topLat); // Compute an interior point. Pick one whose lat is between top and bottom. final double middleLat = (topLat - Math.PI * 0.5) * 0.5; final double sinMiddleLat = Math.sin(middleLat); this.interiorPoint = new GeoPoint(planetModel, sinMiddleLat, 0.0, Math.sqrt(1.0 - sinMiddleLat * sinMiddleLat), 1.0); this.topBoundaryPoint = new GeoPoint(planetModel, sinTopLat, 0.0, Math.sqrt(1.0 - sinTopLat * sinTopLat), 1.0); this.topPlane = new SidedPlane(interiorPoint, planetModel, sinTopLat); this.edgePoints = new GeoPoint[]{topBoundaryPoint}; }
/** Constructor. *@param planetModel is the planet model. *@param bottomLat is the bottom latitude. */ public GeoNorthLatitudeZone(final PlanetModel planetModel, final double bottomLat) { super(planetModel); this.bottomLat = bottomLat; final double sinBottomLat = Math.sin(bottomLat); this.cosBottomLat = Math.cos(bottomLat); // Compute an interior point. Pick one whose lat is between top and bottom. final double middleLat = (Math.PI * 0.5 + bottomLat) * 0.5; final double sinMiddleLat = Math.sin(middleLat); this.interiorPoint = new GeoPoint(planetModel, sinMiddleLat, 0.0, Math.sqrt(1.0 - sinMiddleLat * sinMiddleLat), 1.0); this.bottomBoundaryPoint = new GeoPoint(planetModel, sinBottomLat, 0.0, Math.sqrt(1.0 - sinBottomLat * sinBottomLat), 1.0); this.bottomPlane = new SidedPlane(interiorPoint, planetModel, sinBottomLat); this.edgePoints = new GeoPoint[]{bottomBoundaryPoint}; }
/** Constructor. *@param planetModel is the planet model to use. *@param latitude is the latitude of the latitude zone. */ public GeoDegenerateLatitudeZone(final PlanetModel planetModel, final double latitude) { super(planetModel); this.latitude = latitude; this.sinLatitude = Math.sin(latitude); double cosLatitude = Math.cos(latitude); this.plane = new Plane(planetModel, sinLatitude); // Compute an interior point. interiorPoint = new GeoPoint(planetModel, sinLatitude, 0.0, cosLatitude, 1.0); edgePoints = new GeoPoint[]{interiorPoint}; }
public GeoComplexPolygon createGeoComplexPolygon(final PlanetModel planetModel, final List<List<GeoPoint>> pointsList, final GeoPoint testPoint) { // Is it inside or outside? final Boolean isTestPointInside = isInsidePolygon(testPoint, points); if (isTestPointInside != null) { try { // Legal pole if (isTestPointInside == poleMustBeInside) { return new GeoComplexPolygon(planetModel, pointsList, testPoint, isTestPointInside); } else { return new GeoComplexPolygon(planetModel, pointsList, new GeoPoint(-testPoint.x, -testPoint.y, -testPoint.z), !isTestPointInside); } } catch (IllegalArgumentException e) { // Probably bad choice of test point. return null; } } // If pole choice was illegal, try another one return null; }
/** * Accepts only values in the following ranges: lon: {@code -PI -> PI} */ public GeoDegenerateLongitudeSlice(final PlanetModel planetModel, final double longitude) { super(planetModel); // Argument checking if (longitude < -Math.PI || longitude > Math.PI) throw new IllegalArgumentException("Longitude out of range"); this.longitude = longitude; final double sinLongitude = Math.sin(longitude); final double cosLongitude = Math.cos(longitude); this.plane = new Plane(cosLongitude, sinLongitude); // We need a bounding plane too, which is perpendicular to the longitude plane and sided so that the point (0.0, longitude) is inside. this.interiorPoint = new GeoPoint(planetModel, 0.0, sinLongitude, 1.0, cosLongitude); this.boundingPlane = new SidedPlane(interiorPoint, -sinLongitude, cosLongitude); this.edgePoints = new GeoPoint[]{interiorPoint}; this.planePoints = new GeoPoint[]{planetModel.NORTH_POLE, planetModel.SOUTH_POLE}; }
/** * Constructor for deserialization. * @param planetModel is the planet model. * @param inputStream is the input stream. */ public GeoComplexPolygon(final PlanetModel planetModel, final InputStream inputStream) throws IOException { this(planetModel, readPointsList(planetModel, inputStream), new GeoPoint(planetModel, inputStream), SerializableObject.readBoolean(inputStream)); }
@Override public double distance(Point from, double toX, double toY) { GeoPoint fromGeoPoint; if (from instanceof Geo3dPointShape) { fromGeoPoint = (((Geo3dPointShape) from).shape).getCenter(); } else { fromGeoPoint = new GeoPoint(planetModel, from.getY() * DistanceUtils.DEGREES_TO_RADIANS, from.getX() * DistanceUtils.DEGREES_TO_RADIANS); } GeoPoint toGeoPoint = new GeoPoint(planetModel, toY * DistanceUtils.DEGREES_TO_RADIANS, toX * DistanceUtils.DEGREES_TO_RADIANS); return planetModel.surfaceDistance(fromGeoPoint, toGeoPoint) * DistanceUtils.RADIANS_TO_DEGREES; }
/** Decode GeoPoint value from long docvalues value. * @param docValue is the doc values value. * @return the GeoPoint. */ public static GeoPoint decodePoint(final long docValue) { return new GeoPoint(decodeX(((int)(docValue >> 42)) & 0x1FFFFF), decodeY(((int)(docValue >> 21)) & 0x1FFFFF), decodeZ(((int)(docValue)) & 0x1FFFFF)); }
@Override public Point pointXYZ(double x, double y, double z) { GeoPoint point = new GeoPoint(x, y, z); GeoPointShape pointShape = GeoPointShapeFactory.makeGeoPointShape(planetModel, point.getLatitude(), point.getLongitude()); return new Geo3dPointShape(pointShape, context); //throw new UnsupportedOperationException(); }
private int relate(Point p) { GeoPoint point = new GeoPoint(shape.getPlanetModel(), p.getY() * DistanceUtils.DEGREES_TO_RADIANS, p.getX() * DistanceUtils.DEGREES_TO_RADIANS); if (shape.isWithin(point)) { return GeoArea.WITHIN; } return GeoArea.DISJOINT; }
/** * Creates a new Geo3DPoint field with the specified latitude, longitude (in degrees). * * @throws IllegalArgumentException if the field name is null or latitude or longitude are out of bounds */ public Geo3DPoint(String name, double latitude, double longitude) { super(name, TYPE); GeoUtils.checkLatitude(latitude); GeoUtils.checkLongitude(longitude); // Translate latitude/longitude to x,y,z: final GeoPoint point = new GeoPoint(PlanetModel.WGS84, Geo3DUtil.fromDegrees(latitude), Geo3DUtil.fromDegrees(longitude)); fillFieldsData(point.x, point.y, point.z); }