I've got an initial refactoring of cscs checked in for comment as 
cscs/lib/proj4js.js.  It is mostly jjust re-arranging things to be a 
little more object-oriented using Prototype.js - all the actual 
calculations are the same.

Highlights:
- uses it's own namespace called Proj4js - I can live with cscs as the 
library name but I will make an impassioned plea to change the name of 
this library to Proj4js because I think it is much more descriptive of 
what it does and where it came from
- look up projection definitions from memory, loaded in from disk, or 
failing that then it uses the new spatialreference.org lookup service 
with an Ajax request.  This part is really cool because it means you 
don't necessarily have to know the proj parameters beforehand.
- will dynamically load projection class code from disk, e.g. lcc.js or 
these may also be loaded in your application HTML HEAD element
- offers the following API (this is a rough sketch, I would like to 
document this for NaturalDocs)

Proj4js            //global Namespace object, with some init properties
Proj4js.defs.   //hash of all the proj definitions loaded, as Proj4 
command line options
                      //this could also use JSON, WKT,  etc. formats 
eventually
Proj4js.defs.EPSG4326   //for example

Proj4js.proj   //abstract proj object, constructor takes single srsCode 
argument
                        //which offers the following methods
Proj4js.proj.transform(point, dest)   //transform point from this proj 
into the dest proj
Proj4js.proj.forward(point)               //transform point from lon,lat 
to proj x,y
Proj4js.proj.inverse(point)               //transform point from proj 
x,y to lon,lat

Proj4js.proj.lcc  //class containing the actual code for LCC projection, 
one for each projection type, etc.

Proj4js.datums   //not yet completed, but will handle datum transformations

To use a Proj4js object:
var myProj = new Proj4js.proj(srsCode) ;
var newPoint  = myProj.transform(point, yourProj) ;

The implementation is a little weird in that your will always request a 
Proj4js.proj object, but what you get back is actually Proj4js.proj.lcc 
if you ask for a LCC projection for example.  I think this is OK because 
they all offer transform(), forward() and inverse() methods.

I haven't checked in a working example in SVN yet, but I do have it 
running on my machine and it works well.  I will wait for comments on 
thee naming issue and if this API seems to be acceptable to everyone.

Mike




-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
mapbuilder-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mapbuilder-devel

Reply via email to