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

The following examples show how to use com.vividsolutions.jts.geom.Envelope#expandToInclude() . 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: HibernateLayer.java    From geomajas-project-server with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Bounds are calculated locally, can use any filter, but slower than native.
 * 
 * @param filter
 *            filter which needs to be applied
 * @return the bounds of the specified features
 * @throws LayerException
 *             oops
 */
private Envelope getBoundsLocal(Filter filter) throws LayerException {
	try {
		Session session = getSessionFactory().getCurrentSession();
		Criteria criteria = session.createCriteria(getFeatureInfo().getDataSourceName());
		CriteriaVisitor visitor = new CriteriaVisitor((HibernateFeatureModel) getFeatureModel(), dateFormat);
		Criterion c = (Criterion) filter.accept(visitor, criteria);
		if (c != null) {
			criteria.add(c);
		}
		criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
		List<?> features = criteria.list();
		Envelope bounds = new Envelope();
		for (Object f : features) {
			Envelope geomBounds = getFeatureModel().getGeometry(f).getEnvelopeInternal();
			if (!geomBounds.isNull()) {
				bounds.expandToInclude(geomBounds);
			}
		}
		return bounds;
	} catch (HibernateException he) {
		throw new HibernateLayerException(he, ExceptionCode.HIBERNATE_LOAD_FILTER_FAIL, getFeatureInfo()
				.getDataSourceName(), filter.toString());
	}
}
 
Example 2
Source File: GamaCoordinateSequence.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Method expandEnvelope()
 *
 * @see com.vividsolutions.jts.geom.CoordinateSequence#expandEnvelope(com.vividsolutions.jts.geom.Envelope)
 */
@Override
public Envelope expandEnvelope(final Envelope env) {
	// TODO Create an Envelope3D ??
	for (final GamaPoint p : points) {
		env.expandToInclude(p);
	}
	return env;
}
 
Example 3
Source File: UnboundedCoordinateSequence.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Envelope expandEnvelope(final Envelope env) {
	for (int i = 0; i < nbPoints - 1; i++) {
		env.expandToInclude(points[i]);
	}
	return env;
}
 
Example 4
Source File: Java2DDisplaySurface.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Envelope getVisibleRegionForLayer(final ILayer currentLayer) {
	if (currentLayer instanceof OverlayLayer) { return getScope().getSimulation().getEnvelope(); }
	final Envelope e = new Envelope();
	final Point origin = getOrigin();
	int xc = -origin.x;
	int yc = -origin.y;
	e.expandToInclude((GamaPoint) currentLayer.getModelCoordinatesFrom(xc, yc, this));
	xc = xc + getIGraphics().getViewWidth();
	yc = yc + getIGraphics().getViewHeight();
	e.expandToInclude((GamaPoint) currentLayer.getModelCoordinatesFrom(xc, yc, this));
	return e;
}
 
Example 5
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 6
Source File: GeometryEditPanel.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void zoom(Point2D zoomBox1, Point2D zoomBox2) 
{
  Envelope zoomEnv = new Envelope();
  zoomEnv.expandToInclude(zoomBox1.getX(), zoomBox1.getY());
  zoomEnv.expandToInclude(zoomBox2.getX(), zoomBox2.getY());
  zoom(zoomEnv);
}
 
Example 7
Source File: ConformingDelaunayTriangulator.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static Envelope computeVertexEnvelope(Collection vertices) {
	Envelope env = new Envelope();
	for (Iterator i = vertices.iterator(); i.hasNext();) {
		Vertex v = (Vertex) i.next();
		env.expandToInclude(v.getCoordinate());
	}
	return env;
}
 
Example 8
Source File: ConformingDelaunayTriangulator.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void computeBoundingBox() {
	Envelope vertexEnv = computeVertexEnvelope(initialVertices);
	Envelope segEnv = computeVertexEnvelope(segVertices);

	Envelope allPointsEnv = new Envelope(vertexEnv);
	allPointsEnv.expandToInclude(segEnv);

	double deltaX = allPointsEnv.getWidth() * 0.2;
	double deltaY = allPointsEnv.getHeight() * 0.2;

	double delta = Math.max(deltaX, deltaY);

	computeAreaEnv = new Envelope(allPointsEnv);
	computeAreaEnv.expandBy(delta);
}
 
Example 9
Source File: Node.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Node createExpanded(Node node, Envelope addEnv)
{
  Envelope expandEnv = new Envelope(addEnv);
  if (node != null) expandEnv.expandToInclude(node.env);

  Node largerNode = createNode(expandEnv);
  if (node != null) largerNode.insertNode(node);
  return largerNode;
}
 
Example 10
Source File: CombineUnionService.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
public Envelope combine(List<GetLocationResult> results) {
	Envelope result = null;
	for (GetLocationResult add : results) {
		Envelope envelope = add.getEnvelope();
		if (null == result) {
			result = envelope;
		} else {
			result.expandToInclude(envelope);
		}
	}
	return result;
}
 
Example 11
Source File: BeanLayer.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Retrieve the bounds of the specified features.
 * 
 * @return the bounds of the specified features
 */
public Envelope getBounds(Filter queryFilter) throws LayerException {
	Iterator<?> it = getElements(queryFilter, 0, 0);
	// start with null envelope
	Envelope bounds = new Envelope();
	while (it.hasNext()) {
		Object o = it.next();
		Geometry g = featureModel.getGeometry(o);
		bounds.expandToInclude(g.getEnvelopeInternal());
	}
	return bounds;
}
 
Example 12
Source File: UniqueCoordinateSequence.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Envelope expandEnvelope(final Envelope env) {
	env.expandToInclude(point);
	return env;
}