Skip to content

v2: EPSG:4326 to EPSG:2157 inconsistency with proj with negative latitude #11

@davidjb

Description

@davidjb

Many thanks for creating this library. I've tried the following transform between EPSG:4326 and EPSG:2157 and the calculations appear fine when inside the bounds of EPSG:2157. However, when outside the bounds and latitude becomes negative, there are in inconsistencies between wgs84 and other tools like proj. Testing something like Null Island (0,0) is fine and consistent, but once latitude is negative, results differ:

package main

import (
	"fmt"

	"github.com/wroge/wgs84/v2"
)

func main() {
	transform := wgs84.Transform(wgs84.EPSG(4326), wgs84.EPSG(2157)).Round(3)

	// Consistent
	east, north, h := transform(0, 0, 0)
	fmt.Printf("%.3f\t%.3f %.3f\n", east, north, h)

	// go run main.go
	// 1493322.696     -5179198.412 0.000
	// echo 0 0 | cs2cs +init=epsg:4326 +to +init=epsg:2157 -d 3
	// 1493322.696     -5179198.412 0.000
	// https://epsg.io/transform#s_srs=4326&t_srs=2157&x=0&y=-0
	// 1493322.696462611 -5179198.412407922

	// Inconsistent - negative lat
	east, north, h = transform(100, -1, 0)
	fmt.Printf("%.3f\t%.3f %.3f\n", east, north, h)

	// go run main.go
	// 12431088.352    -5548823.633 0.000
	// echo 100 -10 | cs2cs +init=epsg:4326 +to +init=epsg:2157 -d 3
	// 12431089.926    -24809902.916 0.000
	// https://epsg.io/transform#s_srs=4326&t_srs=2157&x=100.0000000&y=-10.0000000
	// 12431089.925768612 -24809902.916357957
}

Tested with the current commit on v2 at 5fb8989. Let me know if you need any more info.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions