Package it.geosolutions.unredd.geostore.model

Examples of it.geosolutions.unredd.geostore.model.UNREDDLayer


        Resource srcLayer = srcGeostore.searchLayer(layerName);
        if(srcLayer == null) {
            throw new ActionException(this, "Source Layer not found [" + layerName+ "]");
        }

        UNREDDLayer layerResource = new UNREDDLayer(srcLayer);
        String srcPath = layerResource.getAttribute(UNREDDLayer.Attributes.MOSAICPATH);
        String dstPath = layerResource.getAttribute(UNREDDLayer.Attributes.DISSMOSAICPATH);

        LOGGER.info(layerName + " found in the Staging Area Geostore");

        // TODO ***** add layer in destination if it does not exist
        LOGGER.error("TODO: add layer in destination if it does not exist");

        // ****************************************
        // check source layer update
        //
        // ****************************************

        LOGGER.info("Searching source LayerUpdate [" + layerName + ", " + year + "," + month + "]");

        Resource srcLayerUpdatesSA = srcGeostore.searchLayerUpdate(layerName, year, month, day);
        if (srcLayerUpdatesSA == null) {
            throw new ActionException(this, "Source LayerUpdate not found [" + layerName + ", " + year + "," + month + "]");
        }

            LOGGER.info("Source LayerUpdate found [" + layerName + ", " + year + "," + month + "]");

       
        boolean isVector = request.getFormat().equals(UNREDDFormat.VECTOR);
        DataStore srcDS=null,destDS=null;
        try {
          srcDS=PostGISUtils.createDatastore(conf.getSrcPostGisConfig());
          destDS=PostGISUtils.createDatastore(conf.getDstPostGisConfig());
         
          if (isVector) {
            // ****************************************
              // Copy the features and raster data
              // ----------
              // Copy feats identified by layer, year and month
              // from the staging area postgis db to the dissemination db
              // in case update is set on true we should
              // firstly remove the old features from the dissemination db.
              // This controls will be made directly in the updatePostGIS method.
            //
            // After features copy copy the raster data from staging mosaic path to dissemination mosaic path.
            // Altought the mosaic_path destination This tiff is not a mosaic granule but is needed for dynamic stats.         
              // ****************************************
            LOGGER.info("The request is VECTOR format based:");
              LOGGER.info("Updating PostGIS...");
              updatePostGIS(srcDS, destDS, layerName, year, month, day);
              LOGGER.info("Copy raster data used for dynamic stats...");
              this.copyRaster(srcPath, dstPath, layerName, year, month, day);
          }
          else {
            // ****************************************
            // Copy the raster
            // ----------
            // copies the raster located into the mosaic
            // staging area directory to the dissemination mosaic.
            // This  operation is performed both in case of a first publishing
            // and successive ones
            //
            // ****************************************
            LOGGER.info("The request is RASTER format based:");
            LOGGER.info("Update the mosaic...");
           
            File srcRasterFile = new File(srcPath, filename);
            File mosaicDir = new File(dstPath);
           
            String style = layerResource.getAttribute(UNREDDLayer.Attributes.LAYERSTYLE);
                  if(style==null || style.isEmpty()){
                      style = DEFAULT_MOSAIC_STYLE;
                  }
                  StringBuilder msg = new StringBuilder();
                  msg.append("Publishing the Mosaic Granule with Style -> ");
                  msg.append(style);
                  LOGGER.info(msg.toString());
           
            //create bounding box with values setted on GeoStore
            double [] bbox = new double[4];
              bbox[0] = Double.valueOf(layerResource.getAttribute(Attributes.RASTERX0));
              bbox[1] = Double.valueOf(layerResource.getAttribute(Attributes.RASTERY0));
              bbox[2] = Double.valueOf(layerResource.getAttribute(Attributes.RASTERX1));
              bbox[3] = Double.valueOf(layerResource.getAttribute(Attributes.RASTERY1));
             
              Mosaic mosaic = new Mosaic(conf.getDstGeoServerConfig(), mosaicDir, getTempDir(), getConfigDir());
              mosaic.add(conf.getDstGeoServerConfig().getWorkspace(), layerName, srcRasterFile, "EPSG:4326", bbox, style, conf.getDatastorePath());
          }

View Full Code Here


            Resource layerRes = geoStoreUtil.searchLayer(layerName);
            if(layerRes == null) {
                LOGGER.warn("Could not find Layer '"+layerName+"' for StatsDef '"+statsDefName+"'");
                continue;
            }
            UNREDDLayer layer = new UNREDDLayer(layerRes);

            List<Resource> layerUpdates = geoStoreUtil.searchLayerUpdateByLayer(layerName);
            LOGGER.info("Found " + layerUpdates.size() + " LayerUpdates for Layer " + layerName);

            // Compute stats for every time coordinate this layer has
            int layerUps = layerUpdates.size();
            int layerUpsCnt = 0;
            for (Resource layerUpdateRes : layerUpdates) {
                float minorStep = layerUpsCnt++ / layerUps;
                String msg = "Starting reprocessing StatsDef:" + statsDefName + " Layer:" + layerName + " LayerUpdate:" + layerUpdateRes.getName();
                LOGGER.info(msg);
                this.listenerForwarder.progressing(rescale(min, max, majorStep*(1+minorStep)), msg);

                UNREDDLayerUpdate layerUpdate = new UNREDDLayerUpdate(layerUpdateRes);
                String year = layerUpdate.getAttribute(UNREDDLayerUpdate.Attributes.YEAR);
                String month = layerUpdate.getAttribute(UNREDDLayerUpdate.Attributes.MONTH);
                String day = layerUpdate.getAttribute(UNREDDLayerUpdate.Attributes.DAY);

                String rasterPath = layer.getAttribute(Attributes.MOSAICPATH);
                String rasterFile = NameUtils.buildTifFileName(layerName, year, month, day);
                String rasterFullPath = new File(rasterPath, rasterFile).getAbsolutePath();

                Map<Tokens, String> tokens = FlowUtil.fillTokens(rasterFullPath, layerName, year, month, null);
                flowUtil.processStatistics(geoStoreUtil, statsDefRes, year, month, day, tokens);
View Full Code Here

        if (layerRes == null) {
            throw new ActionException(this, "Layer not found: " + layerName);
        }

        UNREDDLayer layer = new UNREDDLayer(layerRes);
        LOGGER.info(layerName + " found in the Staging Area Geostore");


        // ========================================
        // Load layerUpdate

        LOGGER.info("Searching layer update [" + layerName + ", " + year + "," + month + "]");

        Resource layerUpdatesRes = null;
        try {
            layerUpdatesRes = geoStoreUtil.searchLayerUpdate(layerName, year, month, day);
        } catch (GeoStoreException e) {
            throw new ActionException(this, "Error while searching LayerUpdate: " + layerName, e);
        }

        if (layerUpdatesRes == null) {
            LOGGER.warn("Missing Layer update [" + layerName + ", " + year + "," + month + "]");

            // create the missing LayerUpdate entry
            try {
                geoStoreUtil.insertLayerUpdate(layerName, year, month, day);
            } catch (GeoStoreException e) {
                throw new ActionException(this, "Error while inserting a LayerUpdate", e);
            }
        }

        try {
            layerUpdatesRes = geoStoreUtil.searchLayerUpdate(layerName, year, month, day);
        } catch (GeoStoreException e) {
            throw new ActionException(this, "LayerUpdate not createds: " + layerName, e);
        }

        UNREDDLayerUpdate layerUpdate = new UNREDDLayerUpdate(layerUpdatesRes);

        // ========================================
        // In case of update we should regenerate the tiff.
        // We have also retile, overview it and move it to the mosaic directory

        File rasterfile = null;
        String layerFormat = layer.getAttribute(Attributes.LAYERTYPE);

        if (UNREDDFormat.VECTOR.name().equals(layerFormat)) {

            rasterfile = reprocessVector(layer, layerUpdate);

        } else if (UNREDDFormat.RASTER.name().equals(layerFormat)) {

            File dir = new File(layer.getAttribute(UNREDDLayer.Attributes.MOSAICPATH));
            String filename = NameUtils.buildTifFileName(layerName, year, month, day);
            rasterfile = new File(dir, filename);

        } else {
            throw new ActionException(this, "Unrecognized layer format '"+layerFormat+"'");
View Full Code Here

        LOGGER.info("===== Add sample data: Layer");
        File mosaicDir = new File(getTempDir(), "mosaic");
        mosaicDir.mkdir();

        UNREDDLayer layer = new UNREDDLayer();
        layer.setAttribute(UNREDDLayer.Attributes.LAYERTYPE, UNREDDFormat.RASTER.getName());
        layer.setAttribute(UNREDDLayer.Attributes.MOSAICPATH, mosaicDir.getAbsolutePath());
        //layer.setAttribute(UNREDDLayer.Attributes.DESTORIGRELATIVEPATH, getTempDir().getAbsolutePath());
        layer.setAttribute(UNREDDLayer.Attributes.RASTERPIXELWIDTH,  "3876");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERPIXELHEIGHT, "3562");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERX0, "21");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERX1, "23");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERY0, "-6.5");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERY1, "5.1");

        return layer;
    }
View Full Code Here

        LOGGER.info("===== Add sample data: Vector Layer");
        File mosaicDir = new File(getTempDir(), "mosaic");
        mosaicDir.mkdir();

        UNREDDLayer layer = new UNREDDLayer();
        layer.setAttribute(UNREDDLayer.Attributes.LAYERTYPE, UNREDDFormat.VECTOR.getName());
        layer.setAttribute(UNREDDLayer.Attributes.MOSAICPATH, mosaicDir.getAbsolutePath());
        //layer.setAttribute(UNREDDLayer.Attributes.DESTORIGRELATIVEPATH, getTempDir().getAbsolutePath());
        layer.setAttribute(UNREDDLayer.Attributes.RASTERPIXELWIDTH,  "3876");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERPIXELHEIGHT, "3562");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERX0, "21");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERX1, "23");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERY0, "-6.5");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERY1, "5.1");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERATTRIBNAME, "scene_id");
        layer.setAttribute(UNREDDLayer.Attributes.RASTERNODATA,     "999999");

        return layer;
    }
View Full Code Here

    @Test
    @Ignore
    public void testBadFormat() throws GeoStoreException, FlowException, ActionException {
        clearPlayfield();
        UNREDDLayer layer = buildRasterLayer();
        layer.setAttribute(UNREDDLayer.Attributes.LAYERTYPE, UNREDDFormat.VECTOR.getName());
        RESTResource layerResource = layer.createRESTResource();
        layerResource.setName("layer1");
        gstcu.insert(layerResource);

        //=== Data is set, prepare flow
        LOGGER.info("===== Run the code!");
View Full Code Here

    @Test
    @Ignore
    public void testBadSize() throws GeoStoreException, FlowException, ActionException {
        clearPlayfield();
        UNREDDLayer layer = buildRasterLayer();
        layer.setAttribute(UNREDDLayer.Attributes.RASTERPIXELWIDTH, "42");
        RESTResource layerResource = layer.createRESTResource();
        layerResource.setName("layer1");
        gstcu.insert(layerResource);

        //=== Data is set, prepare flow
        LOGGER.info("===== Run the code!");
View Full Code Here

    @Test
    @Ignore
    public void testBadExistingLayerUpdate() throws GeoStoreException, FlowException, ActionException {
        clearPlayfield();
        UNREDDLayer layer = buildRasterLayer();
        RESTResource layerResource = layer.createRESTResource();
        layerResource.setName("layer1");
        gstcu.insert(layerResource);

        UNREDDLayerUpdate layerUpdate = new UNREDDLayerUpdate();
        layerUpdate.setAttribute(Attributes.YEAR, "2012");
View Full Code Here

    @Test
    public void testProperIngestRaster() throws GeoStoreException, FlowException, ActionException {

        clearPlayfield();
        UNREDDLayer layer = buildRasterLayer();
        RESTResource layerResource = layer.createRESTResource();
        layerResource.setName("layer1");
        gstcu.insert(layerResource);
       
        //=== Data is set, prepare flow
        LOGGER.info("===== Run the code!");
View Full Code Here

    @Test
    public void testProperIngestVector() throws GeoStoreException, FlowException, ActionException {

        clearPlayfield();
        UNREDDLayer layer = buildVectorLayer();
        RESTResource layerResource = layer.createRESTResource();
        layerResource.setName("layer1");
        gstcu.insert(layerResource);

        //=== Data is set, prepare flow
        LOGGER.info("===== Run the code!");
View Full Code Here

TOP

Related Classes of it.geosolutions.unredd.geostore.model.UNREDDLayer

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.