⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testfederation.java

📁 用于GIS(全球地理系统)的分析和处理的代码。
💻 JAVA
字号:
/*
 * This file is part of the GeOxygene project source files. 
 * 
 * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for 
 * the development and deployment of geographic (GIS) applications. It is a open source 
 * contribution of the COGIT laboratory at the Institut G閛graphique National (the French 
 * National Mapping Agency).
 * 
 * See: http://oxygene-project.sourceforge.net 
 *  
 * Copyright (C) 2005 Institut G閛graphique National
 *
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation; 
 * either version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
 * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with 
 * this library (see file LICENSE if present); if not, write to the Free Software 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *  
 */

package fr.ign.cogit.geoxygene.example;

import fr.ign.cogit.geoxygene.datatools.Geodatabase;
import fr.ign.cogit.geoxygene.datatools.ojb.GeodatabaseOjbFactory;
import fr.ign.cogit.geoxygene.feature.FT_FeatureCollection;
import fr.ign.cogit.geoxygene.spatial.geomaggr.GM_Aggregate;
import fr.ign.cogit.geoxygene.spatial.geomroot.GM_Object;

/**
 * Federation de donnees.
 * Exemple d'utilisation de plusieurs "Geodatabase" simultanees.
 * 
 * Remarque : l'utilisation de plusieurs transactions simultanees plante, 
 * a etudier.
 * 
 * @author Thierry Badard & Arnaud Braun
 * @version 1.1
 *
 */

public class TestFederation {


	public static void main(String args[]) {
		
    	Geodatabase db1,db2,db3; 
    	Class featureClass1=null; 
		Class featureClass2=null; 
        long t1,t2;
    
        System.out.println("coucou");
    
		db1 = GeodatabaseOjbFactory.newInstance();
		db2 = GeodatabaseOjbFactory.newInstance("ORACLE_ALIAS_NCDB");
		db3 = GeodatabaseOjbFactory.newInstance("POSTGRES_ALIAS");
		
		System.out.println(db1);
		System.out.println(db2);
		System.out.println(db3);		

    	
    	try {
    		featureClass1 = Class.forName("geoxygene.geodata.Troncon_voie_ferree");
			featureClass2 = Class.forName("geoxygene.geodata.Troncon_voie_ferree_50");
    	} catch (Exception e) {
    		e.printStackTrace();
    	}
       
        
        System.out.println("nombre d'objets : "+db1.countObjects(featureClass1));    
		System.out.println("nombre d'objets : "+db2.countObjects(featureClass2));        
         
        System.out.print("chargement ... "+featureClass1.getName()+"   ");
        t1 = System.currentTimeMillis();
        FT_FeatureCollection coll1 = db1.loadAllFeatures(featureClass1);
        t2 = System.currentTimeMillis();
        System.out.println( (t2-t1) / 1000. );

		System.out.print("chargement ... "+featureClass2.getName()+"  ");
		t1 = System.currentTimeMillis();
		FT_FeatureCollection coll2 = db2.loadAllFeatures(featureClass2);
		t2 = System.currentTimeMillis();
		System.out.println( (t2-t1) / 1000. );
		
		System.out.println("Calcul buffer 1 ...");
		int i = 0;
		GM_Aggregate aggr = new GM_Aggregate();
		coll1.initIterator();
		while (coll1.hasNext()) {
			i++;
			GM_Object geom = coll1.next().getGeom();
			geom = geom.buffer(100.);
			aggr.add(geom);
			if (i > 1000) break;
		}
		
		
		System.out.println("Calcul buffer 2 ...");
		i = 0;
		coll2.initIterator();
		while (coll2.hasNext()) {
			i++;
			GM_Object geom = coll2.next().getGeom();
			geom = geom.buffer(50.);
			aggr.add(geom);
			if (i > 1000) break;
		}
    
		db3.begin();
		System.out.println("begin db3");
        
        System.out.print("ecriture ... ");
        t1 = System.currentTimeMillis();
        aggr.initIterator();
        while (aggr.hasNext()) {
            Resultat res = new  Resultat();
			db3.makePersistent(res);    
			res.setGeom(aggr.next());  			
        }    
        t2 = System.currentTimeMillis();
        System.out.println( (t2-t1) / 1000. );     
                                     
        System.out.print("commit db3... ");
        t1 = System.currentTimeMillis();
        db3.commit();
        t2 = System.currentTimeMillis();
        System.out.println( (t2-t1) / 1000. );        
        System.out.println("OK");
        
		
	}


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -