diff options
| author | Howard Butler <howard@hobu.co> | 2016-04-05 13:19:35 -0500 |
|---|---|---|
| committer | Howard Butler <howard@hobu.co> | 2016-04-05 13:19:35 -0500 |
| commit | 1384b978373cead004211d8548518373d1f4950c (patch) | |
| tree | 05bfe948d718d6bedc82504fc1705012329e383e | |
| parent | a648ae934034924f15e1468b04bd986e007fd381 (diff) | |
| parent | 9b32f9d168b45e2d3eac9be641c5aed3b021d349 (diff) | |
| download | PROJ-1384b978373cead004211d8548518373d1f4950c.tar.gz PROJ-1384b978373cead004211d8548518373d1f4950c.zip | |
Merge pull request #375 from beuan/master
Adding Natural Earth II and Compact Miller
| -rwxr-xr-x | nad/testvarious | 64 | ||||
| -rw-r--r-- | nad/tv_out.dist | 56 | ||||
| -rw-r--r-- | src/Makefile.am | 4 | ||||
| -rw-r--r-- | src/PJ_comill.c | 59 | ||||
| -rw-r--r-- | src/PJ_natearth2.c | 75 | ||||
| -rw-r--r-- | src/lib_proj.cmake | 2 | ||||
| -rw-r--r-- | src/makefile.vc | 4 | ||||
| -rw-r--r-- | src/pj_list.h | 2 |
8 files changed, 260 insertions, 6 deletions
diff --git a/nad/testvarious b/nad/testvarious index a3604ec1..ef1bfbee 100755 --- a/nad/testvarious +++ b/nad/testvarious @@ -508,7 +508,7 @@ $EXE +proj=latlong +ellps=sphere \ EOF # echo "##############################################################" >> ${OUT} -echo "Test the natural earth projection" >> ${OUT} +echo "Test the Natural Earth Projection" >> ${OUT} $EXE +proj=latlong +a=1 +lon_0=0 \ +to +proj=natearth +a=6371008.7714 +b=6371008.7714 -f '%.'7'f' \ -E >>${OUT} <<EOF @@ -539,6 +539,68 @@ $EXE +proj=latlong +a=1 +lon_0=0 \ 180.0 90.0 0 9591912.979377454 9062062.394736718 EOF echo "##############################################################" >> ${OUT} +echo "Test the Natural Earth II Projection" >> ${OUT} +$EXE +proj=latlong +a=1 +lon_0=0 \ + +to +proj=natearth2 +a=6371008.7714 +b=6371008.7714 -f '%.'7'f' \ + -E >>${OUT} <<EOF +0.0 0.0 0 0.00000000 0.00000000 +0.0 22.5 0 0.00000000 2531453.57080958 +0.0 45.0 0 0.00000000 5051471.50086845 +0.0 67.5 0 0.00000000 7395411.22478983 +0.0 90.0 0 0.00000000 9073776.52662810 +45.0 0.0 0 4239151.18200719 0.00000000 +45.0 22.5 0 4138348.61904244 2531453.57080958 +45.0 45.0 0 3830621.33880773 5051471.50086845 +45.0 67.5 0 3158326.32836996 7395411.22478983 +45.0 90.0 0 957973.37034235 9073776.52662810 +90.0 0.0 0 8478302.36401439 0.00000000 +90.0 22.5 0 8276697.23808488 2531453.57080958 +90.0 45.0 0 7661242.67761547 5051471.50086845 +90.0 67.5 0 6316652.65673992 7395411.22478983 +90.0 90.0 0 1915946.74068470 9073776.52662810 +135.0 0.0 0 12717453.54602160 0.00000000 +135.0 22.5 0 12415045.85712730 2531453.57080958 +135.0 45.0 0 11491864.01642320 5051471.50086845 +135.0 67.5 0 9474978.98510988 7395411.22478983 +135.0 90.0 0 2873920.11102705 9073776.52662810 +180.0 0.0 0 16956604.72802880 0.00000000 +180.0 22.5 0 16553394.47616980 2531453.57080958 +180.0 45.0 0 15322485.35523090 5051471.50086845 +180.0 67.5 0 12633305.31347990 7395411.22478983 +180.0 90.0 0 3831893.48136940 9073776.52662810 +EOF +echo "##############################################################" >> ${OUT} +echo "Test the Compact Miller projection" >> ${OUT} +$EXE +proj=latlong +a=1 +lon_0=0 \ + +to +proj=comill +a=6371008.7714 +b=6371008.7714 -f '%.'7'f' \ + -E >>${OUT} <<EOF +0.0 0.0 0 0.0 0.0 +0.0 22.5 0 0.0 2537439.6610749415 +0.0 45.0 0 0.0 5391682.432264133 +0.0 67.5 0 0.0 8661480.510260897 +0.0 90.0 0 0.0 12009484.264916677 +45.0 0.0 0 5003778.588046594 0.0 +45.0 22.5 0 5003778.588046594 2537439.6610749415 +45.0 45.0 0 5003778.588046594 5391682.432264133 +45.0 67.5 0 5003778.588046594 8661480.510260897 +45.0 90.0 0 5003778.588046594 12009484.264916677 +90.0 0.0 0 10007557.176093187 0.0 +90.0 22.5 0 10007557.176093187 2537439.6610749415 +90.0 45.0 0 10007557.176093187 5391682.432264133 +90.0 67.5 0 10007557.176093187 8661480.510260897 +90.0 90.0 0 10007557.176093187 12009484.264916677 +135.0 0.0 0 15011335.76413978 0.0 +135.0 22.5 0 15011335.76413978 2537439.6610749415 +135.0 45.0 0 15011335.76413978 5391682.432264133 +135.0 67.5 0 15011335.76413978 8661480.510260897 +135.0 90.0 0 15011335.76413978 12009484.264916677 +180.0 0.0 0 20015114.352186374 0.0 +180.0 22.5 0 20015114.352186374 2537439.6610749415 +180.0 45.0 0 20015114.352186374 5391682.432264133 +180.0 67.5 0 20015114.352186374 8661480.510260897 +180.0 90.0 0 20015114.352186374 12009484.264916677 +EOF +echo "##############################################################" >> ${OUT} echo "Test pconic (#148)" >> ${OUT} # $EXE +proj=latlong +datum=WGS84 \ diff --git a/nad/tv_out.dist b/nad/tv_out.dist index f61df2f6..28b15622 100644 --- a/nad/tv_out.dist +++ b/nad/tv_out.dist @@ -236,7 +236,7 @@ Test inv geos on a ellipsoid with alternate sweep 1605067.15 -3400461.47 18d25'26"E 33d55'31"S 0.000 3820138.08 2888664.15 47d58'42"E 29d22'11"N 0.000 ############################################################## -Test the natural earth projection +Test the Natural Earth Projection 0.0 0.0 0 0.0000000 0.0000000 0.0000000 0.0 0.0 0.0 22.5 0 0.0000000 2525419.5693838 0.0000000 0.0 2525419.569383768 0.0 45.0 0 0.0000000 5052537.3899732 0.0000000 0.0 5052537.389973222 @@ -263,6 +263,60 @@ Test the natural earth projection 180.0 67.5 0 13419749.8846233 7400065.6562574 0.0000000 1.341974988462332E7 7400065.6562573705 180.0 90.0 0 9591912.9793775 9062062.3947367 0.0000000 9591912.979377454 9062062.394736718 ############################################################## +Test the Natural Earth II Projection +0.0 0.0 0 0.0000000 0.0000000 0.0000000 0.00000000 0.00000000 +0.0 22.5 0 0.0000000 2531453.5708096 0.0000000 0.00000000 2531453.57080958 +0.0 45.0 0 0.0000000 5051471.5008684 0.0000000 0.00000000 5051471.50086845 +0.0 67.5 0 0.0000000 7395411.2247898 0.0000000 0.00000000 7395411.22478983 +0.0 90.0 0 0.0000000 9073776.5266281 0.0000000 0.00000000 9073776.52662810 +45.0 0.0 0 4239151.1820072 0.0000000 0.0000000 4239151.18200719 0.00000000 +45.0 22.5 0 4138348.6190424 2531453.5708096 0.0000000 4138348.61904244 2531453.57080958 +45.0 45.0 0 3830621.3388077 5051471.5008684 0.0000000 3830621.33880773 5051471.50086845 +45.0 67.5 0 3158326.3283700 7395411.2247898 0.0000000 3158326.32836996 7395411.22478983 +45.0 90.0 0 957973.3703423 9073776.5266281 0.0000000 957973.37034235 9073776.52662810 +90.0 0.0 0 8478302.3640144 0.0000000 0.0000000 8478302.36401439 0.00000000 +90.0 22.5 0 8276697.2380849 2531453.5708096 0.0000000 8276697.23808488 2531453.57080958 +90.0 45.0 0 7661242.6776155 5051471.5008684 0.0000000 7661242.67761547 5051471.50086845 +90.0 67.5 0 6316652.6567399 7395411.2247898 0.0000000 6316652.65673992 7395411.22478983 +90.0 90.0 0 1915946.7406847 9073776.5266281 0.0000000 1915946.74068470 9073776.52662810 +135.0 0.0 0 12717453.5460216 0.0000000 0.0000000 12717453.54602160 0.00000000 +135.0 22.5 0 12415045.8571273 2531453.5708096 0.0000000 12415045.85712730 2531453.57080958 +135.0 45.0 0 11491864.0164232 5051471.5008684 0.0000000 11491864.01642320 5051471.50086845 +135.0 67.5 0 9474978.9851099 7395411.2247898 0.0000000 9474978.98510988 7395411.22478983 +135.0 90.0 0 2873920.1110270 9073776.5266281 0.0000000 2873920.11102705 9073776.52662810 +180.0 0.0 0 16956604.7280288 0.0000000 0.0000000 16956604.72802880 0.00000000 +180.0 22.5 0 16553394.4761698 2531453.5708096 0.0000000 16553394.47616980 2531453.57080958 +180.0 45.0 0 15322485.3552309 5051471.5008684 0.0000000 15322485.35523090 5051471.50086845 +180.0 67.5 0 12633305.3134798 7395411.2247898 0.0000000 12633305.31347990 7395411.22478983 +180.0 90.0 0 3831893.4813694 9073776.5266281 0.0000000 3831893.48136940 9073776.52662810 +############################################################## +Test the Compact Miller projection +0.0 0.0 0 0.0000000 0.0000000 0.0000000 0.0 0.0 +0.0 22.5 0 0.0000000 2537439.6610749 0.0000000 0.0 2537439.6610749415 +0.0 45.0 0 0.0000000 5391682.4322641 0.0000000 0.0 5391682.432264133 +0.0 67.5 0 0.0000000 8661480.5102609 0.0000000 0.0 8661480.510260897 +0.0 90.0 0 0.0000000 12009484.2649167 0.0000000 0.0 12009484.264916677 +45.0 0.0 0 5003778.5880466 0.0000000 0.0000000 5003778.588046594 0.0 +45.0 22.5 0 5003778.5880466 2537439.6610749 0.0000000 5003778.588046594 2537439.6610749415 +45.0 45.0 0 5003778.5880466 5391682.4322641 0.0000000 5003778.588046594 5391682.432264133 +45.0 67.5 0 5003778.5880466 8661480.5102609 0.0000000 5003778.588046594 8661480.510260897 +45.0 90.0 0 5003778.5880466 12009484.2649167 0.0000000 5003778.588046594 12009484.264916677 +90.0 0.0 0 10007557.1760932 0.0000000 0.0000000 10007557.176093187 0.0 +90.0 22.5 0 10007557.1760932 2537439.6610749 0.0000000 10007557.176093187 2537439.6610749415 +90.0 45.0 0 10007557.1760932 5391682.4322641 0.0000000 10007557.176093187 5391682.432264133 +90.0 67.5 0 10007557.1760932 8661480.5102609 0.0000000 10007557.176093187 8661480.510260897 +90.0 90.0 0 10007557.1760932 12009484.2649167 0.0000000 10007557.176093187 12009484.264916677 +135.0 0.0 0 15011335.7641398 0.0000000 0.0000000 15011335.76413978 0.0 +135.0 22.5 0 15011335.7641398 2537439.6610749 0.0000000 15011335.76413978 2537439.6610749415 +135.0 45.0 0 15011335.7641398 5391682.4322641 0.0000000 15011335.76413978 5391682.432264133 +135.0 67.5 0 15011335.7641398 8661480.5102609 0.0000000 15011335.76413978 8661480.510260897 +135.0 90.0 0 15011335.7641398 12009484.2649167 0.0000000 15011335.76413978 12009484.264916677 +180.0 0.0 0 20015114.3521864 0.0000000 0.0000000 20015114.352186374 0.0 +180.0 22.5 0 20015114.3521864 2537439.6610749 0.0000000 20015114.352186374 2537439.6610749415 +180.0 45.0 0 20015114.3521864 5391682.4322641 0.0000000 20015114.352186374 5391682.432264133 +180.0 67.5 0 20015114.3521864 8661480.5102609 0.0000000 20015114.352186374 8661480.510260897 +180.0 90.0 0 20015114.3521864 12009484.2649167 0.0000000 20015114.352186374 12009484.264916677 +############################################################## Test pconic (#148) -70.4 -23.65 -2240096.40 -6940342.15 0.00 -2240096.40 -6940342.15 70d24'W 23d39'S 0.000 diff --git a/src/Makefile.am b/src/Makefile.am index 6fd97475..d59e3fde 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,7 +47,7 @@ libproj_la_SOURCES = \ PJ_lask.c PJ_nocol.c PJ_ob_tran.c PJ_oea.c \ PJ_tpeqd.c PJ_vandg.c PJ_vandg2.c PJ_vandg4.c \ PJ_wag7.c PJ_lcca.c PJ_geos.c proj_etmerc.c \ - PJ_boggs.c PJ_collg.c PJ_crast.c PJ_denoy.c \ + PJ_boggs.c PJ_collg.c PJ_comill.c PJ_crast.c PJ_denoy.c \ PJ_eck1.c PJ_eck2.c PJ_eck3.c PJ_eck4.c \ PJ_eck5.c PJ_fahey.c PJ_fouc_s.c PJ_gins8.c PJ_gstmerc.c \ PJ_gn_sinu.c PJ_goode.c PJ_igh.c PJ_hatano.c PJ_loxim.c \ @@ -64,7 +64,7 @@ libproj_la_SOURCES = \ pj_open_lib.c pj_param.c pj_phi2.c pj_pr_list.c \ pj_qsfn.c pj_strerrno.c pj_tsfn.c pj_units.c pj_ctx.c pj_log.c \ pj_zpoly1.c rtodms.c vector1.c pj_release.c pj_gauss.c \ - PJ_healpix.c PJ_natearth.c PJ_calcofi.c pj_fileapi.c \ + PJ_healpix.c PJ_natearth.c PJ_natearth2.c PJ_calcofi.c pj_fileapi.c \ \ pj_gc_reader.c pj_gridcatalog.c \ nad_cvt.c nad_init.c nad_intr.c emess.c emess.h \ diff --git a/src/PJ_comill.c b/src/PJ_comill.c new file mode 100644 index 00000000..ad9914d4 --- /dev/null +++ b/src/PJ_comill.c @@ -0,0 +1,59 @@ +/* +The Compact Miller projection was designed by Tom Patterson, US National +Park Service, in 2014. The polynomial equation was developed by Bojan +Savric and Bernhard Jenny, College of Earth, Ocean, and Atmospheric +Sciences, Oregon State University. +Port to PROJ.4 by Bojan Savric, 4 April 2016 +*/ + +#define PJ_LIB__ +#include <projects.h> +PROJ_HEAD(comill, "Compact Miller") "\n\tCyl., Sph."; + +#define K1 0.9902 +#define K2 0.1604 +#define K3 -0.03054 +#define C1 K1 +#define C2 (3 * K2) +#define C3 (5 * K3) +#define EPS 1e-11 +#define MAX_Y (0.6000207669862655 * PI) + +FORWARD(s_forward); /* spheroid */ + double lat_sq; + + lat_sq = lp.phi * lp.phi; + xy.x = lp.lam; + xy.y = lp.phi * (K1 + lat_sq * (K2 + K3 * lat_sq)); + return (xy); +} +INVERSE(s_inverse); /* spheroid */ + double yc, tol, y2, y4, f, fder; + + /* make sure y is inside valid range */ + if (xy.y > MAX_Y) { + xy.y = MAX_Y; + } else if (xy.y < -MAX_Y) { + xy.y = -MAX_Y; + } + + /* latitude */ + yc = xy.y; + for (;;) { /* Newton-Raphson */ + y2 = yc * yc; + f = (yc * (K1 + y2 * (K2 + K3 * y2))) - xy.y; + fder = C1 + y2 * (C2 + C3 * y2); + yc -= tol = f / fder; + if (fabs(tol) < EPS) { + break; + } + } + lp.phi = yc; + + /* longitude */ + lp.lam = xy.x; + + return (lp); +} +FREEUP; if (P) pj_dalloc(P); } +ENTRY0(comill) P->es = 0; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P) diff --git a/src/PJ_natearth2.c b/src/PJ_natearth2.c new file mode 100644 index 00000000..c3776a8b --- /dev/null +++ b/src/PJ_natearth2.c @@ -0,0 +1,75 @@ +/* +The Natural Earth II projection was designed by Tom Patterson, US National +Park Service, in 2012, using Flex Projector. The polynomial equation was +developed by Bojan Savric and Bernhard Jenny, College of Earth, Ocean, +and Atmospheric Sciences, Oregon State University. +Port to PROJ.4 by Bojan Savric, 4 April 2016 +*/ + +#define PJ_LIB__ +#include <projects.h> +PROJ_HEAD(natearth2, "Natural Earth 2") "\n\tPCyl., Sph."; + +#define A0 0.84719 +#define A1 -0.13063 +#define A2 -0.04515 +#define A3 0.05494 +#define A4 -0.02326 +#define A5 0.00331 +#define B0 1.01183 +#define B1 -0.02625 +#define B2 0.01926 +#define B3 -0.00396 +#define C0 B0 +#define C1 (9 * B1) +#define C2 (11 * B2) +#define C3 (13 * B3) +#define EPS 1e-11 +#define MAX_Y (0.84719 * 0.535117535153096 * PI) + +FORWARD(s_forward); /* spheroid */ + double phi2, phi4, phi6; + + phi2 = lp.phi * lp.phi; + phi4 = phi2 * phi2; + phi6 = phi2 * phi4; + + xy.x = lp.lam * (A0 + A1 * phi2 + phi6 * phi6 * (A2 + A3 * phi2 + A4 * phi4 + A5 * phi6)); + xy.y = lp.phi * (B0 + phi4 * phi4 * (B1 + B2 * phi2 + B3 * phi4)); + return (xy); +} +INVERSE(s_inverse); /* spheroid */ + double yc, tol, y2, y4, y6, f, fder; + + /* make sure y is inside valid range */ + if (xy.y > MAX_Y) { + xy.y = MAX_Y; + } else if (xy.y < -MAX_Y) { + xy.y = -MAX_Y; + } + + /* latitude */ + yc = xy.y; + for (;;) { /* Newton-Raphson */ + y2 = yc * yc; + y4 = y2 * y2; + f = (yc * (B0 + y4 * y4 * (B1 + B2 * y2 + B3 * y4))) - xy.y; + fder = C0 + y4 * y4 * (C1 + C2 * y2 + C3 * y4); + yc -= tol = f / fder; + if (fabs(tol) < EPS) { + break; + } + } + lp.phi = yc; + + /* longitude */ + y2 = yc * yc; + y4 = y2 * y2; + y6 = y2 * y4; + + lp.lam = xy.x / (A0 + A1 * y2 + y6 * y6 * (A2 + A3 * y2 + A4 * y4 + A5 * y6)); + + return (lp); +} +FREEUP; if (P) pj_dalloc(P); } +ENTRY0(natearth2) P->es = 0; P->inv = s_inverse; P->fwd = s_forward; ENDENTRY(P) diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake index a8797a74..ed14e99e 100644 --- a/src/lib_proj.cmake +++ b/src/lib_proj.cmake @@ -55,6 +55,7 @@ SET(SRC_LIBPROJ_PJ PJ_cea.c PJ_chamb.c PJ_collg.c + PJ_comill.c PJ_crast.c PJ_denoy.c PJ_eck1.c @@ -97,6 +98,7 @@ SET(SRC_LIBPROJ_PJ PJ_mod_ster.c PJ_moll.c PJ_natearth.c + PJ_natearth2.c PJ_nell.c PJ_nell_h.c PJ_nocol.c diff --git a/src/makefile.vc b/src/makefile.vc index 435f9943..6989519d 100644 --- a/src/makefile.vc +++ b/src/makefile.vc @@ -14,7 +14,7 @@ conic = \ PJ_rpoly.obj PJ_sconics.obj PJ_lcca.obj cylinder = \ - PJ_cass.obj PJ_cc.obj PJ_cea.obj PJ_eqc.obj \ + PJ_cass.obj PJ_cc.obj PJ_cea.obj PJ_comill.obj PJ_eqc.obj \ PJ_gall.obj PJ_labrd.obj PJ_lsat.obj PJ_misrsom.obj PJ_merc.obj \ PJ_mill.obj PJ_ocea.obj PJ_omerc.obj PJ_patterson.obj PJ_somerc.obj \ PJ_tcc.obj PJ_tcea.obj PJ_tmerc.obj PJ_geos.obj \ @@ -26,7 +26,7 @@ misc = \ PJ_lask.obj PJ_nocol.obj PJ_ob_tran.obj PJ_oea.obj \ PJ_sch.obj PJ_tpeqd.obj PJ_vandg.obj PJ_vandg2.obj \ PJ_vandg4.obj PJ_wag7.obj pj_latlong.obj PJ_krovak.obj \ - pj_geocent.obj PJ_healpix.obj PJ_natearth.obj PJ_qsc.obj + pj_geocent.obj PJ_healpix.obj PJ_natearth.obj PJ_natearth2.obj PJ_qsc.obj pseudo = \ PJ_boggs.obj PJ_collg.obj PJ_crast.obj PJ_denoy.obj \ diff --git a/src/pj_list.h b/src/pj_list.h index 47362d87..baacacc3 100644 --- a/src/pj_list.h +++ b/src/pj_list.h @@ -22,6 +22,7 @@ PROJ_HEAD(cc, "Central Cylindrical") PROJ_HEAD(cea, "Equal Area Cylindrical") PROJ_HEAD(chamb, "Chamberlin Trimetric") PROJ_HEAD(collg, "Collignon") +PROJ_HEAD(comill, "Compact Miller") PROJ_HEAD(crast, "Craster Parabolic (Putnins P4)") PROJ_HEAD(denoy, "Denoyer Semi-Elliptical") PROJ_HEAD(eck1, "Eckert I") @@ -85,6 +86,7 @@ PROJ_HEAD(murd1, "Murdoch I") PROJ_HEAD(murd2, "Murdoch II") PROJ_HEAD(murd3, "Murdoch III") PROJ_HEAD(natearth, "Natural Earth") +PROJ_HEAD(natearth2, "Natural Earth II") PROJ_HEAD(nell, "Nell") PROJ_HEAD(nell_h, "Nell-Hammer") PROJ_HEAD(nicol, "Nicolosi Globular") |
