当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionCode.UNEXPECTED_PROBLEM属性代码示例

本文整理汇总了Java中org.geomajas.global.ExceptionCode.UNEXPECTED_PROBLEM属性的典型用法代码示例。如果您正苦于以下问题:Java ExceptionCode.UNEXPECTED_PROBLEM属性的具体用法?Java ExceptionCode.UNEXPECTED_PROBLEM怎么用?Java ExceptionCode.UNEXPECTED_PROBLEM使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.geomajas.global.ExceptionCode的用法示例。


在下文中一共展示了ExceptionCode.UNEXPECTED_PROBLEM属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBounds

@Override
public Envelope getBounds(Filter filter) throws LayerException {
	FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
	if (source instanceof FeatureStore<?, ?>) {
		SimpleFeatureStore store = (SimpleFeatureStore) source;
		transactionSynchronization.synchTransaction(store);
	}
	try {
		FeatureCollection<SimpleFeatureType, SimpleFeature> fc;
		if (null == filter) {
			fc = source.getFeatures();
		} else {
			fc = source.getFeatures(filter);
		}
		FeatureIterator<SimpleFeature> it = fc.features();
		transactionSynchronization.addIterator(it);
		return fc.getBounds();
	} catch (Throwable t) { // NOSONAR avoid errors (like NPE) as well
		throw new LayerException(t, ExceptionCode.UNEXPECTED_PROBLEM);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:21,代码来源:GeoToolsLayer.java

示例2: getElements

/**
 * {@inheritDoc}
 *
 */
@Transactional(readOnly = true)
public Iterator<?> getElements(Filter filter, int offset, int maxResultSize) throws LayerException {
	FeatureSource<SimpleFeatureType, SimpleFeature> source = getFeatureSource();
	try {
		if (source instanceof FeatureStore<?, ?>) {
			SimpleFeatureStore store = (SimpleFeatureStore) source;
			transactionSynchronization.synchTransaction(store);
		}
		Query query = new Query();
		query.setFilter(filter);
		query.setMaxFeatures(maxResultSize > 0 ? maxResultSize : Integer.MAX_VALUE);
		query.setStartIndex(offset);
		FeatureCollection<SimpleFeatureType, SimpleFeature> fc = source.getFeatures(query);
		FeatureIterator<SimpleFeature> it = fc.features();
		transactionSynchronization.addIterator(it);
		return new JavaIterator(it);
	} catch (Throwable t) { // NOSONAR avoid errors (like NPE) as well
		throw new LayerException(t, ExceptionCode.UNEXPECTED_PROBLEM);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:24,代码来源:GeoToolsLayer.java

示例3: cloneInfo

private VectorLayerRasterizingInfo cloneInfo(VectorLayerRasterizingInfo input) throws GeomajasException {
	try {
		JBossObjectOutputStream jbossSerializer = new JBossObjectOutputStream(null);
		Object obj = jbossSerializer.smartClone(input);
		return (VectorLayerRasterizingInfo) obj;
	} catch (IOException e) {
		// should not happen
		throw new GeomajasException(e, ExceptionCode.UNEXPECTED_PROBLEM);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:10,代码来源:VectorLayerFactory.java

示例4: cloneInfo

private ClientMapInfo cloneInfo(ClientMapInfo input) throws GeomajasException {
	try {
		JBossObjectOutputStream jbossSerializer = new JBossObjectOutputStream(null);
		Object obj = jbossSerializer.smartClone(input);
		return (ClientMapInfo) obj;
	} catch (IOException e) {
		// should not happen
		throw new GeomajasException(e, ExceptionCode.UNEXPECTED_PROBLEM);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:10,代码来源:RasterizeMapCommandTest.java

示例5: getRealAttributes

private Map<String, Attribute> getRealAttributes(VectorLayer layer, Object featureBean) throws LayerException {
	FeatureModel featureModel = layer.getFeatureModel();
	FeatureInfo featureInfo = layer.getLayerInfo().getFeatureInfo();
	String geometryAttributeName = featureInfo.getGeometryType().getName();
	boolean lazy = layer instanceof VectorLayerLazyFeatureConversionSupport &&
			((VectorLayerLazyFeatureConversionSupport) layer).useLazyFeatureConversion();

	Map<String, Attribute> attributes = new HashMap<String, Attribute>();
	for (AbstractAttributeInfo attribute : featureInfo.getAttributes()) {
		if (!(attribute instanceof SyntheticAttributeInfo)) {
			String name = attribute.getName();
			if (!name.equals(geometryAttributeName)) {
				Attribute value;
				if (lazy) {
					// need to use the correct lazy type to allow instanceof to work
					if (attribute instanceof AssociationAttributeInfo) {
						switch (((AssociationAttributeInfo) attribute).getType()) {
							case MANY_TO_ONE:
								value = new LazyManyToOneAttribute(this, featureModel, featureBean, name);
								break;
							case ONE_TO_MANY:
								value = new LazyOneToManyAttribute(this, featureModel, featureBean, name);
								break;
							default:
								throw new LayerException(ExceptionCode.UNEXPECTED_PROBLEM,
										"Coding error, not all AssociationType options are covered");
						}
					} else {
						PrimitiveType type = ((PrimitiveAttributeInfo) attribute).getType();
						value = new LazyPrimitiveAttribute(type, featureModel, featureBean, name);
					}
				} else {
					value = featureModel.getAttribute(featureBean, name);
				}
				attributes.put(name, value);
			}
		}
	}
	return attributes;
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:40,代码来源:AttributeService.java

示例6: execute

@Override
public void execute(SplitPolygonRequest request, SplitPolygonResponse response) throws Exception {
	// convert to most accurate precision model
	com.vividsolutions.jts.geom.Geometry jtsGeometry = converter.toInternal(request.getGeometry());
	if (!(jtsGeometry instanceof Polygon)) {
		throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, "geometry has to be a Polygon");
	}
	Polygon polygon = (Polygon) converter.toInternal(request.getGeometry());

	// Convert to the polygons precision model:
	jtsGeometry = converter.toInternal(request.getSplitter());
	if (!(jtsGeometry instanceof LineString)) {
		throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, "splitter has to be a LineString");
	}
	LineString preciseLine = (LineString) jtsGeometry;
	int precision = polygon.getPrecisionModel().getMaximumSignificantDigits() - 1;
	com.vividsolutions.jts.geom.Geometry bufferedLine = preciseLine.buffer(Math.pow(10.0, -precision));
	com.vividsolutions.jts.geom.Geometry diff = polygon.difference(bufferedLine);

	if (diff instanceof Polygon) {
		response.setGeometries(new Geometry[] { converter.toDto(diff) });
	} else if (diff instanceof MultiPolygon) {
		Geometry[] polygons = new Geometry[diff.getNumGeometries()];
		for (int i = 0; i < diff.getNumGeometries(); i++) {
			polygons[i] = converter.toDto(diff.getGeometryN(i));
		}
		response.setGeometries(polygons);
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:29,代码来源:SplitPolygonCommand.java

示例7: execute

@Override
public void execute(final FeatureSearchRequest request, final FeatureSearchResponse response) throws Exception {
	if (request.getCriterion() == null) {
		throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "criterion");
	}
	if (null == request.getMapCrs()) {
		throw new GeomajasException(ExceptionCode.PARAMETER_MISSING, "mapCrs");
	}
	if (!request.getCriterion().isValid()) {
		throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, "criterion is not valid");
	}

	String mapCrsCode = request.getMapCrs();
	Crs mapCrs = geoService.getCrs2(request.getMapCrs());

	Map<VectorLayer, Filter> filters = dtoSearchConverterService.dtoCriterionToFilters(request.getCriterion(),
			mapCrs);

	Map<String, String> layerFilters = request.getLayerFilters();

	for (Entry<VectorLayer, Filter> entry : filters.entrySet()) {
		String layerId = entry.getKey().getId();
		if (securityContext.isLayerVisible(layerId)) {
			Filter f = entry.getValue();
			if (layerFilters.containsKey(layerId)) {
				String layerFilter = layerFilters.get(layerId);
				f = filterService.createAndFilter(filterService.parseFilter(layerFilter), f);
			}

			List<InternalFeature> temp = layerService.getFeatures(layerId, mapCrs, f, null,
					request.getFeatureIncludes(), 0, request.getMax());
			if (temp.size() > 0) {
				List<Feature> features = new ArrayList<Feature>();
				for (InternalFeature feature : temp) {
					Feature dto = dtoConverterService.toDto(feature);
					dto.setCrs(mapCrsCode);
					features.add(dto);
				}
				response.addLayer(layerId, features);
			}
		}
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt,代码行数:43,代码来源:FeatureSearchCommand.java

示例8: execute

@Override
public void execute(WfsGetCapabilitiesRequest request, WfsGetCapabilitiesResponse response)
		throws GeomajasException {
	try {
		String sourceUrl = request.getBaseUrl();
		URL targetUrl = httpClientFactory.getTargetUrl(sourceUrl);
		
		// Create a WFS GetCapabilities URL:
		URL url = URLBuilder.createWfsURL(targetUrl, request.getVersion(), "GetCapabilities");
		String capa = url.toExternalForm();
		
		Map<String, Serializable> connectionParameters = new HashMap<String, Serializable>();
		connectionParameters.put(WFSDataStoreFactory.URL.key, capa);
		connectionParameters.put(WFSDataStoreFactory.TIMEOUT.key, 10000);
		if (request.getStrategy() != null) {
			connectionParameters.put(WFSDataStoreFactory.WFS_STRATEGY.key, request.getStrategy());
		}
		WFSDataStore wfs = dataStoreFactory.createDataStore(connectionParameters,
				httpClientFactory.create(sourceUrl));
		// The following uses internal geotools classes, anyone knows a more generic way to get the feature types
		// ???
		WfsFeatureTypeListDto wfsFeatureTypeListDto = null;
		String vs = wfs.getWfsClient().getInfo().getVersion();
		WfsVersion version = WfsVersion.fromString(vs);
		switch (version) {
			case V1_0_0:
			case V1_1_0:
				wfsFeatureTypeListDto = create1xxFeatureTypeList(wfs);
				break;
			case V2_0_0:
			default:
				wfsFeatureTypeListDto = create200FeatureTypeList(wfs);
				break;
		}
		WfsGetCapabilitiesDto getCapabilitiesDto = new WfsGetCapabilitiesDto(wfsFeatureTypeListDto);
		response.setGetCapabilitiesDto(getCapabilitiesDto);
	} catch (Exception e) {
		log.error("GetCapabilities failed for " + request.getBaseUrl(), e);
		throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, e.getMessage());
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:41,代码来源:WfsGetCapabilitiesCommand.java

示例9: execute

@Override
public void execute(WfsDescribeFeatureTypeRequest request, WfsDescribeFeatureTypeResponse response)
		throws GeomajasException {
	SimpleFeatureType schema = null;
	try {
		String sourceUrl = request.getBaseUrl();
		URL targetUrl = httpClientFactory.getTargetUrl(sourceUrl);
		
		// Create a WFS GetCapabilities URL:
		URL url = URLBuilder.createWfsURL(targetUrl, request.getVersion(), "GetCapabilities");
		String capa = url.toExternalForm();

		Map<String, Serializable> connectionParameters = new HashMap<String, Serializable>();
		connectionParameters.put(WFSDataStoreFactory.URL.key, capa);
		connectionParameters.put(WFSDataStoreFactory.TIMEOUT.key, 10000);
		if (request.getStrategy() != null) {
			connectionParameters.put(WFSDataStoreFactory.WFS_STRATEGY.key, request.getStrategy());
		}
		// Get the WFS feature source:
		WFSDataStore data = dataStoreFactory.createDataStore(connectionParameters,
				httpClientFactory.create(sourceUrl));
		schema = data.getSchema(request.getTypeName().replace(":", "_"));
	} catch (Exception e) {
		log.error("DescribeFeatureType failed for " + request.getTypeName(), e);
		throw new GeomajasException(ExceptionCode.UNEXPECTED_PROBLEM, e.getMessage());
	}

	if (schema != null) {
		List<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor> descriptors = 
				new ArrayList<org.geomajas.gwt2.client.map.attribute.AttributeDescriptor>();
		for (AttributeDescriptor attributeDescriptor : schema.getAttributeDescriptors()) {
			descriptors.add(createDescriptor(attributeDescriptor));
		}
		WfsFeatureTypeDescriptionDto featureTypeDescriptionDto = new WfsFeatureTypeDescriptionDto();
		featureTypeDescriptionDto.setBaseUrl(request.getBaseUrl());
		featureTypeDescriptionDto.setTypeName(request.getTypeName());
		featureTypeDescriptionDto.setAttributeDescriptors(descriptors);
		response.setFeatureTypeDescription(featureTypeDescriptionDto);
	} else {
		log.error("Missing type name on server: " + request.getTypeName());
		throw new GeomajasException(ExceptionCode.PARAMETER_INVALID_VALUE, request.getTypeName());
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-client-gwt2,代码行数:43,代码来源:WfsDescribeFeatureTypeCommand.java

示例10: getFeaturesByLocation

/** {@inheritDoc}. */
public List<Feature> getFeaturesByLocation(Coordinate layerCoordinate, double layerScale, int pixelTolerance)
		throws LayerException {
	if (!isEnableFeatureInfoSupport()) {
		return Collections.emptyList();
	}

	List<Feature> features = new ArrayList<Feature>();

	Resolution bestResolution = getResolutionForScale(layerScale);
	RasterGrid grid = getRasterGrid(new Envelope(layerCoordinate), bestResolution.getTileWidth(),
			bestResolution.getTileHeight());
	int x = (int) (((layerCoordinate.x - grid.getLowerLeft().x) * bestResolution.getTileWidthPx()) / grid
			.getTileWidth());
	int y = (int) (bestResolution.getTileHeightPx() - (((layerCoordinate.y - grid.getLowerLeft().y) * bestResolution
			.getTileHeightPx()) / grid.getTileHeight()));

	Bbox layerBox = new Bbox(grid.getLowerLeft().x, grid.getLowerLeft().y, grid.getTileWidth(),
			grid.getTileHeight());

	InputStream stream = null;
	try {
		String url = formatGetFeatureInfoUrl(bestResolution.getTileWidthPx(), bestResolution.getTileHeightPx(),
				layerBox, x, y, featureInfoFormat == WmsFeatureInfoFormat.HTML);
		log.debug("getFeaturesByLocation: {} {} {} {}", new Object[] { layerCoordinate, layerScale, pixelTolerance,
				url });
		stream = httpService.getStream(url, this);

		switch (featureInfoFormat) {
			case GML2:
				features = getGmlFeatures(stream, Version.GML2);
				break;
			case GML3:
				features = getGmlFeatures(stream, Version.GML3);
				break;
			case HTML:
				features = getHtmlFeatures(url);
				break;
			case TEXT:
				features = getTextFeatures(stream);
				break;
			case JSON:
				features = getTextFeatures(stream);
				break;
		}

	} catch (LayerException le) {
		throw le; // NOSONAR
	} catch (Exception e) { // NOSONAR
		throw new LayerException(e, ExceptionCode.UNEXPECTED_PROBLEM);
	} finally {
		if (null != stream) {
			try {
				stream.close();
			} catch (IOException ioe) {
				// ignore, closing anyway
			}
		}
	}

	return features;
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:62,代码来源:WmsLayer.java


注:本文中的org.geomajas.global.ExceptionCode.UNEXPECTED_PROBLEM属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。