本文整理汇总了Java中org.geotools.data.wms.WebMapServer类的典型用法代码示例。如果您正苦于以下问题:Java WebMapServer类的具体用法?Java WebMapServer怎么用?Java WebMapServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebMapServer类属于org.geotools.data.wms包,在下文中一共展示了WebMapServer类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getCapabiltiesURL
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
/**
* gets the getCapabilities URL.
* @param mapURL the URL of the Map
* @return getCapabilties URL
*/
public static URL getCapabiltiesURL(URL mapURL) {
URL url = mapURL;
try {
WebMapServer wms = new WebMapServer(mapURL);
HTTPClient httpClient = wms.getHTTPClient();
URL get = wms.
getCapabilities().
getRequest().
getGetCapabilities().
getGet();
if (get != null) {
url = new URL(get.toString() + "request=GetCapabilities");
}
httpClient.getConnectTimeout();
} catch (IOException | ServiceException e) {
log.log(Level.SEVERE, e.getMessage(), e);
}
return url;
}
开发者ID:gdi-by,项目名称:downloadclient,代码行数:25,代码来源:WMSMapSwing.java
示例2: createLayer
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
@Override
public Layer createLayer(LayerContext ctx, PropertySet configuration) {
final WebMapServer mapServer;
try {
mapServer = getWmsServer(configuration);
} catch (Exception e) {
final String message = String.format("Not able to access Web Mapping Server: %s",
configuration.getValue(WmsLayerType.PROPERTY_NAME_URL));
throw new RuntimeException(message, e);
}
final int layerIndex = configuration.getValue(WmsLayerType.PROPERTY_NAME_LAYER_INDEX);
final org.geotools.data.ows.Layer wmsLayer = getLayer(mapServer, layerIndex);
final MultiLevelSource multiLevelSource = createMultiLevelSource(configuration, mapServer, wmsLayer);
final ImageLayer.Type imageLayerType = LayerTypeRegistry.getLayerType(ImageLayer.Type.class);
final PropertySet config = imageLayerType.createLayerConfig(ctx);
config.setValue(ImageLayer.PROPERTY_NAME_MULTI_LEVEL_SOURCE, multiLevelSource);
config.setValue(ImageLayer.PROPERTY_NAME_BORDER_SHOWN, false);
config.setValue(ImageLayer.PROPERTY_NAME_PIXEL_BORDER_SHOWN, false);
final ImageLayer wmsImageLayer = new ImageLayer(this, multiLevelSource, config);
wmsImageLayer.setName(wmsLayer.getName());
return wmsImageLayer;
}
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:27,代码来源:WmsLayerType.java
示例3: main
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
/**
* Prompts the user for a wms service, connects, and asks for a layer and then
* and displays its contents on the screen in a map frame.
*/
public static void main(String[] args) throws Exception {
// display a data store file chooser dialog for shapefiles
URL capabilitiesURL = WMSChooser.showChooseWMS();
if( capabilitiesURL == null ){
System.exit(0); // canceled
}
WebMapServer wms = new WebMapServer( capabilitiesURL );
List<Layer> wmsLayers = WMSLayerChooser.showSelectLayer( wms );
if( wmsLayers == null ){
JOptionPane.showMessageDialog(null, "Could not connect - check url");
System.exit(0);
}
MapContent mapcontent = new MapContent();
mapcontent.setTitle( wms.getCapabilities().getService().getTitle() );
for( Layer wmsLayer : wmsLayers ){
WMSLayer displayLayer = new WMSLayer(wms, wmsLayer );
mapcontent.addLayer(displayLayer);
}
// Now display the map
JMapFrame.showMap(mapcontent);
}
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:28,代码来源:WMSLab.java
示例4: getWMSLayer
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
private org.geotools.data.ows.Layer getWMSLayer( WebMapServer server, String layerName ) {
for( org.geotools.data.ows.Layer layer : server.getCapabilities().getLayerList() ) {
if (layerName.equals(layer.getName())) {
return layer;
}
}
throw new IllegalArgumentException("Could not find layer " + layerName);
}
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:9,代码来源:ImageGenerator.java
示例5: getNextPage
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
@Override
public AbstractLayerSourceAssistantPage getNextPage() {
LayerSourcePageContext pageContext = getContext();
WebMapServer wms = null;
WMSCapabilities wmsCapabilities = null;
String wmsUrl = wmsUrlBox.getSelectedItem().toString();
if (wmsUrl != null && !wmsUrl.isEmpty()) {
try {
wms = getWms(pageContext.getWindow(), wmsUrl);
wmsCapabilities = wms.getCapabilities();
} catch (Exception e) {
e.printStackTrace();
pageContext.showErrorDialog("Failed to access WMS:\n" + e.getMessage());
}
}
history.copyInto(SnapApp.getDefault().getPreferences());
if (wms != null && wmsCapabilities != null) {
pageContext.setPropertyValue(WmsLayerSource.PROPERTY_NAME_WMS, wms);
pageContext.setPropertyValue(WmsLayerSource.PROPERTY_NAME_WMS_CAPABILITIES, wmsCapabilities);
return new WmsAssistantPage2();
} else {
return null;
}
}
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:28,代码来源:WmsAssistantPage1.java
示例6: doInBackground
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
@Override
protected com.bc.ceres.glayer.Layer doInBackground(ProgressMonitor pm) throws Exception {
try {
pm.beginTask("Loading layer from WMS", ProgressMonitor.UNKNOWN);
final LayerType wmsType = LayerTypeRegistry.getLayerType(WmsLayerType.class.getName());
final PropertySet template = wmsType.createLayerConfig(getContext().getLayerContext());
final RasterDataNode raster = SnapApp.getDefault().getSelectedProductSceneView().getRaster();
template.setValue(WmsLayerType.PROPERTY_NAME_RASTER, raster);
template.setValue(WmsLayerType.PROPERTY_NAME_IMAGE_SIZE, mapImageSize);
URL wmsUrl = (URL) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_WMS_URL);
template.setValue(WmsLayerType.PROPERTY_NAME_URL, wmsUrl);
StyleImpl selectedStyle = (StyleImpl) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_STYLE);
String styleName = null;
if (selectedStyle != null) {
styleName = selectedStyle.getName();
}
template.setValue(WmsLayerType.PROPERTY_NAME_STYLE_NAME, styleName);
WebMapServer wms = (WebMapServer) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_WMS);
final List<Layer> layerList = wms.getCapabilities().getLayerList();
Layer selectedLayer = (Layer) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_SELECTED_LAYER);
template.setValue(WmsLayerType.PROPERTY_NAME_LAYER_INDEX, layerList.indexOf(selectedLayer));
CRSEnvelope crsEnvelope = (CRSEnvelope) context.getPropertyValue(WmsLayerSource.PROPERTY_NAME_CRS_ENVELOPE);
template.setValue(WmsLayerType.PROPERTY_NAME_CRS_ENVELOPE, crsEnvelope);
final com.bc.ceres.glayer.Layer layer = wmsType.createLayer(getContext().getLayerContext(), template);
layer.setName(selectedLayer.getName());
return layer;
} finally {
pm.done();
}
}
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:34,代码来源:WmsWorker.java
示例7: downloadWmsImage
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
private static BufferedImage downloadWmsImage(GetMapRequest mapRequest, WebMapServer wms) throws IOException,
ServiceException {
GetMapResponse mapResponse = wms.issueRequest(mapRequest);
try (InputStream inputStream = mapResponse.getInputStream()) {
return ImageIO.read(inputStream);
}
}
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:8,代码来源:WmsLayerType.java
示例8: WMSMapSwing
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
/**
* Constructor.
* @param mapURL mapURL
* @param width width
* @param heigth heigth
* @param layer layer
* @param source source
* @param displayCRS crs of display
*/
public WMSMapSwing(URL mapURL, int width, int heigth, String layer,
CoordinateReferenceSystem displayCRS, String source) {
initGeotoolsLocale();
try {
if (displayCRS == null) {
setDisplayCRS(INITIAL_CRS);
} else {
setDisplayCRS(displayCRS);
}
this.source = source;
this.sb = new StyleBuilder();
this.sf = CommonFactoryFinder.getStyleFactory(null);
this.ff = CommonFactoryFinder.getFilterFactory2(null);
this.mapHeight = heigth;
this.mapWidth = width;
this.vBox = new VBox();
this.wms = new WebMapServer(mapURL);
List<Layer> layers = this.wms.getCapabilities().getLayerList();
baseLayer = null;
boolean layerFound = false;
for (Layer outerLayer : layers) {
String oname = outerLayer.getName();
if (oname != null && oname.equalsIgnoreCase(layer)) {
baseLayer = outerLayer;
// we actually need to set both by hand, else the
// request will fail
baseLayer.setTitle(layer);
baseLayer.setName(layer);
layerFound = true;
}
for (Layer wmsLayer : outerLayer.getChildren()) {
if (wmsLayer.getName().equalsIgnoreCase(layer)) {
baseLayer = wmsLayer.getParent();
baseLayer.setTitle(layer);
baseLayer.setName(layer);
layerFound = true;
break;
}
}
if (layerFound) {
break;
}
}
this.mapContent = new MapContent();
this.mapContent.setTitle(this.title);
this.mapNode = new SwingNode();
this.mapNode.setManaged(false);
this.add(this.mapNode);
this.getChildren().add(vBox);
displayMap(baseLayer);
} catch (IOException | ServiceException | FactoryException e) {
log.log(Level.SEVERE, e.getMessage(), e);
}
}
开发者ID:gdi-by,项目名称:downloadclient,代码行数:65,代码来源:WMSMapSwing.java
示例9: initializeWms
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
/**
* initialize wms server, set wms server and caps and create the tile factory
*
* @param wmsServer
* @param wmsCaps
* @param allMtLayers
* all layers which can be displayed
*/
void initializeWms(final WebMapServer wmsServer, final WMSCapabilities wmsCaps, final ArrayList<MtLayer> allMtLayers) {
_wmsServer = wmsServer;
_wmsCaps = wmsCaps;
_mtLayers = allMtLayers;
_allImageFormats = _wmsCaps.getRequest().getGetMap().getFormats();
if (getImageFormat() == null) {
// set png format as default
String imageFormat = null;
for (final String format : _allImageFormats) {
if (format.equalsIgnoreCase(MapProviderManager.DEFAULT_IMAGE_FORMAT)) {
imageFormat = format;
}
}
setImageFormat(imageFormat == null ? _allImageFormats.get(0) : imageFormat);
}
}
开发者ID:wolfgang-ch,项目名称:mytourbook,代码行数:33,代码来源:MPWms.java
示例10: createMultiLevelSource
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
private static DefaultMultiLevelSource createMultiLevelSource(PropertySet configuration,
WebMapServer wmsServer,
org.geotools.data.ows.Layer layer) {
DefaultMultiLevelSource multiLevelSource;
final String styleName = configuration.getValue(WmsLayerType.PROPERTY_NAME_STYLE_NAME);
final Dimension size = configuration.getValue(WmsLayerType.PROPERTY_NAME_IMAGE_SIZE);
try {
List<StyleImpl> styleList = layer.getStyles();
StyleImpl style = null;
if (!styleList.isEmpty()) {
style = styleList.get(0);
for (StyleImpl currentstyle : styleList) {
if (currentstyle.getName().equals(styleName)) {
style = currentstyle;
}
}
}
CRSEnvelope crsEnvelope = configuration.getValue(WmsLayerType.PROPERTY_NAME_CRS_ENVELOPE);
GetMapRequest mapRequest = wmsServer.createGetMapRequest();
mapRequest.addLayer(layer, style);
mapRequest.setTransparent(true);
mapRequest.setDimensions(size.width, size.height);
mapRequest.setSRS(crsEnvelope.getEPSGCode()); // e.g. "EPSG:4326" = Geographic CRS
mapRequest.setBBox(crsEnvelope);
mapRequest.setFormat("image/png");
final PlanarImage image = PlanarImage.wrapRenderedImage(downloadWmsImage(mapRequest, wmsServer));
RasterDataNode raster = configuration.getValue(WmsLayerType.PROPERTY_NAME_RASTER);
final int sceneWidth = raster.getRasterWidth();
final int sceneHeight = raster.getRasterHeight();
AffineTransform i2mTransform = Product.findImageToModelTransform(raster.getGeoCoding());
i2mTransform.scale((double) sceneWidth / image.getWidth(), (double) sceneHeight / image.getHeight());
final Rectangle2D bounds = DefaultMultiLevelModel.getModelBounds(i2mTransform, image);
final DefaultMultiLevelModel multiLevelModel = new DefaultMultiLevelModel(1, i2mTransform, bounds);
multiLevelSource = new DefaultMultiLevelSource(image, multiLevelModel);
} catch (Exception e) {
throw new IllegalStateException(String.format("Failed to access WMS: %s", configuration.getValue(
WmsLayerType.PROPERTY_NAME_URL)), e);
}
return multiLevelSource;
}
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:43,代码来源:WmsLayerType.java
示例11: getLayer
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
private static org.geotools.data.ows.Layer getLayer(WebMapServer server, int layerIndex) {
return server.getCapabilities().getLayerList().get(layerIndex);
}
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:4,代码来源:WmsLayerType.java
示例12: getWmsServer
import org.geotools.data.wms.WebMapServer; //导入依赖的package包/类
private static WebMapServer getWmsServer(PropertySet configuration) throws IOException, ServiceException {
return new WebMapServer((URL) configuration.getValue(WmsLayerType.PROPERTY_NAME_URL));
}
开发者ID:senbox-org,项目名称:snap-desktop,代码行数:4,代码来源:WmsLayerType.java
注:本文中的org.geotools.data.wms.WebMapServer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论