Source Code Cross Referenced for LinesNotIntersectValidation.java in  » GIS » GeoTools-2.4.1 » org » geotools » validation » spatial » 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 » GeoTools 2.4.1 » org.geotools.validation.spatial 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2004-2006, Geotools Project Managment Committee (PMC)
005:         *    (C) 2004 TOPP - www.openplans.org
006:         *
007:         *    This library is free software; you can redistribute it and/or
008:         *    modify it under the terms of the GNU Lesser General Public
009:         *    License as published by the Free Software Foundation; either
010:         *    version 2.1 of the License, or (at your option) any later version.
011:         *
012:         *    This library is distributed in the hope that it will be useful,
013:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         *    Lesser General Public License for more details.
016:         */
017:        package org.geotools.validation.spatial;
018:
019:        import java.util.ArrayList;
020:        import java.util.Iterator;
021:        import java.util.Map;
022:
023:        import org.geotools.feature.FeatureIterator;
024:        import org.geotools.data.FeatureSource;
025:        import org.geotools.feature.Feature;
026:        import org.geotools.validation.ValidationResults;
027:
028:        import com.vividsolutions.jts.geom.Envelope;
029:        import com.vividsolutions.jts.geom.Geometry;
030:
031:        /**
032:         * This validation plugIn checks to see if any features intersect.
033:         * 
034:         * <p>
035:         * If they do then the validation failed.
036:         * </p>
037:         *
038:         * @author Brent Owens, Refractions Research, Inc.
039:         * @author $Author: dmzwiers $ (last modification)
040:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/main/java/org/geotools/validation/spatial/LinesNotIntersectValidation.java $
041:         * @version $Id: LinesNotIntersectValidation.java 22754 2006-11-16 03:03:20Z jgarnett $
042:         */
043:        public class LinesNotIntersectValidation extends
044:                LineLineAbstractValidation {
045:            /**
046:             * An no argument constructor (for the Java Beans Specification)
047:             */
048:            public LinesNotIntersectValidation() {
049:            }
050:
051:            /**
052:             * Ensure Lines do not intersect.
053:             * 
054:             * <p>
055:             * This is supposed to go off and grab the necesary features from the
056:             * database using the envelope with the typeNames. But it doesn't yet.  It
057:             * just uses the ones passed in through parameter layers.
058:             * </p>
059:             *
060:             * @param layers a HashMap of key="TypeName" value="FeatureSource"
061:             * @param envelope The bounding box of modified features
062:             * @param results Storage for the error and warning messages
063:             *
064:             * @return True if no features intersect. If they do then the validation
065:             *         failed.
066:             *
067:             * @throws Exception DOCUMENT ME!
068:             *
069:             * @see org.geotools.validation.IntegrityValidation#validate(java.util.Map,
070:             *      com.vividsolutions.jts.geom.Envelope,
071:             *      org.geotools.validation.ValidationResults)
072:             */
073:            public boolean validate(Map layers, Envelope envelope,
074:                    ValidationResults results) throws Exception {
075:                ArrayList geoms = new ArrayList(); // FIDs used for lookup to see if any match
076:                boolean result = true;
077:                Iterator it = layers.values().iterator();
078:
079:                while (it.hasNext()) // for each layer
080:                {
081:                    FeatureSource featureSource = (FeatureSource) it.next();
082:                    FeatureIterator features = featureSource.getFeatures()
083:                            .features();
084:
085:                    try {
086:                        while (features.hasNext()) // for each feature
087:                        {
088:                            // check if it intersects any of the previous features
089:                            Feature feature = features.next();
090:                            Geometry geom = feature.getDefaultGeometry();
091:
092:                            for (int i = 0; i < geoms.size(); i++) // for each existing geometry
093:                            {
094:                                // I don't trust this thing to work correctly
095:                                if (geom.crosses((Geometry) geoms.get(i))) {
096:                                    results.error(feature,
097:                                            "Lines cross when they shouldn't.");
098:                                    result = false;
099:                                }
100:                            }
101:
102:                            geoms.add(geom);
103:                        }
104:                    } finally {
105:                        features.close(); // this is an important line    
106:                    }
107:                }
108:
109:                return result;
110:            }
111:
112:            /**
113:             * Override getPriority.
114:             * 
115:             * <p>
116:             * Sets the priority level of this validation.
117:             * </p>
118:             *
119:             * @return A made up priority for this validation.
120:             *
121:             * @see org.geotools.validation.Validation#getPriority()
122:             */
123:            public int getPriority() {
124:                return PRIORITY_INVOLVED;
125:            }
126:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.