Code Monkey home page Code Monkey logo

Comments (3)

sothawo avatar sothawo commented on August 12, 2024

Hello,

this may be indeed confusing, but is not really a fault. When zooming out, you see some areas of the world duplicated, and OpenLayers reports the ccordinates of these areas without considering the wrap around. On the one hand this is incorrect, but on the other you might need this if you want to differentiate between the two New Zealands (although I don't see a real use case).

If you need the coordinates normalized, you can use the following code (similar to what you did already):

private Coordinate normalize(Coordinate coordinate) {
    Double longitude = coordinate.getLongitude();
    while(longitude < -180.0) longitude += 360;
    while(longitude > 180.0) longitude -= 360;
    return new Coordinate(coordinate.getLatitude(), longitude);
}

I think I might add this normalize Method to the Coordinate class, but will not make an extra release, but have it contained in the next one. And I will keep it in the Java code, so the logs from Javascript will show the out-of-range values.

from mapjfx.

vewert avatar vewert commented on August 12, 2024

Thanks for your quick response, and for your information; that makes sense. My use cases always assume a longitude from -180 and 180, so I would use a normalized Coordinate. If you add the normalize method to your next release that would be great, otherwise I'll just create my own normalize method, and handle it on my end.

Thanks again for this excellent project!

from mapjfx.

sothawo avatar sothawo commented on August 12, 2024

resolved; see https://www.sothawo.com/2019/03/mapjfx-2-6-0-and-1-25-0-add-support-for-normalized-coordinates/

from mapjfx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.