[OpenLayers-Commits] r4718 - sandbox/proj4js/lib/proj4js
commits at openlayers.org
commits at openlayers.org
Mon Oct 1 00:06:13 EDT 2007
Author: crschmidt
Date: 2007-10-01 00:06:10 -0400 (Mon, 01 Oct 2007)
New Revision: 4718
Modified:
sandbox/proj4js/lib/proj4js/proj4js.js
Log:
whitespace and formatting cleanups.
Modified: sandbox/proj4js/lib/proj4js/proj4js.js
===================================================================
--- sandbox/proj4js/lib/proj4js/proj4js.js 2007-10-01 04:01:01 UTC (rev 4717)
+++ sandbox/proj4js/lib/proj4js/proj4js.js 2007-10-01 04:06:10 UTC (rev 4718)
@@ -36,244 +36,249 @@
*/
Proj4js = {
- /**
- * Property: defaultDatum
- * The datum to use when no others a specified
- */
- defaultDatum: 'WGS84', //default datum
+ /**
+ * Property: defaultDatum
+ * The datum to use when no others a specified
+ */
+ defaultDatum: 'WGS84', //default datum
- /**
- * Property: proxyScript
- * A proxy script to execute AJAX requests in other domains
- */
- //proxyScript: '/mapbuilder/proxy?url=', //TBD: customize this for spatialreference.org output
- proxyScript: null, //TBD: customize this for spatialreference.org output
+ /**
+ * Property: proxyScript
+ * A proxy script to execute AJAX requests in other domains
+ */
+ //proxyScript: '/mapbuilder/proxy?url=', //TBD: customize this for spatialreference.org output
+ proxyScript: null, //TBD: customize this for spatialreference.org output
- /**
- * Property: defsLookupService
- * AJAX service to retreive projection definition parameters from
- */
- defsLookupService: 'http://spatialreference.org/ref',
+ /**
+ * Property: defsLookupService
+ * AJAX service to retreive projection definition parameters from
+ */
+ defsLookupService: 'http://spatialreference.org/ref',
- /**
- * Property: libPath
- * internal: http server path to library code.
- * TBD figure this out automatically
- */
- //libPath: '/cscs/lib/', //
- libPath: '../lib/proj4js/', //
+ /**
+ * Property: libPath
+ * internal: http server path to library code.
+ * TBD figure this out automatically
+ */
+ //libPath: '/cscs/lib/', //
+ libPath: '../lib/proj4js/', //
- /**
- * Method: transform(source, dest, point)
- * Transform a point coordinate from one map projection to another.
- *
- * Parameters:
- * source - {Proj4js.Proj} source map projection for the transformation
- * dest - {Proj4js.Proj} destination map projection for the transformation
- * point - {Proj4js.Point} point to transform, may be geodetic (long, lat)
- * or projected Cartesian (x,y)
- */
- transform : function(source, dest, point) {
- if (!source.readyToUse || !dest.readyToUse) {
- this.reportError("Proj4js initialization for "+source.srsCode+" not yet complete");
- return;
- }
- if (point.transformed) {
- this.log("point already transformed");
- //return;
- }
+ /**
+ * Method: transform(source, dest, point)
+ * Transform a point coordinate from one map projection to another.
+ *
+ * Parameters:
+ * source - {Proj4js.Proj} source map projection for the transformation
+ * dest - {Proj4js.Proj} destination map projection for the transformation
+ * point - {Proj4js.Point} point to transform, may be geodetic (long, lat)
+ * or projected Cartesian (x,y)
+ */
+ transform : function(source, dest, point) {
+ if (!source.readyToUse || !dest.readyToUse) {
+ this.reportError("Proj4js initialization for "+source.srsCode+" not yet complete");
+ return;
+ }
+
+ if (point.transformed) {
+ this.log("point already transformed");
+ //return;
+ }
- // Transform source points to long/lat, if they aren't already.
- if ( source.projName=="longlat") {
- point.x *= Proj4js.const.D2R; // convert degrees to radians
- point.y *= Proj4js.const.D2R;
- } else {
- if (source.to_meter) {
- point.x *= source.to_meter;
- point.y *= source.to_meter;
- }
- source.inverse(point); // Convert Cartesian to longlat
- }
+ // Transform source points to long/lat, if they aren't already.
+ if ( source.projName=="longlat") {
+ point.x *= Proj4js.const.D2R; // convert degrees to radians
+ point.y *= Proj4js.const.D2R;
+ } else {
+ if (source.to_meter) {
+ point.x *= source.to_meter;
+ point.y *= source.to_meter;
+ }
+ source.inverse(point); // Convert Cartesian to longlat
+ }
- // Adjust for the prime meridian if necessary
- if ( source.from_greenwich) { point.x += source.from_greenwich; }
+ // Adjust for the prime meridian if necessary
+ if (source.from_greenwich) {
+ point.x += source.from_greenwich;
+ }
- // Convert datums if needed, and if possible.
- point = this.datum_transform( source.datum, dest.datum, point );
+ // Convert datums if needed, and if possible.
+ point = this.datum_transform( source.datum, dest.datum, point );
- // Adjust for the prime meridian if necessary
- if ( dest.from_greenwich ) { point.x -= dest.from_greenwich; }
+ // Adjust for the prime meridian if necessary
+ if (dest.from_greenwich) {
+ point.x -= dest.from_greenwich;
+ }
- if( dest.projName=="longlat" ) {
- // convert radians to decimal degrees
- point.x *= Proj4js.const.R2D;
- point.y *= Proj4js.const.R2D;
- } else { // else project
- dest.forward(point);
- if (dest.to_meter) {
- point.x /= dest.to_meter;
- point.y /= dest.to_meter;
- }
- }
- point.transformed = true;
- return point;
- }, // transform()
+ if( dest.projName=="longlat" ) {
+ // convert radians to decimal degrees
+ point.x *= Proj4js.const.R2D;
+ point.y *= Proj4js.const.R2D;
+ } else { // else project
+ dest.forward(point);
+ if (dest.to_meter) {
+ point.x /= dest.to_meter;
+ point.y /= dest.to_meter;
+ }
+ }
+ point.transformed = true;
+ return point;
+ }, // transform()
- /** datum_transform()
- source coordinate system definition,
- destination coordinate system definition,
- point to transform in geodetic coordinates (long, lat, height)
- */
- datum_transform : function( source, dest, point ) {
+ /** datum_transform()
+ source coordinate system definition,
+ destination coordinate system definition,
+ point to transform in geodetic coordinates (long, lat, height)
+ */
+ datum_transform : function( source, dest, point ) {
- // Short cut if the datums are identical.
- if( source.compare_datums( dest ) )
- return point; // in this case, zero is sucess,
- // whereas cs_compare_datums returns 1 to indicate TRUE
- // confusing, should fix this
+ // Short cut if the datums are identical.
+ if( source.compare_datums( dest ) )
+ return point; // in this case, zero is sucess,
+ // whereas cs_compare_datums returns 1 to indicate TRUE
+ // confusing, should fix this
- // If this datum requires grid shifts, then apply it to geodetic coordinates.
- if( source.datum_type == Proj4js.const.PJD_GRIDSHIFT )
- {
- alert("ERROR: Grid shift transformations are not implemented yet.");
- /*
- pj_apply_gridshift( pj_param(source.params,"snadgrids").s, 0,
- point_count, point_offset, x, y, z );
- CHECK_RETURN;
+ // If this datum requires grid shifts, then apply it to geodetic coordinates.
+ if( source.datum_type == Proj4js.const.PJD_GRIDSHIFT )
+ {
+ alert("ERROR: Grid shift transformations are not implemented yet.");
+ /*
+ pj_apply_gridshift( pj_param(source.params,"snadgrids").s, 0,
+ point_count, point_offset, x, y, z );
+ CHECK_RETURN;
- src_a = SRS_WGS84_SEMIMAJOR;
- src_es = 0.006694379990;
- */
- }
+ src_a = SRS_WGS84_SEMIMAJOR;
+ src_es = 0.006694379990;
+ */
+ }
- if( dest.datum_type == Proj4js.const.PJD_GRIDSHIFT )
- {
- alert("ERROR: Grid shift transformations are not implemented yet.");
- /*
- dst_a = ;
- dst_es = 0.006694379990;
- */
- }
-
- // Do we need to go through geocentric coordinates?
- // if( source.es != dest.es || source.a != dest.a || // RWG - removed ellipse comparison so
- if( source.datum_type == Proj4js.const.PJD_3PARAM // that longlat CSs do not have to have
- || source.datum_type == Proj4js.const.PJD_7PARAM // an ellipsoid, also should put it a
- || dest.datum_type == Proj4js.const.PJD_3PARAM // tolerance for es if used.
- || dest.datum_type == Proj4js.const.PJD_7PARAM)
- {
-
- // Convert to geocentric coordinates.
- source.geodetic_to_geocentric( point );
- // CHECK_RETURN;
-
- // Convert between datums
- if( source.datum_type == Proj4js.const.PJD_3PARAM || source.datum_type == Proj4js.const.PJD_7PARAM )
+ if( dest.datum_type == Proj4js.const.PJD_GRIDSHIFT )
{
- source.geocentric_to_wgs84(point);
- // CHECK_RETURN;
+ alert("ERROR: Grid shift transformations are not implemented yet.");
+ /*
+ dst_a = ;
+ dst_es = 0.006694379990;
+ */
}
- if( dest.datum_type == Proj4js.const.PJD_3PARAM || dest.datum_type == Proj4js.const.PJD_7PARAM )
+ // Do we need to go through geocentric coordinates?
+ // if( source.es != dest.es || source.a != dest.a || // RWG - removed ellipse comparison so
+ if( source.datum_type == Proj4js.const.PJD_3PARAM // that longlat CSs do not have to have
+ || source.datum_type == Proj4js.const.PJD_7PARAM // an ellipsoid, also should put it a
+ || dest.datum_type == Proj4js.const.PJD_3PARAM // tolerance for es if used.
+ || dest.datum_type == Proj4js.const.PJD_7PARAM)
{
- dest.geocentric_from_wgs84(point);
+
+ // Convert to geocentric coordinates.
+ source.geodetic_to_geocentric( point );
// CHECK_RETURN;
+
+ // Convert between datums
+ if( source.datum_type == Proj4js.const.PJD_3PARAM || source.datum_type == Proj4js.const.PJD_7PARAM )
+ {
+ source.geocentric_to_wgs84(point);
+ // CHECK_RETURN;
+ }
+
+ if( dest.datum_type == Proj4js.const.PJD_3PARAM || dest.datum_type == Proj4js.const.PJD_7PARAM )
+ {
+ dest.geocentric_from_wgs84(point);
+ // CHECK_RETURN;
+ }
+
+ // Convert back to geodetic coordinates
+ dest.geocentric_to_geodetic( point );
+ // CHECK_RETURN;
}
- // Convert back to geodetic coordinates
- dest.geocentric_to_geodetic( point );
- // CHECK_RETURN;
+
+ // Apply grid shift to destination if required
+ if( dest.datum_type == Proj4js.const.PJD_GRIDSHIFT )
+ {
+ alert("ERROR: Grid shift transformations are not implemented yet.");
+ // pj_apply_gridshift( pj_param(dest.params,"snadgrids").s, 1, point);
+ // CHECK_RETURN;
}
+ return point;
+ }, // cs_datum_transform
+ /**
+ * Function: reportError
+ * An internal method to report errors back to user. Should be overridden
+ * by applications to deliver error messages.
+ */
+ reportError: function(msg) {
+ },
- // Apply grid shift to destination if required
- if( dest.datum_type == Proj4js.const.PJD_GRIDSHIFT )
- {
- alert("ERROR: Grid shift transformations are not implemented yet.");
- // pj_apply_gridshift( pj_param(dest.params,"snadgrids").s, 1, point);
- // CHECK_RETURN;
- }
- return point;
- }, // cs_datum_transform
+ /**
+ * Function: log
+ * An internal method to log events.
+ */
+ log: function(msg) {
+ },
- /**
- * Function: reportError
- * An internal method to report errors back to user. Should be overridden
- * by applications to deliver error messages.
- */
- reportError: function(msg) {
- },
+ loadProjDefinition : function(proj) {
- /**
- * Function: log
- * An internal method to log events.
- */
- log: function(msg) {
- },
+ //check in memory
+ if (this.defs[proj.srsCode]) return this.defs[proj.srsCode];
- loadProjDefinition : function(proj) {
+ //set AJAX options
+ var options = {
+ method: 'get',
+ asynchronous: false, //need to wait until defs are loaded before proceeding
+ onSuccess: this.defsLoaded.bind(this,proj.srsCode)
+ }
+
+ //else check for def on the server
+ var url = this.libPath + 'defs/' + proj.srsAuth.toUpperCase() + proj.srsProjNumber + '.js';
+ new OpenLayers.Ajax.Request(url, options);
+ if ( this.defs[proj.srsCode] ) return this.defs[proj.srsCode];
- //check in memory
- if (this.defs[proj.srsCode]) return this.defs[proj.srsCode];
+ //else load from web service via AJAX request
+ var url = this.proxyScript + this.defsLookupService +'/' + proj.srsAuth +'/'+ proj.srsProjNumber + '/proj4';
+ options.onFailure = this.defsFailed.bind(this,proj.srsCode);
+ new OpenLayers.Ajax.Request(url, options);
+ if ( this.defs[proj.srsCode] ) return this.defs[proj.srsCode];
- //set AJAX options
- var options = {
- method: 'get',
- asynchronous: false, //need to wait until defs are loaded before proceeding
- onSuccess: this.defsLoaded.bind(this,proj.srsCode)
- }
-
- //else check for def on the server
- var url = this.libPath + 'defs/' + proj.srsAuth.toUpperCase() + proj.srsProjNumber + '.js';
- new OpenLayers.Ajax.Request(url, options);
- if ( this.defs[proj.srsCode] ) return this.defs[proj.srsCode];
+ return null; //an error if it gets here
+ },
- //else load from web service via AJAX request
- var url = this.proxyScript + this.defsLookupService +'/' + proj.srsAuth +'/'+ proj.srsProjNumber + '/proj4';
- options.onFailure = this.defsFailed.bind(this,proj.srsCode);
- new OpenLayers.Ajax.Request(url, options);
- if ( this.defs[proj.srsCode] ) return this.defs[proj.srsCode];
+ defsLoaded: function(srsCode, transport) {
+ this.defs[srsCode] = transport.responseText;
+ },
- return null; //an error if it gets here
- },
+ defsFailed: function(srsCode) {
+ this.reportError('failed to load projection definition for: '+srsCode);
+ OpenLayers.Util.extend(this.defs[srsCode], this.defs['WGS84']); //set it to something so it can at least continue
+ },
- defsLoaded: function(srsCode, transport) {
- this.defs[srsCode] = transport.responseText;
- },
+ loadProjCode : function(projName) {
+ if (this.Proj[projName]) return;
- defsFailed: function(srsCode) {
- this.reportError('failed to load projection definition for: '+srsCode);
- OpenLayers.Util.extend(this.defs[srsCode], this.defs['WGS84']); //set it to something so it can at least continue
- },
+ //set AJAX options
+ var options = {
+ method: 'get',
+ asynchronous: false, //need to wait until defs are loaded before proceeding
+ onSuccess: this.loadProjCodeSuccess.bind(this, projName),
+ onFailure: this.loadProjCodeFailure.bind(this, projName)
+ };
+
+ //load the projection class
+ var url = this.libPath + 'projCode/' + projName + '.js';
+ new OpenLayers.Ajax.Request(url, options);
+ },
- loadProjCode : function(projName) {
- if (this.Proj[projName]) return;
+ loadProjCodeSuccess : function(projName, transport) {
+ eval(transport.responseText);
+ if (this.Proj[projName].dependsOn){
+ this.loadProjCode(this.Proj[projName].dependsOn);
+ }
+ },
- //set AJAX options
- var options = {
- method: 'get',
- asynchronous: false, //need to wait until defs are loaded before proceeding
- onSuccess: this.loadProjCodeSuccess.bind(this, projName),
- onFailure: this.loadProjCodeFailure.bind(this, projName)
- };
-
- //load the projection class
- var url = this.libPath + 'projCode/' + projName + '.js';
- new OpenLayers.Ajax.Request(url, options);
- },
-
- loadProjCodeSuccess : function(projName, transport) {
- eval(transport.responseText);
- if (this.Proj[projName].dependsOn){
- this.loadProjCode(this.Proj[projName].dependsOn);
+ loadProjCodeFailure : function(projName) {
+ Proj4js.reportError("failed to find projection file for: " + projName);
+ //TBD initialize with identity transforms so proj will still work
}
- },
- loadProjCodeFailure : function(projName) {
- Proj4js.reportError("failed to find projection file for: " + projName);
- //TBD initialize with identity transforms so proj will still work
- }
-
};
/**
@@ -288,6 +293,30 @@
* Flag to indicate if initialization is complete for this Proj object
*/
readyToUse : false,
+
+ /**
+ * Property: title
+ * The title to describe the projection
+ */
+ title: null,
+
+ /**
+ * 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
+ * counterparts.
+ */
+ projName: null,
+ /**
+ * Property: units
+ * The units of the projection. Values include 'm' and 'degrees'
+ */
+ units: null,
+ /**
+ * Property: datum
+ * The datum specified for the projection
+ */
+ datum: null,
/**
* Constructor: initialize
@@ -298,161 +327,137 @@
* (but not always) EPSG codes.
*/
initialize : function(srsCode) {
+ this.srsCode = srsCode.toUpperCase();
+ if (this.srsCode.indexOf("EPSG") == 0) {
+ this.srsCode = this.srsCode;
+ this.srsAuth = 'epsg';
+ this.srsProjNumber = this.srsCode.substring(5);
+ } else {
+ this.srsAuth = '';
+ this.srsProjNumber = this.srsCode;
+ }
- this.srsCode = srsCode.toUpperCase();
- if (this.srsCode.indexOf("EPSG") == 0) {
- this.srsCode = this.srsCode;
- this.srsAuth = 'epsg';
- this.srsProjNumber = this.srsCode.substring(5);
- } else {
- this.srsAuth = '';
- this.srsProjNumber = this.srsCode;
- }
+ this.datum = new Proj4js.datum(); //this will get the default datum
- this.datum = new Proj4js.datum(); //this will get the default datum
+ var defs = Proj4js.loadProjDefinition(this);
+ if (defs) {
+ this.parseDefs(defs);
+ Proj4js.loadProjCode(this.projName);
+ this.callInit();
+ }
- var defs = Proj4js.loadProjDefinition(this);
- if (defs) {
- this.parseDefs(defs);
- Proj4js.loadProjCode(this.projName);
- this.callInit();
- }
-
},
callInit : function() {
- Proj4js.log('projection script loaded for:' + this.projName);
- OpenLayers.Util.extend(this, Proj4js.Proj[this.projName]);
- this.init();
- this.mapXYToLonLat = this.inverse;
- this.lonLatToMapXY = this.forward;
- this.readyToUse = true;
+ Proj4js.log('projection script loaded for:' + this.projName);
+ OpenLayers.Util.extend(this, Proj4js.Proj[this.projName]);
+ this.init();
+ this.mapXYToLonLat = this.inverse;
+ this.lonLatToMapXY = this.forward;
+ this.readyToUse = true;
},
parseDefs : function(proj4opts) {
- var def = { data: proj4opts };
- var paramName, paramVal;
- var paramArray=def.data.split("+");
+ var def = { data: proj4opts };
+ var paramName, paramVal;
+ var paramArray=def.data.split("+");
- for (var prop=0; prop<paramArray.length; prop++) {
- var property = paramArray[prop].split("=");
- paramName = property[0].toLowerCase();
- paramVal = property[1];
+ for (var prop=0; prop<paramArray.length; prop++) {
+ var property = paramArray[prop].split("=");
+ paramName = property[0].toLowerCase();
+ paramVal = property[1];
- switch (paramName.replace(/\s/gi,"")) { // trim out spaces
- case "": break; // throw away nameless parameter
-
- /**
- * Property: title
- * The title to describe the projection
- */
- case "title": this.title = paramVal; break;
- /**
- * 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
- * counterparts.
- */
- case "proj": this.projName = paramVal.replace(/\s/gi,""); break;
- /**
- * Property: units
- * The units of the projection. Values include 'm' and 'degrees'
- */
- case "units": this.units = paramVal.replace(/\s/gi,""); break;
- /**
- * Property: datum
- * The datum specified for the projection
- */
- case "datum": this.datumName = paramVal.replace(/\s/gi,""); break;
-
- /**
- * The rest of these are for internal use only
- */
- case "ellps": this.ellps = paramVal.replace(/\s/gi,""); break;
- case "a": this.a = parseFloat(paramVal); break; // semi-major radius
- case "b": this.b = parseFloat(paramVal); break; // semi-minor radius
- case "lat_1": this.lat1 = paramVal*Proj4js.const.D2R; break; //standard parallel 1
- case "lat_2": this.lat2 = paramVal*Proj4js.const.D2R; break; //standard parallel 2
- case "lon_0": this.long0 = paramVal*Proj4js.const.D2R; break; // lam0, central longitude
- case "lat_0": this.lat0 = paramVal*Proj4js.const.D2R; break; // phi0, central latitude
- case "x_0": this.x0 = parseFloat(paramVal); break; // false easting
- case "y_0": this.y0 = parseFloat(paramVal); break; // false northing
- case "k": this.k0 = parseFloat(paramVal); break; // projection scale factor
- case "R_A": this.R = parseFloat(paramVal); break; //Spheroid radius
- case "zone": this.zone = parseInt(paramVal); break; // UTM Zone
- case "towgs84":this.datum_params = paramVal.split(","); break;
- case "to_meter": this.to_meter = parseFloat(paramVal); break; // cartesian scaling
- case "from_greenwich": this.from_greenwich = paramVal*Proj4js.const.D2R; break;
- case "no_defs": break;
- default: Proj4js.log("Unrecognized parameter: " + paramName);
- } // switch()
- } // for paramArray
- this.deriveConstants();
+ switch (paramName.replace(/\s/gi,"")) { // trim out spaces
+ case "": break; // throw away nameless parameter
+ case "title": this.title = paramVal; break;
+ case "proj": this.projName = paramVal.replace(/\s/gi,""); break;
+ case "units": this.units = paramVal.replace(/\s/gi,""); break;
+ case "datum": this.datumName = paramVal.replace(/\s/gi,""); break;
+ case "ellps": this.ellps = paramVal.replace(/\s/gi,""); break;
+ case "a": this.a = parseFloat(paramVal); break; // semi-major radius
+ case "b": this.b = parseFloat(paramVal); break; // semi-minor radius
+ case "lat_1": this.lat1 = paramVal*Proj4js.const.D2R; break; //standard parallel 1
+ case "lat_2": this.lat2 = paramVal*Proj4js.const.D2R; break; //standard parallel 2
+ case "lon_0": this.long0 = paramVal*Proj4js.const.D2R; break; // lam0, central longitude
+ case "lat_0": this.lat0 = paramVal*Proj4js.const.D2R; break; // phi0, central latitude
+ case "x_0": this.x0 = parseFloat(paramVal); break; // false easting
+ case "y_0": this.y0 = parseFloat(paramVal); break; // false northing
+ case "k": this.k0 = parseFloat(paramVal); break; // projection scale factor
+ case "R_A": this.R = parseFloat(paramVal); break; //Spheroid radius
+ case "zone": this.zone = parseInt(paramVal); break; // UTM Zone
+ case "towgs84":this.datum_params = paramVal.split(","); break;
+ case "to_meter": this.to_meter = parseFloat(paramVal); break; // cartesian scaling
+ case "from_greenwich": this.from_greenwich = paramVal*Proj4js.const.D2R; break;
+ case "no_defs": break;
+ default: Proj4js.log("Unrecognized parameter: " + paramName);
+ } // switch()
+ } // for paramArray
+ this.deriveConstants();
},
deriveConstants : function() {
- if (!this.a) { // do we have an ellipsoid?
- switch(this.ellps) {
- //case "GRS80": this.a=6378137.0; this.b=6356752.31414036; break;
- //case "WGS84": this.a=6378137.0; this.b=6356752.31424518; break;
- //case "WGS72": this.a=6378135.0; this.b=6356750.52001609; break;
- //case "intl": this.a=6378388.0; this.b=6356911.94612795; break;
- case "MERIT": this.a=6378137.0; this.rf=298.257; this.ellipseName="MERIT 1983"; break;
- case "SGS85": this.a=6378136.0; this.rf=298.257; this.ellipseName="Soviet Geodetic System 85"; break;
- case "GRS80": this.a=6378137.0; this.rf=298.257222101; this.ellipseName="GRS 1980(IUGG, 1980)"; break;
- case "IAU76": this.a=6378140.0; this.rf=298.257; this.ellipseName="IAU 1976"; break;
- case "airy": this.a=6377563.396; this.b=6356256.910; this.ellipseName="Airy 1830"; break;
- case "APL4.": this.a=6378137; this.rf=298.25; this.ellipseName="Appl. Physics. 1965"; break;
- case "NWL9D": this.a=6378145.0; this.rf=298.25; this.ellipseName="Naval Weapons Lab., 1965"; break;
- case "mod_airy": this.a=6377340.189; this.b=6356034.446; this.ellipseName="Modified Airy"; break;
- case "andrae": this.a=6377104.43; this.rf=300.0; this.ellipseName="Andrae 1876 (Den., Iclnd.)"; break;
- case "aust_SA": this.a=6378160.0; this.rf=298.25; this.ellipseName="Australian Natl & S. Amer. 1969"; break;
- case "GRS67": this.a=6378160.0; this.rf=298.2471674270; this.ellipseName="GRS 67(IUGG 1967)"; break;
- case "bessel": this.a=6377397.155; this.rf=299.1528128; this.ellipseName="Bessel 1841"; break;
- case "bess_nam": this.a=6377483.865; this.rf=299.1528128; this.ellipseName="Bessel 1841 (Namibia)"; break;
- case "clrk66": this.a=6378206.4; this.b=6356583.8; this.ellipseName="Clarke 1866"; break;
- case "clrk80": this.a=6378249.145; this.rf=293.4663; this.ellipseName="Clarke 1880 mod."; break;
- case "CPM": this.a=6375738.7; this.rf=334.29; this.ellipseName="Comm. des Poids et Mesures 1799"; break;
- case "delmbr": this.a=6376428.0; this.rf=311.5; this.ellipseName="Delambre 1810 (Belgium)"; break;
- case "engelis": this.a=6378136.05; this.rf=298.2566; this.ellipseName="Engelis 1985"; break;
- case "evrst30": this.a=6377276.345; this.rf=300.8017; this.ellipseName="Everest 1830"; break;
- case "evrst48": this.a=6377304.063; this.rf=300.8017; this.ellipseName="Everest 1948"; break;
- case "evrst56": this.a=6377301.243; this.rf=300.8017; this.ellipseName="Everest 1956"; break;
- case "evrst69": this.a=6377295.664; this.rf=300.8017; this.ellipseName="Everest 1969"; break;
- case "evrstSS": this.a=6377298.556; this.rf=300.8017; this.ellipseName="Everest (Sabah & Sarawak)"; break;
-/* fix these from ellipse.c
- case "fschr60": this.a=6378166.; this.298.3; this.ellipseName="Fischer (Mercury Datum) 1960"; break;
- case "fschr60m": this.a=6378155.", "; this.298.3", "; this.ellipseName=Fischer 1960"; break;
- case "fschr68": this.a=6378150.", "; this.298.3", "; this.ellipseName=1968"; break;
- case "helmert": this.a=6378200.", "; this.298.3", "; this.ellipseName=1906"; break;
- case "hough": this.a=6378270.0; this.rf=297.", "; this.ellipseName="; break;
- case "intl": this.a=6378388.0; this.rf=297.", "; this.ellipseName=1909 (Hayford)"; break;
- case "kaula": this.a=6378163.", "; this.298.24", "; this.ellipseName=1961"; break;
- case "lerch": this.a=6378139.", "; this.298.257", "; this.ellipseName=1979"; break;
- case "mprts": this.a=6397300.", "; this.191.", "Maupertius 1738; this.ellipseName; break;
- case "new_intl": this.a=6378157.5; this.b=6356772.2; this.ellipseName="New International 1967"; break;
- case "plessis": this.a=6376523.", "; this.6355863.", "Plessis 1817 ; this.ellipseName=France)"; break;
+ if (!this.a) { // do we have an ellipsoid?
+ switch(this.ellps) {
+ //case "GRS80": this.a=6378137.0; this.b=6356752.31414036; break;
+ //case "WGS84": this.a=6378137.0; this.b=6356752.31424518; break;
+ //case "WGS72": this.a=6378135.0; this.b=6356750.52001609; break;
+ //case "intl": this.a=6378388.0; this.b=6356911.94612795; break;
+ case "MERIT": this.a=6378137.0; this.rf=298.257; this.ellipseName="MERIT 1983"; break;
+ case "SGS85": this.a=6378136.0; this.rf=298.257; this.ellipseName="Soviet Geodetic System 85"; break;
+ case "GRS80": this.a=6378137.0; this.rf=298.257222101; this.ellipseName="GRS 1980(IUGG, 1980)"; break;
+ case "IAU76": this.a=6378140.0; this.rf=298.257; this.ellipseName="IAU 1976"; break;
+ case "airy": this.a=6377563.396; this.b=6356256.910; this.ellipseName="Airy 1830"; break;
+ case "APL4.": this.a=6378137; this.rf=298.25; this.ellipseName="Appl. Physics. 1965"; break;
+ case "NWL9D": this.a=6378145.0; this.rf=298.25; this.ellipseName="Naval Weapons Lab., 1965"; break;
+ case "mod_airy": this.a=6377340.189; this.b=6356034.446; this.ellipseName="Modified Airy"; break;
+ case "andrae": this.a=6377104.43; this.rf=300.0; this.ellipseName="Andrae 1876 (Den., Iclnd.)"; break;
+ case "aust_SA": this.a=6378160.0; this.rf=298.25; this.ellipseName="Australian Natl & S. Amer. 1969"; break;
+ case "GRS67": this.a=6378160.0; this.rf=298.2471674270; this.ellipseName="GRS 67(IUGG 1967)"; break;
+ case "bessel": this.a=6377397.155; this.rf=299.1528128; this.ellipseName="Bessel 1841"; break;
+ case "bess_nam": this.a=6377483.865; this.rf=299.1528128; this.ellipseName="Bessel 1841 (Namibia)"; break;
+ case "clrk66": this.a=6378206.4; this.b=6356583.8; this.ellipseName="Clarke 1866"; break;
+ case "clrk80": this.a=6378249.145; this.rf=293.4663; this.ellipseName="Clarke 1880 mod."; break;
+ case "CPM": this.a=6375738.7; this.rf=334.29; this.ellipseName="Comm. des Poids et Mesures 1799"; break;
+ case "delmbr": this.a=6376428.0; this.rf=311.5; this.ellipseName="Delambre 1810 (Belgium)"; break;
+ case "engelis": this.a=6378136.05; this.rf=298.2566; this.ellipseName="Engelis 1985"; break;
+ case "evrst30": this.a=6377276.345; this.rf=300.8017; this.ellipseName="Everest 1830"; break;
+ case "evrst48": this.a=6377304.063; this.rf=300.8017; this.ellipseName="Everest 1948"; break;
+ case "evrst56": this.a=6377301.243; this.rf=300.8017; this.ellipseName="Everest 1956"; break;
+ case "evrst69": this.a=6377295.664; this.rf=300.8017; this.ellipseName="Everest 1969"; break;
+ case "evrstSS": this.a=6377298.556; this.rf=300.8017; this.ellipseName="Everest (Sabah & Sarawak)"; break;
+/* f ix these from ellipse.c
+ case "fschr60": this.a=6378166.; this.298.3; this.ellipseName="Fischer (Mercury Datum) 1960"; break;
+ case "fschr60m": this.a=6378155.", "; this.298.3", "; this.ellipseName=Fischer 1960"; break;
+ case "fschr68": this.a=6378150.", "; this.298.3", "; this.ellipseName=1968"; break;
+ case "helmert": this.a=6378200.", "; this.298.3", "; this.ellipseName=1906"; break;
+ case "hough": this.a=6378270.0; this.rf=297.", "; this.ellipseName="; break;
+ case "intl": this.a=6378388.0; this.rf=297.", "; this.ellipseName=1909 (Hayford)"; break;
+ case "kaula": this.a=6378163.", "; this.298.24", "; this.ellipseName=1961"; break;
+ case "lerch": this.a=6378139.", "; this.298.257", "; this.ellipseName=1979"; break;
+ case "mprts": this.a=6397300.", "; this.191.", "Maupertius 1738; this.ellipseName; break;
+ case "new_intl": this.a=6378157.5; this.b=6356772.2; this.ellipseName="New International 1967"; break;
+ case "plessis": this.a=6376523.", "; this.6355863.", "Plessis 1817 ; this.ellipseName=France)"; break;
*/
- case "krass": this.a=6378245.0; this.rf=298.3; this.ellipseName="Krassovsky, 1942"; break;
- case "SEasia": this.a=6378155.0; this.b=6356773.3205; this.ellipseName="Southeast Asia"; break;
- case "walbeck": this.a=6376896.0; this.b=6355834.8467; this.ellipseName="Walbeck"; break;
- case "WGS60": this.a=6378165.0; this.rf=298.3; this.ellipseName="WGS 60"; break;
- case "WGS66": this.a=6378145.0; this.rf=298.25; this.ellipseName="WGS 66"; break;
- case "WGS72": this.a=6378135.0; this.rf=298.26; this.ellipseName="WGS 72"; break;
- case "WGS84": this.a=6378137.0; this.rf=298.257223563; this.ellipseName="WGS 84"; break;
- case "sphere": this.a=6370997.0; this.b=6370997.0; this.ellipseName="Normal Sphere (r=6370997)"; break;
- default: this.a=6378137.0; this.b=6356752.31424518; Proj4js.log("Ellipsoid parameters not provided, assuming WGS84");
+ case "krass": this.a=6378245.0; this.rf=298.3; this.ellipseName="Krassovsky, 1942"; break;
+ case "SEasia": this.a=6378155.0; this.b=6356773.3205; this.ellipseName="Southeast Asia"; break;
+ case "walbeck": this.a=6376896.0; this.b=6355834.8467; this.ellipseName="Walbeck"; break;
+ case "WGS60": this.a=6378165.0; this.rf=298.3; this.ellipseName="WGS 60"; break;
+ case "WGS66": this.a=6378145.0; this.rf=298.25; this.ellipseName="WGS 66"; break;
+ case "WGS72": this.a=6378135.0; this.rf=298.26; this.ellipseName="WGS 72"; break;
+ case "WGS84": this.a=6378137.0; this.rf=298.257223563; this.ellipseName="WGS 84"; break;
+ case "sphere": this.a=6370997.0; this.b=6370997.0; this.ellipseName="Normal Sphere (r=6370997)"; break;
+ default: this.a=6378137.0; this.b=6356752.31424518; Proj4js.log("Ellipsoid parameters not provided, assuming WGS84");
+ }
}
- }
- if (this.rf && !this.b) this.b = (1.0 - 1.0/this.rf) * this.a;
- this.a2 = this.a * this.a; // used in geocentric
- this.b2 = this.b * this.b; // used in geocentric
- this.es = (this.a2-this.b2)/this.a2; // e ^ 2
- //this.es=1-(Math.pow(this.b,2)/Math.pow(this.a,2));
- this.e = Math.sqrt(this.es); // eccentricity
- this.ep2=(this.a2-this.b2)/this.b2; // used in geocentric
+ if (this.rf && !this.b) this.b = (1.0 - 1.0/this.rf) * this.a;
+ this.a2 = this.a * this.a; // used in geocentric
+ this.b2 = this.b * this.b; // used in geocentric
+ this.es = (this.a2-this.b2)/this.a2; // e ^ 2
+ //this.es=1-(Math.pow(this.b,2)/Math.pow(this.a,2));
+ this.e = Math.sqrt(this.es); // eccentricity
+ this.ep2=(this.a2-this.b2)/this.b2; // used in geocentric
- this.datum = new Proj4js.datum(this);
+ this.datum = new Proj4js.datum(this);
}
});
@@ -487,9 +492,9 @@
Proj4js.defs = {
// These are so widely used, we'll go ahead and throw them in
// without requiring a separate .js file
- WGS84 : "+title=long/lat:WGS84 +proj=longlat +a=6378137.0 +b=6356752.31424518 +ellps=WGS84 +datum=WGS84",
- EPSG4326 : "+title=long/lat:WGS84 +proj=longlat +a=6378137.0 +b=6356752.31424518 +ellps=WGS84 +datum=WGS84",
- EPSG4269 : "+title=long/lat:NAD83 +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83"
+ 'WGS84': "+title=long/lat:WGS84 +proj=longlat +a=6378137.0 +b=6356752.31424518 +ellps=WGS84 +datum=WGS84",
+ 'EPSG:4326': "+title=long/lat:WGS84 +proj=longlat +a=6378137.0 +b=6356752.31424518 +ellps=WGS84 +datum=WGS84",
+ 'EPSG:4269': "+title=long/lat:NAD83 +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83"
};
Proj4js.const = {
More information about the Commits
mailing list