Source Code Cross Referenced for TestLib.java in  » GIS » GeOxygene-1.3 » fr » ign » cogit » geoxygene » util » algo » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeOxygene 1.3 » fr.ign.cogit.geoxygene.util.algo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the GeOxygene project source files. 
003:         * 
004:         * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for 
005:         * the development and deployment of geographic (GIS) applications. It is a open source 
006:         * contribution of the COGIT laboratory at the Institut Géographique National (the French 
007:         * National Mapping Agency).
008:         * 
009:         * See: http://oxygene-project.sourceforge.net 
010:         *  
011:         * Copyright (C) 2005 Institut Géographique National
012:         *
013:         * This library is free software; you can redistribute it and/or modify it under the terms
014:         * of the GNU Lesser General Public License as published by the Free Software Foundation; 
015:         * either version 2.1 of the License, or any later version.
016:         *
017:         * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
018:         * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
019:         * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020:         *
021:         * You should have received a copy of the GNU Lesser General Public License along with 
022:         * this library (see file LICENSE if present); if not, write to the Free Software 
023:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:         *  
025:         */
026:
027:        package fr.ign.cogit.geoxygene.util.algo;
028:
029:        import java.util.Date;
030:
031:        import fr.ign.cogit.geoxygene.datatools.Geodatabase;
032:        import fr.ign.cogit.geoxygene.datatools.ojb.GeodatabaseOjbFactory;
033:        import fr.ign.cogit.geoxygene.example.Resultat;
034:        import fr.ign.cogit.geoxygene.feature.FT_FeatureCollection;
035:        import fr.ign.cogit.geoxygene.spatial.geomaggr.GM_MultiSurface;
036:        import fr.ign.cogit.geoxygene.spatial.geomroot.GM_Object;
037:
038:        /**
039:         * Test de toutes les methodes d'une bibliotheque de geometrie algorithmique.
040:         * Generique : on peut creer une nouvelle classe pour l'appel aux methodes,
041:         * par extension de util.GeomAlgorithms .
042:         *
043:         * @author Thierry Badard, Arnaud Braun & Christophe Pele 
044:         * @version 1.1
045:         * 
046:         */
047:
048:        public class TestLib {
049:
050:            // private GeomAlgorithms algo;   // les algorithmes a tester - generique 
051:            private JtsAlgorithms algo; // typage JTS pour tester des algos specifiques a JTS
052:
053:            private double seuil = 50.0; // seuil pour le buffer     
054:
055:            // Alias de Connection a Oracle (dans le fichier de mapping repository_database.xml)
056:            private String ORACLE_ALIAS = "ORACLE_ALIAS";
057:
058:            private Geodatabase db; // connection a la base de donnees
059:            private Class featureClass1, featureClass2; // classes de FT_Feature a charger     
060:            private FT_FeatureCollection featureList1, featureList2; // result du chargement 
061:            private GM_MultiSurface aggr1; // agregat geometrique issu du chargement
062:            private GM_MultiSurface aggr2; // agregat geometrique issu du chargement
063:            private GM_Object geom; // ceci sera le resultat geometrique des algos
064:            private Resultat result; // resultat a rendre persistant
065:
066:            public TestLib() {
067:
068:                db = GeodatabaseOjbFactory.newInstance(ORACLE_ALIAS);
069:
070:                aggr1 = new GM_MultiSurface(); /* eventuellement new GM_MultiCurve(); */
071:                aggr2 = new GM_MultiSurface(); /* eventuellement new GM_MultiCurve(); */
072:
073:                /* definir ici la bibliotheque a tester */
074:                algo = new JtsAlgorithms();
075:                //algos =new OracleAlgorithms(db,0.0000000005);
076:
077:                /* definir ici les classe d'objets geographiques a charger */
078:                try {
079:                    //featureClass1 = Class.forName("geoschema.feature.Batiment_surf");
080:                    //featureClass1 = Class.forName("geoschema.feature.Troncon_route_bdc");
081:                    featureClass1 = Class
082:                            .forName("geoschema.feature.Topo_bati_extrait5");
083:                    featureClass2 = Class
084:                            .forName("geoschema.feature.Topo_bati_extrait5_translate");
085:                } catch (ClassNotFoundException e) {
086:                    System.out.println("classe geographique non trouvee : "
087:                            + featureClass1.getName());
088:                    System.out.println("classe geographique non trouvee : "
089:                            + featureClass2.getName());
090:                }
091:            }
092:
093:            public static void main(String args[]) {
094:                TestLib test = new TestLib();
095:                test.testAll();
096:            }
097:
098:            public void testAll() {
099:
100:                // Debut d'une transaction
101:                System.out.println("Debut transaction");
102:                db.begin();
103:
104:                // Recherche du nombre d'objets a traiter
105:                int n = db.countObjects(featureClass1);
106:                System.out.println("Nombre d'objets a traiter classe 1:" + n);
107:                n = db.countObjects(featureClass2);
108:                System.out.println("Nombre d'objets a traiter classe 2:" + n);
109:
110:                // Chargement de tous les objets
111:                featureList1 = db.loadAllFeatures(featureClass1);
112:                featureList2 = db.loadAllFeatures(featureClass2);
113:                System.out.println("chargement termine");
114:
115:                // Constitution des agregats
116:                featureList1.initIterator();
117:                while (featureList1.hasNext())
118:                    aggr1.add(featureList1.next().getGeom());
119:                featureList2.initIterator();
120:                while (featureList2.hasNext())
121:                    aggr2.add(featureList2.next().getGeom());
122:
123:                // buffer
124:                System.out.println("buffer ...");
125:                System.out.println("\t" + new Date(System.currentTimeMillis()));
126:                geom = algo.buffer(aggr1, seuil);
127:                System.out.println("\t" + new Date(System.currentTimeMillis()));
128:                result = new Resultat();
129:                result.setGeom(geom);
130:                db.makePersistent(result);
131:                db.checkpoint();
132:
133:                // centroide
134:                System.out.println("centroide ...");
135:                System.out.println("\t" + new Date(System.currentTimeMillis()));
136:                geom = algo.centroid(aggr1);
137:                System.out.println("\t" + new Date(System.currentTimeMillis()));
138:                result = new Resultat();
139:                result.setGeom(geom);
140:                db.makePersistent(result);
141:                db.checkpoint();
142:
143:                // enveloppe convexe
144:                System.out.println("enveloppe convexe ...");
145:                System.out.println("\t" + new Date(System.currentTimeMillis()));
146:                geom = algo.convexHull(aggr1);
147:                System.out.println("\t" + new Date(System.currentTimeMillis()));
148:                result = new Resultat();
149:                result.setGeom(geom);
150:                db.makePersistent(result);
151:                db.checkpoint();
152:
153:                // difference
154:                System.out.println("difference ...");
155:                System.out.println("\t" + new Date(System.currentTimeMillis()));
156:                geom = algo.difference(aggr1, aggr2);
157:                System.out.println("\t" + new Date(System.currentTimeMillis()));
158:                result = new Resultat();
159:                result.setGeom(geom);
160:                db.makePersistent(result);
161:                db.checkpoint();
162:
163:                // intersection
164:                System.out.println("intersection ...");
165:                System.out.println("\t" + new Date(System.currentTimeMillis()));
166:                geom = algo.intersection(aggr1, aggr2);
167:                System.out.println("\t" + new Date(System.currentTimeMillis()));
168:                result = new Resultat();
169:                result.setGeom(geom);
170:                db.makePersistent(result);
171:                db.checkpoint();
172:
173:                // union
174:                System.out.println("union ...");
175:                System.out.println("\t" + new Date(System.currentTimeMillis()));
176:                geom = algo.union(aggr1, aggr2);
177:                System.out.println("\t" + new Date(System.currentTimeMillis()));
178:                result = new Resultat();
179:                result.setGeom(geom);
180:                db.makePersistent(result);
181:                db.checkpoint();
182:
183:                // difference symetrique
184:                System.out.println("difference symetrique ...");
185:                System.out.println("\t" + new Date(System.currentTimeMillis()));
186:                geom = algo.symDifference(aggr1, aggr2);
187:                System.out.println("\t" + new Date(System.currentTimeMillis()));
188:                result = new Resultat();
189:                result.setGeom(geom);
190:                db.makePersistent(result);
191:                db.checkpoint();
192:
193:                // predicat contains
194:                System.out.println(" predicat contains ...");
195:                System.out.println("\t" + new Date(System.currentTimeMillis()));
196:                System.out.println(algo.contains(aggr1, aggr2));
197:                System.out.println("\t" + new Date(System.currentTimeMillis()));
198:
199:                // predicat intersects
200:                System.out.println(" predicat intersects ...");
201:                System.out.println("\t" + new Date(System.currentTimeMillis()));
202:                System.out.println(algo.intersects(aggr1, aggr2));
203:                System.out.println("\t" + new Date(System.currentTimeMillis()));
204:
205:                // predicat equals
206:                System.out.println(" predicat equals ...");
207:                System.out.println("\t" + new Date(System.currentTimeMillis()));
208:                System.out.println(algo.equals(aggr1, aggr2));
209:                System.out.println("\t" + new Date(System.currentTimeMillis()));
210:
211:                // distance
212:                System.out.println(" distance ...");
213:                System.out.println("\t" + new Date(System.currentTimeMillis()));
214:                System.out.println(algo.distance(aggr1, aggr2));
215:                System.out.println("\t" + new Date(System.currentTimeMillis()));
216:
217:                // longueur
218:                System.out.println(" longueur ...");
219:                System.out.println("\t" + new Date(System.currentTimeMillis()));
220:                System.out.println(algo.length(aggr1));
221:                System.out.println("\t" + new Date(System.currentTimeMillis()));
222:
223:                // aire
224:                System.out.println(" aire ...");
225:                System.out.println("\t" + new Date(System.currentTimeMillis()));
226:                System.out.println(algo.area(aggr1));
227:                System.out.println("\t" + new Date(System.currentTimeMillis()));
228:
229:                // ## ce qui suit est specifique JTS
230:
231:                // predicat equals exact
232:                System.out.println(" predicat equals exact ...");
233:                System.out.println("\t" + new Date(System.currentTimeMillis()));
234:                System.out.println(algo.equalsExact(aggr1, aggr2));
235:                System.out.println("\t" + new Date(System.currentTimeMillis()));
236:
237:                // predicat crosses
238:                System.out.println(" predicat crosses ...");
239:                System.out.println("\t" + new Date(System.currentTimeMillis()));
240:                System.out.println(algo.crosses(aggr1, aggr2));
241:                System.out.println("\t" + new Date(System.currentTimeMillis()));
242:
243:                // predicat disjoint
244:                System.out.println(" predicat disjoint ...");
245:                System.out.println("\t" + new Date(System.currentTimeMillis()));
246:                System.out.println(algo.disjoint(aggr1, aggr2));
247:                System.out.println("\t" + new Date(System.currentTimeMillis()));
248:
249:                // predicat within
250:                System.out.println(" predicat within ...");
251:                System.out.println("\t" + new Date(System.currentTimeMillis()));
252:                System.out.println(algo.within(aggr1, aggr2));
253:                System.out.println("\t" + new Date(System.currentTimeMillis()));
254:
255:                // predicat overlaps
256:                System.out.println(" predicat overlaps ...");
257:                System.out.println("\t" + new Date(System.currentTimeMillis()));
258:                System.out.println(algo.overlaps(aggr1, aggr2));
259:                System.out.println("\t" + new Date(System.currentTimeMillis()));
260:
261:                // predicat touches
262:                System.out.println(" predicat touches ...");
263:                System.out.println("\t" + new Date(System.currentTimeMillis()));
264:                System.out.println(algo.touches(aggr1, aggr2));
265:                System.out.println("\t" + new Date(System.currentTimeMillis()));
266:
267:                // isValid
268:                System.out.println(" isValid ...");
269:                System.out.println("\t" + new Date(System.currentTimeMillis()));
270:                System.out.println(algo.isValid(aggr1));
271:                System.out.println("\t" + new Date(System.currentTimeMillis()));
272:
273:                // isEmpty
274:                System.out.println(" isEmpty ...");
275:                System.out.println("\t" + new Date(System.currentTimeMillis()));
276:                System.out.println(algo.isEmpty(aggr1));
277:                System.out.println("\t" + new Date(System.currentTimeMillis()));
278:
279:                // isSimple
280:                System.out.println(" isSimple ...");
281:                System.out.println("\t" + new Date(System.currentTimeMillis()));
282:                System.out.println(algo.isSimple(aggr1));
283:                System.out.println("\t" + new Date(System.currentTimeMillis()));
284:
285:                // dimension
286:                System.out.println(" dimension ...");
287:                System.out.println("\t" + new Date(System.currentTimeMillis()));
288:                System.out.println(algo.dimension(aggr1));
289:                System.out.println("\t" + new Date(System.currentTimeMillis()));
290:
291:                // numPoints
292:                System.out.println(" numPoints ...");
293:                System.out.println("\t" + new Date(System.currentTimeMillis()));
294:                System.out.println(algo.numPoints(aggr1));
295:                System.out.println("\t" + new Date(System.currentTimeMillis()));
296:
297:                // translate
298:                System.out.println("translate ...");
299:                System.out.println("\t" + new Date(System.currentTimeMillis()));
300:                geom = algo.translate(aggr1, 50, 50, 0);
301:                System.out.println("\t" + new Date(System.currentTimeMillis()));
302:                result = new Resultat();
303:                result.setGeom(geom);
304:                db.makePersistent(result);
305:                db.checkpoint();
306:
307:                // boundary
308:                System.out.println("boundary ...");
309:                System.out.println("\t" + new Date(System.currentTimeMillis()));
310:                geom = algo.boundary(aggr1);
311:                System.out.println("\t" + new Date(System.currentTimeMillis()));
312:                result = new Resultat();
313:                result.setGeom(geom);
314:                db.makePersistent(result);
315:                db.checkpoint();
316:
317:                //Fermeture transaction
318:                System.out.println("commit");
319:                db.commit();
320:
321:            }
322:
323:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.