Java Code Examples for com.vividsolutions.jts.geom.Envelope#getMinX()

The following examples show how to use com.vividsolutions.jts.geom.Envelope#getMinX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalProfile.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
public LocalProfile(Envelope bounds, int minTileSize) {
	this.origin = new Coordinate(bounds.getMinX(), bounds.getMinY());
	this.bounds = bounds;
	tileWidth = minTileSize;
	tileHeight = minTileSize;
	double ratio = bounds.getWidth() / bounds.getHeight();
	if (ratio >= 1) {
		tileWidth = (int) Math.ceil(tileHeight * ratio);
		maxResolution = bounds.getHeight() / tileHeight;
	} else {
		tileHeight = (int) Math.ceil(tileWidth / ratio);
		maxResolution = bounds.getWidth() / tileWidth;
	}
	for (int i = 0; i < 30; i++) {
		resolutions[i] = getResolution(i);
	}
}
 
Example 2
Source File: OSMMap.java    From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void drawDebugTapEnvelope(MapView pMapView, ILatLng pPosition, float zoom) {
    Envelope env = jtsModel.createTapEnvelope(pPosition, zoom);
    PathOverlay path;
    if (debugTapEnvelopePath == null) {
        path = new PathOverlay();
        debugTapEnvelopePath = path;
        pMapView.getOverlays().add(path);
    } else {
        path = debugTapEnvelopePath;
    }
    Paint paint = path.getPaint();
    paint.setStrokeWidth(0); // hairline mode
    paint.setARGB(200, 0, 255, 255);
    double maxX = env.getMaxX();
    double maxY = env.getMaxY();
    double minX = env.getMinX();
    double minY = env.getMinY();
    path.clearPath();
    path.addPoint(minY, minX);
    path.addPoint(maxY, minX);
    path.addPoint(maxY, maxX);
    path.addPoint(minY, maxX);
    path.addPoint(minY, minX);
}
 
Example 3
Source File: Quadtree.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Ensure that the envelope for the inserted item has non-zero extents.
 * Use the current minExtent to pad the envelope, if necessary
 */
public static Envelope ensureExtent(Envelope itemEnv, double minExtent)
{
  //The names "ensureExtent" and "minExtent" are misleading -- sounds like
  //this method ensures that the extents are greater than minExtent.
  //Perhaps we should rename them to "ensurePositiveExtent" and "defaultExtent".
  //[Jon Aquino]
  double minx = itemEnv.getMinX();
  double maxx = itemEnv.getMaxX();
  double miny = itemEnv.getMinY();
  double maxy = itemEnv.getMaxY();
  // has a non-zero extent
  if (minx != maxx && miny != maxy) return itemEnv;

  // pad one or both extents
  if (minx == maxx) {
    minx = minx - minExtent / 2.0;
    maxx = minx + minExtent / 2.0;
  }
  if (miny == maxy) {
    miny = miny - minExtent / 2.0;
    maxy = miny + minExtent / 2.0;
  }
  return new Envelope(minx, maxx, miny, maxy);
}
 
Example 4
Source File: CreateRandomShapeFunctions.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static Geometry haltonPointsWithBases(Geometry g, int nPts, int basei, int basej)
{
  Envelope env = FunctionsUtil.getEnvelopeOrDefault(g);
  Coordinate[] pts = new Coordinate[nPts];
  double baseX = env.getMinX();
  double baseY = env.getMinY();
  
  int i = 0;
  while (i < nPts) {
    double x = baseX + env.getWidth() * haltonOrdinate(i + 1, basei);
    double y = baseY + env.getHeight() * haltonOrdinate(i + 1, basej);
    Coordinate p = new Coordinate(x, y);
    if (! env.contains(p))
      continue;
    pts[i++] = p;
  }
  return FunctionsUtil.getFactoryOrDefault(g).createMultiPoint(pts);
}
 
Example 5
Source File: CreateRandomShapeFunctions.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static Geometry randomSegments(Geometry g, int nPts) {
  Envelope env = FunctionsUtil.getEnvelopeOrDefault(g);
  GeometryFactory geomFact = FunctionsUtil.getFactoryOrDefault(g);
  double xLen = env.getWidth();
  double yLen = env.getHeight();

  List lines = new ArrayList();

  for (int i = 0; i < nPts; i++) {
    double x0 = env.getMinX() + xLen * Math.random();
    double y0 = env.getMinY() + yLen * Math.random();
    double x1 = env.getMinX() + xLen * Math.random();
    double y1 = env.getMinY() + yLen * Math.random();
    lines.add(geomFact.createLineString(new Coordinate[] {
        new Coordinate(x0, y0), new Coordinate(x1, y1) }));
  }
  return geomFact.buildGeometry(lines);
}
 
Example 6
Source File: CreateRandomShapeFunctions.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
public static Geometry randomSegmentsInGrid(Geometry g, int nPts) {
  Envelope env = FunctionsUtil.getEnvelopeOrDefault(g);
  GeometryFactory geomFact = FunctionsUtil.getFactoryOrDefault(g);

  int nCell = (int) Math.sqrt(nPts) + 1;

  double xLen = env.getWidth() / nCell;
  double yLen = env.getHeight() / nCell;

  List lines = new ArrayList();

  for (int i = 0; i < nCell; i++) {
    for (int j = 0; j < nCell; j++) {
      double x0 = env.getMinX() + i * xLen + xLen * Math.random();
      double y0 = env.getMinY() + j * yLen + yLen * Math.random();
      double x1 = env.getMinX() + i * xLen + xLen * Math.random();
      double y1 = env.getMinY() + j * yLen + yLen * Math.random();
      lines.add(geomFact.createLineString(new Coordinate[] {
          new Coordinate(x0, y0), new Coordinate(x1, y1) }));
    }
  }
  return geomFact.buildGeometry(lines);
}
 
Example 7
Source File: Envelope3D.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Computes the distance between this and another <code>Envelope</code>. The distance between overlapping Envelopes
 * is 0. Otherwise, the distance is the Euclidean distance between the closest points.
 */
@Override
public double distance(final Envelope env) {
	if (intersects(env)) { return 0; }

	double dx = 0.0;
	if (getMaxX() < env.getMinX()) {
		dx = env.getMinX() - getMaxX();
	} else if (getMinX() > env.getMaxX()) {
		dx = getMinX() - env.getMaxX();
	}

	double dy = 0.0;
	if (getMaxY() < env.getMinY()) {
		dy = env.getMinY() - getMaxY();
	} else if (getMinY() > env.getMaxY()) {
		dy = getMinY() - env.getMaxY();
	}

	double dz = 0.0;
	final double otherMinZ = getMinZOf(env);
	final double otherMaxZ = getMaxZOf(env);
	if (maxz < otherMinZ) {
		dz = otherMinZ - maxz;
	} else if (minz > otherMaxZ) {
		dz = minz - otherMaxZ;
	}

	// if either is zero, the envelopes overlap either vertically or
	// horizontally
	if (dx == 0.0 && dz == 0.0) { return dy; }
	if (dy == 0.0 && dz == 0.0) { return dx; }
	if (dx == 0.0 && dy == 0.0) { return dz; }
	return Math.sqrt(dx * dx + dy * dy + dz * dz);
}
 
Example 8
Source File: TmsController.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Get a raster layer tile from the TMS server.
 *
 * @param layerId layer id
 * @param crs crs, e.g. EPSG:4326
 * @param tileLevel tile level, 0 is highest level
 * @param xIndex x-index of tile
 * @param yIndex y-index of tile
 * @param request servlet request
 * @param response servlet response
 * @throws Exception
 */
@RequestMapping(value = MAPPING + "{layerId}@{crs}/{tileLevel}/{xIndex}/{yIndex}.{imageFormat}",
		method = RequestMethod.GET)
public void getRasterTile(@PathVariable String layerId, @PathVariable String crs, @PathVariable Integer tileLevel,
		@PathVariable Integer xIndex, @PathVariable Integer yIndex, @PathVariable String imageFormat,
		HttpServletRequest request, HttpServletResponse response) throws Exception {
	Crs tileCrs = geoService.getCrs2(crs);
	// calculate the tile extent
	Envelope maxExtent = getRasterLayerExtent(layerId, crs);
	RasterLayer layer = configurationService.getRasterLayer(layerId);
	double resolution = 0;
	if (layer.getLayerInfo().getResolutions().size() > 0) {
		// use resolutions of server for raster layer (as yet not reprojectable)
		resolution = layer.getLayerInfo().getResolutions().get(tileLevel);
	} else {
		// if no resolutions, fall back to quad tree numbers
		resolution = 1 / getScale(layer.getLayerInfo().getTileWidth(), tileLevel, layer.getLayerInfo()
				.getMaxExtent().getWidth());
	}
	double centerX = maxExtent.getMinX() + (xIndex + 0.5) * resolution * layer.getLayerInfo().getTileWidth();
	double centerY = maxExtent.getMinY() + (yIndex + 0.5) * resolution * layer.getLayerInfo().getTileHeight();
	Envelope tileBounds = new Envelope(centerX, centerX, centerY, centerY);
	List<RasterTile> tiles = rasterLayerService.getTiles(layerId, tileCrs, tileBounds, 1 / resolution);
	if (tiles.size() == 1) {
		log.debug("Rendering raster layer tile " + layerId + "/" + tileLevel + "-" + xIndex + "-" + yIndex);
		log.debug("Url = " + tiles.get(0).getUrl());
		log.debug("Tile = " + tiles.get(0));
		String url = tiles.get(0).getUrl();
		if (isRedirectRasterLayers()) {
			response.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
			response.setHeader("Location", url);
		} else {
			writeToResponse(layer, url.replace(".jpeg", ".png"), request, response);
		}
	}
}
 
Example 9
Source File: StressTestHarness.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
Geometry createRandomTestGeometry(Envelope env, double size, int nPts)
{
	double width = env.getWidth();
	double xOffset = width * Math.random();
	double yOffset = env.getHeight() * Math.random();
  Coordinate basePt = new Coordinate(
  				env.getMinX() + xOffset,
  				env.getMinY() + yOffset);
  Geometry test = createTestCircle(basePt, size, nPts);
  if (test instanceof Polygon && Math.random() > 0.5) {
  	test = test.getBoundary();
  }
  return test;
}
 
Example 10
Source File: PreparedPolygonIntersectsStressTest.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
LineString createTestLine(Envelope env, double size, int nPts)
{
	double width = env.getWidth();
	double xOffset = width * Math.random();
	double yOffset = env.getHeight() * Math.random();
  Coordinate basePt = new Coordinate(
  				env.getMinX() + xOffset,
  				env.getMinY() + yOffset);
  LineString line = createTestLine(basePt, size, nPts);
  return line;
}
 
Example 11
Source File: Node.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Node(Envelope env, int level)
{
  //this.parent = parent;
  this.env = env;
  this.level = level;
  centrex = (env.getMinX() + env.getMaxX()) / 2;
  centrey = (env.getMinY() + env.getMaxY()) / 2;
}
 
Example 12
Source File: NodeBase.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Gets the index of the subquad that wholly contains the given envelope.
 * If none does, returns -1.
 * 
 * @return the index of the subquad that wholly contains the given envelope
 * or -1 if no subquad wholly contains the envelope
 */
public static int getSubnodeIndex(Envelope env, double centrex, double centrey)
{
  int subnodeIndex = -1;
  if (env.getMinX() >= centrex) {
    if (env.getMinY() >= centrey) subnodeIndex = 3;
    if (env.getMaxY() <= centrey) subnodeIndex = 1;
  }
  if (env.getMaxX() <= centrex) {
    if (env.getMinY() >= centrey) subnodeIndex = 2;
    if (env.getMaxY() <= centrey) subnodeIndex = 0;
  }
  return subnodeIndex;
}
 
Example 13
Source File: KdTree.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void queryNode(KdNode currentNode,
    Envelope queryEnv, boolean odd, KdNodeVisitor visitor) {
  if (currentNode == null)
    return;

  double min;
  double max;
  double discriminant;
  if (odd) {
    min = queryEnv.getMinX();
    max = queryEnv.getMaxX();
    discriminant = currentNode.getX();
  } else {
    min = queryEnv.getMinY();
    max = queryEnv.getMaxY();
    discriminant = currentNode.getY();
  }
  boolean searchLeft = min < discriminant;
  boolean searchRight = discriminant <= max;

  // search is computed via in-order traversal
  if (searchLeft) {
    queryNode(currentNode.getLeft(), queryEnv, !odd, visitor);
  }
  if (queryEnv.contains(currentNode.getCoordinate())) {
    visitor.visit(currentNode);
  }
  if (searchRight) {
    queryNode(currentNode.getRight(), queryEnv, !odd, visitor);
  }

}
 
Example 14
Source File: CrsTransformImpl.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param id id
 * @param source source CRS
 * @param target target CRS
 * @param mathTransform transformation
 * @param transformableEnvelope bounding bow of transformable area
 */
public CrsTransformImpl(String id, Crs source, Crs target, MathTransform mathTransform,
		Envelope transformableEnvelope) {
	this(id, source, target, mathTransform);
	if (null != transformableEnvelope) {
		this.transformableEnvelope = transformableEnvelope;
		this.transformableBbox = new Bbox(transformableEnvelope.getMinX(), transformableEnvelope.getMinY(),
				transformableEnvelope.getMaxX(), transformableEnvelope.getMaxY());
		this.transformableGeometry = JTS.toGeometry(transformableEnvelope);
	}
}
 
Example 15
Source File: SVGTestWriter.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public String write(Testable testable) {
    StringBuffer text = new StringBuffer();
    
    Geometry ga = testable.getGeometry(0);
    Geometry gb = testable.getGeometry(1);
    
    Envelope env = new Envelope();
    if (ga != null) env.expandToInclude(ga.getEnvelopeInternal());
    if (gb != null) env.expandToInclude(gb.getEnvelopeInternal());
    
    String viewBox = env.getMinX() + " " + env.getMinY() + " " + env.getMaxX() + " " + env.getMaxY();
    
    text.append("<?xml version='1.0' standalone='no'?>\n");
    text.append("<!DOCTYPE svg PUBLIC '-//W3C//DTD SVG 1.1//EN' 'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'>\n");
    text.append("<svg width='400' height='400' viewBox='" + viewBox + "'  version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>\n");
    String name = testable.getName() == null ? "" : testable.getName();
    String description = testable.getDescription() == null ? "" : testable.getDescription();
    //text.append("          \"" + name + "\",\n");
    text.append("  <desc>" + description + "</desc>\n");
    
    String a = writeGeometryStyled(ga, "#bbbbff", "#0000ff");
    String b = writeGeometryStyled(gb, "#ffbbbb", "#ff0000");
    text.append(a + "\n");
    text.append("\n");
    text.append(b + "\n");
    text.append("</svg>\n");
    return text.toString();
}
 
Example 16
Source File: GeometryEditPanel.java    From jts with GNU Lesser General Public License v2.1 4 votes vote down vote up
private void drawMark(Graphics2D g) {
  if (markPoint == null)
    return;
  
  String markLabel = markPoint.x + ",  " + markPoint.y;
  int strWidth = g.getFontMetrics().stringWidth(markLabel);

  double markSize = AppConstants.HIGHLIGHT_SIZE;
  Point2D highlightPointView = viewport.toView(markPoint);
  double markX = highlightPointView.getX();
  double markY = highlightPointView.getY();
  Ellipse2D.Double shape = new Ellipse2D.Double(
      markX - markSize / 2, 
      markY - markSize / 2,
      markSize, markSize);
  AWTUtil.setStroke(g, 4);
  g.setColor(AppConstants.HIGHLIGHT_CLR);
  g.draw(shape);
  
  // draw label box
  Envelope viewEnv = viewport.getViewEnv();
  
  int bottomOffset = 10;
  int boxHgt = 20;
  int boxPadX = 20;
  int boxWidth = strWidth + 2 * boxPadX;
  int arrowWidth = 10;
  int arrowOffset = 2;
  int labelOffsetY = 5;
  
  int bottom = (int) viewEnv.getMaxY() - bottomOffset;
  int centreX = (int) (viewEnv.getMinX() + viewEnv.getMaxX()) / 2;
  
  int boxMinX = centreX - boxWidth/2;
  int boxMaxX = centreX + boxWidth/2;
  int boxMinY = bottom - boxHgt;
  int boxMaxY = bottom;
  
  int[] xpts = new int[] { 
      boxMinX, centreX - arrowWidth/2, (int) markX, centreX + arrowWidth/2,
      boxMaxX, boxMaxX,   boxMinX };
  int[] ypts = new int[] {  
      boxMinY, boxMinY, (int) (markY + arrowOffset), boxMinY,
      boxMinY, boxMaxY, boxMaxY };
  
  Polygon poly = new Polygon(xpts, ypts, xpts.length);
  
  g.setColor(AppConstants.HIGHLIGHT_FILL_CLR);
  g.fill(poly);
  AWTUtil.setStroke(g, 1);
  g.setColor(ColorUtil.opaque(AppConstants.HIGHLIGHT_CLR));
  g.draw(poly);

  // draw mark point label
  g.setColor(Color.BLACK);
  g.drawString(markLabel, centreX - strWidth/2, boxMaxY - labelOffsetY);

}
 
Example 17
Source File: FeatureStoreImpl.java    From sensorhub with Mozilla Public License 2.0 4 votes vote down vote up
public Iterator<AbstractFeature> getFeatures(IFeatureFilter filter)
{        
    // case of requesting by IDs
    Collection<String> foiIDs = filter.getFeatureIDs();
    if (foiIDs != null && !foiIDs.isEmpty())
    {
        final Set<String> ids = new LinkedHashSet<String>();
        ids.addAll(filter.getFeatureIDs());
        final Iterator<String> it = ids.iterator();
        
        Iterator<AbstractFeature> it2 = new Iterator<AbstractFeature>()
        {
            AbstractFeature nextFeature;
            
            public boolean hasNext()
            {
                return (nextFeature != null);
            }

            public AbstractFeature next()
            {
                AbstractFeature currentFeature = nextFeature;
                nextFeature = null;
                
                while (nextFeature == null && it.hasNext())
                    nextFeature = idIndex.get(it.next());
                                    
                return currentFeature;
            }

            public void remove()
            {                    
            }
        };
        
        it2.next();
        return it2;
    }
        
    // case of ROI
    if (filter.getRoi() != null)
    {
        // iterate through spatial index using bounding rectangle
        // TODO filter on exact polygon geometry using JTS
        Envelope env = filter.getRoi().getEnvelopeInternal();
        double[] coords = new double[] {env.getMinX(), env.getMinY(), Double.NEGATIVE_INFINITY, env.getMaxX(), env.getMaxY(), Double.POSITIVE_INFINITY};
        return geoIndex.iterator(new RectangleRn(coords));
    }
    
    // TODO handle ROI + IDs?        
    
    return idIndex.iterator();
}
 
Example 18
Source File: GoogleLayer.java    From geomajas-project-server with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public List<RasterTile> paint(CoordinateReferenceSystem targetCrs, Envelope bounds, double scale)
		throws GeomajasException {
	if (isTilesEnabled()) {
		try {
			CrsTransform layerToMap = geoService.getCrsTransform(crs, targetCrs);
			CrsTransform mapToLayer = geoService.getCrsTransform(targetCrs, crs);
			CrsTransform layerToWsg84 = geoService.getCrsTransform(crs, geoService.getCrs2(WSG_84));

			// find the center of the map in map coordinates (positive y-axis)
			Coordinate boundsCenter = new Coordinate((bounds.getMinX() + bounds.getMaxX()) / 2,
					(bounds.getMinY() + bounds.getMaxY()) / 2);

			// Translate the map coordinates to layer coordinates, assumes equal x-y orientation
			Envelope layerBounds = geoService.transform(bounds, mapToLayer);
			// double layerScale = bounds.getWidth() * scale / layerBounds.getWidth();
			layerBounds = clipBounds(layerBounds);
			if (layerBounds.isNull()) {
				return new ArrayList<RasterTile>(0);
			}

			// find zoomlevel
			// scale in pix/m should just above the given scale so we have at least one
			// screen pixel per google pixel ! (otherwise text unreadable)
			int zoomLevel = getBestZoomLevelForScaleInPixPerMeter(mapToLayer, boundsCenter, scale);
			log.debug("zoomLevel={}", zoomLevel);

			RasterGrid grid = getRasterGrid(layerBounds, tileSize * resolutions[zoomLevel], tileSize
					* resolutions[zoomLevel]);

			// We calculate the first tile's screen box with this assumption
			List<RasterTile> result = new ArrayList<RasterTile>();
			for (int i = grid.getXmin(); i < grid.getXmax(); i++) {
				for (int j = grid.getYmin(); j < grid.getYmax(); j++) {
					double x = grid.getLowerLeft().x + (i - grid.getXmin()) * grid.getTileWidth();
					double y = grid.getLowerLeft().y + (j - grid.getYmin()) * grid.getTileHeight();
					// layer coordinates
					Bbox worldBox;
					Bbox layerBox;
					layerBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight());
					// Transforming back to map coordinates will only result in a proper grid if the transformation
					// is nearly affine
					worldBox = geoService.transform(layerBox, layerToMap);

					// Rounding to avoid white space between raster tiles lower-left becomes upper-left in inverted
					// y-space
					Bbox screenBox = new Bbox(Math.round(scale * worldBox.getX()), -Math.round(scale
							* worldBox.getMaxY()), Math.round(scale * worldBox.getMaxX())
							- Math.round(scale * worldBox.getX()), Math.round(scale * worldBox.getMaxY())
							- Math.round(scale * worldBox.getY()));

					RasterTile image = new RasterTile(screenBox, getId() + "." + zoomLevel + "." + i + "," + j);

					String url = tileUrl;

					Coordinate center = new Coordinate((layerBox.getX() + layerBox.getMaxX()) / 2,
							(layerBox.getY() + layerBox.getMaxY()) / 2);
					Coordinate centerInWsg84 = JTS.transform(center, new Coordinate(), layerToWsg84);
					url = url.replace("${center}",
							Double.toString(centerInWsg84.y) + "," + Double.toString(centerInWsg84.x));
					url = url.replace("${level}", Integer.toString(zoomLevel));

					// When we are trying to display the tiles on a different coordinate system, use double scaled
					// images so that renderings are more smooth. This will return an image tileSize*2 x tileSize*2.
					// Disabled becausd the printing plugin can't handle this!
					// if (!layerToMap.isIdentity()) {
					// url += "&scale=2";
					// }

					image.setCode(new TileCode(zoomLevel, i, j));
					image.setUrl(url);
					log.debug("adding image {}", image);
					result.add(image);
				}
			}

			return result;

		} catch (TransformException e) {
			throw new GeomajasException(e, ExceptionCode.RENDER_TRANSFORMATION_FAILED);
		}
	} else {
		return Collections.emptyList();
	}
}
 
Example 19
Source File: TileUtil.java    From geomajas-project-server with GNU Affero General Public License v3.0 3 votes vote down vote up
/**
 * Get the bounding box for a certain tile.
 * 
 * @param code
 *            The unique tile code. Determines what tile we're talking about.
 * @param maxExtent
 *            The maximum extent of the grid to which this tile belongs.
 * @param scale
 *            The current client side scale.
 * @return Returns the bounding box for the tile, expressed in the layer's coordinate system.
 */
public static Envelope getTileBounds(TileCode code, Envelope maxExtent, double scale) {
	double[] layerSize = getTileLayerSize(code, maxExtent, scale);
	if (layerSize[0] == 0) {
		return null;
	}
	double cX = maxExtent.getMinX() + code.getX() * layerSize[0];
	double cY = maxExtent.getMinY() + code.getY() * layerSize[1];
	return new Envelope(cX, cX + layerSize[0], cY, cY + layerSize[1]);
}
 
Example 20
Source File: DtoConverterServiceImpl.java    From geomajas-project-server with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Convert JTS envelope into a {@link Bbox}.
 * 
 * @param envelope
 *            JTS envelope
 * @return Geomajas {@link Bbox}
 */
public Bbox toDto(Envelope envelope) {
	return new Bbox(envelope.getMinX(), envelope.getMinY(), envelope.getWidth(), envelope.getHeight());
}