Opened 12 years ago

Closed 12 years ago

#74 closed defect (invalid)

Krovak projection wrong

Reported by: jachym Owned by: madair
Priority: major Milestone: 1.1.1
Component: core Version: trunk
Keywords: Cc:

Description

Current implementation of krovak's projection in Proj4js is wrong and gives completely wrong results when transforming.

EPSG (originally ESRI) code for "Krovak" projection - 102067 is defined wrong in defs/EPSG102067.js

I do not know, how far krovak.js is really a port from C-implementation of PROJ4, but the results, it is giving is different.

102067 definition should look like:

Proj4js.defs["EPSG:102067"] = "+title=Krovak JTSK +proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813975277778 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56 +no_defs <>";

NOTE: +lon_0 parameter differs from what's in proj4js, there is *no* +czech parameter (again difference from proj4js)

command line transformation (uses PROJ4):

# <102067> +proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813975277778 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +units=m +towgs84=498.17,136.89,510.08,6.007,4.343,3.831,3.38 +no_defs <> 

echo "-868208.53 -1095793.57"|cs2cs +init=epsg:102067 +to +init=epsg:4326 -f "%f"
12.806988	49.452262 42.825377

With Proj4js (same EPSG:102067 definition, as used in PROJ4, described higher of this ticket):

in:12.806988,49.452262	out:-408626.6895276231,1149248.7588554663
}}
(to be seen in the patch, attached to this ticket)

can be tested also with OpenLayers:
{{{
b = new OpenLayers.Bounds(-10,-10,-10,-10);
p = new OpenLayers.Projection("epsg:102067");
b.transform(p,p);
b.toString();

"-9.34790492033495,10.61670492280592,-9.34790492033495,10.61670492280592" // <- this should be cca -10,-10,-10,-10
}}}

Attachments (2)

test-krovak-proj.diff (2.4 KB ) - added by jachym 12 years ago.
Tests with krovak projection based on http://grass.fsv.cvut.cz/gwiki/S-JTSK#S-JTSK_.E2.86.92_WGS84
krovak.patch (1.7 KB ) - added by jachym 12 years ago.

Download all attachments as: .zip

Change History (6)

by jachym, 12 years ago

Attachment: test-krovak-proj.diff added

comment:1 by jachym, 12 years ago

Ok, I think, I have a patch, which makes it work as expected. Patch attached, works now. I just had a look into original PJ_krovak.c code. One note: EPSG:102067 was (is) unofficial EPSG code used for the projection used in Czech. Nowadays, we finally have official code, which is 5514.

p1 = new OpenLayers.Projection("epsg:5514");
p2 = new OpenLayers.Projection("epsg:4326");
g = new OpenLayers.Geometry.Point(12.806988,49.452262);
g.transform(p2,p1);
// result should be something like in:-868208.53,-1095793.57	

Patch attached

by jachym, 12 years ago

Attachment: krovak.patch added

comment:2 by madair, 12 years ago

Status: newassigned

I'm having trouble getting this to pass the test with this patch (assuming the second towgs84 is the correct one).

Wondering if I've missed anything.

comment:3 by jachym, 12 years ago

Sorry for late response (I'm back to this after some time)

I have difficulties to pass the test too, even rebuild the library (cd build && python build.py && python buildUncompressed.py).

p = new Proj4js.Proj("epsg:1202067");
p.a // gives 6377397.155
p.a = 1; // fixing it, this is actually the part of the patch
p.czech  = true; // fixing another issue - original proj4, AFAIK uses +czech for getting positive coordinates

Proj4js.transform(Proj4js.WGS84,p, new Proj4js.Point([12.806988,49.452262]))

  Class
    x: -868208.5236106912
    y: -1095793.5552113685
    z: -42.822896994650364

// voila, expected result

Problem must be somewhere more deeper (maybe

comment:4 by jachym, 12 years ago

Resolution: invalid
Status: assignedclosed

Hmm, apparently, I had a mess in the code (build.py and buildUncompressed.py took some fore files, which were overwriting each other).

I'm closing this ticket and creating new one with new patch.

Note: See TracTickets for help on using tickets.