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.upperRightLongitude = rightEnv.getMinX(); this.upperRightLatitude = Math.max(rightEnv.getMaxY(), leftEnv.getMaxY()); this.lowerLeftLatitude = Math.min(rightEnv.getMinY(), leftEnv.getMinY());
/** * Finds all non-horizontal segments intersecting the stabbing line. * The stabbing line is the ray to the right of stabbingRayLeftPt. * * @param stabbingRayLeftPt the left-hand origin of the stabbing line * @return a List of {@link DepthSegments} intersecting the stabbing line */ private List findStabbedSegments(Coordinate stabbingRayLeftPt) { List stabbedSegments = new ArrayList(); for (Iterator i = subgraphs.iterator(); i.hasNext(); ) { BufferSubgraph bsg = (BufferSubgraph) i.next(); // optimization - don't bother checking subgraphs which the ray does not intersect Envelope env = bsg.getEnvelope(); if (stabbingRayLeftPt.y < env.getMinY() || stabbingRayLeftPt.y > env.getMaxY()) continue; findStabbedSegments(stabbingRayLeftPt, bsg.getDirectedEdges(), stabbedSegments); } return stabbedSegments; }
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>"
private void buildIndex() { //Envelope env = ring.getEnvelopeInternal(); tree = new Bintree(); Coordinate[] pts = CoordinateArrays.removeRepeatedPoints(ring.getCoordinates()); List mcList = MonotoneChainBuilder.getChains(pts); for (int i = 0; i < mcList.size(); i++) { MonotoneChain mc = (MonotoneChain) mcList.get(i); Envelope mcEnv = mc.getEnvelope(); interval.min = mcEnv.getMinY(); interval.max = mcEnv.getMaxY(); tree.insert(interval, mc); } }
@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; }