Commit f69ba750 authored by Michael Adair's avatar Michael Adair
Browse files

closes #17: add support for decoding URN and URL projection codes

parent e54524b7
Loading
Loading
Loading
Loading
+26 −3
Original line number Diff line number Diff line
@@ -420,7 +420,7 @@ Proj4js.Proj = Proj4js.Class({
  /**
   * Property: projName
   * The projection class for this projection, e.g. lcc (lambert conformal conic,
   * or merc for mercator.  These are exactly equicvalent to their Proj4 
   * or merc for mercator).  These are exactly equivalent to their Proj4 
   * counterparts.
   */
  projName: null,
@@ -444,6 +444,29 @@ Proj4js.Proj = Proj4js.Class({
  * (but not always) EPSG codes.
  */
  initialize: function(srsCode) {
      this.srsCodeInput = srsCode;
      // DGR 2008-08-03 : support urn and url
      if (srsCode.indexOf('urn:') == 0) {
          //urn:ORIGINATOR:def:crs:CODESPACE:VERSION:ID
          var urn = srsCode.split(':');
          if ((urn[1] == 'ogc' || urn[1] =='x-ogc') &&
              (urn[2] =='def') &&
              (urn[3] =='crs') &&
              urn.length == 7) {
              srsCode = urn[4]+':'+urn[6];
          }
      } else if (srsCode.indexOf('http://') == 0) {
          //url#ID
          var url = srsCode.split('#');
          if (url[0].match(/epsg.org/)) {
            // http://www.epsg.org/#
            srsCode = 'EPSG:'+url[1];
          } else if (url[0].match(/RIG.xml/)) {
            //http://librairies.ign.fr/geoportail/resources/RIG.xml#
            //http://interop.ign.fr/registers/ign/RIG.xml#
            srsCode = 'IGNF:'+url[1];
          }
      }
      this.srsCode = srsCode.toUpperCase();
      if (this.srsCode.indexOf("EPSG") == 0) {
          this.srsCode = this.srsCode;
@@ -888,7 +911,7 @@ Proj4js.common = {
    return phi;
  },

// Needed for Gauss Laborde
// Needed for Gauss Schreiber
// Original:  Denis Makarov (info@binarythings.com)
// Web Site:  http://www.binarythings.com
  sinh : function(x)
@@ -1340,7 +1363,7 @@ var maxiter = 30;
Proj4js.Point = Proj4js.Class({

    /**
     * Constructor! Proj4js.Point
     * Constructor: Proj4js.Point
     *
     * Parameters:
     * - x {float} or {Array} either the first coordinates component or