Refine search
private URL getNominatimGeocoderUrl(String address, Envelope bbox) throws IOException { UriBuilder uriBuilder = UriBuilder.fromUri(nominatimUrl); uriBuilder.queryParam("q", address); uriBuilder.queryParam("format", "json"); if (bbox != null) { uriBuilder.queryParam("viewbox", bbox.getMinX() + "," + bbox.getMinY() + "," + bbox.getMaxX() + "," + bbox.getMaxY()); uriBuilder.queryParam("bounded", 1); } else if (viewBox != null) { uriBuilder.queryParam("viewbox", viewBox); uriBuilder.queryParam("bounded", 1); } if (resultLimit != null) { uriBuilder.queryParam("limit", resultLimit); } if (emailAddress != null) { uriBuilder.queryParam("email", emailAddress); } URI uri = uriBuilder.build(); return new URL(uri.toString()); }
@Override public Envelope expandPixels(double marginXPixels, double marginYPixels) { Envelope retval = new Envelope(bbox); retval.expandBy( marginXPixels / tileRequest.width * (bbox.getMaxX() - bbox.getMinX()), marginYPixels / tileRequest.height * (bbox.getMaxY() - bbox.getMinY())); return retval; } };
this.lowerLeftLongitude = rightEnv.getMinX(); this.upperRightLongitude = rightEnv.getMaxX(); this.lowerLeftLatitude = rightEnv.getMinY(); this.upperRightLatitude = rightEnv.getMaxY(); } else if (this.rightEnv.getArea() == 0) { this.lowerLeftLongitude = leftEnv.getMinX(); this.upperRightLongitude = leftEnv.getMaxX(); this.lowerLeftLatitude = leftEnv.getMinY(); this.upperRightLatitude = leftEnv.getMaxY(); } else { this.lowerLeftLongitude = leftEnv.getMinX(); this.upperRightLongitude = rightEnv.getMaxX(); } else { this.lowerLeftLongitude = leftEnv.getMaxX(); this.upperRightLongitude = rightEnv.getMinX(); this.upperRightLatitude = Math.max(rightEnv.getMaxY(), leftEnv.getMaxY()); this.lowerLeftLatitude = Math.min(rightEnv.getMinY(), leftEnv.getMinY());
private void buildIndex() { sweepLine = new SweepLineIndex(); for (int i = 0; i < rings.size(); i++) { LinearRing ring = (LinearRing) rings.get(i); Envelope env = ring.getEnvelopeInternal(); SweepLineInterval sweepInt = new SweepLineInterval(env.getMinX(), env.getMaxX(), ring); sweepLine.add(sweepInt); } }
double minY = floor(extent.getMinY(), _latYStep); double maxY = ceil(extent.getMaxY(), _latYStep); double minX = floor(extent.getMinX(), _lonXStep); double maxX = ceil(extent.getMaxX(), _lonXStep); + region.getMaxY() + "</TOP>" + "<BOTTOM>" + region.getMinY() + "</BOTTOM>" + "<LEFT>" + region.getMinX() + "</LEFT>" + "<RIGHT>" + region.getMaxX() + "</RIGHT>" + "</EXTENT>"
@SuppressWarnings("unchecked") public void mouseClicked() { Envelope screenEnv = new Envelope(new Coordinate(mouseX, mouseY)); screenEnv.expandBy(4, 4); Envelope env = new Envelope(toModelX(screenEnv.getMinX()), toModelX(screenEnv.getMaxX()), toModelY(screenEnv.getMinY()), toModelY(screenEnv.getMaxY())); List<Vertex> nearby = (List<Vertex>) vertexIndex.query(env); selector.verticesSelected(nearby); drawLevel = DRAW_ALL; }
/** * Creates an elliptical {@link Polygon}. * If the supplied envelope is square the * result will be a circle. * * @return an ellipse or circle */ public Polygon createEllipse() { Envelope env = dim.getEnvelope(); double xRadius = env.getWidth() / 2.0; double yRadius = env.getHeight() / 2.0; double centreX = env.getMinX() + xRadius; double centreY = env.getMinY() + yRadius; Coordinate[] pts = new Coordinate[nPts + 1]; int iPt = 0; for (int i = 0; i < nPts; i++) { double ang = i * (2 * Math.PI / nPts); double x = xRadius * Math.cos(ang) + centreX; double y = yRadius * Math.sin(ang) + centreY; pts[iPt++] = coord(x, y); } pts[iPt] = new Coordinate(pts[0]); LinearRing ring = geomFact.createLinearRing(pts); Polygon poly = geomFact.createPolygon(ring, null); return (Polygon) rotate(poly); } /**
public static PointSet regularGrid (Envelope envelope, double gridSizeMeters) { // non-ideal but for now make a grid in projected space // to see why this is wrong, look at a map of Iowa and note that it leans to the left // This is because they started surveying the township and range system (which is a grid) // from the east, and wound up further west in the north than the south, which led them // to resurvey the baseline every 24 miles, which explains why one is often driving // down a rural road in the midwestern US and comes to a point where the road makes two 90- // degree curves in quick succession to reach the new survey baseline. double gridSizeLat = SphericalDistanceLibrary.metersToDegrees(gridSizeMeters); double gridSizeLon = SphericalDistanceLibrary.metersToLonDegrees(gridSizeMeters, (envelope.getMaxY() + envelope.getMinY()) / 2); // how large will it be? int npts = (int) (envelope.getHeight() / gridSizeLat + 1) * (int) (envelope.getWidth() / gridSizeLon + 1); PointSet ret = new PointSet(npts); int idx = 0; for (double lon = envelope.getMinX(); lon < envelope.getMaxX(); lon += gridSizeLon) { for (double lat = envelope.getMinY(); lat < envelope.getMaxY(); lat += gridSizeLat) { PointFeature pf = new PointFeature("" + idx); pf.setLat(lat); pf.setLon(lon); ret.addFeature(pf, idx++); } } return ret; }