proj.pas 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. {
  2. Translation of the proj.4 headers for FreePascal
  3. Copyright (C) 2009 by Ivo Steinmann
  4. }
  5. (******************************************************************************
  6. * $Id: proj_api.h,v 1.17 2008/07/21 20:47:09 fwarmerdam Exp $
  7. *
  8. * Project: PROJ.4
  9. * Purpose: Public (application) include file for PROJ.4 API, and constants.
  10. * Author: Frank Warmerdam, <[email protected]>
  11. *
  12. ******************************************************************************
  13. * Copyright (c) 2001, Frank Warmerdam <[email protected]>
  14. *
  15. * Permission is hereby granted, free of charge, to any person obtaining a
  16. * copy of this software and associated documentation files (the "Software"),
  17. * to deal in the Software without restriction, including without limitation
  18. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  19. * and/or sell copies of the Software, and to permit persons to whom the
  20. * Software is furnished to do so, subject to the following conditions:
  21. *
  22. * The above copyright notice and this permission notice shall be included
  23. * in all copies or substantial portions of the Software.
  24. *
  25. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  26. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  27. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  28. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  29. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  30. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  31. * DEALINGS IN THE SOFTWARE.
  32. ******************************************************************************)
  33. unit proj;
  34. {$mode objfpc}
  35. {$MINENUMSIZE 4}
  36. {$h+}
  37. interface
  38. uses
  39. ctypes;
  40. {$IFDEF WINDOWS}
  41. {$DEFINE DYNLINK}
  42. {$ENDIF}
  43. {$IFDEF DYNLINK}
  44. const
  45. {$IF Defined(WINDOWS)}
  46. proj4lib = 'libproj.dll';
  47. {$ELSEIF Defined(UNIX)}
  48. proj4lib = 'libproj.so';
  49. {$ELSE}
  50. {$MESSAGE ERROR 'DYNLINK not supported'}
  51. {$IFEND}
  52. {$ELSE}
  53. {$LINKLIB proj}
  54. {$ENDIF}
  55. { List of projections (proj=)
  56. aea : Albers Equal Area
  57. Conic Sph&Ell
  58. lat_1= lat_2=
  59. aeqd : Azimuthal Equidistant
  60. Azi, Sph&Ell
  61. lat_0 guam
  62. airy : Airy
  63. Misc Sph, no inv.
  64. no_cut lat_b=
  65. aitoff : Aitoff
  66. Misc Sph
  67. alsk : Mod. Stererographics of Alaska
  68. Azi(mod)
  69. apian : Apian Globular I
  70. Misc Sph, no inv.
  71. august : August Epicycloidal
  72. Misc Sph, no inv.
  73. bacon : Bacon Globular
  74. Misc Sph, no inv.
  75. bipc : Bipolar conic of western hemisphere
  76. Conic Sph.
  77. boggs : Boggs Eumorphic
  78. PCyl., no inv., Sph.
  79. bonne : Bonne (Werner lat_1=90)
  80. Conic Sph&Ell
  81. lat_1=
  82. cass : Cassini
  83. Cyl, Sph&Ell
  84. cc : Central Cylindrical
  85. Cyl, Sph
  86. cea : Equal Area Cylindrical
  87. Cyl, Sph&Ell
  88. lat_ts=
  89. chamb : Chamberlin Trimetric
  90. Misc Sph, no inv.
  91. lat_1= lon_1= lat_2= lon_2= lat_3= lon_3=
  92. collg : Collignon
  93. PCyl, Sph.
  94. crast : Craster Parabolic (Putnins P4)
  95. PCyl., Sph.
  96. denoy : Denoyer Semi-Elliptical
  97. PCyl., no inv., Sph.
  98. eck1 : Eckert I
  99. PCyl., Sph.
  100. eck2 : Eckert II
  101. PCyl. Sph.
  102. eck3 : Eckert III
  103. PCyl, Sph.
  104. eck4 : Eckert IV
  105. PCyl, Sph.
  106. eck5 : Eckert V
  107. PCyl, Sph.
  108. eck6 : Eckert VI
  109. PCyl, Sph.
  110. eqc : Equidistant Cylindrical (Plate Caree)
  111. Cyl, Sph
  112. lat_ts=
  113. eqdc : Equidistant Conic
  114. Conic, Sph&Ell
  115. lat_1= lat_2=
  116. euler : Euler
  117. Conic, Sph
  118. lat_1= and lat_2=
  119. fahey : Fahey
  120. Pcyl, Sph.
  121. fouc : Foucaut
  122. PCyl., Sph.
  123. fouc_s : Foucaut Sinusoidal
  124. PCyl., Sph.
  125. gall : Gall (Gall Stereographic)
  126. Cyl, Sph
  127. geos : Geostationary Satellite View
  128. Azi, Sph&Ell
  129. h=
  130. gins8 : Ginsburg VIII (TsNIIGAiK)
  131. PCyl, Sph., no inv.
  132. gn_sinu : General Sinusoidal Series
  133. PCyl, Sph.
  134. m= n=
  135. gnom : Gnomonic
  136. Azi, Sph.
  137. goode : Goode Homolosine
  138. PCyl, Sph.
  139. gs48 : Mod. Stererographics of 48 U.S.
  140. Azi(mod)
  141. gs50 : Mod. Stererographics of 50 U.S.
  142. Azi(mod)
  143. hammer : Hammer & Eckert-Greifendorff
  144. Misc Sph, no inv.
  145. W= M=
  146. hatano : Hatano Asymmetrical Equal Area
  147. PCyl, Sph.
  148. imw_p : International Map of the World Polyconic
  149. Mod. Polyconic, Ell
  150. lat_1= and lat_2= [lon_1=]
  151. kav5 : Kavraisky V
  152. PCyl., Sph.
  153. kav7 : Kavraisky VII
  154. PCyl, Sph.
  155. krovak : Krovak
  156. PCyl., Ellps.
  157. labrd : Laborde
  158. Cyl, Sph
  159. Special for Madagascar
  160. laea : Lambert Azimuthal Equal Area
  161. Azi, Sph&Ell
  162. lagrng : Lagrange
  163. Misc Sph, no inv.
  164. W=
  165. larr : Larrivee
  166. Misc Sph, no inv.
  167. lask : Laskowski
  168. Misc Sph, no inv.
  169. lonlat : Lat/long (Geodetic)
  170. latlon : Lat/long (Geodetic alias)
  171. lcc : Lambert Conformal Conic
  172. Conic, Sph&Ell
  173. lat_1= and lat_2= or lat_0
  174. lcca : Lambert Conformal Conic Alternative
  175. Conic, Sph&Ell
  176. lat_0=
  177. leac : Lambert Equal Area Conic
  178. Conic, Sph&Ell
  179. lat_1= south
  180. lee_os : Lee Oblated Stereographic
  181. Azi(mod)
  182. loxim : Loximuthal
  183. PCyl Sph
  184. lsat : Space oblique for LANDSAT
  185. Cyl, Sph&Ell
  186. lsat= path=
  187. mbt_s : McBryde-Thomas Flat-Polar Sine (No. 1)
  188. PCyl., Sph.
  189. mbt_fps : McBryde-Thomas Flat-Pole Sine (No. 2)
  190. Cyl., Sph.
  191. mbtfpp : McBride-Thomas Flat-Polar Parabolic
  192. Cyl., Sph.
  193. mbtfpq : McBryde-Thomas Flat-Polar Quartic
  194. Cyl., Sph.
  195. mbtfps : McBryde-Thomas Flat-Polar Sinusoidal
  196. PCyl, Sph.
  197. merc : Mercator
  198. Cyl, Sph&Ell
  199. lat_ts=
  200. mil_os : Miller Oblated Stereographic
  201. Azi(mod)
  202. mill : Miller Cylindrical
  203. Cyl, Sph
  204. moll : Mollweide
  205. PCyl., Sph.
  206. murd1 : Murdoch I
  207. Conic, Sph
  208. lat_1= and lat_2=
  209. murd2 : Murdoch II
  210. Conic, Sph
  211. lat_1= and lat_2=
  212. murd3 : Murdoch III
  213. Conic, Sph
  214. lat_1= and lat_2=
  215. nell : Nell
  216. PCyl., Sph.
  217. nell_h : Nell-Hammer
  218. PCyl., Sph.
  219. nicol : Nicolosi Globular
  220. Misc Sph, no inv.
  221. nsper : Near-sided perspective
  222. Azi, Sph
  223. h=
  224. nzmg : New Zealand Map Grid
  225. fixed Earth
  226. ob_tran : General Oblique Transformation
  227. Misc Sph
  228. o_proj= plus parameters for projection
  229. o_lat_p= o_lon_p= (new pole) or
  230. o_alpha= o_lon_c= o_lat_c= or
  231. o_lon_1= o_lat_1= o_lon_2= o_lat_2=
  232. ocea : Oblique Cylindrical Equal Area
  233. Cyl, Sphlonc= alpha= or
  234. lat_1= lat_2= lon_1= lon_2=
  235. oea : Oblated Equal Area
  236. Misc Sph
  237. n= m= theta=
  238. omerc : Oblique Mercator
  239. Cyl, Sph&Ell
  240. no_rot rot_conv no_uoff and
  241. alpha= lonc= or
  242. lon_1= lat_1= lon_2= lat_2=
  243. ortel : Ortelius Oval
  244. Misc Sph, no inv.
  245. ortho : Orthographic
  246. Azi, Sph.
  247. pconic : Perspective Conic
  248. Conic, Sph
  249. lat_1= and lat_2=
  250. poly : Polyconic (American)
  251. Conic, Sph&Ell
  252. putp1 : Putnins P1
  253. PCyl, Sph.
  254. putp2 : Putnins P2
  255. PCyl., Sph.
  256. putp3 : Putnins P3
  257. PCyl., Sph.
  258. putp3p : Putnins P3'
  259. PCyl., no inv., Sph.
  260. putp4p : Putnins P4'
  261. PCyl., Sph.
  262. putp5 : Putnins P5
  263. PCyl., Sph.
  264. putp5p : Putnins P5'
  265. PCyl., Sph.
  266. putp6 : Putnins P6
  267. PCyl., Sph.
  268. putp6p : Putnins P6'
  269. PCyl., Sph.
  270. qua_aut : Quartic Authalic
  271. PCyl., Sph.
  272. robin : Robinson
  273. PCyl., Sph.
  274. rouss : Roussilhe Stereographic
  275. Azi., Ellps.
  276. rpoly : Rectangular Polyconic
  277. Conic, Sph., no inv.
  278. lat_ts=
  279. sinu : Sinusoidal (Sanson-Flamsteed)
  280. PCyl, Sph&Ell
  281. somerc : Swiss. Obl. Mercator
  282. Cyl, Ell
  283. For CH1903
  284. stere : Stereographic
  285. Azi, Sph&Ell
  286. lat_ts=
  287. sterea : Oblique Stereographic Alternative
  288. Azimuthal, Sph&Ell
  289. tcc : Transverse Central Cylindrical
  290. Cyl, Sph, no inv.
  291. tcea : Transverse Cylindrical Equal Area
  292. Cyl, Sph
  293. tissot : Tissot
  294. Conic, Sph
  295. lat_1= and lat_2=
  296. tmerc : Transverse Mercator
  297. Cyl, Sph&Ell
  298. tpeqd : Two Point Equidistant
  299. Misc Sph
  300. lat_1= lon_1= lat_2= lon_2=
  301. tpers : Tilted perspective
  302. Azi, Sph
  303. tilt= azi= h=
  304. ups : Universal Polar Stereographic
  305. Azi, Sph&Ell
  306. south
  307. urm5 : Urmaev V
  308. PCyl., Sph.
  309. n= q= alphi=
  310. urmfps : Urmaev Flat-Polar Sinusoidal
  311. PCyl, Sph.
  312. n=
  313. utm : Universal Transverse Mercator (UTM)
  314. Cyl, Sph
  315. zone= south
  316. vandg : van der Grinten (I)
  317. Misc Sph
  318. vandg2 : van der Grinten II
  319. Misc Sph, no inv.
  320. vandg3 : van der Grinten III
  321. Misc Sph, no inv.
  322. vandg4 : van der Grinten IV
  323. Misc Sph, no inv.
  324. vitk1 : Vitkovsky I
  325. Conic, Sph
  326. lat_1= and lat_2=
  327. wag1 : Wagner I (Kavraisky VI)
  328. PCyl, Sph.
  329. wag2 : Wagner II
  330. PCyl., Sph.
  331. wag3 : Wagner III
  332. PCyl., Sph.
  333. lat_ts=
  334. wag4 : Wagner IV
  335. PCyl., Sph.
  336. wag5 : Wagner V
  337. PCyl., Sph.
  338. wag6 : Wagner VI
  339. PCyl, Sph.
  340. wag7 : Wagner VII
  341. Misc Sph, no inv.
  342. weren : Werenskiold I
  343. PCyl., Sph.
  344. wink1 : Winkel I
  345. PCyl., Sph.
  346. lat_ts=
  347. wink2 : Winkel II
  348. PCyl., Sph., no inv.
  349. lat_1=
  350. wintri : Winkel Tripel
  351. Misc Sph
  352. lat_1
  353. }
  354. (* Try to update this every version! *)
  355. const
  356. PJ_VERSION = 461;
  357. //extern char const pj_release[]; /* global release id string */
  358. const
  359. RAD_TO_DEG = 57.29577951308232;
  360. DEG_TO_RAD = 0.0174532925199432958;
  361. //extern int pj_errno; /* global error return code */
  362. type
  363. projUV = record
  364. u, v: cdouble;
  365. end;
  366. projPJ = pointer;
  367. projXY = projUV;
  368. projLP = projUV;
  369. (* procedure prototypes *)
  370. function pj_fwd(val: projLP; proj: projPJ): projXY; cdecl; external;
  371. function pj_inv(val: projXY; proj: projPJ): projLP; cdecl; external;
  372. function pj_transform(src, dst: projPJ; point_count: clong; point_offset: cint; x,y,z: pcdouble): cint; cdecl; external;
  373. function pj_datum_transform(src, dst: projPJ; point_count: clong; point_offset: cint; x,y,z: pcdouble): cint; cdecl; external;
  374. function pj_geocentric_to_geodetic(a, es: cdouble; point_count: clong; point_offset: cint; x,y,z: pcdouble): cint; cdecl; external;
  375. function pj_geodetic_to_geocentric(a, es: cdouble; point_count: clong; point_offset: cint; x,y,z: pcdouble): cint; cdecl; external;
  376. function pj_compare_datums(srcdefn: projPJ; dstdefn: projPJ): cint; cdecl; external;
  377. function pj_apply_gridshift(c: pchar; i: cint; point_count: clong; point_offset: cint; x,y,z: pcdouble): cint; cdecl; external;
  378. type
  379. projFinder = function(s: pchar): pchar; cdecl;
  380. procedure pj_deallocate_grids; cdecl; external;
  381. function pj_is_latlong(proj: projPJ): cint; cdecl; external;
  382. function pj_is_geocent(proj: projPJ): cint; cdecl; external;
  383. procedure pj_pr_list(proj: projPJ); cdecl; external;
  384. procedure pj_free(proj: projPJ); cdecl; external;
  385. procedure pj_set_finder(finder: projFinder); cdecl; external;
  386. procedure pj_set_searchpath(count: cint; path: ppchar); cdecl; external;
  387. function pj_init(argc: cint; argv: ppchar): projPJ; cdecl; external;
  388. function pj_init_plus(args: pchar): projPJ; cdecl; external;
  389. function pj_get_def(proj: projPJ; i: cint): pchar; cdecl; external;
  390. function pj_latlong_from_proj(proj: projPJ): projPJ; cdecl; external;
  391. function pj_malloc(size: csize_t): pointer; cdecl; external;
  392. procedure pj_dalloc(ptr: pointer); cdecl; external;
  393. function pj_strerrno(err: cint): pchar; cdecl; external;
  394. function pj_get_errno_ref: pcint; cdecl; external;
  395. function pj_get_release: pchar; cdecl; external;
  396. (***************************************************************************)
  397. (* RSC IDENTIFIER: GEOCENTRIC
  398. *
  399. * ABSTRACT
  400. *
  401. * This component provides conversions between Geodetic coordinates (latitude,
  402. * longitude in radians and height in meters) and Geocentric coordinates
  403. * (X, Y, Z) in meters.
  404. *
  405. * ERROR HANDLING
  406. *
  407. * This component checks parameters for valid values. If an invalid value
  408. * is found, the error code is combined with the current error code using
  409. * the bitwise or. This combining allows multiple error codes to be
  410. * returned. The possible error codes are:
  411. *
  412. * GEOCENT_NO_ERROR : No errors occurred in function
  413. * GEOCENT_LAT_ERROR : Latitude out of valid range
  414. * (-90 to 90 degrees)
  415. * GEOCENT_LON_ERROR : Longitude out of valid range
  416. * (-180 to 360 degrees)
  417. * GEOCENT_A_ERROR : Semi-major axis less than or equal to zero
  418. * GEOCENT_B_ERROR : Semi-minor axis less than or equal to zero
  419. * GEOCENT_A_LESS_B_ERROR : Semi-major axis less than semi-minor axis
  420. *
  421. *
  422. * REUSE NOTES
  423. *
  424. * GEOCENTRIC is intended for reuse by any application that performs
  425. * coordinate conversions between geodetic coordinates and geocentric
  426. * coordinates.
  427. *
  428. *
  429. * REFERENCES
  430. *
  431. * An Improved Algorithm for Geocentric to Geodetic Coordinate Conversion,
  432. * Ralph Toms, February 1996 UCRL-JC-123138.
  433. *
  434. * Further information on GEOCENTRIC can be found in the Reuse Manual.
  435. *
  436. * GEOCENTRIC originated from : U.S. Army Topographic Engineering Center
  437. * Geospatial Information Division
  438. * 7701 Telegraph Road
  439. * Alexandria, VA 22310-3864
  440. *
  441. * LICENSES
  442. *
  443. * None apply to this component.
  444. *
  445. * RESTRICTIONS
  446. *
  447. * GEOCENTRIC has no restrictions.
  448. *
  449. * ENVIRONMENT
  450. *
  451. * GEOCENTRIC was tested and certified in the following environments:
  452. *
  453. * 1. Solaris 2.5 with GCC version 2.8.1
  454. * 2. Windows 95 with MS Visual C++ version 6
  455. *
  456. * MODIFICATIONS
  457. *
  458. * Date Description
  459. * ---- -----------
  460. *
  461. *
  462. *)
  463. (***************************************************************************)
  464. (*
  465. * DEFINES
  466. *)
  467. const
  468. GEOCENT_NO_ERROR = $0000;
  469. GEOCENT_LAT_ERROR = $0001;
  470. GEOCENT_LON_ERROR = $0002;
  471. GEOCENT_A_ERROR = $0004;
  472. GEOCENT_B_ERROR = $0008;
  473. GEOCENT_A_LESS_B_ERROR = $0010;
  474. (***************************************************************************)
  475. (*
  476. * FUNCTION PROTOTYPES
  477. *)
  478. type
  479. PGeocentricInfo = ^GeocentricInfo;
  480. GeocentricInfo = record
  481. Geocent_a : cdouble; (* Semi-major axis of ellipsoid in meters *)
  482. Geocent_b : cdouble; (* Semi-minor axis of ellipsoid *)
  483. Geocent_a2 : cdouble; (* Square of semi-major axis *)
  484. Geocent_b2 : cdouble; (* Square of semi-minor axis *)
  485. Geocent_e2 : cdouble; (* Eccentricity squared *)
  486. Geocent_ep2 : cdouble; (* 2nd eccentricity squared *)
  487. end;
  488. procedure pj_Init_Geocentric(var gi: GeocentricInfo); cdecl; external;
  489. function pj_Set_Geocentric_Parameters(var gi: GeocentricInfo; a, b: cdouble): clong; cdecl; external;
  490. (*
  491. * The function Set_Geocentric_Parameters receives the ellipsoid parameters
  492. * as inputs and sets the corresponding state variables.
  493. *
  494. * a : Semi-major axis, in meters. (input)
  495. * b : Semi-minor axis, in meters. (input)
  496. *)
  497. procedure pj_Get_Geocentric_Parameters(var gi: GeocentricInfo; var a, b: cdouble); cdecl; external;
  498. (*
  499. * The function Get_Geocentric_Parameters returns the ellipsoid parameters
  500. * to be used in geocentric coordinate conversions.
  501. *
  502. * a : Semi-major axis, in meters. (output)
  503. * b : Semi-minor axis, in meters. (output)
  504. *)
  505. function pj_Convert_Geodetic_To_Geocentric(var gi: GeocentricInfo; Latitude, Longitude, Height: cdouble;
  506. var X, Y, Z: cdouble): clong; cdecl; external;
  507. (*
  508. * The function Convert_Geodetic_To_Geocentric converts geodetic coordinates
  509. * (latitude, longitude, and height) to geocentric coordinates (X, Y, Z),
  510. * according to the current ellipsoid parameters.
  511. *
  512. * Latitude : Geodetic latitude in radians (input)
  513. * Longitude : Geodetic longitude in radians (input)
  514. * Height : Geodetic height, in meters (input)
  515. * X : Calculated Geocentric X coordinate, in meters. (output)
  516. * Y : Calculated Geocentric Y coordinate, in meters. (output)
  517. * Z : Calculated Geocentric Z coordinate, in meters. (output)
  518. *
  519. *)
  520. procedure pj_Convert_Geocentric_To_Geodetic(var gi: GeocentricInfo; X, Y, Z: cdouble;
  521. var Latitude, Longitude, Height: cdouble); cdecl; external;
  522. (*
  523. * The function Convert_Geocentric_To_Geodetic converts geocentric
  524. * coordinates (X, Y, Z) to geodetic coordinates (latitude, longitude,
  525. * and height), according to the current ellipsoid parameters.
  526. *
  527. * X : Geocentric X coordinate, in meters. (input)
  528. * Y : Geocentric Y coordinate, in meters. (input)
  529. * Z : Geocentric Z coordinate, in meters. (input)
  530. * Latitude : Calculated latitude value in radians. (output)
  531. * Longitude : Calculated longitude value in radians. (output)
  532. * Height : Calculated height value, in meters. (output)
  533. *)
  534. implementation
  535. end.