proj.pas 18 KB

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