Search in sources :

Example 1 with AreaReportPDF

use of au.org.emii.portal.util.AreaReportPDF in project spatial-portal by AtlasOfLivingAustralia.

the class AreaReportPDFComposer method onFinish.

@Override
public boolean onFinish() {
    if (pool != null) {
        return true;
    }
    //close any existing area report
    Window w = (Window) getPage().getFellowIfAny("popupResults");
    if (w != null) {
        w.detach();
    }
    SelectedArea sa = getSelectedArea();
    String areaName = getSelectedAreaName();
    String areaDisplayName = getSelectedAreaDisplayName();
    MapLayer ml = getMapComposer().getMapLayer(areaName);
    double[] bbox = null;
    if (ml != null && ml.getMapLayerMetadata().getBbox() != null && ml.getMapLayerMetadata().getBbox().size() == 4) {
        bbox = new double[4];
        bbox[0] = ml.getMapLayerMetadata().getBbox().get(0);
        bbox[1] = ml.getMapLayerMetadata().getBbox().get(1);
        bbox[2] = ml.getMapLayerMetadata().getBbox().get(2);
        bbox[3] = ml.getMapLayerMetadata().getBbox().get(3);
    }
    String wktTmp = (ml == null ? sa.getWkt() : (ml.getFacets() == null ? ml.getWKT() : null));
    if (wktTmp == null && ml != null && ml.getPid() != null) {
        wktTmp = Util.readUrl(CommonData.getLayersServer() + "/shape/wkt/" + ml.getPid());
    }
    final String queryWkt = (ml == null ? sa.getWkt() : (ml.getFacets() == null ? ml.getWKT() : null));
    final String area = areaDisplayName;
    final String wkt = wktTmp;
    final List<Facet> facets = (ml != null && ml.getFacets() != null ? ml.getFacets() : null);
    progress = new ConcurrentHashMap();
    progress.put("label", "Starting");
    progress.put("percent", 0.0);
    Callable pdfAreaReport = new Callable<AreaReportPDF>() {

        @Override
        public AreaReportPDF call() {
            return new AreaReportPDF(wkt, area, facets, queryWkt, progress);
        }
    };
    pool = Executors.newFixedThreadPool(1);
    future = pool.submit(pdfAreaReport);
    getMapComposer().getOpenLayersJavascript().execute("setTimeout('checkProgress()', 2000);");
    divProgress.setVisible(true);
    return true;
}
Also used : AreaReportPDF(au.org.emii.portal.util.AreaReportPDF) SelectedArea(au.org.emii.portal.menu.SelectedArea) MapLayer(au.org.emii.portal.menu.MapLayer) Facet(au.org.ala.legend.Facet)

Aggregations

Facet (au.org.ala.legend.Facet)1 MapLayer (au.org.emii.portal.menu.MapLayer)1 SelectedArea (au.org.emii.portal.menu.SelectedArea)1 AreaReportPDF (au.org.emii.portal.util.AreaReportPDF)1