SpatialReferenceSystem.java

  1. package de.turnertech.ows.srs;

  2. public enum SpatialReferenceSystem {

  3.     /** WGS84 */
  4.     CRS84("OGC:CRS84", "http://www.opengis.net/def/crs/OGC/1.3/CRS84", "urn:ogc:def:crs:OGC:1.3:CRS84", (byte)2, (byte)0, (byte)1),

  5.     /** WGS84 */
  6.     EPSG4326("EPSG:4326", "http://www.opengis.net/def/crs/EPSG/0/4326", "urn:ogc:def:crs:EPSG::4326", (byte)2, (byte)1, (byte)0),

  7.     /** WebMercator */
  8.     EPSG3857("EPSG:3857", "http://www.opengis.net/def/crs/EPSG/0/3857", "urn:ogc:def:crs:EPSG::3857", (byte)2, (byte)0, (byte)1);

  9.     private final String code;
  10.    
  11.     private final String uri;

  12.     private final String urn;

  13.     private final byte dimension;

  14.     private final byte xIndex;

  15.     private final byte yIndex;

  16.     private SpatialReferenceSystem(String code, String uri, String urn, byte dimension, byte xIndex, byte yIndex) {
  17.         this.code = code;
  18.         this.uri = uri;
  19.         this.dimension = dimension;
  20.         this.urn = urn;
  21.         this.xIndex = xIndex;
  22.         this.yIndex = yIndex;
  23.     }

  24.     public String getCode() {
  25.         return code;
  26.     }

  27.     public String getUri() {
  28.         return uri;
  29.     }

  30.     public String getUrn() {
  31.         return urn;
  32.     }

  33.     public byte getDimension() {
  34.         return dimension;
  35.     }

  36.     public byte getXIndex() {
  37.         return xIndex;
  38.     }

  39.     public byte getYIndex() {
  40.         return yIndex;
  41.     }

  42.     public static SpatialReferenceSystem from(String value) {
  43.         if(value == null) return null;

  44.         for(SpatialReferenceSystem srs : SpatialReferenceSystem.values()) {
  45.             if(srs.getUri().equalsIgnoreCase(value) || srs.getUrn().equalsIgnoreCase(value) || srs.getCode().equalsIgnoreCase(value)) {
  46.                 return srs;
  47.             }
  48.         }

  49.         return null;
  50.     }
  51.    
  52. }