Commit 0fa9afc2 authored by Michael Adair's avatar Michael Adair
Browse files

closes #28: set the correct name for the script file in the built versions of Proj4js

parent 6acb6181
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@ import jsmin, mergejs

sourceDirectory = "../lib"
configFilename = "library.cfg"
outputFilename = "../lib/proj4js-compressed.js"
filename = "proj4js-compressed.js"
outputFilename = "../lib/" + filename

if len(sys.argv) > 1:
    configFilename = sys.argv[1]
@@ -21,6 +22,8 @@ if len(sys.argv) > 2:

print "Merging libraries."
merged = mergejs.run(sourceDirectory, None, configFilename)
print "Setting the filename to "+filename
merged = merged.replace('scriptName: "proj4js.js",','scriptName: "'+filename+'",');
print "Compressing."
minimized = jsmin.jsmin(merged)
print "Adding license file."
+4 −1
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@ import jsmin, mergejs

sourceDirectory = "../lib"
configFilename = "library.cfg"
outputFilename = "../lib/proj4js-combined.js"
filename = "proj4js-combined.js"
outputFilename = "../lib/" + filename

if len(sys.argv) > 1:
    configFilename = sys.argv[1] + ".cfg"
@@ -16,6 +17,8 @@ if len(sys.argv) > 2:

print "Merging libraries."
merged = mergejs.run(sourceDirectory, None, configFilename)
print "Setting the filename to "+filename
merged = merged.replace('scriptName: "proj4js.js",','scriptName: "'+filename+'",');
print "Adding license file."
merged = file("license.txt").read() + merged

+62 −35
Original line number Diff line number Diff line
@@ -318,7 +318,7 @@ Proj4js = {
     * Property: scriptName
     * {String} The filename of this script without any path.
     */
    scriptName: "proj4js.js",
    scriptName: "proj4js-combined.js",

    /**
     * Property: defsLookupService
@@ -435,7 +435,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,
@@ -459,6 +459,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;
@@ -513,7 +536,7 @@ Proj4js.Proj = Proj4js.Class({
 */
    loadFromService: function() {
      //else load from web service
      var url = Proj4js.defsLookupService +'/' + this.srsAuth +'/'+ this.srsProjNumber + '/proj4js';
      var url = Proj4js.defsLookupService +'/' + this.srsAuth +'/'+ this.srsProjNumber + '/proj4js/';
      Proj4js.loadScript(url, 
            Proj4js.bind(this.defsLoaded, this),
            Proj4js.bind(this.defsFailed, this),
@@ -661,7 +684,7 @@ Proj4js.Proj = Proj4js.Class({
              case "y_0":    this.y0 = parseFloat(paramVal); break;  // false northing
              case "k_0":    this.k0 = parseFloat(paramVal); break;  // projection scale factor
              case "k":      this.k0 = parseFloat(paramVal); break;  // both forms returned
              case "R_A":    this.R = true; break;   //Spheroid radius 
              case "r_a":    this.R_A = true; break;                 // sphere--area of ellipsoid
              case "zone":   this.zone = parseInt(paramVal); break;  // UTM Zone
              case "south":   this.utmSouth = true; break;  // UTM north/south
              case "towgs84":this.datum_params = paramVal.split(","); break;
@@ -711,7 +734,7 @@ Proj4js.Proj = Proj4js.Class({
      this.es = (this.a2-this.b2)/this.a2;  // e ^ 2
      this.e = Math.sqrt(this.es);        // eccentricity
      if (this.R_A) {
        this.a *= 1. - this.es * (Proj4js.common.SIXTH + this.es * (Proj4js.RA4 + this.es * Proj4js.RA6));
        this.a *= 1. - this.es * (Proj4js.common.SIXTH + this.es * (Proj4js.common.RA4 + this.es * Proj4js.common.RA6));
        this.a2 = this.a * this.a;
        this.b2 = this.b * this.b;
        this.es = 0.;
@@ -756,9 +779,11 @@ Proj4js.defs = {
  // without requiring a separate .js file
  'WGS84': "+title=long/lat:WGS84 +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees",
  'EPSG:4326': "+title=long/lat:WGS84 +proj=longlat +a=6378137.0 +b=6356752.31424518 +ellps=WGS84 +datum=WGS84 +units=degrees",
  'EPSG:4269': "+title=long/lat:NAD83 +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees" 
  'EPSG:4269': "+title=long/lat:NAD83 +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees",
  'EPSG:900913': "+title= Google Mercator EPSG:900913 +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"
};
//+a=6378137.0 +b=6356752.31424518 +ellps=WGS84 +datum=WGS84",
Proj4js.defs['GOOGLE'] = Proj4js.defs['EPSG:900913'];

Proj4js.common = {
  PI : 3.141592653589793238, //Math.PI,
  HALF_PI : 1.570796326794896619, //Math.PI*0.5,
@@ -903,7 +928,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)
@@ -1355,7 +1380,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
@@ -1855,7 +1880,7 @@ Proj4js.Proj.poly = {
			b = al * al + (p.x/this.a) * (p.x/this.a);
			iflg = phi4z(this.es,this.e0,this.e1,this.e2,this.e3,this.al,b,c,lat);
			if (iflg != 1) return(iflg);
			lon = Proj4js.common.adjust_lon((asinz(p.x * c / this.a) / Math.sin(lat)) + this.long0);
			lon = Proj4js.common.adjust_lon((Proj4js.common.asinz(p.x * c / this.a) / Math.sin(lat)) + this.long0);
		}

		p.x=lon;
@@ -2348,7 +2373,7 @@ Proj4js.Proj.tmerc = {
      var temp = this.lat0 + p.y/(this.a * this.k0);
      var h = Math.cos(temp);
      con = Math.sqrt((1.0 - h * h)/(1.0 + g * g));
      lat = Math.asinz(con);
      lat = Proj4js.common.asinz(con);
      if (temp < 0)
        lat = -lat;
      if ((g == 0) && (h == 0)) {
@@ -2767,6 +2792,7 @@ Proj4js.Proj.stere = {
// Stereographic forward equations--mapping lat,long to x,y
  forward: function(p) {
    var lon = p.x;
    lon = Proj4js.common.adjust_lon(lon - this.long0);
    var lat = p.y;
    var x, y
    
@@ -2929,7 +2955,7 @@ Proj4js.Proj.stere = {
    		if (Math.abs(phi_l - lat) < this.CONV) {
    			if (this.mode == this.S_POLE) lat = -lat;
    			lon = (x == 0. && y == 0.) ? 0. : Math.atan2(x, y);
          p.x = lon;
          p.x = Proj4js.common.adjust_lon(lon + this.long0);
          p.y = lat
    			return p;
    		}
@@ -3276,7 +3302,7 @@ Proj4js.Proj.mill = {
    var lat=p.y;
    /* Forward equations
      -----------------*/
    dlon = Proj4js.common.adjust_lon(lon -this.long0);
    var dlon = Proj4js.common.adjust_lon(lon -this.long0);
    var x = this.x0 + this.a * dlon;
    var y = this.y0 + this.a * Math.log(Math.tan((Proj4js.common.PI / 4.0) + (lat / 2.5))) * 1.25;

@@ -3400,15 +3426,15 @@ License: LGPL as per: http://www.gnu.org/copyleft/lesser.html

// following constants #define'd in geocent.h
// var GEOCENT_NO_ERROR  = 0x0000;
var GEOCENT_LAT_ERROR = 0x0001;
// var GEOCENT_LAT_ERROR = 0x0001; /* DGR, 2008-09-04 : not necessary to have a global variable */
// var GEOCENT_LON_ERROR = 0x0002;
// var cs.a_ERROR        = 0x0004;
// var cs.b_ERROR        = 0x0008;
// var cs.a_LESS_B_ERROR = 0x0010;

// following constants from geocent.c
var COS_67P5  = 0.38268343236508977;  /* cosine of 67.5 degrees */
var AD_C      = 1.0026000;            /* Toms region 1 constant */
// var COS_67P5  = 0.38268343236508977;  /* cosine of 67.5 degrees */ /* DGR, 2008-09-04 : defined in proj4js.js */
// var AD_C      = 1.0026000;            /* Toms region 1 constant */ /* DGR, 2008-09-04 : defined in proj4js.js */

function cs_geodetic_to_geocentric (cs, p) {

@@ -3426,6 +3452,7 @@ function cs_geodetic_to_geocentric (cs, p) {
 *
 */

  var GEOCENT_LAT_ERROR = 0x0001;
  var Longitude = p.x;
  var Latitude = p.y;
  var Height = p.z;
@@ -3444,11 +3471,11 @@ function cs_geodetic_to_geocentric (cs, p) {
  ** range as it may just be a rounding issue.  Also removed longitude
  ** test, it should be wrapped by Math.cos() and Math.sin().  NFW for PROJ.4, Sep/2001.
  */
  if( Latitude < -HALF_PI && Latitude > -1.001 * HALF_PI )
      Latitude = -HALF_PI;
  else if( Latitude > HALF_PI && Latitude < 1.001 * HALF_PI )
      Latitude = HALF_PI;
  else if ((Latitude < -HALF_PI) || (Latitude > HALF_PI))
  if( Latitude < -Proj4js.common.HALF_PI && Latitude > -1.001 * Proj4js.common.HALF_PI )
      Latitude = -Proj4js.common.HALF_PI;
  else if( Latitude > Proj4js.common.HALF_PI && Latitude < 1.001 * Proj4js.common.HALF_PI )
      Latitude = Proj4js.common.HALF_PI;
  else if ((Latitude < -Proj4js.common.HALF_PI) || (Latitude > Proj4js.common.HALF_PI))
  { /* Latitude out of range */
    Error_Code |= GEOCENT_LAT_ERROR;
  }
@@ -3516,11 +3543,11 @@ function cs_geocentric_to_geodetic (cs, p) {
  {
      if (Y > 0)
      {
          Longitude = HALF_PI;
          Longitude = Proj4js.common.HALF_PI;
      }
      else if (Y < 0)
      {
          Longitude = -HALF_PI;
          Longitude = -Proj4js.common.HALF_PI;
      }
      else
      {
@@ -3528,15 +3555,15 @@ function cs_geocentric_to_geodetic (cs, p) {
          Longitude = 0.0;
          if (Z > 0.0)
          {  /* north pole */
              Latitude = HALF_PI;
              Latitude = Proj4js.common.HALF_PI;
          }
          else if (Z < 0.0)
          {  /* south pole */
              Latitude = -HALF_PI;
              Latitude = -Proj4js.common.HALF_PI;
          }
          else
          {  /* center of earth */
              Latitude = HALF_PI;
              Latitude = Proj4js.common.HALF_PI;
              Height = -cs.b;
              return;
          }
@@ -3544,7 +3571,7 @@ function cs_geocentric_to_geodetic (cs, p) {
  }
  W2 = X*X + Y*Y;
  W = Math.sqrt(W2);
  T0 = Z * AD_C;
  T0 = Z * Proj4js.common.AD_C;
  S0 = Math.sqrt(T0 * T0 + W2);
  Sin_B0 = T0 / S0;
  Cos_B0 = W / S0;
@@ -3555,11 +3582,11 @@ function cs_geocentric_to_geodetic (cs, p) {
  Sin_p1 = T1 / S1;
  Cos_p1 = Sum / S1;
  Rn = cs.a / Math.sqrt(1.0 - cs.es * Sin_p1 * Sin_p1);
  if (Cos_p1 >= COS_67P5)
  if (Cos_p1 >= Proj4js.common.COS_67P5)
  {
      Height = W / Cos_p1 - Rn;
  }
  else if (Cos_p1 <= -COS_67P5)
  else if (Cos_p1 <= -Proj4js.common.COS_67P5)
  {
      Height = W / -Cos_p1 - Rn;
  }
@@ -3586,7 +3613,7 @@ function cs_geocentric_to_geodetic (cs, p) {
//  p = point to transform in geocentric coordinates (x,y,z)
function cs_geocentric_to_wgs84( defn, p ) {

  if( defn.datum_type == PJD_3PARAM )
  if( defn.datum_type == Proj4js.common.PJD_3PARAM )
  {
    // if( x[io] == HUGE_VAL )
    //    continue;
@@ -3595,7 +3622,7 @@ function cs_geocentric_to_wgs84( defn, p ) {
    p.z += defn.datum_params[2];

  }
  else  // if( defn.datum_type == PJD_7PARAM )
  else  // if( defn.datum_type == Proj4js.common.PJD_7PARAM )
  {
    var Dx_BF =defn.datum_params[0];
    var Dy_BF =defn.datum_params[1];
@@ -3621,7 +3648,7 @@ function cs_geocentric_to_wgs84( defn, p ) {
//  point to transform in geocentric coordinates (x,y,z)
function cs_geocentric_from_wgs84( defn, p ) {

  if( defn.datum_type == PJD_3PARAM )
  if( defn.datum_type == Proj4js.common.PJD_3PARAM )
  {
    //if( x[io] == HUGE_VAL )
    //    continue;
@@ -3630,7 +3657,7 @@ function cs_geocentric_from_wgs84( defn, p ) {
    p.z -= defn.datum_params[2];

  }
  else // if( defn.datum_type == PJD_7PARAM )
  else // if( defn.datum_type == Proj4js.common.PJD_7PARAM )
  {
    var Dx_BF =defn.datum_params[0];
    var Dy_BF =defn.datum_params[1];
@@ -4240,7 +4267,7 @@ Proj4js.Proj.lcc = {
      }

      var con  = Math.abs( Math.abs(lat) - Proj4js.common.HALF_PI);
      var ts;
      var ts, rh1;
      if (con > Proj4js.common.EPSLN) {
        ts = Proj4js.common.tsfnz(this.e, lat, Math.sin(lat) );
        rh1 = this.a * this.f0 * Math.pow(ts, this.ns);
+25 −24

File changed.

Preview size limit exceeded, changes collapsed.