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.impl;
034:
035: import com.vividsolutions.jts.util.Assert;
036:
037: import com.vividsolutions.jump.coordsys.CoordinateSystem;
038: import com.vividsolutions.jump.coordsys.Radius;
039: import com.vividsolutions.jump.coordsys.Spheroid;
040:
041: /**
042: * Provides a number of named coordinate systems.
043: */
044: public class PredefinedCoordinateSystems {
045: public static final CoordinateSystem BC_ALBERS_NAD_83 = new CoordinateSystem(
046: "BC Albers", 42102, new Albers() {
047:
048: {
049: setSpheroid(new Spheroid(new Radius(Radius.GRS80)));
050: setParameters(-126.0, 50.0, 58.5, 45.0, 1000000.0,
051: 0.0);
052: }
053: });
054: public static final CoordinateSystem GEOGRAPHICS_WGS_84 = new CoordinateSystem(
055: "Geographics", 4326, new LatLong());
056: public static final CoordinateSystem UTM_07N_WGS_84 = createUTMNorth(7);
057: public static final CoordinateSystem UTM_08N_WGS_84 = createUTMNorth(8);
058: public static final CoordinateSystem UTM_09N_WGS_84 = createUTMNorth(9);
059: public static final CoordinateSystem UTM_10N_WGS_84 = createUTMNorth(10);
060: public static final CoordinateSystem UTM_11N_WGS_84 = createUTMNorth(11);
061:
062: private PredefinedCoordinateSystems() {
063: }
064:
065: private static CoordinateSystem createUTMNorth(final int zone) {
066: Assert.isTrue(1 <= zone && zone <= 60);
067: //Pad with zero to facilitate sorting [Jon Aquino]
068: return new CoordinateSystem("UTM " + (zone < 10 ? "0" : "")
069: + zone + "N", 32600 + zone,
070: new UniversalTransverseMercator() {
071: {
072: setSpheroid(new Spheroid(new Radius(
073: Radius.GRS80)));
074: setParameters(zone);
075: }
076: });
077: }
078:
079: public static CoordinateSystem getCoordinateSystem(int epsgCode) {
080: CoordinateSystem cs = null;
081:
082: if (epsgCode == GEOGRAPHICS_WGS_84.getEPSGCode()) {
083: cs = GEOGRAPHICS_WGS_84;
084: } else if (epsgCode == BC_ALBERS_NAD_83.getEPSGCode()) {
085: cs = BC_ALBERS_NAD_83;
086: } else if (epsgCode == UTM_07N_WGS_84.getEPSGCode()) {
087: cs = UTM_07N_WGS_84;
088: } else if (epsgCode == UTM_08N_WGS_84.getEPSGCode()) {
089: cs = UTM_08N_WGS_84;
090: } else if (epsgCode == UTM_09N_WGS_84.getEPSGCode()) {
091: cs = UTM_09N_WGS_84;
092: } else if (epsgCode == UTM_10N_WGS_84.getEPSGCode()) {
093: cs = UTM_10N_WGS_84;
094: } else if (epsgCode == UTM_11N_WGS_84.getEPSGCode()) {
095: cs = UTM_11N_WGS_84;
096: } else {
097: // don't do an assertion - it should be alright if the EPSG code
098: // is one of the predefined ones.
099: }
100:
101: return cs;
102: }
103:
104: }
|