V1_0.java [src/java/m/gis/intersect] Revision:   Date:
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package m.gis.intersect;

import java.util.ListIterator;
import java.util.logging.Level;
import javax.ws.rs.Path;
import m.gis.GISModelDataService;
import m.utils.Layer;
import m.utils.test.github.GitHub;
import oms3.annotations.*;

/**
 *
 * @author ktraff
 */
@Name("intersect")
@Description("CSIP Intersection Service")
@Path("m/intersect/1.0")
public class V1_0 extends GISModelDataService {
    
    String testUrl;

    @Override
    protected void preProcess() throws Exception {
        super.preProcess();
    }

    @Override
    protected String process() throws Exception {
        Layer resultLayer = null;
        if (layers.size() > 0) {
            ListIterator<Layer> iterator = layers.listIterator();
            resultLayer = iterator.next();
            while (iterator.hasNext()) {
                resultLayer = db.intersect(resultLayer, iterator.next());
            }
        }
        result.put(db.toJSON(resultLayer, outputSRID));
        testUrl = GitHub.createGist("intersection.json", 
                "csip-gis intersection result", result.getJSONObject(0).toString()).getGeoJSONUrl();
        LOG.log(Level.INFO, testUrl);
        return EXEC_OK;
    }

    @Override
    protected void postProcess() throws Exception {
        super.postProcess();
        putResult("testUrl", testUrl);
    }

}