Package org.geotools.geopkg.wps.GeoPackageProcessRequest

Examples of org.geotools.geopkg.wps.GeoPackageProcessRequest.TilesLayer


                 
                   gpkg.add(e, (SimpleFeatureCollectioncollection);
               }
              
           } else if (layer.getType() == LayerType.TILES) {
               TilesLayer tiles = (TilesLayer) layer;              
               GetMapRequest request = new GetMapRequest();
              
               request.setLayers(new ArrayList<MapLayerInfo>());
               for (QName layerQName : tiles.getLayers()) {
                   LayerInfo layerInfo = null;
                   if ("".equals(layerQName.getNamespaceURI())) {
                       layerInfo = catalog.getLayerByName(layerQName.getLocalPart());
                   } else {
                       layerInfo = catalog.getLayerByName(new NameImpl(layerQName.getNamespaceURI(), layerQName.getLocalPart()));
                   }
                   if (layerInfo == null) {
                       throw new ServiceException("Layer not found: " + layerQName);
                   }
                   request.getLayers().add(new MapLayerInfo(layerInfo));
               }

               if (tiles.getBbox() == null) {
                   try {
                       // generate one from requests layers
                       CoordinateReferenceSystem crs =
                           tiles.getSrs() != null ? CRS.decode(tiles.getSrs().toString()) : null;
   
                       ReferencedEnvelope bbox = null;
                       for (MapLayerInfo l : request.getLayers()) {
                           ResourceInfo r = l.getResource();
                           ReferencedEnvelope b = null;
                           if (crs != null) {
                               // transform from lat lon bbox
                               b = r.getLatLonBoundingBox().transform(crs, true);
                           }
                           else {
                               // use native bbox
                               b = r.getNativeBoundingBox();
                               if (bbox != null) {
                                   // transform
                                   b = b.transform(bbox.getCoordinateReferenceSystem(), true);
                               }
                           }
   
                           if (bbox != null) {
                               bbox.include(b);
                           }
                           else {
                               bbox = b;
                           }
                       }

                       request.setBbox(bbox);
                   }
                   catch(Exception e) {
                       String msg = "Must specify bbox, unable to derive from requested layers";
                       throw new RuntimeException(msg ,e);
                   }
               }
               else {
                   request.setBbox(tiles.getBbox());
               }

               if (tiles.getSrs() == null) {
                   // use srs of first layer
                   ResourceInfo r = request.getLayers().iterator().next().getResource();
                   request.setSRS(r.getSRS());
               }
               else {
                   request.setSRS(tiles.getSrs().toString());
               }

               // Get the request SRS defined and set is as the request CRS
               String srs = request.getSRS();
               if(srs != null && !srs.isEmpty()){
                   try {
                       request.setCrs(CRS.decode(srs));
                   } catch (FactoryException e) {
                       throw new RuntimeException(e);
                   }
               }

               request.setBgColor(tiles.getBgColor());
               request.setTransparent(tiles.isTransparent());
               request.setStyleBody(tiles.getSldBody());
               if (tiles.getSld() != null) {
                   request.setStyleUrl(tiles.getSld().toURL());
               }
               else if (tiles.getSldBody() != null) {
                   request.setStyleBody(tiles.getSldBody());
               }
               else {
                   request.setStyles(new ArrayList<Style>());
                   if (tiles.getStyles() != null) {
                       for (String styleName : tiles.getStyles()) {
                           StyleInfo info = catalog.getStyleByName(styleName);
                           if (info != null){
                               request.getStyles().add(info.getStyle());
                           }                      
                       }
                   }
                   if (request.getStyles().isEmpty()) {
                       for (MapLayerInfo layerInfo : request.getLayers()) {
                           request.getStyles().add(layerInfo.getDefaultStyle());
                       }
                   }
               }
               request.setFormat("none");
               Map formatOptions = new HashMap();
               formatOptions.put("format",tiles.getFormat());
               if (tiles.getCoverage() != null) {
                   if (tiles.getCoverage().getMinZoom() != null) {
                       formatOptions.put("min_zoom", tiles.getCoverage().getMinZoom());
                   }
                   if (tiles.getCoverage().getMaxZoom() != null) {
                       formatOptions.put("max_zoom", tiles.getCoverage().getMaxZoom());
                   }
                   if (tiles.getCoverage().getMinColumn() != null) {                      
                       formatOptions.put("min_column", tiles.getCoverage().getMinColumn());
                   }
                   if (tiles.getCoverage().getMaxColumn() != null) {
                       formatOptions.put("max_column", tiles.getCoverage().getMaxColumn());
                   }
                   if (tiles.getCoverage().getMinRow() != null) {
                       formatOptions.put("min_row", tiles.getCoverage().getMinRow());
                   }
                   if (tiles.getCoverage().getMaxRow() != null) {
                       formatOptions.put("max_row", tiles.getCoverage().getMaxRow());
                   }
               }
               if (tiles.getGridSetName() != null) {
                   formatOptions.put("gridset", tiles.getGridSetName());
               }
               request.setFormatOptions(formatOptions);
                             
               TileEntry e = new TileEntry();                
               addLayerMetadata(e, tiles);
              
               if (tiles.getGrids() != null) {
                   mapOutput.addTiles(gpkg, e, request, tiles.getGrids(), layer.getName());
               } else {
                   mapOutput.addTiles(gpkg, e, request, layer.getName());
               }
           }
       }
View Full Code Here

TOP

Related Classes of org.geotools.geopkg.wps.GeoPackageProcessRequest.TilesLayer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.