Source Code Cross Referenced for ExtendedCoordinateSequence.java in  » GIS » jts » com » vividsolutions » jtsexample » geom » 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 » jts » com.vividsolutions.jtsexample.geom 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The JTS Topology Suite is a collection of Java classes that
003:         * implement the fundamental operations required to validate a given
004:         * geo-spatial data set to a known topological specification.
005:         *
006:         * Copyright (C) 2001 Vivid Solutions
007:         *
008:         * This library is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU Lesser General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2.1 of the License, or (at your option) any later version.
012:         *
013:         * This library is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * Lesser General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU Lesser General Public
019:         * License along with this library; if not, write to the Free Software
020:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
021:         *
022:         * For more information, contact:
023:         *
024:         *     Vivid Solutions
025:         *     Suite #1A
026:         *     2328 Government Street
027:         *     Victoria BC  V8T 5G5
028:         *     Canada
029:         *
030:         *     (250)385-6040
031:         *     www.vividsolutions.com
032:         */
033:        package com.vividsolutions.jtsexample.geom;
034:
035:        import com.vividsolutions.jts.geom.*;
036:
037:        /**
038:         * Demonstrates how to implement a CoordinateSequence for a new kind of
039:         * coordinate (an {@link ExtendedCoordinate} in this example). In this
040:         * implementation, Coordinates returned by #toArray and #get are live -- parties
041:         * that change them are actually changing the ExtendedCoordinateSequence's
042:         * underlying data.
043:         *
044:         * @version 1.7
045:         */
046:        public class ExtendedCoordinateSequence implements  CoordinateSequence {
047:            public static ExtendedCoordinate[] copy(Coordinate[] coordinates) {
048:                ExtendedCoordinate[] copy = new ExtendedCoordinate[coordinates.length];
049:                for (int i = 0; i < coordinates.length; i++) {
050:                    copy[i] = new ExtendedCoordinate(coordinates[i]);
051:                }
052:                return copy;
053:            }
054:
055:            public static ExtendedCoordinate[] copy(CoordinateSequence coordSeq) {
056:                ExtendedCoordinate[] copy = new ExtendedCoordinate[coordSeq
057:                        .size()];
058:                for (int i = 0; i < coordSeq.size(); i++) {
059:                    copy[i] = new ExtendedCoordinate(coordSeq.getCoordinate(i));
060:                }
061:                return copy;
062:            }
063:
064:            private ExtendedCoordinate[] coordinates;
065:
066:            /**
067:             * Copy constructor -- simply aliases the input array, for better performance.
068:             */
069:            public ExtendedCoordinateSequence(ExtendedCoordinate[] coordinates) {
070:                this .coordinates = coordinates;
071:            }
072:
073:            /**
074:             * Constructor that makes a copy of an array of Coordinates.
075:             * Always makes a copy of the input array, since the actual class
076:             * of the Coordinates in the input array may be different from ExtendedCoordinate.
077:             */
078:            public ExtendedCoordinateSequence(Coordinate[] copyCoords) {
079:                coordinates = copy(copyCoords);
080:            }
081:
082:            /**
083:             * Constructor that makes a copy of a CoordinateSequence.
084:             */
085:            public ExtendedCoordinateSequence(CoordinateSequence coordSeq) {
086:                coordinates = copy(coordSeq);
087:            }
088:
089:            /**
090:             * Constructs a sequence of a given size, populated
091:             * with new {@link ExtendedCoordinate}s.
092:             *
093:             * @param size the size of the sequence to create
094:             */
095:            public ExtendedCoordinateSequence(int size) {
096:                coordinates = new ExtendedCoordinate[size];
097:                for (int i = 0; i < size; i++) {
098:                    coordinates[i] = new ExtendedCoordinate();
099:                }
100:            }
101:
102:            /**
103:             * @see com.vividsolutions.jts.geom.CoordinateSequence#getDimension()
104:             */
105:            public int getDimension() {
106:                return 4;
107:            }
108:
109:            public Coordinate getCoordinate(int i) {
110:                return coordinates[i];
111:            }
112:
113:            /**
114:             * @see com.vividsolutions.jts.geom.CoordinateSequence#getX(int)
115:             */
116:            public Coordinate getCoordinateCopy(int index) {
117:                return new Coordinate(coordinates[index]);
118:            }
119:
120:            /**
121:             * @see com.vividsolutions.jts.geom.CoordinateSequence#getX(int)
122:             */
123:            public void getCoordinate(int index, Coordinate coord) {
124:                coord.x = coordinates[index].x;
125:                coord.y = coordinates[index].y;
126:            }
127:
128:            /**
129:             * @see com.vividsolutions.jts.geom.CoordinateSequence#getX(int)
130:             */
131:            public double getX(int index) {
132:                return coordinates[index].x;
133:            }
134:
135:            /**
136:             * @see com.vividsolutions.jts.geom.CoordinateSequence#getY(int)
137:             */
138:            public double getY(int index) {
139:                return coordinates[index].y;
140:            }
141:
142:            /**
143:             * @see com.vividsolutions.jts.geom.CoordinateSequence#getOrdinate(int, int)
144:             */
145:            public double getOrdinate(int index, int ordinateIndex) {
146:                switch (ordinateIndex) {
147:                case CoordinateSequence.X:
148:                    return coordinates[index].x;
149:                case CoordinateSequence.Y:
150:                    return coordinates[index].y;
151:                case CoordinateSequence.Z:
152:                    return coordinates[index].z;
153:                case 4:
154:                    return coordinates[index].getM();
155:                }
156:                return Double.NaN;
157:            }
158:
159:            /**
160:             * @see com.vividsolutions.jts.geom.CoordinateSequence#setOrdinate(int, int, double)
161:             */
162:            public void setOrdinate(int index, int ordinateIndex, double value) {
163:                switch (ordinateIndex) {
164:                case CoordinateSequence.X:
165:                    coordinates[index].x = value;
166:                case CoordinateSequence.Y:
167:                    coordinates[index].y = value;
168:                case CoordinateSequence.Z:
169:                    coordinates[index].z = value;
170:                case 4:
171:                    coordinates[index].setM(value);
172:                }
173:            }
174:
175:            public Object clone() {
176:                ExtendedCoordinate[] cloneCoordinates = new ExtendedCoordinate[size()];
177:                for (int i = 0; i < coordinates.length; i++) {
178:                    cloneCoordinates[i] = (ExtendedCoordinate) coordinates[i]
179:                            .clone();
180:                }
181:
182:                return new ExtendedCoordinateSequence(cloneCoordinates);
183:            }
184:
185:            public int size() {
186:                return coordinates.length;
187:            }
188:
189:            public Coordinate[] toCoordinateArray() {
190:                return coordinates;
191:            }
192:
193:            public Envelope expandEnvelope(Envelope env) {
194:                for (int i = 0; i < coordinates.length; i++) {
195:                    env.expandToInclude(coordinates[i]);
196:                }
197:                return env;
198:            }
199:
200:            public String toString() {
201:                StringBuffer strBuf = new StringBuffer();
202:                strBuf.append("ExtendedCoordinateSequence [");
203:                for (int i = 0; i < coordinates.length; i++) {
204:                    if (i > 0)
205:                        strBuf.append(", ");
206:                    strBuf.append(coordinates[i]);
207:                }
208:                strBuf.append("]");
209:                return strBuf.toString();
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.