Source Code Cross Referenced for PolygonNotOverlappingPolygonValidation.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:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation; either
009:         *    version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.validation.spatial;
017:
018:        import java.util.Map;
019:        import java.util.logging.Logger;
020:
021:        import org.geotools.data.FeatureSource;
022:        import org.geotools.feature.Feature;
023:        import org.geotools.feature.FeatureCollection;
024:        import org.geotools.validation.ValidationResults;
025:
026:        import com.vividsolutions.jts.geom.Envelope;
027:        import com.vividsolutions.jts.geom.Geometry;
028:
029:        /**
030:         * PolygonBoundaryCoveredByPolygonValidation purpose.
031:         * 
032:         * <p>
033:         * Ensures Polygon Boundary is not covered by the Polygon.
034:         * </p>
035:         *
036:         * @author dzwiers, Refractions Research, Inc.
037:         * @author $Author: jive $ (last modification)
038:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/main/java/org/geotools/validation/spatial/PolygonNotOverlappingPolygonValidation.java $
039:         * @version $Id: PolygonNotOverlappingPolygonValidation.java 27862 2007-11-12 19:51:19Z desruisseaux $
040:         */
041:        public class PolygonNotOverlappingPolygonValidation extends
042:                PolygonPolygonAbstractValidation {
043:
044:            private static final Logger LOGGER = org.geotools.util.logging.Logging
045:                    .getLogger("org.geotools.validation");
046:
047:            /**
048:             * PolygonBoundaryCoveredByPolygonValidation constructor.
049:             * 
050:             * <p>
051:             * Description
052:             * </p>
053:             */
054:            public PolygonNotOverlappingPolygonValidation() {
055:                super ();
056:
057:                // TODO Auto-generated constructor stub
058:            }
059:
060:            /**
061:             * Ensure Polygon Boundary is not covered by the Polygon.
062:             * 
063:             * <p></p>
064:             *
065:             * @param layers a HashMap of key="TypeName" value="FeatureSource"
066:             * @param envelope The bounding box of modified features
067:             * @param results Storage for the error and warning messages
068:             *
069:             * @return True if no features intersect. If they do then the validation
070:             *         failed.
071:             *
072:             * @throws Exception DOCUMENT ME!
073:             *
074:             * @see org.geotools.validation.IntegrityValidation#validate(java.util.Map,
075:             *      com.vividsolutions.jts.geom.Envelope,
076:             *      org.geotools.validation.ValidationResults)
077:             */
078:            public boolean validate(Map layers, Envelope envelope,
079:                    ValidationResults results) throws Exception {
080:
081:                LOGGER.finer("Starting test " + getName() + " ("
082:                        + getClass().getName() + ")");
083:                String typeRef1 = getPolygonTypeRef();
084:                LOGGER.finer(typeRef1 + ": looking up FeatureSource ");
085:                FeatureSource polySource1 = (FeatureSource) layers
086:                        .get(typeRef1);
087:                LOGGER.finer(typeRef1 + ": found "
088:                        + polySource1.getSchema().getTypeName());
089:
090:                FeatureCollection collection1 = polySource1.getFeatures(); // limit with envelope
091:                Object[] poly1 = collection1.toArray();
092:
093:                String typeRef2 = getRestrictedPolygonTypeRef();
094:                LOGGER.finer(typeRef2 + ": looking up FeatureSource ");
095:                FeatureSource polySource2 = (FeatureSource) layers
096:                        .get(typeRef2);
097:                LOGGER.finer(typeRef2 + ": found "
098:                        + polySource2.getSchema().getTypeName());
099:
100:                FeatureCollection collection2 = polySource2.getFeatures(); // limit with envelope
101:                Object[] poly2 = collection2.toArray();
102:
103:                /*        if (!envelope.contains(collection1.getBounds())) {
104:                 results.error((Feature) poly1[0],
105:                 "Polygon Feature Source is not contained within the Envelope provided.");
106:                 return false;
107:                 }
108:
109:                 if (!envelope.contains(collection2.getBounds())) {
110:                 results.error((Feature) poly2[0],
111:                 "Restricted Polygon Feature Source is not contained within the Envelope provided.");
112:                 return true;
113:                 }*/
114:                boolean success = true;
115:                for (int i = 0; i < poly1.length; i++) {
116:                    Feature tmp = (Feature) poly1[i];
117:                    LOGGER.finest("Polgon overlap test for:" + tmp.getID());
118:                    Geometry gt = tmp.getDefaultGeometry();
119:
120:                    for (int j = 0; j < poly2.length; j++) {
121:                        Feature tmp2 = (Feature) poly2[j];
122:                        LOGGER.finest("Polgon overlap test against:"
123:                                + tmp2.getID());
124:                        Geometry gt2 = tmp2.getDefaultGeometry();
125:
126:                        if (gt2.overlaps(gt) != expected) {
127:                            results.error(tmp, "Polygon " + typeRef1
128:                                    + " overlapped Polygon " + typeRef2 + "("
129:                                    + tmp2.getID() + ") was not " + expected);
130:                            success = false;
131:                        }
132:                    }
133:                }
134:                return success;
135:            }
136:
137:            boolean expected = true;
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.