Code Monkey home page Code Monkey logo

Comments (4)

jandam avatar jandam commented on July 22, 2024

Maybe same issue as in other projects
OSGeo/PROJ#233

OpenOrienteering/mapper#542

from proj4j.

karol-bujacek avatar karol-bujacek commented on July 22, 2024

I’ve also encountered problems with EPSG:5514. I am not so experienced in this field, so I might be wrong and the problem might lie in my code, but I’ve checked other two tools and the result is different than result from Proj4J.

I need to convert from EPSG:4326 to EPSG:5514. According to page https://epsg.io/5514, coordinates should be negative. Using the transform tool on the same page, https://epsg.io/transform#s_srs=4326&t_srs=5514&x=16.6000000&y=49.1900000, I got negative numbers -598803.96 and -1161258.17.

Using the cs2cs command line tool, Rel. 6.3.1, February 10th, 2020, I got result with negative numbers:

~ echo 16.606451133 49.193040494 | cs2cs  +init=epsg:4326 +to +init=epsg:5514 
-598298.71	-1160969.65 0.00

(installed as deb package, https://proj.org/install.html#debian)

However, Proj4J gives different results. This is test code and log output is below.

import org.junit.Before;
import org.junit.Test;
import org.locationtech.proj4j.CRSFactory;
import org.locationtech.proj4j.CoordinateTransform;
import org.locationtech.proj4j.CoordinateTransformFactory;
import org.locationtech.proj4j.ProjCoordinate;

import static org.junit.Assert.assertEquals;

public class TransformTest {
    private  ProjCoordinate toCoordinate;

    @Before
    public void doTransform() {
        final String coordinateSystemFrom = "epsg:4326";
        final String coordinateSystemTo = "epsg:5514";

        CoordinateTransformFactory coordinateTransformFactory = new CoordinateTransformFactory();
        CRSFactory csFactory = new CRSFactory();

        CoordinateTransform transform = coordinateTransformFactory.createTransform(
                csFactory.createFromName(coordinateSystemFrom),
                csFactory.createFromName(coordinateSystemTo)
        );

        ProjCoordinate fromCoordinate = new ProjCoordinate(16.6064512, 49.1930405);
        toCoordinate = new ProjCoordinate();
        transform.transform(fromCoordinate, toCoordinate);
    }

    @Test
    public void test_x() {
        assertEquals(-598298.71, toCoordinate.x, 1);
    }

    @Test
    public void test_y() {
        assertEquals(-1160969.65, toCoordinate.y, 1);
    }
}

From the log:

java.lang.AssertionError: 
Expected :-598298.71
Actual   :598300.1459260784
java.lang.AssertionError: 
Expected :-1160969.65
Actual   :1160972.570532075

from proj4j.

karol-bujacek avatar karol-bujacek commented on July 22, 2024

The abovementioned test is working if I use this as a second parameter for coordinateTransformFactory.createTransform:

        String paramStr = "+proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 " +
                "+alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +pm=greenwich" +
                "+units=m +no_defs +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56 +axis=wsu";

        CoordinateTransform transform = coordinateTransformFactory.createTransform(
                csFactory.createFromName(coordinateSystemFrom),
                csFactory.createFromParameters("5514", paramStr)
        );

This param string is copied from comment OSGeo/PROJ#233 (comment) and +axis=wsu is used, as OSGeo/PROJ#233 (comment) suggested. The value wsu is taken from the proj documentation https://proj.org/usage/projections.html#axis-orientation.

After this change these two tests are passing.

However, I am not sure if the fix can be ‘so easy’. As I stated in my previous comment, I am quite new in this field without solid knowledge (I am not deeply involved into GIS, I just need to do some simple transformations in my application) and I might overlook some unwanted side effects.

from proj4j.

karol-bujacek avatar karol-bujacek commented on July 22, 2024

And by the way, I am using Proj4J version 1.1.1.

from proj4j.

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.