d3/d3-geo-projection

advice needed

Opened this issue · 1 comments

your d3-geo-projections look super interesting.

i usually develop with c++ and use the openframework.cc libraries.
i was hoping to use your geographic projections code posted here in my project.

while i am mostly able to translate your code in to c++ i am not sure how your call your different projection functions and build a map from them.

do you pass in 360˚ values for λ and φ do represent the whole globe/ sphere?

here is how i translated eckert1.

ofPoint ofApp::eckert1(float λ,float φ) {
    //https://github.com/d3/d3-geo-projection/blob/master/src/eckert1.js
    float α = sqrt(8 / (3 * PI));
    return ofPoint(α * λ * (1 - abs(φ) / PI),α * φ);
}

ofPoint ofApp::eckert1_invert(float x,float y) {
    float α = sqrt(8 / (3 * PI));
    float φ = y / α;
    return ofPoint(x / (α * (1 - abs(φ) / PI)),φ);
};

i say mostly able because for example i am not sure what ε epsilon stands for in naturalEarth.invert function.

thanks for any advice.
stephan.

Months late, but here’s your answer!

do you pass in 360˚ values for λ and φ do represent the whole globe/ sphere?

Yes, but in radians. So longitude (λ) goes from -π to +π, and latitude (φ) goes from -π/2 to +π/2. ε is for handling limited numerical precision, such as divide by zero. It is defined as 1e-6 in math.js.