Opened 11 years ago

Closed 11 years ago

#89 closed defect (fixed)

Enable smaller custom builds of Proj4js through more modularisation

Reported by: ejn Owned by: madair
Priority: major Milestone: future
Component: core Version: trunk
Keywords: custom build Cc:

Description

Attached to this ticket is a patch which breaks out various parts of the Proj4js code into separate files. The result of this modularisation is a smaller core Proj4js, which is particularly of interest for those wanting to use a custom build of Proj4js or reduce the initial load weight.

Highlights:

  • WKT loading and dynamic loading of definitions are put into separate module files which monkey-patch the classes to (re)enable these features, reducing the size of the base code.
  • The number of datums, ellipsoids and prime meridians defined by default is reduced to one (WGS84 / Greenwich).
    • Datums and ellipsoids may be dynamically loaded in the same way as projCode (iff the loader module is included!)
      • This feature increases the amount of functions, and therefore the size of the core library, but allows increased flexibility for small custom builds where the coordinate systems which will be used are not all known in advance.
    • Prime meridians may be included individually
    • "Compatibility files" are provided to bulk-load the prime eridians, ellipsoids, datums and coordinate systems previously defined in the base Proj4js
  • the default compile using library.cfg is functionally identical to the previous version, with the addition of dynamic loading of datums and ellipsoids.
  • two sample build files for minimalistic builds (base.cfg and useloader.cfg) are supplied.

One minor downside of the modularisation is that the build from library.cfg actually increases very slightly in size, but I believe that this is offset by the potential size decreases from custom builds: of course, users should then be guided to use these!

I'm happy to improve this patch if necessary for acceptance: particularly the dynamic loading of ellipsoids and datums is maybe a bit too much flexibility and works partly against the aim of this patch: I personally think that an acceptable alternative would be to still reduce the default lists of these to one and require manually (or via the "compatibility files") adding those which are wanted, as is the case for the prime meridians.

Note that the only reason I didn't add dynamic loading of prime meridians (for consistency with datums and ellipsoids) is because this would have required significant refactoring of the code as the point at which these are used is buried deep in a switch statement while parsing the definitions. If necessary I could add this to the patch.

Attachments (1)

modularisation.patch (70.8 KB ) - added by ejn 11 years ago.
Patch against r2318 to further modularise Proj4js

Download all attachments as: .zip

Change History (4)

by ejn, 11 years ago

Attachment: modularisation.patch added

Patch against r2318 to further modularise Proj4js

comment:1 by ejn, 11 years ago

A further point for modularisation/reducing the core size would be reducing the number of calculation support functions and constants included in the base, but this would require a mechanism for monkey-patching them in as required by the individual cartographic projections (or the current dependsOn could be misused for this?)

comment:2 by madair, 11 years ago

Status: newassigned

I like where this is going, but might hold off on this until the closure branch is working and merged back to trunk. That includes a lot more code cleanup.

comment:3 by madair, 11 years ago

Resolution: fixed
Status: assignedclosed

work now being carried out on github, inlcuding addressing these, please file new issues there as required https://github.com/proj4js/proj4js

Note: See TracTickets for help on using tickets.