Source Code Cross Referenced for SpatialRelationOp.java in  » GIS » openjump » org » openjump » core » spatialAttributeOps » 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 » openjump » org.openjump.core.spatialAttributeOps 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI 
003:         * for visualizing and manipulating spatial features with geometry and attributes.
004:         *
005:         * JUMP is Copyright (C) 2003 Vivid Solutions
006:         *
007:         * This program implements extensions to JUMP and is
008:         * Copyright (C) Stefan Steiniger.
009:         * 
010:         * This program is free software; you can redistribute it and/or
011:         * modify it under the terms of the GNU General Public License
012:         * as published by the Free Software Foundation; either version 2
013:         * of the License, or (at your option) any later version.
014:         * 
015:         * This program is distributed in the hope that it will be useful,
016:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
017:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
018:         * GNU General Public License for more details.
019:         * 
020:         * You should have received a copy of the GNU General Public License
021:         * along with this program; if not, write to the Free Software
022:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
023:         * 
024:         * For more information, contact:
025:         * Stefan Steiniger
026:         * perriger@gmx.de
027:         */
028:        /***********************************************
029:         * created on 		22.06.2006
030:         * last modified: 	
031:         * 
032:         * author:			sstein
033:         * 
034:         * description:
035:         * 		contains some method to extract sets of features
036:         * 		which fullfill some spatial criterion
037:         * 
038:         ***********************************************/package org.openjump.core.spatialAttributeOps;
039:
040:        import java.util.ArrayList;
041:        import java.util.Iterator;
042:        import java.util.List;
043:
044:        import com.vividsolutions.jts.geom.Geometry;
045:        import com.vividsolutions.jts.geom.Point;
046:        import com.vividsolutions.jts.index.quadtree.Quadtree;
047:        import com.vividsolutions.jump.feature.Feature;
048:
049:        /**
050:         *
051:         * contains some method to extract sets of features
052:         * which fullfill some spatial criterion<p>
053:         * notes:<p>
054:         * - use "intersects" only for polygon geometries (condition intersection area > 0).<p>
055:         * - "contains" can be used for polygons and points (centroid from polygon is calculated)<p>
056:         * 
057:         * @author sstein
058:         * 
059:         */
060:        public class SpatialRelationOp {
061:            public final static int CONTAINS = 0;
062:            public final static int INTERSECTS = 1;
063:            public final static int COVEREDBY = 2;
064:
065:            //public final static int TOUCHES = 3;
066:
067:            public static String getName(int spatialRel) {
068:                String retval = "";
069:                if (spatialRel == 0) {
070:                    retval = "contains";
071:                } else if (spatialRel == 1) {
072:                    retval = "intersects";
073:                }
074:                return retval;
075:            }
076:
077:            /**
078:             * note: if input feature is point and spatial attribute is "intersect" or "covered by" the 
079:             * candidate features are selected from a 10.0m radius   
080:             * @param spatialRelation
081:             * @param featureTree
082:             * @param g
083:             * @param radius
084:             * @return ArrayList of Feature fullfilling the spatial criterion
085:             */
086:            public static List evaluateSpatial(int spatialRelation,
087:                    Quadtree featureTree, Geometry g, double radius) {
088:
089:                List foundItems = new ArrayList();
090:
091:                if (spatialRelation == SpatialRelationOp.CONTAINS) {
092:                    Geometry buffer = g.buffer(radius);
093:                    List candidates = featureTree.query(buffer
094:                            .getEnvelopeInternal());
095:                    if (g instanceof  Point) {
096:                        radius = 10.0;
097:                        Geometry buffer2 = g.buffer(radius);
098:                        candidates = featureTree.query(buffer2
099:                                .getEnvelopeInternal());
100:                    }
101:                    for (Iterator iter = candidates.iterator(); iter.hasNext();) {
102:                        Feature candidate = (Feature) iter.next();
103:                        boolean retval = buffer.contains(candidate
104:                                .getGeometry().getCentroid());
105:                        if (retval) {
106:                            foundItems.add(candidate);
107:                        }
108:                    }
109:                } else if (spatialRelation == SpatialRelationOp.INTERSECTS) {
110:                    Geometry buffer = g.buffer(radius);
111:                    List candidates = featureTree.query(buffer
112:                            .getEnvelopeInternal());
113:                    if (g instanceof  Point) {
114:                        radius = 10.0;
115:                        Geometry buffer2 = g.buffer(radius);
116:                        candidates = featureTree.query(buffer2
117:                                .getEnvelopeInternal());
118:                        //-- reset to point geom
119:                        buffer = g;
120:                    }
121:                    for (Iterator iter = candidates.iterator(); iter.hasNext();) {
122:                        Feature candidate = (Feature) iter.next();
123:                        Geometry geom = buffer.intersection(candidate
124:                                .getGeometry());
125:                        if (geom.getArea() > 0) {
126:                            foundItems.add(candidate);
127:                        }
128:                    }
129:                } else if (spatialRelation == SpatialRelationOp.COVEREDBY) {
130:                    Geometry buffer = g.buffer(radius);
131:                    List candidates = featureTree.query(buffer
132:                            .getEnvelopeInternal());
133:                    if (g instanceof  Point) {
134:                        radius = 10.0;
135:                        Geometry buffer2 = g.buffer(radius);
136:                        candidates = featureTree.query(buffer2
137:                                .getEnvelopeInternal());
138:                        //-- reset to point geom
139:                        buffer = g;
140:                    }
141:                    for (Iterator iter = candidates.iterator(); iter.hasNext();) {
142:                        Feature candidate = (Feature) iter.next();
143:                        if (buffer.coveredBy(candidate.getGeometry())) {
144:                            foundItems.add(candidate);
145:                        }
146:                    }
147:                } else {
148:                    System.out
149:                            .println("SpatialRelationOp: spatial relation does not exit");
150:                }
151:                return foundItems;
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.