
import fr.ocelet.runtime.*;
import fr.ocelet.runtime.affectoperators.*;
import fr.ocelet.runtime.relation.*;
import edu.uci.ics.jung.graph.util.Pair;
import java.util.Collection;

public class Main extends Model {
    
    public Main() {
        super();
    }
    
    public void run() {
        KmlFile kml = new KmlFile();
        Geometry geom = new Geometry();
        ShapeFile shp = new ShapeFile();
        defProperty("voisinVase",new Hproperty<VoisinageVase>());
        setProperty("voisinVase",new VoisinageVase());
        defProperty("voisinRive",new Hproperty<VoisinageRive>());
        setProperty("voisinRive",new VoisinageRive());
        shp.read("D:\\TETIS\\ANR - Programme Blanc\\01-Execution\\Landscapes\\Mangrove-AIC\\1986-2001\\sinnamary1988_1_latlong.shp");
        List<List<List<Double>>> shpCoordinates = shp.getCoordinates();
        Vase vase2 = new Vase();
        vase2.setProperty("id",2);
        vase2.setProperty("coordinates",shpCoordinates.get(2));
        vase2.setProperty("geom",geom);
        vase2.setProperty("kml",kml);
        Vase vase3 = new Vase();
        vase3.setProperty("id",3);
        vase3.setProperty("coordinates",shpCoordinates.get(3));
        vase3.setProperty("geom",geom);
        vase3.setProperty("kml",kml);
        Rive rive = new Rive();
        rive.setProperty("coordinates",shpCoordinates.get(0));
        rive.setProperty("kml",kml);
        Vase vase1 = new Vase();
        vase1.setProperty("id",1);
        vase1.setProperty("coordinates",geom.stickToLine(shpCoordinates.get(1), ((List<List<Double>>)rive.getProperty("coordinates"))));
        vase1.setProperty("geom",geom);
        vase1.setProperty("kml",kml);
        Ocean ocean = new Ocean();
        ocean.setProperty("houle",2.0E-4);
        ocean.setProperty("sable",2.0E-4);
        graphConnect("voisinVase",new Pair<Entity>(vase1, ocean));
        graphConnect("voisinVase",new Pair<Entity>(vase2, ocean));
        graphConnect("voisinVase",new Pair<Entity>(vase3, ocean));
        graphConnect("voisinRive",new Pair<Entity>(rive, vase1));
        kml.addCoordinateStep("1988", ((List<List<Double>>)vase1.getProperty("coordinates")));
        kml.addCoordinateStep("1988", ((List<List<Double>>)vase2.getProperty("coordinates")));
        kml.addCoordinateStep("1988", ((List<List<Double>>)vase3.getProperty("coordinates")));
        kml.addCoordinateStep("1988", ((List<List<Double>>)rive.getProperty("coordinates")));
        List<String> dates = kml.getDates(1989, 2010);
        for (String date : dates) {
            graphApplyBehavior("voisinVase",new VoisinageVase.Evolve(date, ((List<List<Double>>)rive.getProperty("coordinates"))));
            graphApplyBehavior("voisinRive",new VoisinageRive.Evolve(date));
        }
        kml.createKmlFile("mangrove.kml");
    }
    
    public static void main(final java.lang.String[] args) {
        Main main = new Main();
        main.run();
    }
}