Java Code Examples for com.vividsolutions.jts.geom.GeometryFactory#toGeometry()

The following examples show how to use com.vividsolutions.jts.geom.GeometryFactory#toGeometry() . 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: AllowAllAuthorization.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
protected Geometry getAuthorizedArea(String layerId) {
	if (null == biggestGeometry) {
		// build Geometry which covers biggest possible area
		Envelope maxBounds = new Envelope(-Float.MAX_VALUE, Float.MAX_VALUE, -Float.MAX_VALUE, Float.MAX_VALUE);
		PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
		GeometryFactory geometryFactory = new GeometryFactory(precisionModel, 0);
		biggestGeometry = geometryFactory.toGeometry(maxBounds);
	}
	return biggestGeometry;
}
 
Example 2
Source File: DefaultSecurityContext.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
private Geometry areaCombine(String layerId, AreaCombineGetter areaGetter) {
	if (null == authentications || authentications.size() == 0) {
		// no authorizations, so nothing should be allowed
		return null;
	}

	Layer<?> layer = configurationService.getLayer(layerId);
	if (null == layer) {
		log.error("areaCombine on unknown layer " + layerId);
		return null;
	}
	LayerInfo layerInfo = layer.getLayerInfo();

	// base is the max bounds of the layer
	Envelope maxBounds = converterService.toInternal(layerInfo.getMaxExtent());
	PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
	int srid = geoService.getSridFromCrs(layer.getLayerInfo().getCrs());
	GeometryFactory geometryFactory = new GeometryFactory(precisionModel, srid);
	Geometry geometry = geometryFactory.toGeometry(maxBounds);

	// limit based on authorizations
	for (Authentication authentication : authentications) {
		for (BaseAuthorization authorization : authentication.getAuthorizations()) {
			if (authorization instanceof AreaAuthorization) {
				geometry = geometry.intersection(areaGetter.get((AreaAuthorization) authorization));
			}
		}
	}
	geometry.setSRID(srid); // force srid, even when not set correctly by security service
	return geometry;
}
 
Example 3
Source File: OddFeatureAuthorization.java    From geomajas-project-server with GNU Affero General Public License v3.0 5 votes vote down vote up
protected Geometry getAuthorizedArea(String layerId) {
	if (null == biggestGeometry) {
		// build Geometry which covers biggest possible area
		Envelope maxBounds = new Envelope(-Double.MAX_VALUE, Double.MAX_VALUE,
				-Double.MAX_VALUE, Double.MAX_VALUE);
		PrecisionModel precisionModel = new PrecisionModel(PrecisionModel.FLOATING);
		GeometryFactory geometryFactory = new GeometryFactory(precisionModel, 0);
		biggestGeometry = geometryFactory.toGeometry(maxBounds);
	}
	return biggestGeometry;
}