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: * Copyright (C) 2003 Vivid Solutions
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program 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
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions
024: * Suite #1A
025: * 2328 Government Street
026: * Victoria BC V8T 5G5
027: * Canada
028: *
029: * (250)385-6040
030: * www.vividsolutions.com
031: */
032:
033: package com.vividsolutions.jump.coordsys;
034:
035: import java.io.Serializable;
036:
037: import com.vividsolutions.jts.util.Assert;
038: import com.vividsolutions.jump.I18N;
039:
040: /**
041: * This class represents a coordinate system.
042: */
043: public class CoordinateSystem implements Comparable, Serializable {
044: private static final long serialVersionUID = -811718450919581831L;
045: private Projection projection;
046: private String name;
047: private int epsgCode;
048: public static final CoordinateSystem UNSPECIFIED = new CoordinateSystem(
049: I18N.get("coordsys.CoordinateSystem.unspecified"), 0, null) {
050: private static final long serialVersionUID = -811718450919581831L;
051:
052: public Projection getProjection() {
053: throw new UnsupportedOperationException();
054: }
055:
056: public int getEPSGCode() {
057: throw new UnsupportedOperationException();
058: }
059: };
060:
061: /**
062: * @see http://www.javaworld.com/javaworld/javatips/jw-javatip122.html
063: */
064: private Object readResolve() {
065: return name.equals(UNSPECIFIED.name) ? UNSPECIFIED : this ;
066: }
067:
068: public CoordinateSystem(String name, int epsgCode,
069: Projection projection) {
070: this .name = name;
071: this .projection = projection;
072: this .epsgCode = epsgCode;
073: }
074:
075: public String toString() {
076: return name;
077: }
078:
079: public String getName() {
080: return name;
081: }
082:
083: public Projection getProjection() {
084: return projection;
085: }
086:
087: public int getEPSGCode() {
088: return epsgCode;
089: }
090:
091: public int compareTo(Object o) {
092: Assert.isTrue(o instanceof CoordinateSystem);
093: if (this == o) {
094: return 0;
095: }
096: if (this == UNSPECIFIED) {
097: return -1;
098: }
099: if (o == UNSPECIFIED) {
100: return 1;
101: }
102: return toString().compareTo(o.toString());
103: }
104:
105: }
|