src\PtvMercator.js - leaflet.ptv

API Docs for: 0.1.0
Show:

File: src\PtvMercator.js

  1. /**
  2. @module L.CRS
  3. **/
  4.  
  5. /**
  6. Provides the PTV Mercator coordinate reference system.
  7. @class L.CRS.PTVMercator
  8. @constructor
  9. **/
  10. L.CRS.PTVMercator = L.extend({}, L.CRS, {
  11. /**
  12. Standard code name of the CRS passed into WMS services.
  13. @property code
  14. @type String
  15. @default "PTV:MERCATOR"
  16. @readOnly
  17. **/
  18. code: 'PTV:MERCATOR',
  19.  
  20. /**
  21. Projection that this CRS uses.
  22. @property projection
  23. @type L.IProjection
  24. @readOnly
  25. **/
  26. projection: L.Projection.SphericalMercator,
  27.  
  28. /**
  29. Transformation that this CRS uses to turn projected coordinates into screen coordinates for a particular tile service.
  30. @property transformation
  31. @type L.Transformation
  32. @readOnly
  33. **/
  34. transformation: new L.Transformation(0.5 / Math.PI, 0.5, -0.5 / Math.PI, 0.5),
  35.  
  36. /**
  37. The earth radius used for projections.
  38. @property earthRadius
  39. @type Number
  40. @default 6371000
  41. @private
  42. **/
  43. _earthRadius: 6371000,
  44.  
  45. /**
  46. Projects a geographical coordinate into a PTV Mercator point.
  47. @method project
  48. @return {Point} PTV Mercator point.
  49. **/
  50. project: function(latlng) {
  51. var projectedPoint = this.projection.project(latlng);
  52. return projectedPoint.multiplyBy(this._earthRadius);
  53. },
  54.  
  55. /**
  56. Unprojects a PTV Mercator point to a geographical coordinate.
  57. @method unproject
  58. @return {L.LatLng} Geographical coordinate.
  59. **/
  60. unproject: function(point) {
  61. point = new L.Point(point.x, point.y).divideBy(this._earthRadius);
  62. return this.projection.unproject(point);
  63. }
  64. });
  65.