Skip to content

Commit

Permalink
equirectangular (EPSG:4326) projection
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Torres committed Feb 24, 2017
1 parent ba4dd53 commit e78e46a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ function project(lonlats, tolerance) {
}

function projectPoint(p) {
var sin = Math.sin(p[1] * Math.PI / 180),
x = (p[0] / 360 + 0.5),
y = (0.5 - 0.25 * Math.log((1 + sin) / (1 - sin)) / Math.PI);
// use equirectangular (4326) projection instead of Mercator
var x = (p[0] / 180) + 1
var y = -(p[1] / 180) + 0.5

y = y < 0 ? 0 :
y > 1 ? 1 : y;
Expand Down

2 comments on commit e78e46a

@markeberhart
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diegotorresd - THANK YOU for looking into this! Going to try this out! If this really works it is definitely something to merge into geojson-vt overall.

@DrPDash
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@diegotorresd @markeberhart

Hi, I used the package from: https://unpkg.com/geojson-vt@3.1.0/geojson-vt.js and replaced, per your suggestion, as below.

// function v(t) { var e = Math.sin(t * Math.PI / 180), n = .5 - .25 * Math.log((1 + e) / (1 - e)) / Math.PI; return n < 0 ? 0 : 1 < n ? 1 : n }
function v(t) { var n = -(t[1] / 180) + 0.5; return n < 0 ? 0 : 1 < n ? 1 : n }

It does not work the expected way per your description and the points are misplaced. Any suggestions? Perhaps you could point to your geojson-vt.js file?
Thanks

Please sign in to comment.