Commit 89487e1f97006314b1422a91bbbc5b0dfa4dcee7

Authored by Edmar Moretti
1 parent 25fd30e1

Inclusão da biblioteca proj4php

Showing 66 changed files with 7253 additions and 3 deletions   Show diff stats
admin/js/estat_editor.js
... ... @@ -576,6 +576,7 @@ i3GEOadmin.editor = {
576 576 '<p class="paragrafo" >shp: <br><input type="file" size=22 name="i3GEOuploadshp" style="top:0px;left:0px;cursor:pointer;"></p>' +
577 577 '<p class="paragrafo" >shx: <br><input type="file" size=22 name="i3GEOuploadshx" style="top:0px;left:0px;cursor:pointer;"></p>' +
578 578 '<p class="paragrafo" >dbf: <br><input type="file" size=22 name="i3GEOuploaddbf" style="top:0px;left:0px;cursor:pointer;"></p>' +
  579 + '<p class="paragrafo" >prj (opcional): <br><input type="file" size=22 name="i3GEOuploadprj" style="top:0px;left:0px;cursor:pointer;"></p>' +
579 580 '</fieldset>' +
580 581 '<fieldset class=subbloco >' +
581 582 '<legend>Destino</legend>' +
... ...
admin/php/metaestat_uploadshp_submit.php
... ... @@ -51,17 +51,28 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){
51 51 $status = move_uploaded_file($Arquivo,$dir_tmp."/".$nomePrefixo.".shp");
52 52 if($status != 1)
53 53 {echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo SHP";exit;}
  54 +
54 55 $Arquivo = $_FILES['i3GEOuploadshx']['tmp_name'];
55 56 $status = move_uploaded_file($Arquivo,$dir_tmp."/".$nomePrefixo.".shx");
56 57 if($status != 1)
57 58 {echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo SHX";exit;}
  59 +
58 60 $Arquivo = $_FILES['i3GEOuploaddbf']['tmp_name'];
59 61 $status = move_uploaded_file($Arquivo,$dir_tmp."/".$nomePrefixo.".dbf");
60 62 if($status != 1)
61 63 {echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo DBF";exit;}
62   -
63   - if(!file_exists($dir_tmp."/".$nomePrefixo.".shp"))
64   - {echo "<p class='paragrafo' >Ocorreu algum problema no envio do arquivo ".$dir_tmp."/".$nomePrefixo;paraAguarde();exit;}
  64 +
  65 + if($_FILES['i3GEOuploadprj']['tmp_name'] != ""){
  66 + $Arquivo = $_FILES['i3GEOuploadprj']['tmp_name'];
  67 + $status = move_uploaded_file($Arquivo,$dir_tmp."/".$nomePrefixo.".prj");
  68 + if($status != 1){
  69 + echo "<p class='paragrafo' >Ocorreu um erro no envio do arquivo PRJ";exit;
  70 + }
  71 + }
  72 + if(!file_exists($dir_tmp."/".$nomePrefixo.".shp")){
  73 + echo "<p class='paragrafo' >Ocorreu algum problema no envio do arquivo ".$dir_tmp."/".$nomePrefixo;paraAguarde();
  74 + exit;
  75 + }
65 76 $arqshp = $dir_tmp."/".$nomePrefixo.".shp";
66 77  
67 78 //pega os parametros de conexao
... ... @@ -75,6 +86,9 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){
75 86 $mapObj = ms_newMapObjFromString("MAP END");
76 87 $layer = ms_newLayerObj($mapObj);
77 88 $layer->set("data",$arqshp);
  89 + if(file_exists($dir_tmp."/".$nomePrefixo.".prj")){
  90 + $layer->setprojection("AUTO");
  91 + }
78 92 $layer->open();
79 93 $colunasTemp = $layer->getItems();
80 94 $colunas = array();
... ... @@ -190,8 +204,25 @@ if (isset($_FILES[&#39;i3GEOuploadshp&#39;][&#39;name&#39;])){
190 204 sleep(1);
191 205 $srid = 4326;
192 206 $escapar = "'";
  207 + $prjMapa = $mapObj->getProjection();
  208 + $prjTema = $layer->getProjection();
  209 + if (($prjTema != "") && ($prjMapa != $prjTema))
  210 + {
  211 + $projInObj = ms_newprojectionobj($prjTema);
  212 + $projOutObj = ms_newprojectionobj($prjMapa);
  213 + }
  214 + else{
  215 + $projOutObj = "";
  216 + $projInObj = "";
  217 + }
193 218 for ($i=0; $i<$numshapes;$i++){
194 219 $s = $layer->getShape(new resultObj($i));
  220 + //projeta o shape se existir .prj
  221 + if($_FILES['i3GEOuploadprj']['tmp_name'] != "" && $projInObj != ""){
  222 + $s->project($projInObj, $projOutObj);
  223 + //para nao projetar com postgis
  224 + $_POST["insrid"] = $_POST["outsrid"];
  225 + }
195 226 $vs = array();
196 227  
197 228 foreach($colunas as $coluna){
... ...
aplicmap/dados/utm21.prj 0 → 100644
... ... @@ -0,0 +1 @@
  1 +PROJCS["SAD69 / UTM zone 21S (deprecated)",GEOGCS["SAD69",DATUM["D_South_American_1969",SPHEROID["GRS_1967",6378160,298.247167427]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-57],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",10000000],UNIT["Meter",1]]
... ...
pacotes/proj4php-proj4php5.2/LICENSE 0 → 100644
... ... @@ -0,0 +1,505 @@
  1 + GNU LESSER GENERAL PUBLIC LICENSE
  2 + Version 2.1, February 1999
  3 +
  4 + Copyright (C) 1991, 1999 Free Software Foundation, Inc.
  5 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  6 + Everyone is permitted to copy and distribute verbatim copies
  7 + of this license document, but changing it is not allowed.
  8 +
  9 +(This is the first released version of the Lesser GPL. It also counts
  10 + as the successor of the GNU Library Public License, version 2, hence
  11 + the version number 2.1.)
  12 +
  13 + Preamble
  14 +
  15 + The licenses for most software are designed to take away your
  16 +freedom to share and change it. By contrast, the GNU General Public
  17 +Licenses are intended to guarantee your freedom to share and change
  18 +free software--to make sure the software is free for all its users.
  19 +
  20 + This license, the Lesser General Public License, applies to some
  21 +specially designated software packages--typically libraries--of the
  22 +Free Software Foundation and other authors who decide to use it. You
  23 +can use it too, but we suggest you first think carefully about whether
  24 +this license or the ordinary General Public License is the better
  25 +strategy to use in any particular case, based on the explanations below.
  26 +
  27 + When we speak of free software, we are referring to freedom of use,
  28 +not price. Our General Public Licenses are designed to make sure that
  29 +you have the freedom to distribute copies of free software (and charge
  30 +for this service if you wish); that you receive source code or can get
  31 +it if you want it; that you can change the software and use pieces of
  32 +it in new free programs; and that you are informed that you can do
  33 +these things.
  34 +
  35 + To protect your rights, we need to make restrictions that forbid
  36 +distributors to deny you these rights or to ask you to surrender these
  37 +rights. These restrictions translate to certain responsibilities for
  38 +you if you distribute copies of the library or if you modify it.
  39 +
  40 + For example, if you distribute copies of the library, whether gratis
  41 +or for a fee, you must give the recipients all the rights that we gave
  42 +you. You must make sure that they, too, receive or can get the source
  43 +code. If you link other code with the library, you must provide
  44 +complete object files to the recipients, so that they can relink them
  45 +with the library after making changes to the library and recompiling
  46 +it. And you must show them these terms so they know their rights.
  47 +
  48 + We protect your rights with a two-step method: (1) we copyright the
  49 +library, and (2) we offer you this license, which gives you legal
  50 +permission to copy, distribute and/or modify the library.
  51 +
  52 + To protect each distributor, we want to make it very clear that
  53 +there is no warranty for the free library. Also, if the library is
  54 +modified by someone else and passed on, the recipients should know
  55 +that what they have is not the original version, so that the original
  56 +author's reputation will not be affected by problems that might be
  57 +introduced by others.
  58 +
  59 + Finally, software patents pose a constant threat to the existence of
  60 +any free program. We wish to make sure that a company cannot
  61 +effectively restrict the users of a free program by obtaining a
  62 +restrictive license from a patent holder. Therefore, we insist that
  63 +any patent license obtained for a version of the library must be
  64 +consistent with the full freedom of use specified in this license.
  65 +
  66 + Most GNU software, including some libraries, is covered by the
  67 +ordinary GNU General Public License. This license, the GNU Lesser
  68 +General Public License, applies to certain designated libraries, and
  69 +is quite different from the ordinary General Public License. We use
  70 +this license for certain libraries in order to permit linking those
  71 +libraries into non-free programs.
  72 +
  73 + When a program is linked with a library, whether statically or using
  74 +a shared library, the combination of the two is legally speaking a
  75 +combined work, a derivative of the original library. The ordinary
  76 +General Public License therefore permits such linking only if the
  77 +entire combination fits its criteria of freedom. The Lesser General
  78 +Public License permits more lax criteria for linking other code with
  79 +the library.
  80 +
  81 + We call this license the "Lesser" General Public License because it
  82 +does Less to protect the user's freedom than the ordinary General
  83 +Public License. It also provides other free software developers Less
  84 +of an advantage over competing non-free programs. These disadvantages
  85 +are the reason we use the ordinary General Public License for many
  86 +libraries. However, the Lesser license provides advantages in certain
  87 +special circumstances.
  88 +
  89 + For example, on rare occasions, there may be a special need to
  90 +encourage the widest possible use of a certain library, so that it becomes
  91 +a de-facto standard. To achieve this, non-free programs must be
  92 +allowed to use the library. A more frequent case is that a free
  93 +library does the same job as widely used non-free libraries. In this
  94 +case, there is little to gain by limiting the free library to free
  95 +software only, so we use the Lesser General Public License.
  96 +
  97 + In other cases, permission to use a particular library in non-free
  98 +programs enables a greater number of people to use a large body of
  99 +free software. For example, permission to use the GNU C Library in
  100 +non-free programs enables many more people to use the whole GNU
  101 +operating system, as well as its variant, the GNU/Linux operating
  102 +system.
  103 +
  104 + Although the Lesser General Public License is Less protective of the
  105 +users' freedom, it does ensure that the user of a program that is
  106 +linked with the Library has the freedom and the wherewithal to run
  107 +that program using a modified version of the Library.
  108 +
  109 + The precise terms and conditions for copying, distribution and
  110 +modification follow. Pay close attention to the difference between a
  111 +"work based on the library" and a "work that uses the library". The
  112 +former contains code derived from the library, whereas the latter must
  113 +be combined with the library in order to run.
  114 +
  115 + GNU LESSER GENERAL PUBLIC LICENSE
  116 + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  117 +
  118 + 0. This License Agreement applies to any software library or other
  119 +program which contains a notice placed by the copyright holder or
  120 +other authorized party saying it may be distributed under the terms of
  121 +this Lesser General Public License (also called "this License").
  122 +Each licensee is addressed as "you".
  123 +
  124 + A "library" means a collection of software functions and/or data
  125 +prepared so as to be conveniently linked with application programs
  126 +(which use some of those functions and data) to form executables.
  127 +
  128 + The "Library", below, refers to any such software library or work
  129 +which has been distributed under these terms. A "work based on the
  130 +Library" means either the Library or any derivative work under
  131 +copyright law: that is to say, a work containing the Library or a
  132 +portion of it, either verbatim or with modifications and/or translated
  133 +straightforwardly into another language. (Hereinafter, translation is
  134 +included without limitation in the term "modification".)
  135 +
  136 + "Source code" for a work means the preferred form of the work for
  137 +making modifications to it. For a library, complete source code means
  138 +all the source code for all modules it contains, plus any associated
  139 +interface definition files, plus the scripts used to control compilation
  140 +and installation of the library.
  141 +
  142 + Activities other than copying, distribution and modification are not
  143 +covered by this License; they are outside its scope. The act of
  144 +running a program using the Library is not restricted, and output from
  145 +such a program is covered only if its contents constitute a work based
  146 +on the Library (independent of the use of the Library in a tool for
  147 +writing it). Whether that is true depends on what the Library does
  148 +and what the program that uses the Library does.
  149 +
  150 + 1. You may copy and distribute verbatim copies of the Library's
  151 +complete source code as you receive it, in any medium, provided that
  152 +you conspicuously and appropriately publish on each copy an
  153 +appropriate copyright notice and disclaimer of warranty; keep intact
  154 +all the notices that refer to this License and to the absence of any
  155 +warranty; and distribute a copy of this License along with the
  156 +Library.
  157 +
  158 + You may charge a fee for the physical act of transferring a copy,
  159 +and you may at your option offer warranty protection in exchange for a
  160 +fee.
  161 +
  162 + 2. You may modify your copy or copies of the Library or any portion
  163 +of it, thus forming a work based on the Library, and copy and
  164 +distribute such modifications or work under the terms of Section 1
  165 +above, provided that you also meet all of these conditions:
  166 +
  167 + a) The modified work must itself be a software library.
  168 +
  169 + b) You must cause the files modified to carry prominent notices
  170 + stating that you changed the files and the date of any change.
  171 +
  172 + c) You must cause the whole of the work to be licensed at no
  173 + charge to all third parties under the terms of this License.
  174 +
  175 + d) If a facility in the modified Library refers to a function or a
  176 + table of data to be supplied by an application program that uses
  177 + the facility, other than as an argument passed when the facility
  178 + is invoked, then you must make a good faith effort to ensure that,
  179 + in the event an application does not supply such function or
  180 + table, the facility still operates, and performs whatever part of
  181 + its purpose remains meaningful.
  182 +
  183 + (For example, a function in a library to compute square roots has
  184 + a purpose that is entirely well-defined independent of the
  185 + application. Therefore, Subsection 2d requires that any
  186 + application-supplied function or table used by this function must
  187 + be optional: if the application does not supply it, the square
  188 + root function must still compute square roots.)
  189 +
  190 +These requirements apply to the modified work as a whole. If
  191 +identifiable sections of that work are not derived from the Library,
  192 +and can be reasonably considered independent and separate works in
  193 +themselves, then this License, and its terms, do not apply to those
  194 +sections when you distribute them as separate works. But when you
  195 +distribute the same sections as part of a whole which is a work based
  196 +on the Library, the distribution of the whole must be on the terms of
  197 +this License, whose permissions for other licensees extend to the
  198 +entire whole, and thus to each and every part regardless of who wrote
  199 +it.
  200 +
  201 +Thus, it is not the intent of this section to claim rights or contest
  202 +your rights to work written entirely by you; rather, the intent is to
  203 +exercise the right to control the distribution of derivative or
  204 +collective works based on the Library.
  205 +
  206 +In addition, mere aggregation of another work not based on the Library
  207 +with the Library (or with a work based on the Library) on a volume of
  208 +a storage or distribution medium does not bring the other work under
  209 +the scope of this License.
  210 +
  211 + 3. You may opt to apply the terms of the ordinary GNU General Public
  212 +License instead of this License to a given copy of the Library. To do
  213 +this, you must alter all the notices that refer to this License, so
  214 +that they refer to the ordinary GNU General Public License, version 2,
  215 +instead of to this License. (If a newer version than version 2 of the
  216 +ordinary GNU General Public License has appeared, then you can specify
  217 +that version instead if you wish.) Do not make any other change in
  218 +these notices.
  219 +
  220 + Once this change is made in a given copy, it is irreversible for
  221 +that copy, so the ordinary GNU General Public License applies to all
  222 +subsequent copies and derivative works made from that copy.
  223 +
  224 + This option is useful when you wish to copy part of the code of
  225 +the Library into a program that is not a library.
  226 +
  227 + 4. You may copy and distribute the Library (or a portion or
  228 +derivative of it, under Section 2) in object code or executable form
  229 +under the terms of Sections 1 and 2 above provided that you accompany
  230 +it with the complete corresponding machine-readable source code, which
  231 +must be distributed under the terms of Sections 1 and 2 above on a
  232 +medium customarily used for software interchange.
  233 +
  234 + If distribution of object code is made by offering access to copy
  235 +from a designated place, then offering equivalent access to copy the
  236 +source code from the same place satisfies the requirement to
  237 +distribute the source code, even though third parties are not
  238 +compelled to copy the source along with the object code.
  239 +
  240 + 5. A program that contains no derivative of any portion of the
  241 +Library, but is designed to work with the Library by being compiled or
  242 +linked with it, is called a "work that uses the Library". Such a
  243 +work, in isolation, is not a derivative work of the Library, and
  244 +therefore falls outside the scope of this License.
  245 +
  246 + However, linking a "work that uses the Library" with the Library
  247 +creates an executable that is a derivative of the Library (because it
  248 +contains portions of the Library), rather than a "work that uses the
  249 +library". The executable is therefore covered by this License.
  250 +Section 6 states terms for distribution of such executables.
  251 +
  252 + When a "work that uses the Library" uses material from a header file
  253 +that is part of the Library, the object code for the work may be a
  254 +derivative work of the Library even though the source code is not.
  255 +Whether this is true is especially significant if the work can be
  256 +linked without the Library, or if the work is itself a library. The
  257 +threshold for this to be true is not precisely defined by law.
  258 +
  259 + If such an object file uses only numerical parameters, data
  260 +structure layouts and accessors, and small macros and small inline
  261 +functions (ten lines or less in length), then the use of the object
  262 +file is unrestricted, regardless of whether it is legally a derivative
  263 +work. (Executables containing this object code plus portions of the
  264 +Library will still fall under Section 6.)
  265 +
  266 + Otherwise, if the work is a derivative of the Library, you may
  267 +distribute the object code for the work under the terms of Section 6.
  268 +Any executables containing that work also fall under Section 6,
  269 +whether or not they are linked directly with the Library itself.
  270 +
  271 + 6. As an exception to the Sections above, you may also combine or
  272 +link a "work that uses the Library" with the Library to produce a
  273 +work containing portions of the Library, and distribute that work
  274 +under terms of your choice, provided that the terms permit
  275 +modification of the work for the customer's own use and reverse
  276 +engineering for debugging such modifications.
  277 +
  278 + You must give prominent notice with each copy of the work that the
  279 +Library is used in it and that the Library and its use are covered by
  280 +this License. You must supply a copy of this License. If the work
  281 +during execution displays copyright notices, you must include the
  282 +copyright notice for the Library among them, as well as a reference
  283 +directing the user to the copy of this License. Also, you must do one
  284 +of these things:
  285 +
  286 + a) Accompany the work with the complete corresponding
  287 + machine-readable source code for the Library including whatever
  288 + changes were used in the work (which must be distributed under
  289 + Sections 1 and 2 above); and, if the work is an executable linked
  290 + with the Library, with the complete machine-readable "work that
  291 + uses the Library", as object code and/or source code, so that the
  292 + user can modify the Library and then relink to produce a modified
  293 + executable containing the modified Library. (It is understood
  294 + that the user who changes the contents of definitions files in the
  295 + Library will not necessarily be able to recompile the application
  296 + to use the modified definitions.)
  297 +
  298 + b) Use a suitable shared library mechanism for linking with the
  299 + Library. A suitable mechanism is one that (1) uses at run time a
  300 + copy of the library already present on the user's computer system,
  301 + rather than copying library functions into the executable, and (2)
  302 + will operate properly with a modified version of the library, if
  303 + the user installs one, as long as the modified version is
  304 + interface-compatible with the version that the work was made with.
  305 +
  306 + c) Accompany the work with a written offer, valid for at
  307 + least three years, to give the same user the materials
  308 + specified in Subsection 6a, above, for a charge no more
  309 + than the cost of performing this distribution.
  310 +
  311 + d) If distribution of the work is made by offering access to copy
  312 + from a designated place, offer equivalent access to copy the above
  313 + specified materials from the same place.
  314 +
  315 + e) Verify that the user has already received a copy of these
  316 + materials or that you have already sent this user a copy.
  317 +
  318 + For an executable, the required form of the "work that uses the
  319 +Library" must include any data and utility programs needed for
  320 +reproducing the executable from it. However, as a special exception,
  321 +the materials to be distributed need not include anything that is
  322 +normally distributed (in either source or binary form) with the major
  323 +components (compiler, kernel, and so on) of the operating system on
  324 +which the executable runs, unless that component itself accompanies
  325 +the executable.
  326 +
  327 + It may happen that this requirement contradicts the license
  328 +restrictions of other proprietary libraries that do not normally
  329 +accompany the operating system. Such a contradiction means you cannot
  330 +use both them and the Library together in an executable that you
  331 +distribute.
  332 +
  333 + 7. You may place library facilities that are a work based on the
  334 +Library side-by-side in a single library together with other library
  335 +facilities not covered by this License, and distribute such a combined
  336 +library, provided that the separate distribution of the work based on
  337 +the Library and of the other library facilities is otherwise
  338 +permitted, and provided that you do these two things:
  339 +
  340 + a) Accompany the combined library with a copy of the same work
  341 + based on the Library, uncombined with any other library
  342 + facilities. This must be distributed under the terms of the
  343 + Sections above.
  344 +
  345 + b) Give prominent notice with the combined library of the fact
  346 + that part of it is a work based on the Library, and explaining
  347 + where to find the accompanying uncombined form of the same work.
  348 +
  349 + 8. You may not copy, modify, sublicense, link with, or distribute
  350 +the Library except as expressly provided under this License. Any
  351 +attempt otherwise to copy, modify, sublicense, link with, or
  352 +distribute the Library is void, and will automatically terminate your
  353 +rights under this License. However, parties who have received copies,
  354 +or rights, from you under this License will not have their licenses
  355 +terminated so long as such parties remain in full compliance.
  356 +
  357 + 9. You are not required to accept this License, since you have not
  358 +signed it. However, nothing else grants you permission to modify or
  359 +distribute the Library or its derivative works. These actions are
  360 +prohibited by law if you do not accept this License. Therefore, by
  361 +modifying or distributing the Library (or any work based on the
  362 +Library), you indicate your acceptance of this License to do so, and
  363 +all its terms and conditions for copying, distributing or modifying
  364 +the Library or works based on it.
  365 +
  366 + 10. Each time you redistribute the Library (or any work based on the
  367 +Library), the recipient automatically receives a license from the
  368 +original licensor to copy, distribute, link with or modify the Library
  369 +subject to these terms and conditions. You may not impose any further
  370 +restrictions on the recipients' exercise of the rights granted herein.
  371 +You are not responsible for enforcing compliance by third parties with
  372 +this License.
  373 +
  374 + 11. If, as a consequence of a court judgment or allegation of patent
  375 +infringement or for any other reason (not limited to patent issues),
  376 +conditions are imposed on you (whether by court order, agreement or
  377 +otherwise) that contradict the conditions of this License, they do not
  378 +excuse you from the conditions of this License. If you cannot
  379 +distribute so as to satisfy simultaneously your obligations under this
  380 +License and any other pertinent obligations, then as a consequence you
  381 +may not distribute the Library at all. For example, if a patent
  382 +license would not permit royalty-free redistribution of the Library by
  383 +all those who receive copies directly or indirectly through you, then
  384 +the only way you could satisfy both it and this License would be to
  385 +refrain entirely from distribution of the Library.
  386 +
  387 +If any portion of this section is held invalid or unenforceable under any
  388 +particular circumstance, the balance of the section is intended to apply,
  389 +and the section as a whole is intended to apply in other circumstances.
  390 +
  391 +It is not the purpose of this section to induce you to infringe any
  392 +patents or other property right claims or to contest validity of any
  393 +such claims; this section has the sole purpose of protecting the
  394 +integrity of the free software distribution system which is
  395 +implemented by public license practices. Many people have made
  396 +generous contributions to the wide range of software distributed
  397 +through that system in reliance on consistent application of that
  398 +system; it is up to the author/donor to decide if he or she is willing
  399 +to distribute software through any other system and a licensee cannot
  400 +impose that choice.
  401 +
  402 +This section is intended to make thoroughly clear what is believed to
  403 +be a consequence of the rest of this License.
  404 +
  405 + 12. If the distribution and/or use of the Library is restricted in
  406 +certain countries either by patents or by copyrighted interfaces, the
  407 +original copyright holder who places the Library under this License may add
  408 +an explicit geographical distribution limitation excluding those countries,
  409 +so that distribution is permitted only in or among countries not thus
  410 +excluded. In such case, this License incorporates the limitation as if
  411 +written in the body of this License.
  412 +
  413 + 13. The Free Software Foundation may publish revised and/or new
  414 +versions of the Lesser General Public License from time to time.
  415 +Such new versions will be similar in spirit to the present version,
  416 +but may differ in detail to address new problems or concerns.
  417 +
  418 +Each version is given a distinguishing version number. If the Library
  419 +specifies a version number of this License which applies to it and
  420 +"any later version", you have the option of following the terms and
  421 +conditions either of that version or of any later version published by
  422 +the Free Software Foundation. If the Library does not specify a
  423 +license version number, you may choose any version ever published by
  424 +the Free Software Foundation.
  425 +
  426 + 14. If you wish to incorporate parts of the Library into other free
  427 +programs whose distribution conditions are incompatible with these,
  428 +write to the author to ask for permission. For software which is
  429 +copyrighted by the Free Software Foundation, write to the Free
  430 +Software Foundation; we sometimes make exceptions for this. Our
  431 +decision will be guided by the two goals of preserving the free status
  432 +of all derivatives of our free software and of promoting the sharing
  433 +and reuse of software generally.
  434 +
  435 + NO WARRANTY
  436 +
  437 + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
  438 +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
  439 +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
  440 +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
  441 +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
  442 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  443 +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
  444 +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
  445 +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
  446 +
  447 + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
  448 +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
  449 +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
  450 +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
  451 +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
  452 +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
  453 +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
  454 +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
  455 +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  456 +DAMAGES.
  457 +
  458 + END OF TERMS AND CONDITIONS
  459 +
  460 + How to Apply These Terms to Your New Libraries
  461 +
  462 + If you develop a new library, and you want it to be of the greatest
  463 +possible use to the public, we recommend making it free software that
  464 +everyone can redistribute and change. You can do so by permitting
  465 +redistribution under these terms (or, alternatively, under the terms of the
  466 +ordinary General Public License).
  467 +
  468 + To apply these terms, attach the following notices to the library. It is
  469 +safest to attach them to the start of each source file to most effectively
  470 +convey the exclusion of warranty; and each file should have at least the
  471 +"copyright" line and a pointer to where the full notice is found.
  472 +
  473 + {description}
  474 + Copyright (C) {year} {fullname}
  475 +
  476 + This library is free software; you can redistribute it and/or
  477 + modify it under the terms of the GNU Lesser General Public
  478 + License as published by the Free Software Foundation; either
  479 + version 2.1 of the License, or (at your option) any later version.
  480 +
  481 + This library is distributed in the hope that it will be useful,
  482 + but WITHOUT ANY WARRANTY; without even the implied warranty of
  483 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  484 + Lesser General Public License for more details.
  485 +
  486 + You should have received a copy of the GNU Lesser General Public
  487 + License along with this library; if not, write to the Free Software
  488 + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
  489 + USA
  490 +
  491 +Also add information on how to contact you by electronic and paper mail.
  492 +
  493 +You should also get your employer (if you work as a programmer) or your
  494 +school, if any, to sign a "copyright disclaimer" for the library, if
  495 +necessary. Here is a sample; alter the names:
  496 +
  497 + Yoyodyne, Inc., hereby disclaims all copyright interest in the
  498 + library `Frob' (a library for tweaking knobs) written by James Random
  499 + Hacker.
  500 +
  501 + {signature of Ty Coon}, 1 April 1990
  502 + Ty Coon, President of Vice
  503 +
  504 +That's all there is to it!
  505 +
... ...
pacotes/proj4php-proj4php5.2/README.md 0 → 100644
... ... @@ -0,0 +1,25 @@
  1 +# proj4php
  2 +PHP-class for proj4
  3 +This is a PHP-Class for geographic coordinates transformation using proj4 definitions, thanks to a translation from Proj4JS.
  4 +
  5 +## Using
  6 +
  7 +```php
  8 +include("proj4php");
  9 +
  10 +$proj4 = new Proj4php();
  11 +$projL93 = new Proj4phpProj('EPSG:2154',$proj4);
  12 +$projWGS84 = new Proj4phpProj('EPSG:4326',$proj4);
  13 +
  14 +$pointSrc = new proj4phpPoint('652709.401','6859290.946');
  15 +$pointDest = $proj4->transform($projL93,$projWGS84,$pointSrc);
  16 +
  17 +echo "Source : ".$pointSrc->toShortString()." in L93 <br>";
  18 +echo "Conversion : ".$pointDest->toShortString()." in WGS84<br><br>";
  19 +```
  20 +
  21 +There's is also way to define inline projections.
  22 +
  23 +## Developping
  24 +
  25 +Fill free to fork us and submit your changes !
... ...
pacotes/proj4php-proj4php5.2/composer.json 0 → 100644
... ... @@ -0,0 +1,35 @@
  1 +{
  2 + "name": "proj4php/proj4php",
  3 + "license": "LGPL-2.1",
  4 + "type": "library",
  5 + "description": "A PHP-Class for geographic coordinates transformation using proj4 definitions, thanks to a translation from Proj4JS",
  6 + "keywords": [
  7 + "geographic",
  8 + "coordinates",
  9 + "proj4",
  10 + "proj4js"
  11 + ],
  12 + "homepage": "https://github.com/proj4php/proj4php",
  13 + "authors": [
  14 + {
  15 + "name": "julien2512",
  16 + "email": "moquet.julien@gmail.com",
  17 + "homepage": "https://github.com/julien2512",
  18 + "role": "Developer"
  19 + },
  20 + {
  21 + "name": "winne27",
  22 + "homepage": "http://github.com/winne27",
  23 + "role": "Developer"
  24 + }
  25 + ],
  26 + "require": {
  27 + "php": ">=5.2.0"
  28 + },
  29 + "require-dev": {
  30 + "phpunit/phpunit": "4.0.*"
  31 + },
  32 + "autoload": {
  33 + "classmap": ["src/"]
  34 + }
  35 +}
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/LGPL GNU lesser licence.txt 0 → 100644
... ... @@ -0,0 +1,165 @@
  1 + GNU LESSER GENERAL PUBLIC LICENSE
  2 + Version 3, 29 June 2007
  3 +
  4 + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
  5 + Everyone is permitted to copy and distribute verbatim copies
  6 + of this license document, but changing it is not allowed.
  7 +
  8 +
  9 + This version of the GNU Lesser General Public License incorporates
  10 +the terms and conditions of version 3 of the GNU General Public
  11 +License, supplemented by the additional permissions listed below.
  12 +
  13 + 0. Additional Definitions.
  14 +
  15 + As used herein, "this License" refers to version 3 of the GNU Lesser
  16 +General Public License, and the "GNU GPL" refers to version 3 of the GNU
  17 +General Public License.
  18 +
  19 + "The Library" refers to a covered work governed by this License,
  20 +other than an Application or a Combined Work as defined below.
  21 +
  22 + An "Application" is any work that makes use of an interface provided
  23 +by the Library, but which is not otherwise based on the Library.
  24 +Defining a subclass of a class defined by the Library is deemed a mode
  25 +of using an interface provided by the Library.
  26 +
  27 + A "Combined Work" is a work produced by combining or linking an
  28 +Application with the Library. The particular version of the Library
  29 +with which the Combined Work was made is also called the "Linked
  30 +Version".
  31 +
  32 + The "Minimal Corresponding Source" for a Combined Work means the
  33 +Corresponding Source for the Combined Work, excluding any source code
  34 +for portions of the Combined Work that, considered in isolation, are
  35 +based on the Application, and not on the Linked Version.
  36 +
  37 + The "Corresponding Application Code" for a Combined Work means the
  38 +object code and/or source code for the Application, including any data
  39 +and utility programs needed for reproducing the Combined Work from the
  40 +Application, but excluding the System Libraries of the Combined Work.
  41 +
  42 + 1. Exception to Section 3 of the GNU GPL.
  43 +
  44 + You may convey a covered work under sections 3 and 4 of this License
  45 +without being bound by section 3 of the GNU GPL.
  46 +
  47 + 2. Conveying Modified Versions.
  48 +
  49 + If you modify a copy of the Library, and, in your modifications, a
  50 +facility refers to a function or data to be supplied by an Application
  51 +that uses the facility (other than as an argument passed when the
  52 +facility is invoked), then you may convey a copy of the modified
  53 +version:
  54 +
  55 + a) under this License, provided that you make a good faith effort to
  56 + ensure that, in the event an Application does not supply the
  57 + function or data, the facility still operates, and performs
  58 + whatever part of its purpose remains meaningful, or
  59 +
  60 + b) under the GNU GPL, with none of the additional permissions of
  61 + this License applicable to that copy.
  62 +
  63 + 3. Object Code Incorporating Material from Library Header Files.
  64 +
  65 + The object code form of an Application may incorporate material from
  66 +a header file that is part of the Library. You may convey such object
  67 +code under terms of your choice, provided that, if the incorporated
  68 +material is not limited to numerical parameters, data structure
  69 +layouts and accessors, or small macros, inline functions and templates
  70 +(ten or fewer lines in length), you do both of the following:
  71 +
  72 + a) Give prominent notice with each copy of the object code that the
  73 + Library is used in it and that the Library and its use are
  74 + covered by this License.
  75 +
  76 + b) Accompany the object code with a copy of the GNU GPL and this license
  77 + document.
  78 +
  79 + 4. Combined Works.
  80 +
  81 + You may convey a Combined Work under terms of your choice that,
  82 +taken together, effectively do not restrict modification of the
  83 +portions of the Library contained in the Combined Work and reverse
  84 +engineering for debugging such modifications, if you also do each of
  85 +the following:
  86 +
  87 + a) Give prominent notice with each copy of the Combined Work that
  88 + the Library is used in it and that the Library and its use are
  89 + covered by this License.
  90 +
  91 + b) Accompany the Combined Work with a copy of the GNU GPL and this license
  92 + document.
  93 +
  94 + c) For a Combined Work that displays copyright notices during
  95 + execution, include the copyright notice for the Library among
  96 + these notices, as well as a reference directing the user to the
  97 + copies of the GNU GPL and this license document.
  98 +
  99 + d) Do one of the following:
  100 +
  101 + 0) Convey the Minimal Corresponding Source under the terms of this
  102 + License, and the Corresponding Application Code in a form
  103 + suitable for, and under terms that permit, the user to
  104 + recombine or relink the Application with a modified version of
  105 + the Linked Version to produce a modified Combined Work, in the
  106 + manner specified by section 6 of the GNU GPL for conveying
  107 + Corresponding Source.
  108 +
  109 + 1) Use a suitable shared library mechanism for linking with the
  110 + Library. A suitable mechanism is one that (a) uses at run time
  111 + a copy of the Library already present on the user's computer
  112 + system, and (b) will operate properly with a modified version
  113 + of the Library that is interface-compatible with the Linked
  114 + Version.
  115 +
  116 + e) Provide Installation Information, but only if you would otherwise
  117 + be required to provide such information under section 6 of the
  118 + GNU GPL, and only to the extent that such information is
  119 + necessary to install and execute a modified version of the
  120 + Combined Work produced by recombining or relinking the
  121 + Application with a modified version of the Linked Version. (If
  122 + you use option 4d0, the Installation Information must accompany
  123 + the Minimal Corresponding Source and Corresponding Application
  124 + Code. If you use option 4d1, you must provide the Installation
  125 + Information in the manner specified by section 6 of the GNU GPL
  126 + for conveying Corresponding Source.)
  127 +
  128 + 5. Combined Libraries.
  129 +
  130 + You may place library facilities that are a work based on the
  131 +Library side by side in a single library together with other library
  132 +facilities that are not Applications and are not covered by this
  133 +License, and convey such a combined library under terms of your
  134 +choice, if you do both of the following:
  135 +
  136 + a) Accompany the combined library with a copy of the same work based
  137 + on the Library, uncombined with any other library facilities,
  138 + conveyed under the terms of this License.
  139 +
  140 + b) Give prominent notice with the combined library that part of it
  141 + is a work based on the Library, and explaining where to find the
  142 + accompanying uncombined form of the same work.
  143 +
  144 + 6. Revised Versions of the GNU Lesser General Public License.
  145 +
  146 + The Free Software Foundation may publish revised and/or new versions
  147 +of the GNU Lesser General Public License from time to time. Such new
  148 +versions will be similar in spirit to the present version, but may
  149 +differ in detail to address new problems or concerns.
  150 +
  151 + Each version is given a distinguishing version number. If the
  152 +Library as you received it specifies that a certain numbered version
  153 +of the GNU Lesser General Public License "or any later version"
  154 +applies to it, you have the option of following the terms and
  155 +conditions either of that published version or of any later version
  156 +published by the Free Software Foundation. If the Library as you
  157 +received it does not specify a version number of the GNU Lesser
  158 +General Public License, you may choose any version of the GNU Lesser
  159 +General Public License ever published by the Free Software Foundation.
  160 +
  161 + If the Library as you received it specifies that a proxy can decide
  162 +whether future versions of the GNU Lesser General Public License shall
  163 +apply, that proxy's public statement of acceptance of any version is
  164 +permanent authorization for you to choose that version for the
  165 +Library.
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/WSProj4PHP_1.0.php 0 → 100644
... ... @@ -0,0 +1,104 @@
  1 +<?php
  2 +
  3 +include_once("proj4php.php");
  4 +
  5 +$error = false;
  6 +
  7 +/**
  8 + * Geometry-Points
  9 + */
  10 +if( isset( $_GET['GEOM'] ) ) {
  11 + list($x, $y) = explode( ' ', $_GET['GEOM'] );
  12 +} else {
  13 + if( isset( $_GET['x'] ) ) {
  14 + $x = $_GET['x'];
  15 + }
  16 + else
  17 + $error = true;
  18 +
  19 + if( isset( $_GET['y'] ) ) {
  20 + $y = $_GET['y'];
  21 + }
  22 + else
  23 + $error = true;
  24 +}
  25 +
  26 +/**
  27 + * Source-CRS
  28 + */
  29 +if( isset( $_GET['SOURCECRS'] ) ) {
  30 + $srcProjection = str_replace( '::', ':', $_GET['SOURCECRS'] );
  31 +} else if( isset( $_GET['projectionxy'] ) ) {
  32 + $srcProjection = $_GET['projectionxy'];
  33 + $srcProjection = str_replace( '::', ':', $srcProjection );
  34 +}
  35 +else
  36 + $srcProjection = 'EPSG:2154';
  37 +
  38 +/**
  39 + * Target-CRS
  40 + */
  41 +if( isset( $_GET['TARGETCRS'] ) ) {
  42 + $tgtProjection = str_replace( '::', ':', $_GET['TARGETCRS'] );
  43 +} else if( isset( $_GET['projection'] ) ) {
  44 + $tgtProjection = $_GET['projection'];
  45 + $tgtProjection = str_replace( '::', ':', $tgtProjection );
  46 +}
  47 +else
  48 + $tgtProjection = 'EPSG:4326';
  49 +
  50 +/**
  51 + * Format
  52 + */
  53 +if( isset( $_GET['format'] ) ) {
  54 + $format = $_GET['format'];
  55 + if( !($format == 'xml' || $format == 'json') )
  56 + $error = true;
  57 +}
  58 +else
  59 + $format = 'xml';
  60 +
  61 +
  62 +$proj4 = new Proj4php();
  63 +$projsource = new Proj4phpProj( $srcProjection, $proj4 );
  64 +$projdest = new Proj4phpProj( $tgtProjection, $proj4 );
  65 +
  66 +// check the projections
  67 +if( Proj4php::$defs[$srcProjection] == Proj4php::$defs['WGS84'] && $srcProjection != 'EPSG:4326' )
  68 + $error = true;
  69 +if( Proj4php::$defs[$tgtProjection] == Proj4php::$defs['WGS84'] && $tgtProjection != 'EPSG:4326' )
  70 + $error = true;
  71 +
  72 +if( $error === true ) {
  73 + if( $format == 'json' ) {
  74 + echo "{\"status\":\"error\", \"erreur\": {\"code\": 2, \"message\": \"Wrong parameters.\"} }";
  75 + exit;
  76 + } else {
  77 + echo "<reponse>";
  78 + echo " <erreur>";
  79 + echo " <code>2</code>";
  80 + echo " <message>Wrong parameters</message>";
  81 + echo " </erreur>";
  82 + echo "</reponse>";
  83 + exit;
  84 + }
  85 +}
  86 +
  87 +$pointSrc = new proj4phpPoint( $x, $y );
  88 +$pointDest = $proj4->transform( $projsource, $projdest, $pointSrc );
  89 +
  90 +$tgtProjection = str_replace( ':', '::', $tgtProjection );
  91 +
  92 +if( $format == 'json' ) {
  93 + echo "{\"status\" :\"success\", \"point\" : {\"x\":" . $pointDest->x . ", \"y\":" . $pointDest->y . ",\"projection\" :\"" . $tgtProjection . "\"}}";
  94 + exit;
  95 +} else {
  96 + header ("Content-Type:text/xml");
  97 + echo "<reponse>";
  98 + echo "<point>";
  99 + echo "<x>" . $pointDest->x . "</x>";
  100 + echo "<y>" . $pointDest->y . "</y>";
  101 + echo "<projection>" . $tgtProjection . "</projection>";
  102 + echo "</point>";
  103 + echo "</reponse>";
  104 +}
0 105 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG102757.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:102757"] = "+title=NAD 1983 StatePlane Wyoming West Central FIPS 4903 Feet +proj=tmerc +lat_0=40.5 +lon_0=-108.75 +x_0=600000.0 +y_0=0 +k=0.999938 +a=6378137.0 +b=6356752.3141403 +to_meter=0.3048006096012192";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG102758.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:102758"] = "+title=NAD 1983 StatePlane Wyoming West FIPS 4904 Feet +proj=tmerc +lat_0=40.5 +lon_0=-110.0833333333333 +x_0=800000 +y_0=100000 +k=0.999938 +a=6378137.0 +b=6356752.3141403 +to_meter=0.3048006096012192";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG2154.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:2154"] = "+proj=lcc +lat_1=49 +lat_2=44 +lat_0=46.5 +lon_0=3 +x_0=700000 +y_0=6600000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs";
0 3 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG21781.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:21781"] = "+title=CH1903 / LV03 +proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG25832.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:25832"] = "+proj=utm +zone=32 +ellps=GRS80 +units=m +no_defs";
0 3 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG25833.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:25833"] = "+proj=utm +zone=33 +ellps=GRS80 +units=m +no_defs";
0 3 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG26591.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:26591"] = "+title= Monte Mario (Rome) / Italy zone 1 EPSG:26591 +proj=tmerc +lat_0=0 +lon_0=-3.45233333333333 +from_greenwich=12.45233333333333 +k=0.999600 +x_0=1500000 +y_0=0 +a=6378388.0, +b=6356911.94612795 +units=m";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG26912.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG26912"] = "+title=NAD83 / UTM zone 12N +proj=utm +zone=12 +a=6378137.0 +b=6356752.3141403";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG27200.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:27200"] = "+title=New Zealand Map Grid +proj=nzmg +lat_0=-41 +lon_0=173 +x_0=2510000 +y_0=6023150 +ellps=intl +datum=nzgd49 +units=m +no_defs";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG27563.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:27563"]="+title=NTF (Paris)/Lambert Sud France +proj=lcc +lat_1=44.10000000000001 +lat_0=44.10000000000001 +lon_0=0 +k_0=0.9998774990000001 +x_0=600000 +y_0=200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs ";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG27571.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:27571"] = "+proj=lcc +lat_1=49.50000000000001 +lat_0=49.50000000000001 +lon_0=0 +k_0=0.999877341 +x_0=600000 +y_0=1200000 +a=6378249.2 +b=6356515 +towgs84=-168,-60,320,0,0,0,0 +pm=paris +units=m +no_defs";
0 3 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG31370.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:31370"] = "+proj=lcc +lat_1=51.16666723333334 +lat_2=49.83333389999999 +lat_0=90 +lon_0=4.367486666666666 +x_0=150000.013 +y_0=5400088.438 +ellps=intl +towgs84=-99.1,53.3,-112.5,0.419,-0.83,1.885,-1.0 +units=m +no_defs";
0 3 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG31467.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:31467"] = "+proj=tmerc +lat_0=0 +lon_0=9 +k=1.000000 +x_0=3500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs";
0 3 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG31468.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:31468"] = "+proj=tmerc +lat_0=0 +lon_0=12 +k=1.000000 +x_0=4500000 +y_0=0 +ellps=bessel +datum=potsdam +units=m +no_defs";
0 3 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG41001.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:41001"] = "+title=simple mercator EPSG:41001 +proj=merc +lat_ts=0 +lon_0=0 +k=1.000000 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG4139.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:4139"] = "+title=Puerto Rico EPSG:4139 (3 param datum shift) +proj=longlat +towgs84 = 11,72,-101,0,0,0,0 +a=6378206.4 +b=6356583.8";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG4181.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:4181"] = "+title=Luxembourg 1930 EPSG:4181 (7 param datum shift) +proj=longlat +towgs84=-193,13.7,-39.3,-0.41,-2.933,2.688,0.43 +a=6378388.0, +b=6356911.94612795";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG42304.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:42304"]="+title=Atlas of Canada, LCC +proj=lcc +lat_1=49 +lat_2=77 +lat_0=49 +lon_0=-95 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs";
0 3 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG4272.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:4272"] = "+title=NZGD49 +proj=longlat +ellps=intl +datum=nzgd49 +no_defs ";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG4302.php 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:4302"] = "+title=Trinidad 1903 EPSG:4302 (7 param datum shift) +proj=longlat +a=6378293.63683822 +b=6356617.979337744 +towgs84=-61.702,284.488,472.052,0,0,0,0";
  3 +
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG5514.php 0 → 100644
... ... @@ -0,0 +1,2 @@
  1 +<?php
  2 +Proj4php::$defs["EPSG:5514"]= "+title=S-JTSK EPSG:5514 +proj=krovak +lat_0=49.5 +lon_0=24.83333333333333 +alpha=30.28813972222222 +k=0.9999 +x_0=0 +y_0=0 +ellps=bessel +pm=greenwich +units=m +no_defs +towgs84=570.8,85.7,462.8,4.998,1.587,5.261,3.56";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG900913.php 0 → 100644
... ... @@ -0,0 +1,6 @@
  1 +<?php
  2 +// Google Mercator projection
  3 +// Used in combination with GoogleMercator layer type in OpenLayers
  4 +//+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs
  5 +
  6 +Proj4php::$defs["EPSG:900913"]= "+title= Google Mercator EPSG:900913 +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/EPSG900913.txt 0 → 100644
... ... @@ -0,0 +1,11 @@
  1 +// Google Mercator projection
  2 +// Used in combination with GoogleMercator layer type in OpenLayers
  3 +//+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs
  4 +
  5 +csList.EPSG900913= "\
  6 + +title= Google Mercator EPSG:900913\
  7 + +proj=merc +a=6378137 +b=6378137 \
  8 + +lat_ts=0.0 +lon_0=0.0 \
  9 + +x_0=0.0 +y_0=0 +k=1.0 \
  10 + +units=m +nadgrids=@null +no_defs \
  11 +";
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/defs/GOOGLE.php 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +<?php
  2 +Proj4php::$defs["GOOGLE"]="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs";
  3 +Proj4php::$defs["EPSG:900913"]=Proj4php::$defs["GOOGLE"];
0 4 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/proj4php.php 0 → 100644
... ... @@ -0,0 +1,418 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Simple conversion from javascript to PHP of Proj4php by Mike Adair madairATdmsolutions.ca and Richard Greenwood rich@greenwoodmap.com
  6 + *
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +$dir = dirname( __FILE__ );
  10 +
  11 +require_once($dir . "/proj4phpProj.php");
  12 +require_once($dir . "/proj4phpCommon.php");
  13 +require_once($dir . "/proj4phpDatum.php");
  14 +require_once($dir . "/proj4phpLongLat.php");
  15 +require_once($dir . "/proj4phpPoint.php");
  16 +
  17 +class Proj4php {
  18 + protected $defaultDatum = 'WGS84';
  19 + public static $ellipsoid = array( );
  20 + public static $common = null;
  21 + public static $datum = array( );
  22 + public static $defs = array( );
  23 + public static $wktProjections = array( );
  24 + public static $WGS84 = null;
  25 + public static $primeMeridian = array( );
  26 + public static $proj = array( );
  27 + public $msg = '';
  28 + /**
  29 + * Property: defsLookupService
  30 + * service to retreive projection definition parameters from
  31 + */
  32 + public static $defsLookupService = 'http://spatialreference.org/ref';
  33 +
  34 + /**
  35 + Proj4php.defs is a collection of coordinate system definition objects in the
  36 + PROJ.4 command line format.
  37 + Generally a def is added by means of a separate .js file for example:
  38 +
  39 + <SCRIPT type="text/javascript" src="defs/EPSG26912.js"></SCRIPT>
  40 +
  41 + def is a CS definition in PROJ.4 WKT format, for example:
  42 + +proj="tmerc" //longlat, etc.
  43 + +a=majorRadius
  44 + +b=minorRadius
  45 + +lat0=somenumber
  46 + +long=somenumber
  47 + */
  48 + protected function initDefs() {
  49 + // These are so widely used, we'll go ahead and throw them in
  50 + // without requiring a separate .js file
  51 + self::$defs['WGS84'] = "+title=long/lat:WGS84 +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees";
  52 + self::$defs['EPSG:4326'] = "+title=long/lat:WGS84 +proj=longlat +a=6378137.0 +b=6356752.31424518 +ellps=WGS84 +datum=WGS84 +units=degrees";
  53 + self::$defs['EPSG:4269'] = "+title=long/lat:NAD83 +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees";
  54 + self::$defs['EPSG:3875'] = "+title= Google Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs";
  55 + self::$defs['EPSG:3785'] = self::$defs['EPSG:3875'];
  56 + self::$defs['GOOGLE'] = self::$defs['EPSG:3875'];
  57 + self::$defs['EPSG:900913'] = self::$defs['EPSG:3875'];
  58 + self::$defs['EPSG:102113'] = self::$defs['EPSG:3875'];
  59 + }
  60 +
  61 + //lookup table to go from the projection name in WKT to the Proj4php projection name
  62 + //build this out as required
  63 + protected function initWKTProjections() {
  64 + self::$wktProjections["Lambert Tangential Conformal Conic Projection"] = "lcc";
  65 + self::$wktProjections["Mercator"] = "merc";
  66 + self::$wktProjections["Mercator_1SP"] = "merc";
  67 + self::$wktProjections["Transverse_Mercator"] = "tmerc";
  68 + self::$wktProjections["Transverse Mercator"] = "tmerc";
  69 + self::$wktProjections["Lambert Azimuthal Equal Area"] = "laea";
  70 + self::$wktProjections["Universal Transverse Mercator System"] = "utm";
  71 + }
  72 +
  73 + protected function initDatum() {
  74 + self::$datum["WGS84"] = array( 'towgs84' => "0,0,0", 'ellipse' => "WGS84", 'datumName' => "WGS84" );
  75 + self::$datum["GGRS87"] = array( 'towgs84' => "-199.87,74.79,246.62", 'ellipse' => "GRS80", 'datumName' => "Greek_Geodetic_Reference_System_1987" );
  76 + self::$datum["NAD83"] = array( 'towgs84' => "0,0,0", 'ellipse' => "GRS80", 'datumName' => "North_American_Datum_1983" );
  77 + self::$datum["NAD27"] = array( 'nadgrids' => "@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat", 'ellipse' => "clrk66", 'datumName' => "North_American_Datum_1927" );
  78 + self::$datum["potsdam"] = array( 'towgs84' => "606.0,23.0,413.0", 'ellipse' => "bessel", 'datumName' => "Potsdam Rauenberg 1950 DHDN" );
  79 + self::$datum["carthage"] = array( 'towgs84' => "-263.0,6.0,431.0", 'ellipse' => "clark80", 'datumName' => "Carthage 1934 Tunisia" );
  80 + self::$datum["hermannskogel"] = array( 'towgs84' => "653.0,-212.0,449.0", 'ellipse' => "bessel", 'datumName' => "Hermannskogel" );
  81 + self::$datum["ire65"] = array( 'towgs84' => "482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15", 'ellipse' => "mod_airy", 'datumName' => "Ireland 1965" );
  82 + self::$datum["nzgd49"] = array( 'towgs84' => "59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993", 'ellipse' => "intl", 'datumName' => "New Zealand Geodetic Datum 1949" );
  83 + self::$datum["OSGB36"] = array( 'towgs84' => "446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894", 'ellipse' => "airy", 'datumName' => "Airy 1830" );
  84 + }
  85 +
  86 + protected function initEllipsoid() {
  87 + self::$ellipsoid["MERIT"] = array( 'a' => 6378137.0, 'rf' => 298.257, 'ellipseName' => "MERIT 1983" );
  88 + self::$ellipsoid["SGS85"] = array( 'a' => 6378136.0, 'rf' => 298.257, 'ellipseName' => "Soviet Geodetic System 85" );
  89 + self::$ellipsoid["GRS80"] = array( 'a' => 6378137.0, 'rf' => 298.257222101, 'ellipseName' => "GRS 1980(IUGG, 1980)" );
  90 + self::$ellipsoid["IAU76"] = array( 'a' => 6378140.0, 'rf' => 298.257, 'ellipseName' => "IAU 1976" );
  91 + self::$ellipsoid["airy"] = array( 'a' => 6377563.396, 'b' => 6356256.910, 'ellipseName' => "Airy 1830" );
  92 + self::$ellipsoid["APL4."] = array( 'a' => 6378137, 'rf' => 298.25, 'ellipseName' => "Appl. Physics. 1965" );
  93 + self::$ellipsoid["NWL9D"] = array( 'a' => 6378145.0, 'rf' => 298.25, 'ellipseName' => "Naval Weapons Lab., 1965" );
  94 + self::$ellipsoid["mod_airy"] = array( 'a' => 6377340.189, 'b' => 6356034.446, 'ellipseName' => "Modified Airy" );
  95 + self::$ellipsoid["andrae"] = array( 'a' => 6377104.43, 'rf' => 300.0, 'ellipseName' => "Andrae 1876 (Den., Iclnd.)" );
  96 + self::$ellipsoid["aust_SA"] = array( 'a' => 6378160.0, 'rf' => 298.25, 'ellipseName' => "Australian Natl & S. Amer. 1969" );
  97 + self::$ellipsoid["GRS67"] = array( 'a' => 6378160.0, 'rf' => 298.2471674270, 'ellipseName' => "GRS 67(IUGG 1967)" );
  98 + self::$ellipsoid["bessel"] = array( 'a' => 6377397.155, 'rf' => 299.1528128, 'ellipseName' => "Bessel 1841" );
  99 + self::$ellipsoid["bess_nam"] = array( 'a' => 6377483.865, 'rf' => 299.1528128, 'ellipseName' => "Bessel 1841 (Namibia)" );
  100 + self::$ellipsoid["clrk66"] = array( 'a' => 6378206.4, 'b' => 6356583.8, 'ellipseName' => "Clarke 1866" );
  101 + self::$ellipsoid["clrk80"] = array( 'a' => 6378249.145, 'rf' => 293.4663, 'ellipseName' => "Clarke 1880 mod." );
  102 + self::$ellipsoid["CPM"] = array( 'a' => 6375738.7, 'rf' => 334.29, 'ellipseName' => "Comm. des Poids et Mesures 1799" );
  103 + self::$ellipsoid["delmbr"] = array( 'a' => 6376428.0, 'rf' => 311.5, 'ellipseName' => "Delambre 1810 (Belgium)" );
  104 + self::$ellipsoid["engelis"] = array( 'a' => 6378136.05, 'rf' => 298.2566, 'ellipseName' => "Engelis 1985" );
  105 + self::$ellipsoid["evrst30"] = array( 'a' => 6377276.345, 'rf' => 300.8017, 'ellipseName' => "Everest 1830" );
  106 + self::$ellipsoid["evrst48"] = array( 'a' => 6377304.063, 'rf' => 300.8017, 'ellipseName' => "Everest 1948" );
  107 + self::$ellipsoid["evrst56"] = array( 'a' => 6377301.243, 'rf' => 300.8017, 'ellipseName' => "Everest 1956" );
  108 + self::$ellipsoid["evrst69"] = array( 'a' => 6377295.664, 'rf' => 300.8017, 'ellipseName' => "Everest 1969" );
  109 + self::$ellipsoid["evrstSS"] = array( 'a' => 6377298.556, 'rf' => 300.8017, 'ellipseName' => "Everest (Sabah & Sarawak)" );
  110 + self::$ellipsoid["fschr60"] = array( 'a' => 6378166.0, 'rf' => 298.3, 'ellipseName' => "Fischer (Mercury Datum) 1960" );
  111 + self::$ellipsoid["fschr60m"] = array( 'a' => 6378155.0, 'rf' => 298.3, 'ellipseName' => "Fischer 1960" );
  112 + self::$ellipsoid["fschr68"] = array( 'a' => 6378150.0, 'rf' => 298.3, 'ellipseName' => "Fischer 1968" );
  113 + self::$ellipsoid["helmert"] = array( 'a' => 6378200.0, 'rf' => 298.3, 'ellipseName' => "Helmert 1906" );
  114 + self::$ellipsoid["hough"] = array( 'a' => 6378270.0, 'rf' => 297.0, 'ellipseName' => "Hough" );
  115 + self::$ellipsoid["intl"] = array( 'a' => 6378388.0, 'rf' => 297.0, 'ellipseName' => "International 1909 (Hayford)" );
  116 + self::$ellipsoid["kaula"] = array( 'a' => 6378163.0, 'rf' => 298.24, 'ellipseName' => "Kaula 1961" );
  117 + self::$ellipsoid["lerch"] = array( 'a' => 6378139.0, 'rf' => 298.257, 'ellipseName' => "Lerch 1979" );
  118 + self::$ellipsoid["mprts"] = array( 'a' => 6397300.0, 'rf' => 191.0, 'ellipseName' => "Maupertius 1738" );
  119 + self::$ellipsoid["new_intl"] = array( 'a' => 6378157.5, 'b' => 6356772.2, 'ellipseName' => "New International 1967" );
  120 + self::$ellipsoid["plessis"] = array( 'a' => 6376523.0, 'rf' => 6355863.0, 'ellipseName' => "Plessis 1817 (France)" );
  121 + self::$ellipsoid["krass"] = array( 'a' => 6378245.0, 'rf' => 298.3, 'ellipseName' => "Krassovsky, 1942" );
  122 + self::$ellipsoid["SEasia"] = array( 'a' => 6378155.0, 'b' => 6356773.3205, 'ellipseName' => "Southeast Asia" );
  123 + self::$ellipsoid["walbeck"] = array( 'a' => 6376896.0, 'b' => 6355834.8467, 'ellipseName' => "Walbeck" );
  124 + self::$ellipsoid["WGS60"] = array( 'a' => 6378165.0, 'rf' => 298.3, 'ellipseName' => "WGS 60" );
  125 + self::$ellipsoid["WGS66"] = array( 'a' => 6378145.0, 'rf' => 298.25, 'ellipseName' => "WGS 66" );
  126 + self::$ellipsoid["WGS72"] = array( 'a' => 6378135.0, 'rf' => 298.26, 'ellipseName' => "WGS 72" );
  127 + self::$ellipsoid["WGS84"] = array( 'a' => 6378137.0, 'rf' => 298.257223563, 'ellipseName' => "WGS 84" );
  128 + self::$ellipsoid["sphere"] = array( 'a' => 6370997.0, 'b' => 6370997.0, 'ellipseName' => "Normal Sphere (r=6370997)" );
  129 + }
  130 +
  131 + protected function initPrimeMeridian() {
  132 + self::$primeMeridian["greenwich"] = '0.0'; //"0dE",
  133 + self::$primeMeridian["lisbon"] = -9.131906111111; //"9d07'54.862\"W",
  134 + self::$primeMeridian["paris"] = 2.337229166667; //"2d20'14.025\"E",
  135 + self::$primeMeridian["bogota"] = -74.080916666667; //"74d04'51.3\"W",
  136 + self::$primeMeridian["madrid"] = -3.687938888889; //"3d41'16.58\"W",
  137 + self::$primeMeridian["rome"] = 12.452333333333; //"12d27'8.4\"E",
  138 + self::$primeMeridian["bern"] = 7.439583333333; //"7d26'22.5\"E",
  139 + self::$primeMeridian["jakarta"] = 106.807719444444; //"106d48'27.79\"E",
  140 + self::$primeMeridian["ferro"] = -17.666666666667; //"17d40'W",
  141 + self::$primeMeridian["brussels"] = 4.367975; //"4d22'4.71\"E",
  142 + self::$primeMeridian["stockholm"] = 18.058277777778; //"18d3'29.8\"E",
  143 + self::$primeMeridian["athens"] = 23.7163375; //"23d42'58.815\"E",
  144 + self::$primeMeridian["oslo"] = 10.722916666667; //"10d43'22.5\"E"
  145 + }
  146 +
  147 + /**
  148 + *
  149 + */
  150 + public function __construct() {
  151 +
  152 + $this->initWKTProjections();
  153 + $this->initDefs();
  154 + $this->initDatum();
  155 + $this->initEllipsoid();
  156 + $this->initPrimeMeridian();
  157 +
  158 + self::$proj['longlat'] = new proj4phpLongLat();
  159 + self::$proj['identity'] = new proj4phpLongLat();
  160 + self::$common = new proj4phpCommon();
  161 + self::$WGS84 = new Proj4phpProj( 'WGS84' );
  162 + }
  163 +
  164 + /**
  165 + * Method: transform(source, dest, point)
  166 + * Transform a point coordinate from one map projection to another. This is
  167 + * really the only public method you should need to use.
  168 + *
  169 + * Parameters:
  170 + * source - {Proj4phpProj} source map projection for the transformation
  171 + * dest - {Proj4phpProj} destination map projection for the transformation
  172 + * point - {Object} point to transform, may be geodetic (long, lat) or
  173 + * projected Cartesian (x,y), but should always have x,y properties.
  174 + */
  175 + public function transform( $source, $dest, $point) {
  176 + $this->msg = '';
  177 + if( !$source->readyToUse ) {
  178 + self::reportError( "Proj4php initialization for:" . $source->srsCode . " not yet complete" );
  179 + return $point;
  180 + }
  181 + if( !$dest->readyToUse ) {
  182 + self::reportError( "Proj4php initialization for:" . $dest->srsCode . " not yet complete" );
  183 + return $point;
  184 + }
  185 +
  186 + // DGR, 2010/11/12
  187 +
  188 + if( $source->axis != "enu" ) {
  189 + $this->adjust_axis( $source, false, $point );
  190 + }
  191 +
  192 + // Transform source points to long/lat, if they aren't already.
  193 + if( $source->projName == "longlat" ) {
  194 + $point->x *= Proj4php::$common->D2R; // convert degrees to radians
  195 + $point->y *= Proj4php::$common->D2R;
  196 + } else {
  197 + if( isset($source->to_meter) )
  198 + {
  199 + $point->x *= $source->to_meter;
  200 + $point->y *= $source->to_meter;
  201 + }
  202 + $source->inverse( $point ); // Convert Cartesian to longlat
  203 + }
  204 + // Adjust for the prime meridian if necessary
  205 + if( isset( $source->from_greenwich ) ) {
  206 + $point->x += $source->from_greenwich;
  207 + }
  208 +
  209 + // Convert datums if needed, and if possible.
  210 + $point = $this->datum_transform( $source->datum, $dest->datum, $point );
  211 +
  212 + // Adjust for the prime meridian if necessary
  213 + if( isset( $dest->from_greenwich ) ) {
  214 + $point->x -= $dest->from_greenwich;
  215 + }
  216 +
  217 + if( $dest->projName == "longlat" ) {
  218 + // convert radians to decimal degrees
  219 + $point->x *= Proj4php::$common->R2D;
  220 + $point->y *= Proj4php::$common->R2D;
  221 + } else { // else project
  222 + $dest->forward( $point );
  223 + if( isset($dest->to_meter) ) {
  224 + $point->x /= $dest->to_meter;
  225 + $point->y /= $dest->to_meter;
  226 + }
  227 + }
  228 +
  229 + // DGR, 2010/11/12
  230 + if( $dest->axis != "enu" ) {
  231 + $this->adjust_axis( $dest, true, $point );
  232 + }
  233 +
  234 + // Nov 2014 - changed Werner Schäffer
  235 + // clone point to avoid a lot of problems
  236 + return (clone $point);
  237 +
  238 + }
  239 +
  240 + /** datum_transform()
  241 + source coordinate system definition,
  242 + destination coordinate system definition,
  243 + point to transform in geodetic coordinates (long, lat, height)
  244 + */
  245 + public function datum_transform( $source, $dest, $point ) {
  246 +
  247 + // Short cut if the datums are identical.
  248 + if( $source->compare_datums( $dest ) ) {
  249 + return $point; // in this case, zero is sucess,
  250 + // whereas cs_compare_datums returns 1 to indicate TRUE
  251 + // confusing, should fix this
  252 + }
  253 +
  254 + // Explicitly skip datum transform by setting 'datum=none' as parameter for either source or dest
  255 + if( $source->datum_type == Proj4php::$common->PJD_NODATUM
  256 + || $dest->datum_type == Proj4php::$common->PJD_NODATUM ) {
  257 + return $point;
  258 + }
  259 +
  260 + /*
  261 + // If this datum requires grid shifts, then apply it to geodetic coordinates.
  262 + if( $source->datum_type == Proj4php::$common->PJD_GRIDSHIFT ) {
  263 + throw(new Exception( "ERROR: Grid shift transformations are not implemented yet." ));
  264 + }
  265 +
  266 + if( $dest->datum_type == Proj4php::$common->PJD_GRIDSHIFT ) {
  267 + throw(new Exception( "ERROR: Grid shift transformations are not implemented yet." ));
  268 + }
  269 + */
  270 +
  271 + // Do we need to go through geocentric coordinates?
  272 + if( $source->es != $dest->es || $source->a != $dest->a
  273 + || $source->datum_type == Proj4php::$common->PJD_3PARAM
  274 + || $source->datum_type == Proj4php::$common->PJD_7PARAM
  275 + || $dest->datum_type == Proj4php::$common->PJD_3PARAM
  276 + || $dest->datum_type == Proj4php::$common->PJD_7PARAM ) {
  277 +
  278 + // Convert to geocentric coordinates.
  279 + $source->geodetic_to_geocentric( $point );
  280 + // CHECK_RETURN;
  281 + // Convert between datums
  282 + if( $source->datum_type == Proj4php::$common->PJD_3PARAM || $source->datum_type == Proj4php::$common->PJD_7PARAM ) {
  283 + $source->geocentric_to_wgs84( $point );
  284 + // CHECK_RETURN;
  285 + }
  286 +
  287 + if( $dest->datum_type == Proj4php::$common->PJD_3PARAM || $dest->datum_type == Proj4php::$common->PJD_7PARAM ) {
  288 + $dest->geocentric_from_wgs84( $point );
  289 + // CHECK_RETURN;
  290 + }
  291 +
  292 + // Convert back to geodetic coordinates
  293 + $dest->geocentric_to_geodetic( $point );
  294 + // CHECK_RETURN;
  295 + }
  296 +
  297 + // Apply grid shift to destination if required
  298 + /*
  299 + if( $dest->datum_type == Proj4php::$common->PJD_GRIDSHIFT ) {
  300 + throw(new Exception( "ERROR: Grid shift transformations are not implemented yet." ));
  301 + // pj_apply_gridshift( pj_param(dest.params,"snadgrids").s, 1, point);
  302 + // CHECK_RETURN;
  303 + }
  304 + */
  305 + return $point;
  306 + }
  307 +
  308 +
  309 + /**
  310 + * Function: adjust_axis
  311 + * Normalize or de-normalized the x/y/z axes. The normal form is "enu"
  312 + * (easting, northing, up).
  313 + * Parameters:
  314 + * crs {Proj4php.Proj} the coordinate reference system
  315 + * denorm {Boolean} when false, normalize
  316 + * point {Object} the coordinates to adjust
  317 + */
  318 + public function adjust_axis( $crs, $denorm, $point ) {
  319 +
  320 + $xin = $point->x;
  321 + $yin = $point->y;
  322 + $zin = isset( $point->z ) ? $point->z : 0.0;
  323 + #$v;
  324 + #$t;
  325 + for( $i = 0; $i < 3; $i++ ) {
  326 + if( $denorm && $i == 2 && !isset( $point->z ) ) {
  327 + continue;
  328 + }
  329 + if( $i == 0 ) {
  330 + $v = $xin;
  331 + $t = 'x';
  332 + } else if( $i == 1 ) {
  333 + $v = $yin;
  334 + $t = 'y';
  335 + } else {
  336 + $v = $zin;
  337 + $t = 'z';
  338 + }
  339 + switch( $crs->axis[$i] ) {
  340 + case 'e':
  341 + $point[$t] = $v;
  342 + break;
  343 + case 'w':
  344 + $point[$t] = -$v;
  345 + break;
  346 + case 'n':
  347 + $point[$t] = $v;
  348 + break;
  349 + case 's':
  350 + $point[$t] = -$v;
  351 + break;
  352 + case 'u':
  353 + if( isset( $point[$t] ) ) {
  354 + $point->z = $v;
  355 + }
  356 + break;
  357 + case 'd':
  358 + if( isset( $point[$t] ) ) {
  359 + $point->z = -$v;
  360 + }
  361 + break;
  362 + default :
  363 + throw(new Exception( "ERROR: unknow axis (" . $crs->axis[$i] . ") - check definition of " . $crs->projName ));
  364 + return null;
  365 + }
  366 + }
  367 + return $point;
  368 + }
  369 +
  370 + /**
  371 + * Function: reportError
  372 + * An internal method to report errors back to user.
  373 + * Override this in applications to report error messages or throw exceptions.
  374 + */
  375 + public static function reportError( $msg ) {
  376 + throw(new Exception($msg));
  377 + }
  378 +
  379 + /**
  380 + * Function : loadScript
  381 + * adapted from original. PHP is simplier.
  382 + */
  383 + public static function loadScript( $filename, $onload = null, $onfail = null, $loadCheck = null ) {
  384 +
  385 + if( stripos($filename, 'http://') !== false ) {
  386 + return @file_get_contents($filename);
  387 + }
  388 + elseif( file_exists( $filename ) ) {
  389 + require_once($filename);
  390 + return true;
  391 + }
  392 + else {
  393 + throw(new Exception( "File $filename could not be found or was not able to be loaded." ));
  394 + }
  395 + }
  396 +
  397 + /**
  398 + * Function: extend
  399 + * Copy all properties of a source object to a destination object. Modifies
  400 + * the passed in destination object. Any properties on the source object
  401 + * that are set to undefined will not be (re)set on the destination object.
  402 + *
  403 + * Parameters:
  404 + * destination - {Object} The object that will be modified
  405 + * source - {Object} The object with properties to be set on the destination
  406 + *
  407 + * Returns:
  408 + * {Object} The destination object.
  409 + */
  410 + public static function extend( $destination, $source ) {
  411 + if( $source != null )
  412 + foreach( $source as $key => $value ) {
  413 + $destination->$key = $value;
  414 + }
  415 + return $destination;
  416 + }
  417 +
  418 +}
0 419 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/proj4phpCommon.php 0 → 100644
... ... @@ -0,0 +1,389 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Author : Julien Moquet
  5 + *
  6 + * Inspired by Proj4js from Mike Adair madairATdmsolutions.ca
  7 + * and Richard Greenwood rich@greenwoodmap.com
  8 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  9 + */
  10 +class Proj4phpCommon {
  11 +
  12 + public $PI = M_PI; #3.141592653589793238; //Math.PI,
  13 + public $HALF_PI = M_PI_2; #1.570796326794896619; //Math.PI*0.5,
  14 + public $TWO_PI = 6.283185307179586477; //Math.PI*2,
  15 + public $FORTPI = 0.78539816339744833;
  16 + public $R2D = 57.29577951308232088;
  17 + public $D2R = 0.01745329251994329577;
  18 + public $SEC_TO_RAD = 4.84813681109535993589914102357e-6; /* SEC_TO_RAD = Pi/180/3600 */
  19 + public $EPSLN = 1.0e-10;
  20 + public $MAX_ITER = 20;
  21 + // following constants from geocent.c
  22 + public $COS_67P5 = 0.38268343236508977; /* cosine of 67.5 degrees */
  23 + public $AD_C = 1.0026000; /* Toms region 1 constant */
  24 +
  25 + /* datum_type values */
  26 + public $PJD_UNKNOWN = 0;
  27 + public $PJD_3PARAM = 1;
  28 + public $PJD_7PARAM = 2;
  29 + public $PJD_GRIDSHIFT = 3;
  30 + public $PJD_WGS84 = 4; // WGS84 or equivalent
  31 + public $PJD_NODATUM = 5; // WGS84 or equivalent
  32 +
  33 + const SRS_WGS84_SEMIMAJOR = 6378137.0; // only used in grid shift transforms
  34 +
  35 + // ellipoid pj_set_ell.c
  36 +
  37 + public $SIXTH = .1666666666666666667; /* 1/6 */
  38 + public $RA4 = .04722222222222222222; /* 17/360 */
  39 + public $RA6 = .02215608465608465608; /* 67/3024 */
  40 + public $RV4 = .06944444444444444444; /* 5/72 */
  41 + public $RV6 = .04243827160493827160; /* 55/1296 */
  42 +
  43 +
  44 + /* meridinal distance for ellipsoid and inverse
  45 + * * 8th degree - accurate to < 1e-5 meters when used in conjuction
  46 + * * with typical major axis values.
  47 + * * Inverse determines phi to EPS (1e-11) radians, about 1e-6 seconds.
  48 + */
  49 + protected $C00 = 1.0;
  50 + protected $C02 = .25;
  51 + protected $C04 = .046875;
  52 + protected $C06 = .01953125;
  53 + protected $C08 = .01068115234375;
  54 + protected $C22 = .75;
  55 + protected $C44 = .46875;
  56 + protected $C46 = .01302083333333333333;
  57 + protected $C48 = .00712076822916666666;
  58 + protected $C66 = .36458333333333333333;
  59 + protected $C68 = .00569661458333333333;
  60 + protected $C88 = .3076171875;
  61 +
  62 + /**
  63 + * Function to compute the constant small m which is the radius of
  64 + * a parallel of latitude, phi, divided by the semimajor axis.
  65 + *
  66 + * @param type $eccent
  67 + * @param type $sinphi
  68 + * @param type $cosphi
  69 + * @return type
  70 + */
  71 + public function msfnz( $eccent, $sinphi, $cosphi ) {
  72 +
  73 + $con = $eccent * $sinphi;
  74 +
  75 + return $cosphi / (sqrt( 1.0 - $con * $con ));
  76 + }
  77 +
  78 + /**
  79 + * Function to compute the constant small t for use in the forward
  80 + * computations in the Lambert Conformal Conic and the Polar
  81 + * Stereographic projections.
  82 + *
  83 + * @param type $eccent
  84 + * @param type $phi
  85 + * @param type $sinphi
  86 + * @return type
  87 + */
  88 + public function tsfnz( $eccent, $phi, $sinphi ) {
  89 +
  90 + $con = $eccent * $sinphi;
  91 + $com = 0.5 * $eccent;
  92 + $con = pow( ((1.0 - $con) / (1.0 + $con) ), $com );
  93 +
  94 + return (tan( .5 * (M_PI_2 - $phi) ) / $con);
  95 + }
  96 +
  97 + /**
  98 + * Function to compute the latitude angle, phi2, for the inverse of the
  99 + * Lambert Conformal Conic and Polar Stereographic projections.
  100 + *
  101 + * rise up an assertion if there is no convergence.
  102 + *
  103 + * @param type $eccent
  104 + * @param type $ts
  105 + * @return type
  106 + */
  107 + public function phi2z( $eccent, $ts ) {
  108 +
  109 + $eccnth = .5 * $eccent;
  110 + $phi = M_PI_2 - 2 * atan( $ts );
  111 +
  112 + for( $i = 0; $i <= 15; $i++ ) {
  113 + $con = $eccent * sin( $phi );
  114 + $dphi = M_PI_2 - 2 * atan( $ts * (pow( ((1.0 - $con) / (1.0 + $con) ), $eccnth )) ) - $phi;
  115 + $phi += $dphi;
  116 + if( abs( $dphi ) <= .0000000001 )
  117 + return $phi;
  118 + }
  119 + assert( "false; /* phi2z has NoConvergence */" );
  120 +
  121 + return (-9999);
  122 + }
  123 +
  124 + /**
  125 + * Function to compute constant small q which is the radius of a
  126 + * parallel of latitude, phi, divided by the semimajor axis.
  127 + *
  128 + * @param type $eccent
  129 + * @param type $sinphi
  130 + * @return type
  131 + */
  132 + public function qsfnz( $eccent, $sinphi ) {
  133 +
  134 + if( $eccent > 1.0e-7 ) {
  135 +
  136 + $con = $eccent * $sinphi;
  137 +
  138 + return (( 1.0 - $eccent * $eccent) * ($sinphi / (1.0 - $con * $con) - (.5 / $eccent) * log( (1.0 - $con) / (1.0 + $con) )));
  139 + }
  140 +
  141 + return (2.0 * $sinphi);
  142 + }
  143 +
  144 + /**
  145 + * Function to eliminate roundoff errors in asin
  146 + *
  147 + * @param type $x
  148 + * @return type
  149 + */
  150 + public function asinz( $x ) {
  151 +
  152 + return asin(
  153 + abs( $x ) > 1.0 ? ($x > 1.0 ? 1.0 : -1.0) : $x
  154 + );
  155 +
  156 + #if( abs( $x ) > 1.0 ) {
  157 + # $x = ($x > 1.0) ? 1.0 : -1.0;
  158 + #}
  159 + #return asin( $x );
  160 + }
  161 +
  162 + /**
  163 + * following functions from gctpc cproj.c for transverse mercator projections
  164 + *
  165 + * @param type $x
  166 + * @return type
  167 + */
  168 + public function e0fn( $x ) {
  169 + return (1.0 - 0.25 * $x * (1.0 + $x / 16.0 * (3.0 + 1.25 * $x)));
  170 + }
  171 +
  172 + /**
  173 + *
  174 + * @param type $x
  175 + * @return type
  176 + */
  177 + public function e1fn( $x ) {
  178 + return (0.375 * $x * (1.0 + 0.25 * $x * (1.0 + 0.46875 * $x)));
  179 + }
  180 +
  181 + /**
  182 + *
  183 + * @param type $x
  184 + * @return type
  185 + */
  186 + public function e2fn( $x ) {
  187 + return (0.05859375 * $x * $x * (1.0 + 0.75 * $x));
  188 + }
  189 +
  190 + /**
  191 + *
  192 + * @param type $x
  193 + * @return type
  194 + */
  195 + public function e3fn( $x ) {
  196 + return ($x * $x * $x * (35.0 / 3072.0));
  197 + }
  198 +
  199 + /**
  200 + *
  201 + * @param type $e0
  202 + * @param type $e1
  203 + * @param type $e2
  204 + * @param type $e3
  205 + * @param type $phi
  206 + * @return type
  207 + */
  208 + public function mlfn( $e0, $e1, $e2, $e3, $phi ) {
  209 + return ($e0 * $phi - $e1 * sin( 2.0 * $phi ) + $e2 * sin( 4.0 * $phi ) - $e3 * sin( 6.0 * $phi ));
  210 + }
  211 +
  212 + /**
  213 + *
  214 + * @param type $esinp
  215 + * @param type $exp
  216 + * @return type
  217 + */
  218 + public function srat( $esinp, $exp ) {
  219 + return (pow( (1.0 - $esinp) / (1.0 + $esinp), $exp ));
  220 + }
  221 +
  222 + /**
  223 + * Function to return the sign of an argument
  224 + *
  225 + * @param type $x
  226 + * @return type
  227 + */
  228 + public function sign( $x ) {
  229 +
  230 + return $x < 0.0 ? -1 : 1;
  231 + }
  232 +
  233 + /**
  234 + * Function to adjust longitude to -180 to 180; input in radians
  235 + *
  236 + * @param type $x
  237 + * @return type
  238 + */
  239 + public function adjust_lon( $x ) {
  240 +
  241 + return (abs( $x ) < M_PI) ? $x : ($x - ($this->sign( $x ) * $this->TWO_PI) );
  242 + }
  243 +
  244 + /**
  245 + * IGNF - DGR : algorithms used by IGN France
  246 + * Function to adjust latitude to -90 to 90; input in radians
  247 + *
  248 + * @param type $x
  249 + * @return type
  250 + */
  251 + public function adjust_lat( $x ) {
  252 +
  253 + $x = (abs( $x ) < M_PI_2) ? $x : ($x - ($this->sign( $x ) * M_PI) );
  254 +
  255 + return $x;
  256 + }
  257 +
  258 + /**
  259 + * Latitude Isometrique - close to tsfnz ...
  260 + *
  261 + * @param type $eccent
  262 + * @param float $phi
  263 + * @param type $sinphi
  264 + * @return string
  265 + */
  266 + public function latiso( $eccent, $phi, $sinphi ) {
  267 +
  268 + if( abs( $phi ) > M_PI_2 )
  269 + return +NaN;
  270 + if( $phi == M_PI_2 )
  271 + return INF;
  272 + if( $phi == -1.0 * M_PI_2 )
  273 + return -1.0 * INF;
  274 +
  275 + $con = $eccent * $sinphi;
  276 +
  277 + return log( tan( (M_PI_2 + $phi) / 2.0 ) ) + $eccent * log( (1.0 - $con) / (1.0 + $con) ) / 2.0;
  278 + }
  279 +
  280 + /**
  281 + *
  282 + * @param type $x
  283 + * @param type $L
  284 + * @return type
  285 + */
  286 + public function fL( $x, $L ) {
  287 + return 2.0 * atan( $x * exp( $L ) ) - M_PI_2;
  288 + }
  289 +
  290 + /**
  291 + * Inverse Latitude Isometrique - close to ph2z
  292 + *
  293 + * @param type $eccent
  294 + * @param type $ts
  295 + * @return type
  296 + */
  297 + public function invlatiso( $eccent, $ts ) {
  298 +
  299 + $phi = $this->fL( 1.0, $ts );
  300 + $Iphi = 0.0;
  301 + $con = 0.0;
  302 +
  303 + do {
  304 + $Iphi = $phi;
  305 + $con = $eccent * sin( $Iphi );
  306 + $phi = $this->fL( exp( $eccent * log( (1.0 + $con) / (1.0 - $con) ) / 2.0 ), $ts );
  307 + } while( abs( $phi - $Iphi ) > 1.0e-12 );
  308 +
  309 + return $phi;
  310 + }
  311 +
  312 + /**
  313 + * Grande Normale
  314 + *
  315 + * @param type $a
  316 + * @param type $e
  317 + * @param type $sinphi
  318 + * @return type
  319 + */
  320 + public function gN( $a, $e, $sinphi ) {
  321 + $temp = $e * $sinphi;
  322 + return $a / sqrt( 1.0 - $temp * $temp );
  323 + }
  324 +
  325 + /**
  326 + * code from the PROJ.4 pj_mlfn.c file; this may be useful for other projections
  327 + *
  328 + * @param type $es
  329 + * @return type
  330 + */
  331 + public function pj_enfn( $es ) {
  332 +
  333 + $en = array( );
  334 + $en[0] = $this->C00 - $es * ($this->C02 + $es * ($this->C04 + $es * ($this->C06 + $es * $this->C08)));
  335 + $en[1] = es * ($this->C22 - $es * ($this->C04 + $es * ($this->C06 + $es * $this->C08)));
  336 + $t = $es * $es;
  337 + $en[2] = $t * ($this->C44 - $es * ($this->C46 + $es * $this->C48));
  338 + $t *= $es;
  339 + $en[3] = $t * ($this->C66 - $es * $this->C68);
  340 + $en[4] = $t * $es * $this->C88;
  341 +
  342 + return $en;
  343 + }
  344 +
  345 + /**
  346 + *
  347 + * @param type $phi
  348 + * @param type $sphi
  349 + * @param type $cphi
  350 + * @param type $en
  351 + * @return type
  352 + */
  353 + public function pj_mlfn( $phi, $sphi, $cphi, $en ) {
  354 +
  355 + $cphi *= $sphi;
  356 + $sphi *= $sphi;
  357 +
  358 + return ($en[0] * $phi - $cphi * ($en[1] + $sphi * ($en[2] + $sphi * ($en[3] + $sphi * $en[4]))));
  359 + }
  360 +
  361 + /**
  362 + *
  363 + * @param type $arg
  364 + * @param type $es
  365 + * @param type $en
  366 + * @return type
  367 + */
  368 + public function pj_inv_mlfn( $arg, $es, $en ) {
  369 +
  370 + $k = (float) 1 / (1 - $es);
  371 + $phi = $arg;
  372 +
  373 + for( $i = Proj4php::$common->MAX_ITER; $i; --$i ) { /* rarely goes over 2 iterations */
  374 + $s = sin( $phi );
  375 + $t = 1. - $es * $s * $s;
  376 + //$t = $this->pj_mlfn($phi, $s, cos($phi), $en) - $arg;
  377 + //$phi -= $t * ($t * sqrt($t)) * $k;
  378 + $t = ($this->pj_mlfn( $phi, $s, cos( $phi ), $en ) - $arg) * ($t * sqrt( $t )) * $k;
  379 + $phi -= $t;
  380 + if( abs( $t ) < Proj4php::$common->EPSLN )
  381 + return $phi;
  382 + }
  383 +
  384 + Proj4php::reportError( "cass:pj_inv_mlfn: Convergence error" );
  385 +
  386 + return $phi;
  387 + }
  388 +
  389 +}
0 390 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/proj4phpDatum.php 0 → 100644
... ... @@ -0,0 +1,401 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4js from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +
  10 +/** datum object
  11 + */
  12 +class proj4phpDatum {
  13 +
  14 + public $datum_type;
  15 + public $datum_params;
  16 +
  17 + /**
  18 + *
  19 + * @param type $proj
  20 + */
  21 + public function __construct( $proj ) {
  22 +
  23 + $this->datum_type = Proj4php::$common->PJD_WGS84; //default setting
  24 +
  25 + if( isset($proj->datumCode) && $proj->datumCode == 'none' ) {
  26 + $this->datum_type = Proj4php::$common->PJD_NODATUM;
  27 + }
  28 +
  29 + if( isset( $proj->datum_params ) ) {
  30 +
  31 + for( $i = 0; $i < sizeof( $proj->datum_params ); $i++ ) {
  32 + $proj->datum_params[$i] = floatval( $proj->datum_params[$i] );
  33 + }
  34 +
  35 + if( $proj->datum_params[0] != 0 || $proj->datum_params[1] != 0 || $proj->datum_params[2] != 0 ) {
  36 + $this->datum_type = Proj4php::$common->PJD_3PARAM;
  37 + }
  38 +
  39 + if( sizeof( $proj->datum_params ) > 3 ) {
  40 + if( $proj->datum_params[3] != 0 || $proj->datum_params[4] != 0 ||
  41 + $proj->datum_params[5] != 0 || $proj->datum_params[6] != 0 ) {
  42 +
  43 + $this->datum_type = Proj4php::$common->PJD_7PARAM;
  44 + $proj->datum_params[3] *= Proj4php::$common->SEC_TO_RAD;
  45 + $proj->datum_params[4] *= Proj4php::$common->SEC_TO_RAD;
  46 + $proj->datum_params[5] *= Proj4php::$common->SEC_TO_RAD;
  47 + $proj->datum_params[6] = ($proj->datum_params[6] / 1000000.0) + 1.0;
  48 + }
  49 + }
  50 +
  51 + $this->datum_params = $proj->datum_params;
  52 + }
  53 + if( isset( $proj ) ) {
  54 + $this->a = $proj->a; //datum object also uses these values
  55 + $this->b = $proj->b;
  56 + $this->es = $proj->es;
  57 + $this->ep2 = $proj->ep2;
  58 + #$this->datum_params = $proj->datum_params;
  59 + }
  60 + }
  61 +
  62 +
  63 + /**
  64 + *
  65 + * @param type $dest
  66 + * @return boolean Returns TRUE if the two datums match, otherwise FALSE.
  67 + * @throws type
  68 + */
  69 + public function compare_datums( $dest ) {
  70 +
  71 + if( $this->datum_type != $dest->datum_type ) {
  72 + return false; // false, datums are not equal
  73 + } else if( $this->a != $dest->a || abs( $this->es - $dest->es ) > 0.000000000050 ) {
  74 + // the tolerence for es is to ensure that GRS80 and WGS84
  75 + // are considered identical
  76 + return false;
  77 + } else if( $this->datum_type == Proj4php::$common->PJD_3PARAM ) {
  78 + return ($this->datum_params[0] == $dest->datum_params[0]
  79 + && $this->datum_params[1] == $dest->datum_params[1]
  80 + && $this->datum_params[2] == $dest->datum_params[2]);
  81 + } else if( $this->datum_type == Proj4php::$common->PJD_7PARAM ) {
  82 + return ($this->datum_params[0] == $dest->datum_params[0]
  83 + && $this->datum_params[1] == $dest->datum_params[1]
  84 + && $this->datum_params[2] == $dest->datum_params[2]
  85 + && $this->datum_params[3] == $dest->datum_params[3]
  86 + && $this->datum_params[4] == $dest->datum_params[4]
  87 + && $this->datum_params[5] == $dest->datum_params[5]
  88 + && $this->datum_params[6] == $dest->datum_params[6]);
  89 + } else if( $this->datum_type == Proj4php::$common->PJD_GRIDSHIFT ||
  90 + $dest->datum_type == Proj4php::$common->PJD_GRIDSHIFT ) {
  91 + throw(new Exception( "ERROR: Grid shift transformations are not implemented." ));
  92 + return false;
  93 + }
  94 +
  95 + return true; // datums are equal
  96 + }
  97 +
  98 + /*
  99 + * The function Convert_Geodetic_To_Geocentric converts geodetic coordinates
  100 + * (latitude, longitude, and height) to geocentric coordinates (X, Y, Z),
  101 + * according to the current ellipsoid parameters.
  102 + *
  103 + * Latitude : Geodetic latitude in radians (input)
  104 + * Longitude : Geodetic longitude in radians (input)
  105 + * Height : Geodetic height, in meters (input)
  106 + * X : Calculated Geocentric X coordinate, in meters (output)
  107 + * Y : Calculated Geocentric Y coordinate, in meters (output)
  108 + * Z : Calculated Geocentric Z coordinate, in meters (output)
  109 + *
  110 + */
  111 + public function geodetic_to_geocentric( $p ) {
  112 +
  113 + $Longitude = $p->x;
  114 + $Latitude = $p->y;
  115 + $Height = isset( $p->z ) ? $p->z : 0; //Z value not always supplied
  116 + $Error_Code = 0; // GEOCENT_NO_ERROR;
  117 +
  118 + /*
  119 + * * Don't blow up if Latitude is just a little out of the value
  120 + * * range as it may just be a rounding issue. Also removed longitude
  121 + * * test, it should be wrapped by cos() and sin(). NFW for PROJ.4, Sep/2001.
  122 + */
  123 + if( $Latitude < -Proj4php::$common->HALF_PI && $Latitude > -1.001 * Proj4php::$common->HALF_PI ) {
  124 + $Latitude = -Proj4php::$common->HALF_PI;
  125 + } else if( $Latitude > Proj4php::$common->HALF_PI && $Latitude < 1.001 * Proj4php::$common->HALF_PI ) {
  126 + $Latitude = Proj4php::$common->HALF_PI;
  127 + } else if( ($Latitude < -Proj4php::$common->HALF_PI) || ($Latitude > Proj4php::$common->HALF_PI) ) {
  128 + /* Latitude out of range */
  129 + Proj4php::reportError( 'geocent:lat out of range:' . $Latitude );
  130 + return null;
  131 + }
  132 +
  133 + if( $Longitude > Proj4php::$common->PI )
  134 + $Longitude -= (2 * Proj4php::$common->PI);
  135 +
  136 + $Sin_Lat = sin( $Latitude ); /* sin(Latitude) */
  137 + $Cos_Lat = cos( $Latitude ); /* cos(Latitude) */
  138 + $Sin2_Lat = $Sin_Lat * $Sin_Lat; /* Square of sin(Latitude) */
  139 + $Rn = $this->a / (sqrt( 1.0e0 - $this->es * $Sin2_Lat )); /* Earth radius at location */
  140 + $p->x = ($Rn + $Height) * $Cos_Lat * cos( $Longitude );
  141 + $p->y = ($Rn + $Height) * $Cos_Lat * sin( $Longitude );
  142 + $p->z = (($Rn * (1 - $this->es)) + $Height) * $Sin_Lat;
  143 +
  144 + return $Error_Code;
  145 + }
  146 +
  147 +
  148 + /**
  149 + *
  150 + * @param object $p
  151 + * @return type
  152 + */
  153 + public function geocentric_to_geodetic( $p ) {
  154 +
  155 + /* local defintions and variables */
  156 + /* end-criterium of loop, accuracy of sin(Latitude) */
  157 + $genau = 1.E-12;
  158 + $genau2 = ($genau * $genau);
  159 + $maxiter = 30;
  160 + $X = $p->x;
  161 + $Y = $p->y;
  162 + $Z = $p->z ? $p->z : 0.0; //Z value not always supplied
  163 +
  164 + /*
  165 + $P; // distance between semi-minor axis and location
  166 + $RR; // distance between center and location
  167 + $CT; // sin of geocentric latitude
  168 + $ST; // cos of geocentric latitude
  169 + $RX;
  170 + $RK;
  171 + $RN; // Earth radius at location
  172 + $CPHI0; // cos of start or old geodetic latitude in iterations
  173 + $SPHI0; // sin of start or old geodetic latitude in iterations
  174 + $CPHI; // cos of searched geodetic latitude
  175 + $SPHI; // sin of searched geodetic latitude
  176 + $SDPHI; // end-criterium: addition-theorem of sin(Latitude(iter)-Latitude(iter-1))
  177 + $At_Pole; // indicates location is in polar region
  178 + $iter; // of continous iteration, max. 30 is always enough (s.a.)
  179 + $Longitude;
  180 + $Latitude;
  181 + $Height;
  182 + */
  183 +
  184 + $At_Pole = false;
  185 + $P = sqrt( $X * $X + $Y * $Y );
  186 + $RR = sqrt( $X * $X + $Y * $Y + $Z * $Z );
  187 +
  188 + /* special cases for latitude and longitude */
  189 + if( $P / $this->a < $genau ) {
  190 +
  191 + /* special case, if P=0. (X=0., Y=0.) */
  192 + $At_Pole = true;
  193 + $Longitude = 0.0;
  194 +
  195 + /* if (X,Y,Z)=(0.,0.,0.) then Height becomes semi-minor axis
  196 + * of ellipsoid (=center of mass), Latitude becomes PI/2 */
  197 + if( $RR / $this->a < $genau ) {
  198 + $Latitude = Proj4php::$common->HALF_PI;
  199 + $Height = -$this->b;
  200 + return;
  201 + }
  202 + } else {
  203 + /* ellipsoidal (geodetic) longitude
  204 + * interval: -PI < Longitude <= +PI */
  205 + $Longitude = atan2( $Y, $X );
  206 + }
  207 +
  208 + /* --------------------------------------------------------------
  209 + * Following iterative algorithm was developped by
  210 + * "Institut für Erdmessung", University of Hannover, July 1988.
  211 + * Internet: www.ife.uni-hannover.de
  212 + * Iterative computation of CPHI,SPHI and Height.
  213 + * Iteration of CPHI and SPHI to 10**-12 radian res$p->
  214 + * 2*10**-7 arcsec.
  215 + * --------------------------------------------------------------
  216 + */
  217 + $CT = $Z / $RR;
  218 + $ST = $P / $RR;
  219 + $RX = 1.0 / sqrt( 1.0 - $this->es * (2.0 - $this->es) * $ST * $ST );
  220 + $CPHI0 = $ST * (1.0 - $this->es) * $RX;
  221 + $SPHI0 = $CT * $RX;
  222 + $iter = 0;
  223 +
  224 + /* loop to find sin(Latitude) res$p-> Latitude
  225 + * until |sin(Latitude(iter)-Latitude(iter-1))| < genau */
  226 + do {
  227 + ++$iter;
  228 + $RN = $this->a / sqrt( 1.0 - $this->es * $SPHI0 * $SPHI0 );
  229 +
  230 + /* ellipsoidal (geodetic) height */
  231 + $Height = $P * $CPHI0 + $Z * $SPHI0 - $RN * (1.0 - $this->es * $SPHI0 * $SPHI0);
  232 +
  233 + $RK = $this->es * $RN / ($RN + $Height);
  234 + $RX = 1.0 / sqrt( 1.0 - $RK * (2.0 - $RK) * $ST * $ST );
  235 + $CPHI = $ST * (1.0 - $RK) * $RX;
  236 + $SPHI = $CT * $RX;
  237 + $SDPHI = $SPHI * $CPHI0 - $CPHI * $SPHI0;
  238 + $CPHI0 = $CPHI;
  239 + $SPHI0 = $SPHI;
  240 + } while( $SDPHI * $SDPHI > $genau2 && $iter < $maxiter );
  241 +
  242 + /* ellipsoidal (geodetic) latitude */
  243 + $Latitude = atan( $SPHI / abs( $CPHI ) );
  244 +
  245 + $p->x = $Longitude;
  246 + $p->y = $Latitude;
  247 + $p->z = $Height;
  248 +
  249 + return $p;
  250 + }
  251 +
  252 + /**
  253 + * Convert_Geocentric_To_Geodetic
  254 + * The method used here is derived from 'An Improved Algorithm for
  255 + * Geocentric to Geodetic Coordinate Conversion', by Ralph Toms, Feb 1996
  256 + *
  257 + * @param object Point $p
  258 + * @return object Point $p
  259 + */
  260 + public function geocentric_to_geodetic_noniter( $p ) {
  261 +
  262 + /*
  263 + $Longitude;
  264 + $Latitude;
  265 + $Height;
  266 +
  267 + $W; // distance from Z axis
  268 + $W2; // square of distance from Z axis
  269 + $T0; // initial estimate of vertical component
  270 + $T1; // corrected estimate of vertical component
  271 + $S0; // initial estimate of horizontal component
  272 + $S1; // corrected estimate of horizontal component
  273 + $Sin_B0; // sin(B0), B0 is estimate of Bowring aux variable
  274 + $Sin3_B0; // cube of sin(B0)
  275 + $Cos_B0; // cos(B0)
  276 + $Sin_p1; // sin(phi1), phi1 is estimated latitude
  277 + $Cos_p1; // cos(phi1)
  278 + $Rn; // Earth radius at location
  279 + $Sum; // numerator of cos(phi1)
  280 + $At_Pole; // indicates location is in polar region
  281 + */
  282 +
  283 + $X = floatval( $p->x ); // cast from string to float
  284 + $Y = floatval( $p->y );
  285 + $Z = floatval( $p->z ? $p->z : 0 );
  286 +
  287 + $At_Pole = false;
  288 + if( $X <> 0.0 ) {
  289 + $Longitude = atan2( $Y, $X );
  290 + } else {
  291 + if( $Y > 0 ) {
  292 + $Longitude = Proj4php::$common->HALF_PI;
  293 + } else if( Y < 0 ) {
  294 + $Longitude = -Proj4php::$common->HALF_PI;
  295 + } else {
  296 + $At_Pole = true;
  297 + $Longitude = 0.0;
  298 + if( $Z > 0.0 ) { /* north pole */
  299 + $Latitude = Proj4php::$common->HALF_PI;
  300 + } else if( Z < 0.0 ) { /* south pole */
  301 + $Latitude = -Proj4php::$common->HALF_PI;
  302 + } else { /* center of earth */
  303 + $Latitude = Proj4php::$common->HALF_PI;
  304 + $Height = -$this->b;
  305 + return;
  306 + }
  307 + }
  308 + }
  309 + $W2 = $X * $X + $Y * $Y;
  310 + $W = sqrt( $W2 );
  311 + $T0 = $Z * Proj4php::$common->AD_C;
  312 + $S0 = sqrt( $T0 * $T0 + $W2 );
  313 + $Sin_B0 = $T0 / $S0;
  314 + $Cos_B0 = $W / $S0;
  315 + $Sin3_B0 = $Sin_B0 * $Sin_B0 * $Sin_B0;
  316 + $T1 = $Z + $this->b * $this->ep2 * $Sin3_B0;
  317 + $Sum = $W - $this->a * $this->es * $Cos_B0 * $Cos_B0 * $Cos_B0;
  318 + $S1 = sqrt( $T1 * $T1 + $Sum * $Sum );
  319 + $Sin_p1 = $T1 / $S1;
  320 + $Cos_p1 = $Sum / $S1;
  321 + $Rn = $this->a / sqrt( 1.0 - $this->es * $Sin_p1 * $Sin_p1 );
  322 + if( $Cos_p1 >= Proj4php::$common->COS_67P5 ) {
  323 + $Height = $W / $Cos_p1 - $Rn;
  324 + } else if( $Cos_p1 <= -Proj4php::$common->COS_67P5 ) {
  325 + $Height = $W / -$Cos_p1 - $Rn;
  326 + } else {
  327 + $Height = $Z / $Sin_p1 + $Rn * ($this->es - 1.0);
  328 + }
  329 + if( $At_Pole == false ) {
  330 + $Latitude = atan( $Sin_p1 / $Cos_p1 );
  331 + }
  332 +
  333 + $p->x = $Longitude;
  334 + $p->y = $Latitude;
  335 + $p->z = $Height;
  336 +
  337 + return $p;
  338 + }
  339 +
  340 + /************************************************************** */
  341 + // pj_geocentic_to_wgs84( p )
  342 + // p = point to transform in geocentric coordinates (x,y,z)
  343 + public function geocentric_to_wgs84( $p ) {
  344 +
  345 + if( $this->datum_type == Proj4php::$common->PJD_3PARAM ) {
  346 + // if( x[io] == HUGE_VAL )
  347 + // continue;
  348 + $p->x += $this->datum_params[0];
  349 + $p->y += $this->datum_params[1];
  350 + $p->z += $this->datum_params[2];
  351 + } else if( $this->datum_type == Proj4php::$common->PJD_7PARAM ) {
  352 + $Dx_BF = $this->datum_params[0];
  353 + $Dy_BF = $this->datum_params[1];
  354 + $Dz_BF = $this->datum_params[2];
  355 + $Rx_BF = $this->datum_params[3];
  356 + $Ry_BF = $this->datum_params[4];
  357 + $Rz_BF = $this->datum_params[5];
  358 + $M_BF = $this->datum_params[6];
  359 + // if( x[io] == HUGE_VAL )
  360 + // continue;
  361 + $p->x = $M_BF * ( $p->x - $Rz_BF * $p->y + $Ry_BF * $p->z) + $Dx_BF;
  362 + $p->y = $M_BF * ( $Rz_BF * $p->x + $p->y - $Rx_BF * $p->z) + $Dy_BF;
  363 + $p->z = $M_BF * (-$Ry_BF * $p->x + $Rx_BF * $p->y + $p->z) + $Dz_BF;
  364 + }
  365 + }
  366 +
  367 + /*************************************************************** */
  368 +
  369 + // pj_geocentic_from_wgs84()
  370 + // coordinate system definition,
  371 + // point to transform in geocentric coordinates (x,y,z)
  372 + public function geocentric_from_wgs84( $p ) {
  373 +
  374 + if( $this->datum_type == Proj4php::$common->PJD_3PARAM ) {
  375 + //if( x[io] == HUGE_VAL )
  376 + // continue;
  377 + $p->x -= $this->datum_params[0];
  378 + $p->y -= $this->datum_params[1];
  379 + $p->z -= $this->datum_params[2];
  380 + } else if( $this->datum_type == Proj4php::$common->PJD_7PARAM ) {
  381 + $Dx_BF = $this->datum_params[0];
  382 + $Dy_BF = $this->datum_params[1];
  383 + $Dz_BF = $this->datum_params[2];
  384 + $Rx_BF = $this->datum_params[3];
  385 + $Ry_BF = $this->datum_params[4];
  386 + $Rz_BF = $this->datum_params[5];
  387 + $M_BF = $this->datum_params[6];
  388 + $x_tmp = ($p->x - $Dx_BF) / $M_BF;
  389 + $y_tmp = ($p->y - $Dy_BF) / $M_BF;
  390 + $z_tmp = ($p->z - $Dz_BF) / $M_BF;
  391 + //if( x[io] == HUGE_VAL )
  392 + // continue;
  393 +
  394 + $p->x = $x_tmp + $Rz_BF * $y_tmp - $Ry_BF * $z_tmp;
  395 + $p->y = -$Rz_BF * $x_tmp + $y_tmp + $Rx_BF * $z_tmp;
  396 + $p->z = $Ry_BF * $x_tmp - $Rx_BF * $y_tmp + $z_tmp;
  397 + } //cs_geocentric_from_wgs84()
  398 + }
  399 +
  400 +}
  401 +
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/proj4phpLongLat.php 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4js from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodmap.com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +class proj4phpLongLat {
  10 +
  11 + public function init() {
  12 +
  13 + }
  14 +
  15 + public function forward( $pt ) {
  16 + return $pt;
  17 + }
  18 +
  19 + public function inverse( $pt ) {
  20 + return $pt;
  21 + }
  22 +
  23 +}
0 24 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/proj4phpPoint.php 0 → 100644
... ... @@ -0,0 +1,86 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4js from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodmap.com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +
  10 +/**
  11 + * point object, nothing fancy, just allows values to be
  12 + * passed back and forth by reference rather than by value.
  13 + * Other point classes may be used as long as they have
  14 + * x and y properties, which will get modified in the transform method.
  15 +*/
  16 +class proj4phpPoint {
  17 +
  18 + public $x;
  19 + public $y;
  20 + public $z;
  21 +
  22 + /**
  23 + * Constructor: Proj4js.Point
  24 + *
  25 + * Parameters:
  26 + * - x {float} or {Array} either the first coordinates component or
  27 + * the full coordinates
  28 + * - y {float} the second component
  29 + * - z {float} the third component, optional.
  30 + */
  31 + public function __construct( $x = null, $y = null, $z = null ) {
  32 +
  33 + if( is_array( $x ) ) {
  34 + $this->x = $x[0];
  35 + $this->y = $x[1];
  36 + $this->z = isset($x[2]) ? $x[2] : 0.0;#(count( $x ) > 2) ? $x[2] : 0.0;
  37 + } else if( is_string( $x ) && !is_numeric( $y ) ) {
  38 + $coord = explode( ' ', $x );
  39 + $this->x = floatval( $coord[0] );
  40 + $this->y = floatval( $coord[1] );
  41 + $this->z = (count( $coord ) > 2) ? floatval( $coord[2] ) : 0.0;
  42 + } else {
  43 + $this->x = $x !== null ? $x : 0.0;
  44 + $this->y = $y !== null ? $y : 0.0;
  45 + $this->z = $z !== null ? $z : 0.0;
  46 + }
  47 + }
  48 +
  49 + /**
  50 + * APIMethod: clone
  51 + * Build a copy of a Proj4js.Point object.
  52 + *
  53 + * renamed because of PHP keyword.
  54 + *
  55 + * Return:
  56 + * {Proj4js}.Point the cloned point.
  57 + */
  58 + public function __clone() {
  59 + return new Proj4phpPoint( $this->x, $this->y, $this->z );
  60 + }
  61 +
  62 + /**
  63 + * APIMethod: toString
  64 + * Return a readable string version of the point
  65 + *
  66 + * Return:
  67 + * {String} String representation of Proj4js.Point object.
  68 + * (ex. <i>"x=5,y=42"</i>)
  69 + */
  70 + public function toString() {
  71 + return "x=" . $this->x . ",y=" . $this->y;
  72 + }
  73 +
  74 + /**
  75 + * APIMethod: toShortString
  76 + * Return a short string version of the point.
  77 + *
  78 + * Return:
  79 + * {String} Shortened String representation of Proj4js.Point object.
  80 + * (ex. <i>"5, 42"</i>)
  81 + */
  82 + public function toShortString() {
  83 + return $this->x . " " . $this->y;
  84 + }
  85 +
  86 +}
0 87 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/proj4phpProj.php 0 → 100644
... ... @@ -0,0 +1,638 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4js from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodmap.com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +class Proj4phpProj {
  10 +
  11 + /**
  12 + * Property: readyToUse
  13 + * Flag to indicate if initialization is complete for $this Proj object
  14 + */
  15 + public $readyToUse = false;
  16 +
  17 + /**
  18 + * Property: title
  19 + * The title to describe the projection
  20 + */
  21 + public $title = null;
  22 +
  23 + /**
  24 + * Property: projName
  25 + * The projection class for $this projection, e.g. lcc (lambert conformal conic,
  26 + * or merc for mercator). These are exactly equivalent to their Proj4
  27 + * counterparts.
  28 + */
  29 + public $projName = null;
  30 +
  31 + /**
  32 + * Property: projection
  33 + * The projection object for $this projection. */
  34 + public $projection = null;
  35 +
  36 + /**
  37 + * Property: units
  38 + * The units of the projection. Values include 'm' and 'degrees'
  39 + */
  40 + public $units = null;
  41 +
  42 + /**
  43 + * Property: datum
  44 + * The datum specified for the projection
  45 + */
  46 + public $datum = null;
  47 +
  48 + /**
  49 + * Property: x0
  50 + * The x coordinate origin
  51 + */
  52 + public $x0 = 0;
  53 +
  54 + /**
  55 + * Property: y0
  56 + * The y coordinate origin
  57 + */
  58 + public $y0 = 0;
  59 +
  60 + /**
  61 + * Property: localCS
  62 + * Flag to indicate if the projection is a local one in which no transforms
  63 + * are required.
  64 + */
  65 + public $localCS = false;
  66 +
  67 + /**
  68 + *
  69 + * @var type
  70 + */
  71 + protected $wktRE = '/^(\w+)\[(.*)\]$/';
  72 +
  73 + /**
  74 + * Constructor: initialize
  75 + * Constructor for Proj4php::Proj objects
  76 + *
  77 + * Parameters:
  78 + * $srsCode - a code for map projection definition parameters. These are usually
  79 + * (but not always) EPSG codes.
  80 + */
  81 + public function __construct( $srsCode ) {
  82 +
  83 + $this->srsCodeInput = $srsCode;
  84 + //check to see if $this is a WKT string
  85 + if( (strpos( $srsCode, 'GEOGCS' ) !== false) ||
  86 + (strpos( $srsCode, 'GEOCCS' ) !== false) ||
  87 + (strpos( $srsCode, 'PROJCS' ) !== false) ||
  88 + (strpos( $srsCode, 'LOCAL_CS' ) !== false) ) {
  89 + $this->parseWKT( $srsCode );
  90 + $this->deriveConstants();
  91 + $this->loadProjCode( $this->projName );
  92 + return;
  93 + }
  94 +
  95 + // DGR 2008-08-03 : support urn and url
  96 + if( strpos( $srsCode, 'urn:' ) === 0 ) {
  97 + //urn:ORIGINATOR:def:crs:CODESPACE:VERSION:ID
  98 + $urn = explode( ':', $srsCode );
  99 + if( ($urn[1] == 'ogc' || $urn[1] == 'x-ogc') &&
  100 + ($urn[2] == 'def') &&
  101 + ($urn[3] == 'crs') ) {
  102 + $srsCode = $urn[4] . ':' . $urn[strlen( $urn ) - 1];
  103 + }
  104 + } else if( strpos( $srsCode, 'http://' ) === 0 ) {
  105 + //url#ID
  106 + $url = explode( '#', $srsCode );
  107 + if( preg_match( "/epsg.org/", $url[0] ) ) {
  108 + // http://www.epsg.org/#
  109 + $srsCode = 'EPSG:' . $url[1];
  110 + } else if( preg_match( "/RIG.xml/", $url[0] ) ) {
  111 + //http://librairies.ign.fr/geoportail/resources/RIG.xml#
  112 + //http://interop.ign.fr/registers/ign/RIG.xml#
  113 + $srsCode = 'IGNF:' . $url[1];
  114 + }
  115 + }
  116 + $this->srsCode = strtoupper( $srsCode );
  117 + if( strpos( $this->srsCode, "EPSG" ) === 0 ) {
  118 + $this->srsCode = $this->srsCode;
  119 + $this->srsAuth = 'epsg';
  120 + $this->srsProjNumber = substr( $this->srsCode, 5 );
  121 + // DGR 2007-11-20 : authority IGNF
  122 + } else if( strpos( $this->srsCode, "IGNF" ) === 0 ) {
  123 + $this->srsCode = $this->srsCode;
  124 + $this->srsAuth = 'IGNF';
  125 + $this->srsProjNumber = substr( $this->srsCode, 5 );
  126 + // DGR 2008-06-19 : pseudo-authority CRS for WMS
  127 + } else if( strpos( $this->srsCode, "CRS" ) === 0 ) {
  128 + $this->srsCode = $this->srsCode;
  129 + $this->srsAuth = 'CRS';
  130 + $this->srsProjNumber = substr( $this->srsCode, 4 );
  131 + } else {
  132 + $this->srsAuth = '';
  133 + $this->srsProjNumber = $this->srsCode;
  134 + }
  135 + $this->loadProjDefinition();
  136 + }
  137 +
  138 + /**
  139 + * Function: loadProjDefinition
  140 + * Loads the coordinate system initialization string if required.
  141 + * Note that dynamic loading happens asynchronously so an application must
  142 + * wait for the readyToUse property is set to true.
  143 + * To prevent dynamic loading, include the defs through a script tag in
  144 + * your application.
  145 + *
  146 + */
  147 + public function loadProjDefinition() {
  148 + //check in memory
  149 + if( array_key_exists( $this->srsCode, Proj4php::$defs ) ) {
  150 + $this->defsLoaded();
  151 + return;
  152 + }
  153 + //else check for def on the server
  154 + $filename = dirname( __FILE__ ) . '/defs/' . strtoupper( $this->srsAuth ) . $this->srsProjNumber . '.php';
  155 +
  156 + try {
  157 + Proj4php::loadScript( $filename );
  158 + $this->defsLoaded(); // succes
  159 +
  160 + } catch ( Exception $e ) {
  161 + $this->loadFromService(); // fail
  162 + }
  163 + }
  164 +
  165 + /**
  166 + * Function: loadFromService
  167 + * Creates the REST URL for loading the definition from a web service and
  168 + * loads it.
  169 + *
  170 + *
  171 + * DO IT AGAIN. : SHOULD PHP CODE BE GET BY WEBSERVICES ?
  172 + */
  173 + public function loadFromService() {
  174 +
  175 + //else load from web service
  176 + $url = Proj4php::$defsLookupService . '/' . $this->srsAuth . '/' . $this->srsProjNumber . '/proj4/';
  177 + try {
  178 + Proj4php::$defs[strtoupper($this->srsAuth) . ":" . $this->srsProjNumber] = Proj4php::loadScript( $url );
  179 + } catch ( Exception $e ) {
  180 + $this->defsFailed();
  181 + }
  182 + }
  183 +
  184 + /**
  185 + * Function: defsLoaded
  186 + * Continues the Proj object initilization once the def file is loaded
  187 + *
  188 + */
  189 + public function defsLoaded() {
  190 +
  191 + $this->parseDefs();
  192 +
  193 + $this->loadProjCode( $this->projName );
  194 + }
  195 +
  196 + /**
  197 + * Function: checkDefsLoaded
  198 + * $this is the loadCheck method to see if the def object exists
  199 + *
  200 + */
  201 + public function checkDefsLoaded() {
  202 + return isset(Proj4php::$defs[$this->srsCode]) && !empty(Proj4php::$defs[$this->srsCode]);
  203 + }
  204 +
  205 + /**
  206 + * Function: defsFailed
  207 + * Report an error in loading the defs file, but continue on using WGS84
  208 + *
  209 + */
  210 + public function defsFailed() {
  211 + Proj4php::reportError( 'failed to load projection definition for: ' . $this->srsCode );
  212 + Proj4php::$defs[$this->srsCode] = Proj4php::$defs['WGS84']; //set it to something so it can at least continue
  213 + $this->defsLoaded();
  214 + }
  215 +
  216 + /**
  217 + * Function: loadProjCode
  218 + * Loads projection class code dynamically if required.
  219 + * Projection code may be included either through a script tag or in
  220 + * a built version of proj4php
  221 + *
  222 + * An exception occurs if the projection is not found.
  223 + */
  224 + public function loadProjCode( $projName ) {
  225 + if( array_key_exists( $projName, Proj4php::$proj )) {
  226 + $this->initTransforms();
  227 + return;
  228 + }
  229 + //the filename for the projection code
  230 + $filename = dirname( __FILE__ ) . '/projCode/' . $projName . '.php';
  231 +
  232 + try {
  233 + Proj4php::loadScript( $filename );
  234 + $this->loadProjCodeSuccess( $projName );
  235 +
  236 + } catch ( Exception $e ) {
  237 + $this->loadProjCodeFailure( $projName );
  238 + }
  239 + }
  240 +
  241 + /**
  242 + * Function: loadProjCodeSuccess
  243 + * Loads any proj dependencies or continue on to final initialization.
  244 + *
  245 + */
  246 + public function loadProjCodeSuccess( $projName ) {
  247 +
  248 + if( isset(Proj4php::$proj[$projName]->dependsOn) && !empty(Proj4php::$proj[$projName]->dependsOn)) {
  249 + $this->loadProjCode( Proj4php::$proj[$projName]->dependsOn );
  250 + } else {
  251 + $this->initTransforms();
  252 + }
  253 + }
  254 +
  255 + /**
  256 + * Function: defsFailed
  257 + * Report an error in loading the proj file. Initialization of the Proj
  258 + * object has failed and the readyToUse flag will never be set.
  259 + *
  260 + */
  261 + public function loadProjCodeFailure( $projName ) {
  262 + Proj4php::reportError( "failed to find projection file for: " . $projName );
  263 + //TBD initialize with identity transforms so proj will still work?
  264 + }
  265 +
  266 + /**
  267 + * Function: checkCodeLoaded
  268 + * $this is the loadCheck method to see if the projection code is loaded
  269 + *
  270 + */
  271 + public function checkCodeLoaded( $projName ) {
  272 +
  273 + return isset(Proj4php::$proj[$projName]) && !empty(Proj4php::$proj[$projName]);
  274 + }
  275 +
  276 + /**
  277 + * Function: initTransforms
  278 + * Finalize the initialization of the Proj object
  279 + *
  280 + */
  281 + public function initTransforms() {
  282 + $this->projection = new Proj4php::$proj[$this->projName];
  283 + Proj4php::extend( $this->projection, $this );
  284 + // initiate depending class
  285 +
  286 + if( false !== ($dependsOn = isset($this->projection->dependsOn) && !empty($this->projection->dependsOn) ? $this->projection->dependsOn : false) )
  287 + {
  288 + Proj4php::extend( Proj4php::$proj[$dependsOn], $this->projection);
  289 + Proj4php::$proj[$dependsOn]->init();
  290 + Proj4php::extend( $this->projection, Proj4php::$proj[$dependsOn] );
  291 + }
  292 + $this->init();
  293 + $this->readyToUse = true;
  294 + }
  295 +
  296 + /**
  297 + *
  298 + */
  299 + public function init() {
  300 + $this->projection->init();
  301 + }
  302 +
  303 + /**
  304 + *
  305 + * @param type $pt
  306 + * @return type
  307 + */
  308 + public function forward( $pt ) {
  309 + return $this->projection->forward( $pt );
  310 + }
  311 +
  312 + /**
  313 + *
  314 + * @param type $pt
  315 + * @return type
  316 + */
  317 + public function inverse( $pt ) {
  318 + return $this->projection->inverse( $pt );
  319 + }
  320 +
  321 + /**
  322 + * Function: parseWKT
  323 + * Parses a WKT string to get initialization parameters
  324 + *
  325 + */
  326 + public function parseWKT( $wkt ) {
  327 +
  328 + if( false === ($match = preg_match( $this->wktRE, $wkt, $wktMatch )) )
  329 + return;
  330 +
  331 + $wktObject = $wktMatch[1];
  332 + $wktContent = $wktMatch[2];
  333 + $wktTemp = explode( ",", $wktContent );
  334 +
  335 + $wktName = (strtoupper($wktObject) == "TOWGS84") ? "TOWGS84" : array_shift( $wktTemp );
  336 + $wktName = preg_replace( '/^\"/', "", $wktName );
  337 + $wktName = preg_replace( '/\"$/', "", $wktName );
  338 +
  339 + /*
  340 + $wktContent = implode(",",$wktTemp);
  341 + $wktArray = explode("],",$wktContent);
  342 + for ($i=0; i<sizeof($wktArray)-1; ++$i) {
  343 + $wktArray[$i] .= "]";
  344 + }
  345 + */
  346 +
  347 + $wktArray = array();
  348 + $bkCount = 0;
  349 + $obj = "";
  350 +
  351 + foreach( $wktTemp as $token ) {
  352 +
  353 + $bkCount = substr_count($token, "[") - substr_count($token, "]");
  354 +
  355 + // ???
  356 + $obj .= $token;
  357 + if( $bkCount === 0 ) {
  358 + array_push( $wktArray, $obj );
  359 + $obj = "";
  360 + } else {
  361 + $obj .= ",";
  362 + }
  363 + }
  364 +
  365 + //do something based on the type of the wktObject being parsed
  366 + //add in variations in the spelling as required
  367 + switch( $wktObject ) {
  368 + case 'LOCAL_CS':
  369 + $this->projName = 'identity';
  370 + $this->localCS = true;
  371 + $this->srsCode = $wktName;
  372 + break;
  373 + case 'GEOGCS':
  374 + $this->projName = 'longlat';
  375 + $this->geocsCode = $wktName;
  376 + if( !$this->srsCode )
  377 + $this->srsCode = $wktName;
  378 + break;
  379 + case 'PROJCS':
  380 + $$this->srsCode = $wktName;
  381 + break;
  382 + case 'GEOCCS':
  383 + break;
  384 + case 'PROJECTION':
  385 + $this->projName = Proj4php::$wktProjections[$wktName];
  386 + break;
  387 + case 'DATUM':
  388 + $this->datumName = $wktName;
  389 + break;
  390 + case 'LOCAL_DATUM':
  391 + $this->datumCode = 'none';
  392 + break;
  393 + case 'SPHEROID':
  394 + $this->ellps = $wktName;
  395 + $this->a = floatval( array_shift( $wktArray ) );
  396 + $this->rf = floatval( array_shift( $wktArray ) );
  397 + break;
  398 + case 'PRIMEM':
  399 + $this->from_greenwich = floatval( array_shift( $wktArray ) ); //to radians?
  400 + break;
  401 + case 'UNIT':
  402 + $this->units = $wktName;
  403 + $this->unitsPerMeter = floatval( array_shift( $wktArray ) );
  404 + break;
  405 + case 'PARAMETER':
  406 + $name = strtolower( $wktName );
  407 + $value = floatval( array_shift( $wktArray ) );
  408 + //there may be many variations on the wktName values, add in case
  409 + //statements as required
  410 + switch( $name ) {
  411 + case 'false_easting':
  412 + $this->x0 = $value;
  413 + break;
  414 + case 'false_northing':
  415 + $this->y0 = $value;
  416 + break;
  417 + case 'scale_factor':
  418 + $this->k0 = $value;
  419 + break;
  420 + case 'central_meridian':
  421 + $this->long0 = $value * Proj4php::$common->D2R;
  422 + break;
  423 + case 'latitude_of_origin':
  424 + $this->lat0 = $value * Proj4php::$common->D2R;
  425 + break;
  426 + case 'more_here':
  427 + break;
  428 + default:
  429 + break;
  430 + }
  431 + break;
  432 + case 'TOWGS84':
  433 + $this->datum_params = $wktArray;
  434 + break;
  435 + //DGR 2010-11-12: AXIS
  436 + case 'AXIS':
  437 + $name = strtolower( $wktName );
  438 + $value = array_shift( $wktArray );
  439 + switch( $value ) {
  440 + case 'EAST' : $value = 'e';
  441 + break;
  442 + case 'WEST' : $value = 'w';
  443 + break;
  444 + case 'NORTH': $value = 'n';
  445 + break;
  446 + case 'SOUTH': $value = 's';
  447 + break;
  448 + case 'UP' : $value = 'u';
  449 + break;
  450 + case 'DOWN' : $value = 'd';
  451 + break;
  452 + case 'OTHER':
  453 + default : $value = ' ';
  454 + break; //FIXME
  455 + }
  456 + if( !$this->axis ) {
  457 + $this->axis = "enu";
  458 + }
  459 + switch( $name ) {
  460 + case 'X': $this->axis = $value . substr( $this->axis, 1, 2 );
  461 + break;
  462 + case 'Y': $this->axis = substr( $this->axis, 0, 1 ) . $value . substr( $this->axis, 2, 1 );
  463 + break;
  464 + case 'Z': $this->axis = substr( $this->axis, 0, 2 ) . $value;
  465 + break;
  466 + default : break;
  467 + }
  468 + case 'MORE_HERE':
  469 + break;
  470 + default:
  471 + break;
  472 + }
  473 +
  474 + foreach( $wktArray as $wktArrayContent )
  475 + $this->parseWKT( $wktArrayContent );
  476 + }
  477 +
  478 + /**
  479 + * Function: parseDefs
  480 + * Parses the PROJ.4 initialization string and sets the associated properties.
  481 + *
  482 + */
  483 + public function parseDefs() {
  484 +
  485 + $this->defData = Proj4php::$defs[$this->srsCode];
  486 + #$paramName;
  487 + #$paramVal;
  488 + if( !$this->defData ) {
  489 + return;
  490 + }
  491 + $paramArray = explode( "+", $this->defData );
  492 + for( $prop = 0; $prop < sizeof( $paramArray ); $prop++ ) {
  493 + if( strlen( $paramArray[$prop] ) == 0 )
  494 + continue;
  495 + $property = explode( "=", $paramArray[$prop] );
  496 + $paramName = strtolower( $property[0] );
  497 + if( sizeof( $property ) >= 2 ) {
  498 + $paramVal = $property[1];
  499 + }
  500 +
  501 + switch( trim( $paramName ) ) { // trim out spaces
  502 + case "": break; // throw away nameless parameter
  503 + case "title": $this->title = $paramVal;
  504 + break;
  505 + case "proj": $this->projName = trim( $paramVal );
  506 + break;
  507 + case "units": $this->units = trim( $paramVal );
  508 + break;
  509 + case "datum": $this->datumCode = trim( $paramVal );
  510 + break;
  511 + case "nadgrids": $this->nagrids = trim( $paramVal );
  512 + break;
  513 + case "ellps": $this->ellps = trim( $paramVal );
  514 + break;
  515 + case "a": $this->a = floatval( $paramVal );
  516 + break; // semi-major radius
  517 + case "b": $this->b = floatval( $paramVal );
  518 + break; // semi-minor radius
  519 + // DGR 2007-11-20
  520 + case "rf": $this->rf = floatval( paramVal );
  521 + break; // inverse flattening rf= a/(a-b)
  522 + case "lat_0": $this->lat0 = $paramVal * Proj4php::$common->D2R;
  523 + break; // phi0, central latitude
  524 + case "lat_1": $this->lat1 = $paramVal * Proj4php::$common->D2R;
  525 + break; //standard parallel 1
  526 + case "lat_2": $this->lat2 = $paramVal * Proj4php::$common->D2R;
  527 + break; //standard parallel 2
  528 + case "lat_ts": $this->lat_ts = $paramVal * Proj4php::$common->D2R;
  529 + break; // used in merc and eqc
  530 + case "lon_0": $this->long0 = $paramVal * Proj4php::$common->D2R;
  531 + break; // lam0, central longitude
  532 + case "alpha": $this->alpha = floatval( $paramVal ) * Proj4php::$common->D2R;
  533 + break; //for somerc projection
  534 + case "lonc": $this->longc = paramVal * Proj4php::$common->D2R;
  535 + break; //for somerc projection
  536 + case "x_0": $this->x0 = floatval( $paramVal );
  537 + break; // false easting
  538 + case "y_0": $this->y0 = floatval( $paramVal );
  539 + break; // false northing
  540 + case "k_0": $this->k0 = floatval( $paramVal );
  541 + break; // projection scale factor
  542 + case "k": $this->k0 = floatval( $paramVal );
  543 + break; // both forms returned
  544 + case "r_a": $this->R_A = true;
  545 + break; // sphere--area of ellipsoid
  546 + case "zone": $this->zone = intval( $paramVal, 10 );
  547 + break; // UTM Zone
  548 + case "south": $this->utmSouth = true;
  549 + break; // UTM north/south
  550 + case "towgs84": $this->datum_params = explode( ",", $paramVal );
  551 + break;
  552 + case "to_meter": $this->to_meter = floatval( $paramVal );
  553 + break; // cartesian scaling
  554 + case "from_greenwich": $this->from_greenwich = $paramVal * Proj4php::$common->D2R;
  555 + break;
  556 + // DGR 2008-07-09 : if pm is not a well-known prime meridian take
  557 + // the value instead of 0.0, then convert to radians
  558 + case "pm": $paramVal = trim( $paramVal );
  559 + $this->from_greenwich = Proj4php::$primeMeridian[$paramVal] ? Proj4php::$primeMeridian[$paramVal] : floatval( $paramVal );
  560 + $this->from_greenwich *= Proj4php::$common->D2R;
  561 + break;
  562 + // DGR 2010-11-12: axis
  563 + case "axis": $paramVal = trim( $paramVal );
  564 + $legalAxis = "ewnsud";
  565 + if( strlen( paramVal ) == 3 &&
  566 + strpos( $legalAxis, substr( $paramVal, 0, 1 ) ) !== false &&
  567 + strpos( $legalAxis, substr( $paramVal, 1, 1 ) ) !== false &&
  568 + strpos( $legalAxis, substr( $paramVal, 2, 1 ) ) !== false ) {
  569 + $this->axis = $paramVal;
  570 + } //FIXME: be silent ?
  571 + break;
  572 + case "no_defs": break;
  573 + default: //alert("Unrecognized parameter: " . paramName);
  574 + } // switch()
  575 + } // for paramArray
  576 + $this->deriveConstants();
  577 + }
  578 +
  579 + /**
  580 + * Function: deriveConstants
  581 + * Sets several derived constant values and initialization of datum and ellipse parameters.
  582 + *
  583 + */
  584 + public function deriveConstants() {
  585 +
  586 + if( isset( $this->nagrids ) && $this->nagrids == '@null' )
  587 + $this->datumCode = 'none';
  588 +
  589 + if( isset( $this->datumCode ) && $this->datumCode != 'none' ) {
  590 +
  591 + $datumDef = Proj4php::$datum[$this->datumCode];
  592 +
  593 + if( is_array($datumDef ) ) {
  594 + $this->datum_params = array_key_exists( 'towgs84', $datumDef ) ? explode( ',', $datumDef['towgs84'] ) : null;
  595 + $this->ellps = $datumDef['ellipse'];
  596 + $this->datumName = array_key_exists( 'datumName', $datumDef ) ? $datumDef['datumName'] : $this->datumCode;
  597 + }
  598 + }
  599 + if( !isset( $this->a ) ) { // do we have an ellipsoid?
  600 + if( !isset( $this->ellps ) || strlen( $this->ellps ) == 0 || !array_key_exists( $this->ellps, Proj4php::$ellipsoid ) )
  601 + $ellipse = Proj4php::$ellipsoid['WGS84'];
  602 + else {
  603 + $ellipse = Proj4php::$ellipsoid[$this->ellps];
  604 + }
  605 +
  606 + Proj4php::extend( $this, $ellipse );
  607 + }
  608 +
  609 + if( isset( $this->rf ) && !isset( $this->b ) )
  610 + $this->b = (1.0 - 1.0 / $this->rf) * $this->a;
  611 +
  612 + if ( (isset($this->rf) && $this->rf === 0) || abs($this->a - $this->b) < Proj4php::$common->EPSLN) {
  613 + $this->sphere = true;
  614 + $this->b = $this->a;
  615 + }
  616 + $this->a2 = $this->a * $this->a; // used in geocentric
  617 + $this->b2 = $this->b * $this->b; // used in geocentric
  618 + $this->es = ($this->a2 - $this->b2) / $this->a2; // e ^ 2
  619 + $this->e = sqrt( $this->es ); // eccentricity
  620 + if( isset( $this->R_A ) ) {
  621 + $this->a *= 1. - $this->es * (Proj4php::$common->SIXTH + $this->es * (Proj4php::$common->RA4 + $this->es * Proj4php::$common->RA6));
  622 + $this->a2 = $this->a * $this->a;
  623 + $this->b2 = $this->b * $this->b;
  624 + $this->es = 0.0;
  625 + }
  626 + $this->ep2 = ($this->a2 - $this->b2) / $this->b2; // used in geocentric
  627 + if( !isset( $this->k0 ) )
  628 + $this->k0 = 1.0; //default value
  629 +
  630 + //DGR 2010-11-12: axis
  631 + if( !isset( $this->axis ) ) {
  632 + $this->axis = "enu";
  633 + }
  634 +
  635 + $this->datum = new Proj4phpDatum( $this );
  636 + }
  637 +
  638 +}
0 639 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/aea.php 0 → 100644
... ... @@ -0,0 +1,184 @@
  1 +<?php
  2 +/*******************************************************************************
  3 + NAME ALBERS CONICAL EQUAL AREA
  4 +
  5 + PURPOSE: Transforms input longitude and latitude to Easting and Northing
  6 + for the Albers Conical Equal Area projection. The longitude
  7 + and latitude must be in radians. The Easting and Northing
  8 + values will be returned in meters.
  9 +
  10 + PROGRAMMER DATE
  11 + ---------- ----
  12 + T. Mittan, Feb, 1992
  13 +
  14 + ALGORITHM REFERENCES
  15 +
  16 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  17 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  18 + State Government Printing Office, Washington D.C., 1987.
  19 +
  20 + 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  21 + U.S. Geological Survey Professional Paper 1453 , United State Government
  22 + Printing Office, Washington D.C., 1989.
  23 + *******************************************************************************/
  24 +
  25 +/**
  26 + * Author : Julien Moquet
  27 + *
  28 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  29 + * and Richard Greenwood rich@greenwoodma$p->com
  30 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  31 + */
  32 +class Proj4phpProjAea {
  33 +
  34 + /**
  35 + *
  36 + * @return void
  37 + */
  38 + public function init() {
  39 +
  40 + if( abs( $this->lat1 + $this->lat2 ) < Proj4php::$common->EPSLN ) {
  41 + Proj4php::reportError( "aeaInitEqualLatitudes" );
  42 + return;
  43 + }
  44 + $this->temp = $this->b / $this->a;
  45 + $this->es = 1.0 - pow( $this->temp, 2 );
  46 + $this->e3 = sqrt( $this->es );
  47 +
  48 + $this->sin_po = sin( $this->lat1 );
  49 + $this->cos_po = cos( $this->lat1 );
  50 + $this->t1 = $this->sin_po;
  51 + $this->con = $this->sin_po;
  52 + $this->ms1 = Proj4php::$common->msfnz( $this->e3, $this->sin_po, $this->cos_po );
  53 + $this->qs1 = Proj4php::$common->qsfnz( $this->e3, $this->sin_po, $this->cos_po );
  54 +
  55 + $this->sin_po = sin( $this->lat2 );
  56 + $this->cos_po = cos( $this->lat2 );
  57 + $this->t2 = $this->sin_po;
  58 + $this->ms2 = Proj4php::$common->msfnz( $this->e3, $this->sin_po, $this->cos_po );
  59 + $this->qs2 = Proj4php::$common->qsfnz( $this->e3, $this->sin_po, $this->cos_po );
  60 +
  61 + $this->sin_po = sin( $this->lat0 );
  62 + $this->cos_po = cos( $this->lat0 );
  63 + $this->t3 = $this->sin_po;
  64 + $this->qs0 = Proj4php::$common->qsfnz( $this->e3, $this->sin_po, $this->cos_po );
  65 +
  66 + if( abs( $this->lat1 - $this->lat2 ) > Proj4php::$common->EPSLN ) {
  67 + $this->ns0 = ($this->ms1 * $this->ms1 - $this->ms2 * $this->ms2) / ($this->qs2 - $this->qs1);
  68 + } else {
  69 + $this->ns0 = $this->con;
  70 + }
  71 +
  72 + $this->c = $this->ms1 * $this->ms1 + $this->ns0 * $this->qs1;
  73 + $this->rh = $this->a * sqrt( $this->c - $this->ns0 * $this->qs0 ) / $this->ns0;
  74 + }
  75 +
  76 + /**
  77 + * Albers Conical Equal Area forward equations--mapping lat,long to x,y
  78 + *
  79 + * @param Point $p
  80 + * @return Point $p
  81 + */
  82 + public function forward( $p ) {
  83 +
  84 + $lon = $p->x;
  85 + $lat = $p->y;
  86 +
  87 + $this->sin_phi = sin( $lat );
  88 + $this->cos_phi = cos( $lat );
  89 +
  90 + $qs = Proj4php::$common->qsfnz( $this->e3, $this->sin_phi, $this->cos_phi );
  91 + $rh1 = $this->a * sqrt( $this->c - $this->ns0 * $qs ) / $this->ns0;
  92 + $theta = $this->ns0 * Proj4php::$common->adjust_lon( $lon - $this->long0 );
  93 + $x = rh1 * sin( $theta ) + $this->x0;
  94 + $y = $this->rh - $rh1 * cos( $theta ) + $this->y0;
  95 +
  96 + $p->x = $x;
  97 + $p->y = $y;
  98 +
  99 + return $p;
  100 + }
  101 +
  102 + /**
  103 + *
  104 + * @param Point $p
  105 + * @return Point $p
  106 + */
  107 + public function inverse( $p ) {
  108 +
  109 + $p->x -= $this->x0;
  110 + $p->y = $this->rh - $p->y + $this->y0;
  111 +
  112 + if( $this->ns0 >= 0 ) {
  113 + $rh1 = sqrt( $p->x * $p->x + $p->y * $p->y );
  114 + $con = 1.0;
  115 + } else {
  116 + $rh1 = -sqrt( $p->x * $p->x + $p->y * $p->y );
  117 + $con = -1.0;
  118 + }
  119 +
  120 + $theta = 0.0;
  121 + if( $rh1 != 0.0 ) {
  122 + $theta = atan2( $con * $p->x, $con * $p->y );
  123 + }
  124 +
  125 + $con = $rh1 * $this->ns0 / $this->a;
  126 + $qs = ($this->c - $con * $con) / $this->ns0;
  127 +
  128 + if( $this->e3 >= 1e-10 ) {
  129 + $con = 1 - .5 * (1.0 - $this->es) * log( (1.0 - $this->e3) / (1.0 + $this->e3) ) / $this->e3;
  130 + if( abs( abs( $con ) - abs( $qs ) ) > .0000000001 ) {
  131 + $lat = $this->phi1z( $this->e3, $qs );
  132 + } else {
  133 + if( $qs >= 0 ) {
  134 + $lat = .5 * Proj4php::$common->PI;
  135 + } else {
  136 + $lat = -.5 * Proj4php::$common->PI;
  137 + }
  138 + }
  139 + } else {
  140 + $lat = $this->phi1z( $this->e3, $qs );
  141 + }
  142 +
  143 + $lon = Proj4php::$common->adjust_lon( $theta / $this->ns0 + $this->long0 );
  144 +
  145 + $p->x = $lon;
  146 + $p->y = $lat;
  147 +
  148 + return $p;
  149 + }
  150 +
  151 + /**
  152 + * Function to compute phi1, the latitude for the inverse of the Albers Conical Equal-Area projection.
  153 + *
  154 + * @param type $eccent
  155 + * @param type $qs
  156 + * @return $phi or null on Convergence error
  157 + */
  158 + public function phi1z( $eccent, $qs ) {
  159 +
  160 + $phi = Proj4php::$common->asinz( .5 * $qs );
  161 +
  162 + if( $eccent < Proj4php::$common->EPSLN )
  163 + return $phi;
  164 +
  165 + $eccnts = $eccent * $eccent;
  166 + for( $i = 1; $i <= 25; ++$i ) {
  167 + $sinphi = sin( $phi );
  168 + $cosphi = cos( $phi );
  169 + $con = $eccent * $sinphi;
  170 + $com = 1.0 - $con * $con;
  171 + $dphi = .5 * $com * $com / $cosphi * ($qs / (1.0 - $eccnts) - $sinphi / $com + .5 / $eccent * log( (1.0 - $con) / (1.0 + $con) ));
  172 + $phi = $phi + $dphi;
  173 + if( abs( $dphi ) <= 1e-7 )
  174 + return $phi;
  175 + }
  176 +
  177 + Proj4php::reportError( "aea:phi1z:Convergence error" );
  178 +
  179 + return null;
  180 + }
  181 +
  182 +}
  183 +
  184 +Proj4php::$proj['aea'] = new Proj4phpProjAea();
0 185 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/aeqd.php 0 → 100644
... ... @@ -0,0 +1,101 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Author : Julien Moquet
  5 + *
  6 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  7 + * and Richard Greenwood rich@greenwoodma$p->com
  8 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  9 + */
  10 +class Proj4phpProjAeqd {
  11 +
  12 + public function init() {
  13 + $this->sin_p12 = sin( $this->lat0 );
  14 + $this->cos_p12 = cos( $this->lat0 );
  15 + }
  16 +
  17 + /**
  18 + *
  19 + * @param type $p
  20 + * @return type
  21 + */
  22 + public function forward( $p ) {
  23 +
  24 + #$lon = $p->x;
  25 + #$lat = $p->y;
  26 + #$ksp;
  27 +
  28 + $sinphi = sin( $p->y );
  29 + $cosphi = cos( $p->y );
  30 + $dlon = Proj4php::$common->adjust_lon( lon - $this->long0 );
  31 + $coslon = cos( $dlon );
  32 + $g = $this->sin_p12 * $sinphi + $this->cos_p12 * $cosphi * $coslon;
  33 + if( abs( abs( $g ) - 1.0 ) < Proj4php::$common->EPSLN ) {
  34 + $ksp = 1.0;
  35 + if( $g < 0.0 ) {
  36 + Proj4php::reportError( "aeqd:Fwd:PointError" );
  37 + return;
  38 + }
  39 + } else {
  40 + $z = acos( $g );
  41 + $ksp = $z / sin( $z );
  42 + }
  43 + $p->x = $this->x0 + $this->a * $ksp * $cosphi * sin( $dlon );
  44 + $p->y = $this->y0 + $this->a * $ksp * ($this->cos_p12 * $sinphi - $this->sin_p12 * $cosphi * $coslon);
  45 +
  46 + return $p;
  47 + }
  48 +
  49 + /**
  50 + *
  51 + * @param type $p
  52 + * @return type
  53 + */
  54 + public function inverse( $p ) {
  55 +
  56 + $p->x -= $this->x0;
  57 + $p->y -= $this->y0;
  58 +
  59 + $rh = sqrt( $p->x * $p->x + $p->y * $p->y );
  60 + if( $rh > (2.0 * Proj4php::$common->HALF_PI * $this->a) ) {
  61 + Proj4php::reportError( "aeqdInvDataError" );
  62 + return;
  63 + }
  64 + $z = $rh / $this->a;
  65 +
  66 + $sinz = sin( $z );
  67 + $cosz = cos( $z );
  68 +
  69 + $lon = $this->long0;
  70 + #$lat;
  71 + if( abs( $rh ) <= Proj4php::$common->EPSLN ) {
  72 + $lat = $this->lat0;
  73 + } else {
  74 + $lat = Proj4php::$common->asinz( $cosz * $this->sin_p12 + ($p->y * $sinz * $this->cos_p12) / $rh );
  75 + $con = abs( $this->lat0 ) - Proj4php::$common->HALF_PI;
  76 + if( abs( $con ) <= Proj4php::$common->EPSLN ) {
  77 + if( $this->lat0 >= 0.0 ) {
  78 + $lon = Proj4php::$common->adjust_lon( $this->long0 + atan2( $p->x, -$p->y ) );
  79 + } else {
  80 + $lon = Proj4php::$common->adjust_lon( $this->long0 - atan2( -$p->x, $p->y ) );
  81 + }
  82 + } else {
  83 + $con = $cosz - $this->sin_p12 * sin( $lat );
  84 + if( (abs( $con ) < Proj4php::$common->EPSLN) && (abs( $p->x ) < Proj4php::$common->EPSLN) ) {
  85 + //no-op, just keep the lon value as is
  86 + } else {
  87 + #$temp = atan2( ($p->x * $sinz * $this->cos_p12 ), ($con * $rh ) ); // $temp is unused !?!
  88 + $lon = Proj4php::$common->adjust_lon( $this->long0 + atan2( ($p->x * $sinz * $this->cos_p12 ), ($con * $rh ) ) );
  89 + }
  90 + }
  91 + }
  92 +
  93 + $p->x = $lon;
  94 + $p->y = $lat;
  95 +
  96 + return $p;
  97 + }
  98 +
  99 +}
  100 +
  101 +Proj4php::$proj['aeqd'] = new Proj4phpProjAeqd();
0 102 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/cass.php 0 → 100644
... ... @@ -0,0 +1,118 @@
  1 +<?php
  2 +
  3 +/*******************************************************************************
  4 + NAME CASSINI
  5 +
  6 + PURPOSE: Transforms input longitude and latitude to Easting and
  7 + Northing for the Cassini projection. The
  8 + longitude and latitude must be in radians. The Easting
  9 + and Northing values will be returned in meters.
  10 + Ported from PROJ.4.
  11 +
  12 +
  13 + ALGORITHM REFERENCES
  14 +
  15 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  16 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  17 + State Government Printing Office, Washington D.C., 1987.
  18 +
  19 + 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  20 + U.S. Geological Survey Professional Paper 1453 , United State Government
  21 + ****************************************************************************** */
  22 +
  23 +/**
  24 + * Author : Julien Moquet
  25 + *
  26 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  27 + * and Richard Greenwood rich@greenwoodma$p->com
  28 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  29 + */
  30 +//Proj4php.defs["EPSG:28191"] = "+proj=cass +lat_0=31.73409694444445 +lon_0=35.21208055555556 +x_0=170251.555 +y_0=126867.909 +a=6378300.789 +b=6356566.435 +towgs84=-275.722,94.7824,340.894,-8.001,-4.42,-11.821,1 +units=m +no_defs";
  31 +// Initialize the Cassini projection
  32 +// -----------------------------------------------------------------
  33 +
  34 +class Proj4phpProjCass {
  35 +
  36 + public function init() {
  37 + if( !$this->sphere ) {
  38 + $this->en = Proj4php::$common->pj_enfn( $this->es );
  39 + $this->m0 = Proj4php::$common->pj_mlfn( $this->lat0, sin( $this->lat0 ), cos( $this->lat0 ), $this->en );
  40 + }
  41 + }
  42 +
  43 + protected $C1 = .16666666666666666666;
  44 + protected $C2 = .00833333333333333333;
  45 + protected $C3 = .04166666666666666666;
  46 + protected $C4 = .33333333333333333333;
  47 + protected $C5 = .06666666666666666666;
  48 +
  49 + /* Cassini forward equations--mapping lat,long to x,y
  50 + ----------------------------------------------------------------------- */
  51 + public function forward( $p ) {
  52 +
  53 + /* Forward equations
  54 + ----------------- */
  55 + #$x;
  56 + #$y;
  57 + $lam = $p->x;
  58 + $phi = $p->y;
  59 + $lam = Proj4php::$common->adjust_lon( $lam - $this->long0 );
  60 +
  61 + if( $this->sphere ) {
  62 + $x = asin( cos( $phi ) * sin( $lam ) );
  63 + $y = atan2( tan( $phi ), cos( $lam ) ) - $this->phi0;
  64 + } else {
  65 + //ellipsoid
  66 + $this->n = sin( $phi );
  67 + $this->c = cos( $phi );
  68 + $y = $this->pj_mlfn( $phi, $this->n, $this->c, $this->en );
  69 + $this->n = 1. / sqrt( 1. - $this->es * $this->n * $this->n );
  70 + $this->tn = tan( $phi );
  71 + $this->t = $this->tn * $this->tn;
  72 + $this->a1 = $lam * $this->c;
  73 + $this->c *= $this->es * $this->c / (1 - $this->es);
  74 + $this->a2 = $this->a1 * $this->a1;
  75 + $x = $this->n * $this->a1 * (1. - $this->a2 * $this->t * ($this->C1 - (8. - $this->t + 8. * $this->c) * $this->a2 * $this->C2));
  76 + $y -= $this->m0 - $this->n * $this->tn * $this->a2 * (.5 + (5. - $this->t + 6. * $this->c) * $this->a2 * $this->C3);
  77 + }
  78 +
  79 + $p->x = $this->a * $x + $this->x0;
  80 + $p->y = $this->a * $y + $this->y0;
  81 +
  82 + return $p;
  83 + }
  84 +
  85 + /* Inverse equations
  86 + ----------------- */
  87 + public function inverse( $p ) {
  88 + $p->x -= $this->x0;
  89 + $p->y -= $this->y0;
  90 + $x = $p->x / $this->a;
  91 + $y = $p->y / $this->a;
  92 +
  93 + if( $this->sphere ) {
  94 + $this->dd = $y + $this->lat0;
  95 + $phi = asin( sin( $this->dd ) * cos( $x ) );
  96 + $lam = atan2( tan( $x ), cos( $this->dd ) );
  97 + } else {
  98 + /* ellipsoid */
  99 + $ph1 = Proj4php::$common->pj_inv_mlfn( $this->m0 + $y, $this->es, $this->en );
  100 + $this->tn = tan( $ph1 );
  101 + $this->t = $this->tn * $this->tn;
  102 + $this->n = sin( $ph1 );
  103 + $this->r = 1. / (1. - $this->es * $this->n * $this->n);
  104 + $this->n = sqrt( $this->r );
  105 + $this->r *= (1. - $this->es) * $this->n;
  106 + $this->dd = $x / $this->n;
  107 + $this->d2 = $this->dd * $this->dd;
  108 + $phi = $ph1 - ($this->n * $this->tn / $this->r) * $this->d2 * (.5 - (1. + 3. * $this->t) * $this->d2 * $this->C3);
  109 + $lam = $this->dd * (1. + $this->t * $this->d2 * (-$this->C4 + (1. + 3. * $this->t) * $this->d2 * $this->C5)) / cos( $ph1 );
  110 + }
  111 + $p->x = Proj4php::$common->adjust_lon( $this->long0 + $lam );
  112 + $p->y = $phi;
  113 +
  114 + return $p;
  115 + }
  116 +}
  117 +
  118 +Proj4php::$proj['cass'] = new Proj4phpProjCass();
0 119 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/cea.php 0 → 100644
... ... @@ -0,0 +1,97 @@
  1 +<?php
  2 +/*******************************************************************************
  3 + NAME LAMBERT CYLINDRICAL EQUAL AREA
  4 +
  5 + PURPOSE: Transforms input longitude and latitude to Easting and
  6 + Northing for the Lambert Cylindrical Equal Area projection.
  7 + This class of projection includes the Behrmann and
  8 + Gall-Peters Projections. The
  9 + longitude and latitude must be in radians. The Easting
  10 + and Northing values will be returned in meters.
  11 +
  12 + PROGRAMMER DATE
  13 + ---------- ----
  14 + R. Marsden August 2009
  15 + Winwaed Software Tech LLC, http://www.winwaed.com
  16 +
  17 + This function was adapted from the Miller Cylindrical Projection in the Proj4php
  18 + library.
  19 +
  20 + Note: This implementation assumes a Spherical Earth. The (commented) code
  21 + has been included for the ellipsoidal forward transform, but derivation of
  22 + the ellispoidal inverse transform is beyond me. Note that most of the
  23 + Proj4php implementations do NOT currently support ellipsoidal figures.
  24 + Therefore this is not seen as a problem - especially this lack of support
  25 + is explicitly stated here.
  26 +
  27 + ALGORITHM REFERENCES
  28 +
  29 + 1. "Cartographic Projection Procedures for the UNIX Environment -
  30 + A User's Manual" by Gerald I. Evenden, USGS Open File Report 90-284
  31 + and Release 4 Interim Reports (2003)
  32 +
  33 + 2. Snyder, John P., "Flattening the Earth - Two Thousand Years of Map
  34 + Projections", Univ. Chicago Press, 1993
  35 + ****************************************************************************** */
  36 +
  37 +/**
  38 + * Author : Julien Moquet
  39 + *
  40 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  41 + * and Richard Greenwood rich@greenwoodma$p->com
  42 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  43 + */
  44 +class Proj4phpProjCea {
  45 + /* Initialize the Cylindrical Equal Area projection
  46 + ------------------------------------------- */
  47 +
  48 + public function init() {
  49 + //no-op
  50 + }
  51 +
  52 + /* Cylindrical Equal Area forward equations--mapping lat,long to x,y
  53 + ------------------------------------------------------------ */
  54 + public function forward( $p ) {
  55 +
  56 + $lon = $p->x;
  57 + $lat = $p->y;
  58 +
  59 + /* Forward equations
  60 + ----------------- */
  61 + $dlon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  62 + $x = $this->x0 + $this->a * $dlon * cos( $this->lat_ts );
  63 + $y = $this->y0 + $this->a * sin( $lat ) / cos( $this->lat_ts );
  64 + /* Elliptical Forward Transform
  65 + Not implemented due to a lack of a matchign inverse function
  66 + {
  67 + $Sin_Lat = sin(lat);
  68 + $Rn = $this->a * (sqrt(1.0e0 - $this->es * Sin_Lat * Sin_Lat ));
  69 + x = $this->x0 + $this->a * dlon * cos($this->lat_ts);
  70 + y = $this->y0 + Rn * sin(lat) / cos($this->lat_ts);
  71 + }
  72 + */
  73 +
  74 + $p->x = $x;
  75 + $p->y = $y;
  76 +
  77 + return $p;
  78 + }
  79 +
  80 + /**
  81 + * Cylindrical Equal Area inverse equations--mapping x,y to lat/long
  82 + *
  83 + * @param type $p
  84 + * @return type
  85 + */
  86 + public function inverse( $p ) {
  87 + $p->x -= $this->x0;
  88 + $p->y -= $this->y0;
  89 +
  90 + $p->x = Proj4php::$common->adjust_lon( $this->long0 + ($p->x / $this->a) / cos( $this->lat_ts ) );
  91 + $p->y = asin( ($p->y / $this->a) * cos( $this->lat_ts ) );
  92 +
  93 + return $p;
  94 + }
  95 +}
  96 +
  97 +Proj4php::$proj['cea'] = new Proj4phpProjCea();
0 98 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/eqc.php 0 → 100644
... ... @@ -0,0 +1,58 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/* similar to equi.js FIXME proj4 uses eqc */
  10 +class Proj4phpProjEqc {
  11 +
  12 + public function init() {
  13 +
  14 + if( !$this->x0 )
  15 + $this->x0 = 0;
  16 + if( !$this->y0 )
  17 + $this->y0 = 0;
  18 + if( !$this->lat0 )
  19 + $this->lat0 = 0;
  20 + if( !$this->long0 )
  21 + $this->long0 = 0;
  22 + if( !$this->lat_ts )
  23 + $this->lat_ts = 0;
  24 + if( !$this->title )
  25 + $this->title = "Equidistant Cylindrical (Plate Carre)";
  26 +
  27 + $this->rc = cos( $this->lat_ts );
  28 + }
  29 +
  30 + // forward equations--mapping lat,long to x,y
  31 + // -----------------------------------------------------------------
  32 + public function forward( $p ) {
  33 +
  34 + $lon = $p->x;
  35 + $lat = $p->y;
  36 +
  37 + $dlon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  38 + $dlat = Proj4php::$common->adjust_lat( $lat - $this->lat0 );
  39 + $p->x = $this->x0 + ($this->a * $dlon * $this->rc);
  40 + $p->y = $this->y0 + ($this->a * $dlat );
  41 + return $p;
  42 + }
  43 +
  44 + // inverse equations--mapping x,y to lat/long
  45 + // -----------------------------------------------------------------
  46 + public function inverse( $p ) {
  47 +
  48 + $x = $p->x;
  49 + $y = $p->y;
  50 +
  51 + $p->x = Proj4php::$common->adjust_lon( $this->long0 + (($x - $this->x0) / ($this->a * $this->rc)) );
  52 + $p->y = Proj4php::$common->adjust_lat( $this->lat0 + (($y - $this->y0) / ($this->a )) );
  53 + return $p;
  54 + }
  55 +
  56 +}
  57 +
  58 +Proj4php::$proj['eqc'] = new Proj4phpProjEqc();
0 59 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/eqdc.php 0 → 100644
... ... @@ -0,0 +1,152 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME EQUIDISTANT CONIC
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and Northing
  13 + for the Equidistant Conic projection. The longitude and
  14 + latitude must be in radians. The Easting and Northing values
  15 + will be returned in meters.
  16 +
  17 + PROGRAMMER DATE
  18 + ---------- ----
  19 + T. Mittan Mar, 1993
  20 +
  21 + ALGORITHM REFERENCES
  22 +
  23 + 1. Snyder, John $p->, "Map Projections--A Working Manual", U.S. Geological
  24 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  25 + State Government Printing Office, Washington D.C., 1987.
  26 +
  27 + 2. Snyder, John $p-> and Voxland, Philip M., "An Album of Map Projections",
  28 + U.S. Geological Survey Professional Paper 1453 , United State Government
  29 + Printing Office, Washington D.C., 1989.
  30 +*******************************************************************************/
  31 +
  32 +/* Variables common to all subroutines in this code file
  33 +-----------------------------------------------------*/
  34 +
  35 +class Proj4phpProjEqdc {
  36 +
  37 + /* Initialize the Equidistant Conic projection
  38 + ------------------------------------------ */
  39 + public function init() {
  40 +
  41 + /* Place parameters in static storage for common use
  42 + ------------------------------------------------- */
  43 + if( !$this->mode )
  44 + $this->mode = 0; //chosen default mode
  45 + $this->temp = $this->b / $this->a;
  46 + $this->es = 1.0 - pow( $this->temp, 2 );
  47 + $this->e = sqrt( $this->es );
  48 + $this->e0 = Proj4php::$common->e0fn( $this->es );
  49 + $this->e1 = Proj4php::$common->e1fn( $this->es );
  50 + $this->e2 = Proj4php::$common->e2fn( $this->es );
  51 + $this->e3 = Proj4php::$common->e3fn( $this->es );
  52 +
  53 + $this->sinphi = sin( $this->lat1 );
  54 + $this->cosphi = cos( $this->lat1 );
  55 +
  56 + $this->ms1 = Proj4php::$common->msfnz( $this->e, $this->sinphi, $this->cosphi );
  57 + $this->ml1 = Proj4php::$common->mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat1 );
  58 +
  59 + /* format B
  60 + --------- */
  61 + if( $this->mode != 0 ) {
  62 + if( abs( $this->lat1 + $this->lat2 ) < Proj4php::$common->EPSLN ) {
  63 + Proj4php::reportError( "eqdc:Init:EqualLatitudes" );
  64 + //return(81);
  65 + }
  66 + $this->sinphi = sin( $this->lat2 );
  67 + $this->cosphi = cos( $this->lat2 );
  68 +
  69 + $this->ms2 = Proj4php::$common->msfnz( $this->e, $this->sinphi, $this->cosphi );
  70 + $this->ml2 = Proj4php::$common->mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat2 );
  71 + if( abs( $this->lat1 - $this->lat2 ) >= Proj4php::$common->EPSLN ) {
  72 + $this->ns = ($this->ms1 - $this->ms2) / ($this->ml2 - $this->ml1);
  73 + } else {
  74 + $this->ns = $this->sinphi;
  75 + }
  76 + } else {
  77 + $this->ns = $this->sinphi;
  78 + }
  79 + $this->g = $this->ml1 + $this->ms1 / $this->ns;
  80 + $this->ml0 = Proj4php::$common->mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 );
  81 + $this->rh = $this->a * ($this->g - $this->ml0);
  82 + }
  83 +
  84 + /* Equidistant Conic forward equations--mapping lat,long to x,y
  85 + ----------------------------------------------------------- */
  86 + public function forward( $p ) {
  87 + $lon = $p->x;
  88 + $lat = $p->y;
  89 +
  90 + /* Forward equations
  91 + ----------------- */
  92 + $ml = Proj4php::$common->mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $lat );
  93 + $rh1 = $this->a * ($this->g - $ml);
  94 + $theta = $this->ns * Proj4php::$common->adjust_lon( $lon - $this->long0 );
  95 +
  96 + $x = $this->x0 + $rh1 * sin( $theta );
  97 + $y = $this->y0 + $this->rh - $rh1 * cos( $theta );
  98 + $p->x = $x;
  99 + $p->y = $y;
  100 +
  101 + return $p;
  102 + }
  103 +
  104 + /* Inverse equations
  105 + ----------------- */
  106 + public function inverse( $p ) {
  107 +
  108 + $p->x -= $this->x0;
  109 + $p->y = $this->rh - $p->y + $this->y0;
  110 +
  111 + if( $this->ns >= 0 ) {
  112 + $rh1 = sqrt( $p->x * $p->x + $p->y * $p->y );
  113 + $con = 1.0;
  114 + } else {
  115 + $rh1 = -sqrt( $p->x * $p->x + $p->y * $p->y );
  116 + $con = -1.0;
  117 + }
  118 + $theta = 0.0;
  119 + if( $rh1 != 0.0 )
  120 + $theta = atan2( $con * $p->x, $con * $p->y );
  121 + $ml = $this->g - $rh1 / $this->a;
  122 + $lat = $this->phi3z( $ml, $this->e0, $this->e1, $this->e2, $this->e3 );
  123 + $lon = Proj4php::$common->adjust_lon( $this->long0 + $theta / $this->ns );
  124 +
  125 + $p->x = $lon;
  126 + $p->y = $lat;
  127 +
  128 + return $p;
  129 + }
  130 +
  131 + /* Function to compute latitude, phi3, for the inverse of the Equidistant
  132 + Conic projection.
  133 + ----------------------------------------------------------------- */
  134 +
  135 + public function phi3z( $ml, $e0, $e1, $e2, $e3 ) {
  136 +
  137 + $phi = $ml;
  138 + for( $i = 0; $i < 15; $i++ ) {
  139 + $dphi = ($ml + $e1 * sin( 2.0 * $phi ) - $e2 * sin( 4.0 * $phi ) + $e3 * sin( 6.0 * $phi )) / $e0 - $phi;
  140 + $phi += $dphi;
  141 + if( abs( $dphi ) <= .0000000001 ) {
  142 + return $phi;
  143 + }
  144 + }
  145 +
  146 + Proj4php::reportError( "PHI3Z-CONV:Latitude failed to converge after 15 iterations" );
  147 +
  148 + return null;
  149 + }
  150 +}
  151 +
  152 +Proj4php::$proj['eqdc'] = new Proj4phpProjEqdc();
0 153 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/equi.php 0 → 100644
... ... @@ -0,0 +1,80 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME EQUIRECTANGULAR
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the Equirectangular projection. The
  14 + longitude and latitude must be in radians. The Easting
  15 + and Northing values will be returned in meters.
  16 +
  17 + PROGRAMMER DATE
  18 + ---------- ----
  19 + T. Mittan Mar, 1993
  20 +
  21 + ALGORITHM REFERENCES
  22 +
  23 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  24 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  25 + State Government Printing Office, Washington D.C., 1987.
  26 +
  27 + 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  28 + U.S. Geological Survey Professional Paper 1453 , United State Government
  29 + Printing Office, Washington D.C., 1989.
  30 + *******************************************************************************/
  31 +class Proj4phpProjEqui {
  32 +
  33 + public function init() {
  34 + if( !$this->x0 )
  35 + $this->x0 = 0;
  36 + if( !$this->y0 )
  37 + $this->y0 = 0;
  38 + if( !$this->lat0 )
  39 + $this->lat0 = 0;
  40 + if( !$this->long0 )
  41 + $this->long0 = 0;
  42 + ///$this->t2;
  43 + }
  44 +
  45 + /* Equirectangular forward equations--mapping lat,long to x,y
  46 + --------------------------------------------------------- */
  47 + public function forward( $p ) {
  48 +
  49 + $lon = $p->x;
  50 + $lat = $p->y;
  51 +
  52 + $dlon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  53 + $x = $this->x0 + $this->a * $dlon * cos( $this->lat0 );
  54 + $y = $this->y0 + $this->a * $lat;
  55 +
  56 + $this->t1 = $x;
  57 + $this->t2 = cos( $this->lat0 );
  58 + $p->x = $x;
  59 + $p->y = $y;
  60 + return $p;
  61 + }
  62 +
  63 + /* Equirectangular inverse equations--mapping x,y to lat/long
  64 + --------------------------------------------------------- */
  65 + public function inverse( $p ) {
  66 +
  67 + $p->x -= $this->x0;
  68 + $p->y -= $this->y0;
  69 + $lat = $p->y / $this->a;
  70 +
  71 + if( abs( $lat ) > Proj4php::$common->HALF_PI ) {
  72 + Proj4php::reportError( "equi:Inv:DataError" );
  73 + }
  74 + $lon = Proj4php::$common->adjust_lon( $this->long0 + $p->x / ($this->a * cos( $this->lat0 )) );
  75 + $p->x = $lon;
  76 + $p->y = $lat;
  77 + }
  78 +}
  79 +
  80 +Proj4php::$proj['equi'] = new Proj4phpProjEqui();
0 81 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/gauss.php 0 → 100644
... ... @@ -0,0 +1,74 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +class Proj4phpProjGauss {
  10 +
  11 + /**
  12 + *
  13 + */
  14 + public function init() {
  15 +
  16 + $sphi = sin( $this->lat0 );
  17 + $cphi = cos( $this->lat0 );
  18 + $cphi *= $cphi;
  19 + $this->rc = sqrt( 1.0 - $this->es ) / (1.0 - $this->es * $sphi * $sphi);
  20 + $this->C = sqrt( 1.0 + $this->es * $cphi * $cphi / (1.0 - $this->es) );
  21 + $this->phic0 = asin( $sphi / $this->C );
  22 + $this->ratexp = 0.5 * $this->C * $this->e;
  23 + $this->K = tan( 0.5 * $this->phic0 + Proj4php::$common->FORTPI ) / (pow( tan( 0.5 * $this->lat0 + Proj4php::$common->FORTPI ), $this->C ) * Proj4php::$common->srat( $this->e * $sphi, $this->ratexp ));
  24 + }
  25 +
  26 + /**
  27 + *
  28 + * @param type $p
  29 + * @return type
  30 + */
  31 + public function forward( $p ) {
  32 + $lon = $p->x;
  33 + $lat = $p->y;
  34 +
  35 + $p->y = 2.0 * atan( $this->K * pow( tan( 0.5 * $lat + Proj4php::$common->FORTPI ), $this->C ) * Proj4php::$common->srat( $this->e * sin( $lat ), $this->ratexp ) ) - Proj4php::$common->HALF_PI;
  36 + $p->x = $this->C * $lon;
  37 +
  38 + return $p;
  39 + }
  40 +
  41 + /**
  42 + *
  43 + * @param type $p
  44 + * @return null
  45 + */
  46 + public function inverse( $p ) {
  47 +
  48 + $DEL_TOL = 1e-14;
  49 + $lon = $p->x / $this->C;
  50 + $lat = $p->y;
  51 + $num = pow( tan( 0.5 * $lat + Proj4php::$common->FORTPI ) / $this->K, 1. / $this->C );
  52 +
  53 + for( $i = Proj4php::$common->MAX_ITER; $i > 0; --$i ) {
  54 + $lat = 2.0 * atan( $num * Proj4php::$common->srat( $this->e * sin( $p->y ), -0.5 * $this->e ) ) - Proj4php::$common->HALF_PI;
  55 + if( abs( $lat - $p->y ) < $DEL_TOL )
  56 + break;
  57 + $p->y = $lat;
  58 + }
  59 +
  60 + /* convergence failed */
  61 + if( !$i ) {
  62 + Proj4php::reportError( "gauss:inverse:convergence failed" );
  63 + return null;
  64 + }
  65 +
  66 + $p->x = $lon;
  67 + $p->y = $lat;
  68 +
  69 + return $p;
  70 + }
  71 +
  72 +}
  73 +
  74 +Proj4php::$proj['gauss'] = new Proj4phpProjGauss();
0 75 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/gnom.php 0 → 100644
... ... @@ -0,0 +1,145 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*****************************************************************************
  10 + NAME GNOMONIC
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the Gnomonic Projection.
  14 + Implementation based on the existing sterea and ortho
  15 + implementations.
  16 +
  17 + PROGRAMMER DATE
  18 + ---------- ----
  19 + Richard Marsden November 2009
  20 +
  21 + ALGORITHM REFERENCES
  22 +
  23 + 1. Snyder, John P., "Flattening the Earth - Two Thousand Years of Map
  24 + Projections", University of Chicago Press 1993
  25 +
  26 + 2. Wolfram Mathworld "Gnomonic Projection"
  27 + http://mathworld.wolfram.com/GnomonicProjection.html
  28 + Accessed: 12th November 2009
  29 +******************************************************************************/
  30 +
  31 +class Proj4phpProjGnom {
  32 +
  33 + /**
  34 + * Initialize the Gnomonic projection
  35 + *
  36 + * @todo $def not used in context...?
  37 + * @param type $def
  38 + */
  39 + public function init( $def ) {
  40 +
  41 + /* Place parameters in static storage for common use
  42 + ------------------------------------------------- */
  43 + $this->sin_p14 = sin( $this->lat0 );
  44 + $this->cos_p14 = cos( $this->lat0 );
  45 +
  46 + // Approximation for projecting points to the horizon (infinity)
  47 + $this->infinity_dist = 1000 * $this->a;
  48 + $this->rc = 1;
  49 + }
  50 +
  51 + /* Gnomonic forward equations--mapping lat,long to x,y
  52 + --------------------------------------------------- */
  53 + public function forward( $p ) {
  54 +
  55 + /*
  56 + $sinphi;
  57 + $cosphi; // sin and cos value
  58 + $dlon; // delta longitude value
  59 + $coslon; // cos of longitude
  60 + $ksp; // scale factor
  61 + $g;
  62 + */
  63 +
  64 + $lon = $p->x;
  65 + $lat = $p->y;
  66 + /* Forward equations
  67 + ----------------- */
  68 + $dlon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  69 +
  70 + $sinphi = sin( $lat );
  71 + $cosphi = cos( $lat );
  72 +
  73 + $coslon = cos( $dlon );
  74 + $g = $this->sin_p14 * $sinphi + $this->cos_p14 * $cosphi * $coslon;
  75 + $ksp = 1.0;
  76 +
  77 + if( (g > 0) || (abs( g ) <= Proj4php::$common->EPSLN) ) {
  78 + $x = $this->x0 + $this->a * $ksp * $cosphi * sin( $dlon ) / $g;
  79 + $y = $this->y0 + $this->a * $ksp * ($this->cos_p14 * $sinphi - $this->sin_p14 * $cosphi * $coslon) / $g;
  80 + } else {
  81 + Proj4php::reportError( "orthoFwdPointError" );
  82 +
  83 + // Point is in the opposing hemisphere and is unprojectable
  84 + // We still need to return a reasonable point, so we project
  85 + // to infinity, on a bearing
  86 + // equivalent to the northern hemisphere equivalent
  87 + // This is a reasonable approximation for short shapes and lines that
  88 + // straddle the horizon.
  89 +
  90 + $x = $this->x0 + $this->infinity_dist * $cosphi * sin( $dlon );
  91 + $y = $this->y0 + $this->infinity_dist * ($this->cos_p14 * $sinphi - $this->sin_p14 * $cosphi * $coslon);
  92 + }
  93 +
  94 + $p->x = $x;
  95 + $p->y = $y;
  96 +
  97 + return $p;
  98 + }
  99 +
  100 + /**
  101 + *
  102 + * @param type $p
  103 + * @return type
  104 + */
  105 + public function inverse( $p ) {
  106 +
  107 + /*
  108 + $rh; // Rho
  109 + $z; // angle
  110 + $sinc;
  111 + $cosc;
  112 + $c;
  113 + $lon;
  114 + $lat;
  115 + */
  116 +
  117 + /* Inverse equations
  118 + ----------------- */
  119 + $p->x = ($p->x - $this->x0) / $this->a;
  120 + $p->y = ($p->y - $this->y0) / $this->a;
  121 +
  122 + $p->x /= $this->k0;
  123 + $p->y /= $this->k0;
  124 +
  125 + if( ($rh = sqrt( $p->x * $p->x + $p->y * $p->y ) ) ) {
  126 + $c = atan2( $rh, $this->rc );
  127 + $sinc = sin( $c );
  128 + $cosc = cos( $c );
  129 +
  130 + $lat = Proj4php::$common->asinz( $cosc * $this->sin_p14 + ($p->y * $sinc * $this->cos_p14) / $rh );
  131 + $lon = atan2( $p->x * sinc, rh * $this->cos_p14 * $cosc - $p->y * $this->sin_p14 * $sinc );
  132 + $lon = Proj4php::$common->adjust_lon( $this->long0 + $lon );
  133 + } else {
  134 + $lat = $this->phic0;
  135 + $lon = 0.0;
  136 + }
  137 +
  138 + $p->x = $lon;
  139 + $p->y = $lat;
  140 +
  141 + return $p;
  142 + }
  143 +}
  144 +
  145 +Proj4php::$proj['gnom'] = new Proj4phpProjGnom();
0 146 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/gstmerc.php 0 → 100644
... ... @@ -0,0 +1,63 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +class Proj4phpProjGstmerc {
  10 +
  11 + public function init() {
  12 +
  13 + // array of: a, b, lon0, lat0, k0, x0, y0
  14 + $temp = $this->b / $this->a;
  15 + $this->e = sqrt( 1.0 - $temp * $temp );
  16 + $this->lc = $this->long0;
  17 + $this->rs = sqrt( 1.0 + $this->e * $this->e * pow( cos( $this->lat0 ), 4.0 ) / (1.0 - $this->e * $this->e) );
  18 + $sinz = sin( $this->lat0 );
  19 + $pc = asin( $sinz / $this->rs );
  20 + $sinzpc = sin( $pc );
  21 + $this->cp = Proj4php::$common->latiso( 0.0, $pc, $sinzpc ) - $this->rs * Proj4php::$common->latiso( $this->e, $this->lat0, $sinz );
  22 + $this->n2 = $this->k0 * $this->a * sqrt( 1.0 - $this->e * $this->e ) / (1.0 - $this->e * $this->e * $sinz * $sinz);
  23 + $this->xs = $this->x0;
  24 + $this->ys = $this->y0 - $this->n2 * $pc;
  25 +
  26 + if( !$this->title )
  27 + $this->title = "Gauss Schreiber transverse mercator";
  28 + }
  29 +
  30 + // forward equations--mapping lat,long to x,y
  31 + // -----------------------------------------------------------------
  32 + public function forward( $p ) {
  33 +
  34 + $lon = $p->x;
  35 + $lat = $p->y;
  36 +
  37 + $L = $this->rs * ($lon - $this->lc);
  38 + $Ls = $this->cp + ($this->rs * Proj4php::$common->latiso( $this->e, $lat, sin( $lat ) ));
  39 + $lat1 = asin( sin( $L ) / Proj4php::$common->cosh( $Ls ) );
  40 + $Ls1 = Proj4php::$common->latiso( 0.0, $lat1, sin( $lat1 ) );
  41 + $p->x = $this->xs + ($this->n2 * $Ls1);
  42 + $p->y = $this->ys + ($this->n2 * atan( Proj4php::$common->sinh( $Ls ) / cos( $L ) ));
  43 + return $p;
  44 + }
  45 +
  46 + // inverse equations--mapping x,y to lat/long
  47 + // -----------------------------------------------------------------
  48 + public function inverse( $p ) {
  49 +
  50 + $x = $p->x;
  51 + $y = $p->y;
  52 +
  53 + $L = atan( Proj4php::$common->sinh( ($x - $this->xs) / $this->n2 ) / cos( ($y - $this->ys) / $this->n2 ) );
  54 + $lat1 = asin( sin( ($y - $this->ys) / $this->n2 ) / Proj4php::$common->cosh( ($x - $this->xs) / $this->n2 ) );
  55 + $LC = Proj4php::$common->latiso( 0.0, $lat1, sin( $lat1 ) );
  56 + $p->x = $this->lc + $L / $this->rs;
  57 + $p->y = Proj4php::$common->invlatiso( $this->e, ($LC - $this->cp) / $this->rs );
  58 + return $p;
  59 + }
  60 +
  61 +}
  62 +
  63 +Proj4php::$proj['gstmerc'] = new Proj4phpProjGestmerc();
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/krovak.php 0 → 100644
... ... @@ -0,0 +1,157 @@
  1 +<?php
  2 +
  3 +/**
  4 + NOTES: According to EPSG the full Krovak projection method should have
  5 + the following parameters. Within PROJ.4 the azimuth, and pseudo
  6 + standard parallel are hardcoded in the algorithm and can't be
  7 + altered from outside. The others all have defaults to match the
  8 + common usage with Krovak projection.
  9 +
  10 + lat_0 = latitude of centre of the projection
  11 +
  12 + lon_0 = longitude of centre of the projection
  13 +
  14 + * * = azimuth (true) of the centre line passing through the centre of the projection
  15 +
  16 + * * = latitude of pseudo standard parallel
  17 +
  18 + k = scale factor on the pseudo standard parallel
  19 +
  20 + x_0 = False Easting of the centre of the projection at the apex of the cone
  21 +
  22 + y_0 = False Northing of the centre of the projection at the apex of the cone
  23 +
  24 +**/
  25 +class Proj4phpProjKrovak {
  26 +
  27 + /**
  28 + *
  29 + */
  30 + public function init() {
  31 + /* we want Bessel as fixed ellipsoid */
  32 + $this->a = 6377397.155;
  33 + $this->es = 0.006674372230614;
  34 + $this->e = sqrt( $this->es );
  35 + /* if latitude of projection center is not set, use 49d30'N */
  36 + if( !$this->lat0 ) {
  37 + $this->lat0 = 0.863937979737193;
  38 + }
  39 + if( !$this->long0 ) {
  40 + $this->long0 = 0.7417649320975901 - 0.308341501185665;
  41 + }
  42 + /* if scale not set default to 0.9999 */
  43 + if( !$this->k0 ) {
  44 + $this->k0 = 0.9999;
  45 + }
  46 + $this->s45 = 0.785398163397448; /* 45° */
  47 + $this->s90 = 2 * $this->s45;
  48 + $this->fi0 = $this->lat0; /* Latitude of projection centre 49° 30' */
  49 + /* Ellipsoid Bessel 1841 a = 6377397.155m 1/f = 299.1528128,
  50 + e2=0.006674372230614;
  51 + */
  52 + $this->e2 = $this->es; /* 0.006674372230614; */
  53 + $this->e = sqrt( $this->e2 );
  54 + $this->alfa = sqrt( 1. + ($this->e2 * pow( cos( $this->fi0 ), 4 )) / (1. - $this->e2) );
  55 + $this->uq = 1.04216856380474; /* DU(2, 59, 42, 42.69689) */
  56 + $this->u0 = asin( sin( $this->fi0 ) / $this->alfa );
  57 + $this->g = pow( (1. + $this->e * sin( $this->fi0 )) / (1. - $this->e * sin( $this->fi0 )), $this->alfa * $this->e / 2. );
  58 + $this->k = tan( $this->u0 / 2. + $this->s45 ) / pow( tan( $this->fi0 / 2. + $this->s45 ), $this->alfa ) * $this->g;
  59 + $this->k1 = $this->k0;
  60 + $this->n0 = $this->a * sqrt( 1. - $this->e2 ) / (1. - $this->e2 * pow( sin( $this->fi0 ), 2 ));
  61 + $this->s0 = 1.37008346281555; /* Latitude of pseudo standard parallel 78° 30'00" N */
  62 + $this->n = sin( $this->s0 );
  63 + $this->ro0 = $this->k1 * $this->n0 / tan( $this->s0 );
  64 + $this->ad = $this->s90 - $this->uq;
  65 + $this->czech = true; /* Always use czech GIS coordinates -> negative ones */
  66 + }
  67 +
  68 + /**
  69 + * ellipsoid
  70 + * calculate xy from lat/lon
  71 + * Constants, identical to inverse transform function
  72 + *
  73 + * @param type $p
  74 + * @return type
  75 + */
  76 + public function forward( $p ) {
  77 +
  78 + $lon = $p->x;
  79 + $lat = $p->y;
  80 + $delta_lon = Proj4php::$common->adjust_lon( $lon - $this->long0 ); // Delta longitude
  81 +
  82 + /* Transformation */
  83 + $gfi = pow( ((1. + $this->e * sin( $lat )) / (1. - $this->e * sin( $lat )) ), ($this->alfa * $this->e / 2. ) );
  84 + $u = 2. * (atan( $this->k * pow( tan( $lat / 2. + $this->s45 ), $this->alfa ) / $gfi ) - $this->s45);
  85 + $deltav = - $delta_lon * $this->alfa;
  86 + $s = asin( cos( $this->ad ) * sin( $u ) + sin( $this->ad ) * cos( $u ) * cos( $deltav ) );
  87 + $d = asin( cos( $u ) * sin( $deltav ) / cos( $s ) );
  88 + $eps = $this->n * $d;
  89 + $ro = $this->ro0 * pow( tan( $this->s0 / 2. + $this->s45 ), $this->n ) / pow( tan( $s / 2. + $this->s45 ), $this->n );
  90 + /* x and y are reverted! */
  91 + //$p->y = ro * cos(eps) / a;
  92 + //$p->x = ro * sin(eps) / a;
  93 + $p->y = $ro * cos( $eps ) / 1.0;
  94 + $p->x = $ro * sin( $eps ) / 1.0;
  95 +
  96 + if( $this->czech ) {
  97 + $p->y *= -1.0;
  98 + $p->x *= -1.0;
  99 + }
  100 +
  101 + return $p;
  102 + }
  103 +
  104 + /**
  105 + * calculate lat/lon from xy
  106 + *
  107 + * @param Point $p
  108 + * @return Point $p
  109 + */
  110 + public function inverse( $p ) {
  111 +
  112 + /* Transformation */
  113 + /* revert y, x */
  114 + $tmp = $p->x;
  115 + $p->x = $p->y;
  116 + $p->y = $tmp;
  117 +
  118 + if( $this->czech ) {
  119 + $p->y *= -1.0;
  120 + $p->x *= -1.0;
  121 + }
  122 +
  123 + $ro = sqrt( $p->x * $p->x + $p->y * $p->y );
  124 + $eps = atan2( $p->y, $p->x );
  125 + $d = $eps / sin( $this->s0 );
  126 + $s = 2. * (atan( pow( $this->ro0 / $ro, 1. / $this->n ) * tan( $this->s0 / 2. + $this->s45 ) ) - $this->s45);
  127 + $u = asin( cos( $this->ad ) * sin( $s ) - sin( $this->ad ) * cos( $s ) * cos( $d ) );
  128 + $deltav = asin( cos( $s ) * sin( $d ) / cos( $u ) );
  129 + $p->x = $this->long0 - $deltav / $this->alfa;
  130 +
  131 + /* ITERATION FOR $lat */
  132 + $fi1 = $u;
  133 + $ok = 0;
  134 + $iter = 0;
  135 + do {
  136 + $p->y = 2. * ( atan( pow( $this->k, -1. / $this->alfa ) *
  137 + pow( tan( $u / 2. + $this->s45 ), 1. / $this->alfa ) *
  138 + pow( (1. + $this->e * sin( $fi1 )) / (1. - $this->e * sin( $fi1 )), $this->e / 2. )
  139 + ) - $this->s45);
  140 + if( abs( $fi1 - $p->y ) < 0.0000000001 )
  141 + $ok = 1;
  142 + $fi1 = $p->y;
  143 + $iter += 1;
  144 + } while( $ok == 0 && $iter < 15 );
  145 +
  146 + if( $iter >= 15 ) {
  147 + Proj4php::reportError( "PHI3Z-CONV:Latitude failed to converge after 15 iterations" );
  148 + //console.log('iter:', iter);
  149 + return null;
  150 + }
  151 +
  152 + return $p;
  153 + }
  154 +
  155 +}
  156 +
  157 +Proj4php::$proj['krovak'] = new Proj4phpProjKrovak();
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/laea.php 0 → 100644
... ... @@ -0,0 +1,398 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Author : Julien Moquet
  5 + *
  6 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  7 + * and Richard Greenwood rich@greenwoodma$p->com
  8 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  9 + */
  10 +/* * *****************************************************************************
  11 + NAME LAMBERT AZIMUTHAL EQUAL-AREA
  12 +
  13 + PURPOSE: Transforms input longitude and latitude to Easting and
  14 + Northing for the Lambert Azimuthal Equal-Area projection. The
  15 + longitude and latitude must be in radians. The Easting
  16 + and Northing values will be returned in meters.
  17 +
  18 + PROGRAMMER DATE
  19 + ---------- ----
  20 + D. Steinwand, EROS March, 1991
  21 +
  22 + This function was adapted from the Lambert Azimuthal Equal Area projection
  23 + code (FORTRAN) in the General Cartographic Transformation Package software
  24 + which is available from the U.S. Geological Survey National Mapping Division.
  25 +
  26 + ALGORITHM REFERENCES
  27 +
  28 + 1. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
  29 + The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
  30 +
  31 + 2. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  32 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  33 + State Government Printing Office, Washington D.C., 1987.
  34 +
  35 + 3. "Software Documentation for GCTP General Cartographic Transformation
  36 + Package", U.S. Geological Survey National Mapping Division, May 1982.
  37 + * ***************************************************************************** */
  38 +
  39 +class Proj4phpProjLaea {
  40 +
  41 + protected $S_POLE = 1;
  42 + protected $N_POLE = 2;
  43 + protected $EQUIT = 3;
  44 + protected $OBLIQ = 4;
  45 +
  46 + protected $P00 = .33333333333333333333;
  47 + protected $P01 = .17222222222222222222;
  48 + protected $P02 = .10257936507936507936;
  49 + protected $P10 = .06388888888888888888;
  50 + protected $P11 = .06640211640211640211;
  51 + protected $P20 = .01641501294219154443;
  52 +
  53 + /* Initialize the Lambert Azimuthal Equal Area projection
  54 + ------------------------------------------------------ */
  55 + public function init() {
  56 + $t = abs( $this->lat0 );
  57 + if( abs( $t - Proj4php::$common->HALF_PI ) < Proj4php::$common->EPSLN ) {
  58 + $this->mode = $this->lat0 < 0. ? $this->S_POLE : $this->N_POLE;
  59 + } else if( abs( $t ) < Proj4php::$common->EPSLN ) {
  60 + $this->mode = $this->EQUIT;
  61 + } else {
  62 + $this->mode = $this->OBLIQ;
  63 + }
  64 + if( $this->es > 0 ) {
  65 + #$sinphi;
  66 +
  67 + $this->qp = Proj4php::$common->qsfnz( $this->e, 1.0 );
  68 + $this->mmf = .5 / (1. - $this->es);
  69 + $this->apa = $this->authset( $this->es );
  70 + switch( $this->mode ) {
  71 + case $this->N_POLE:
  72 + case $this->S_POLE:
  73 + $this->dd = 1.;
  74 + break;
  75 + case $this->EQUIT:
  76 + $this->rq = sqrt( .5 * $this->qp );
  77 + $this->dd = 1. / $this->rq;
  78 + $this->xmf = 1.;
  79 + $this->ymf = .5 * $this->qp;
  80 + break;
  81 + case $this->OBLIQ:
  82 + $this->rq = sqrt( .5 * $this->qp );
  83 + $sinphi = sin( $this->lat0 );
  84 + $this->sinb1 = Proj4php::$common->qsfnz( $this->e, $sinphi ) / $this->qp;
  85 + $this->cosb1 = sqrt( 1. - $this->sinb1 * $this->sinb1 );
  86 + $this->dd = cos( $this->lat0 ) / (sqrt( 1. - $this->es * $sinphi * $sinphi ) * $this->rq * $this->cosb1);
  87 + $this->ymf = ($this->xmf = $this->rq) / $this->dd;
  88 + $this->xmf *= $this->dd;
  89 + break;
  90 + }
  91 + } else {
  92 + if( $this->mode == $this->OBLIQ ) {
  93 + $this->sinph0 = sin( $this->lat0 );
  94 + $this->cosph0 = cos( $this->lat0 );
  95 + }
  96 + }
  97 + }
  98 +
  99 + /* Lambert Azimuthal Equal Area forward equations--mapping lat,long to x,y
  100 + ----------------------------------------------------------------------- */
  101 + public function forward( $p ) {
  102 +
  103 + /* Forward equations
  104 + ----------------- */
  105 + #$x;
  106 + #$y;
  107 + $lam = $p->x;
  108 + $phi = $p->y;
  109 + $lam = Proj4php::$common->adjust_lon( $lam - $this->long0 );
  110 +
  111 + if( $this->sphere ) {
  112 + /*
  113 + $coslam;
  114 + $cosphi;
  115 + $sinphi;
  116 + */
  117 +
  118 + $sinphi = sin( $phi );
  119 + $cosphi = cos( $phi );
  120 + $coslam = cos( $lam );
  121 + switch( $this->mode ) {
  122 + case $this->OBLIQ:
  123 + case $this->EQUIT:
  124 + $y = ($this->mode == $this->EQUIT) ? 1. + $cosphi * $coslam : 1. + $this->sinph0 * $sinphi + $this->cosph0 * $cosphi * $coslam;
  125 + if( y <= Proj4php::$common->EPSLN ) {
  126 + Proj4php::reportError( "laea:fwd:y less than eps" );
  127 + return null;
  128 + }
  129 + $y = sqrt( 2. / $y );
  130 + $x = $y * cosphi * sin( $lam );
  131 + $y *= ($this->mode == $this->EQUIT) ? $sinphi : $this->cosph0 * $sinphi - $this->sinph0 * $cosphi * $coslam;
  132 + break;
  133 + case $this->N_POLE:
  134 + $coslam = -$coslam;
  135 + case $this->S_POLE:
  136 + if( abs( $phi + $this->phi0 ) < Proj4php::$common->EPSLN ) {
  137 + Proj4php::reportError( "laea:fwd:phi < eps" );
  138 + return null;
  139 + }
  140 + $y = Proj4php::$common->FORTPI - $phi * .5;
  141 + $y = 2. * (($this->mode == $this->S_POLE) ? cos( $y ) : sin( $y ));
  142 + $x = $y * sin( $lam );
  143 + $y *= $coslam;
  144 + break;
  145 + }
  146 + } else {
  147 + /*
  148 + $coslam;
  149 + $sinlam;
  150 + $sinphi;
  151 + $q;
  152 + */
  153 + $sinb = 0.0;
  154 + $cosb = 0.0;
  155 + $b = 0.0;
  156 +
  157 + $coslam = cos( $lam );
  158 + $sinlam = sin( $lam );
  159 + $sinphi = sin( $phi );
  160 + $q = Proj4php::$common->qsfnz( $this->e, $sinphi );
  161 + if( $this->mode == $this->OBLIQ || $this->mode == $this->EQUIT ) {
  162 + $sinb = $q / $this->qp;
  163 + $cosb = sqrt( 1. - $sinb * $sinb );
  164 + }
  165 + switch( $this->mode ) {
  166 + case $this->OBLIQ:
  167 + $b = 1. + $this->sinb1 * $sinb + $this->cosb1 * $cosb * $coslam;
  168 + break;
  169 + case $this->EQUIT:
  170 + $b = 1. + $cosb * $coslam;
  171 + break;
  172 + case $this->N_POLE:
  173 + $b = Proj4php::$common->HALF_PI + $phi;
  174 + $q = $this->qp - $q;
  175 + break;
  176 + case $this->S_POLE:
  177 + $b = $phi - Proj4php::$common->HALF_PI;
  178 + $q = $this->qp + $q;
  179 + break;
  180 + }
  181 + if( abs( $b ) < Proj4php::$common->EPSLN ) {
  182 + Proj4php::reportError( "laea:fwd:b < eps" );
  183 + return null;
  184 + }
  185 + switch( $this->mode ) {
  186 + case $this->OBLIQ:
  187 + case $this->EQUIT:
  188 + $b = sqrt( 2. / $b );
  189 + if( $this->mode == $this->OBLIQ ) {
  190 + $y = $this->ymf * $b * ($this->cosb1 * $sinb - $this->sinb1 * $cosb * $coslam);
  191 + } else {
  192 + $y = ($b = sqrt( 2. / (1. + $cosb * $coslam) )) * $sinb * $this->ymf;
  193 + }
  194 + $x = $this->xmf * $b * $cosb * $sinlam;
  195 + break;
  196 + case $this->N_POLE:
  197 + case $this->S_POLE:
  198 + if( q >= 0. ) {
  199 + $x = ($b = sqrt( $q )) * $sinlam;
  200 + $y = $coslam * (($this->mode == $this->S_POLE) ? $b : -$b);
  201 + } else {
  202 + $x = $y = 0.;
  203 + }
  204 + break;
  205 + }
  206 + }
  207 +
  208 + //v 1.0
  209 + /*
  210 + $sin_lat=sin(lat);
  211 + $cos_lat=cos(lat);
  212 +
  213 + $sin_delta_lon=sin(delta_lon);
  214 + $cos_delta_lon=cos(delta_lon);
  215 +
  216 + $g =$this->sin_lat_o * sin_lat +$this->cos_lat_o * cos_lat * cos_delta_lon;
  217 + if (g == -1.0) {
  218 + Proj4php::reportError("laea:fwd:Point projects to a circle of radius "+ 2.0 * R);
  219 + return null;
  220 + }
  221 + $ksp = $this->a * sqrt(2.0 / (1.0 + g));
  222 + $x = ksp * cos_lat * sin_delta_lon + $this->x0;
  223 + $y = ksp * ($this->cos_lat_o * sin_lat - $this->sin_lat_o * cos_lat * cos_delta_lon) + $this->y0;
  224 + */
  225 + $p->x = $this->a * $x + $this->x0;
  226 + $p->y = $this->a * $y + $this->y0;
  227 +
  228 + return $p;
  229 + }
  230 +
  231 + /* Inverse equations
  232 + ----------------- */
  233 + public function inverse( $p ) {
  234 + $p->x -= $this->x0;
  235 + $p->y -= $this->y0;
  236 + $x = $p->x / $this->a;
  237 + $y = $p->y / $this->a;
  238 +
  239 + if( $this->sphere ) {
  240 + $cosz = 0.0;
  241 + #$rh;
  242 + $sinz = 0.0;
  243 +
  244 + $rh = sqrt( $x * $x + $y * $y );
  245 + $phi = $rh * .5;
  246 + if( $phi > 1. ) {
  247 + Proj4php::reportError( "laea:Inv:DataError" );
  248 + return null;
  249 + }
  250 + $phi = 2. * asin( $phi );
  251 + if( $this->mode == $this->OBLIQ || $this->mode == $this->EQUIT ) {
  252 + $sinz = sin( $phi );
  253 + $cosz = cos( $phi );
  254 + }
  255 + switch( $this->mode ) {
  256 + case $this->EQUIT:
  257 + $phi = (abs( $rh ) <= Proj4php::$common->EPSLN) ? 0. : asin( $y * $sinz / $rh );
  258 + $x *= $sinz;
  259 + $y = $cosz * $rh;
  260 + break;
  261 + case $this->OBLIQ:
  262 + $phi = (abs( $rh ) <= Proj4php::$common->EPSLN) ? $this->phi0 : asin( $cosz * $this->sinph0 + $y * $sinz * $this->cosph0 / $rh );
  263 + $x *= $sinz * $this->cosph0;
  264 + $y = ($cosz - sin( $phi ) * $this->sinph0) * $rh;
  265 + break;
  266 + case $this->N_POLE:
  267 + $y = -$y;
  268 + $phi = Proj4php::$common->HALF_PI - $phi;
  269 + break;
  270 + case $this->S_POLE:
  271 + $phi -= Proj4php::$common->HALF_PI;
  272 + break;
  273 + }
  274 + $lam = ($y == 0. && ($this->mode == $this->EQUIT || $this->mode == $this->OBLIQ)) ? 0. : atan2( $x, $y );
  275 + } else {
  276 + /*
  277 + $cCe;
  278 + $sCe;
  279 + $q;
  280 + $rho;
  281 + */
  282 + $ab = 0.0;
  283 +
  284 + switch( $this->mode ) {
  285 + case $this->EQUIT:
  286 + case $this->OBLIQ:
  287 + $x /= $this->dd;
  288 + $y *= $this->dd;
  289 + $rho = sqrt( $x * $x + $y * $y );
  290 + if( $rho < Proj4php::$common->EPSLN ) {
  291 + $p->x = 0.;
  292 + $p->y = $this->phi0;
  293 + return $p;
  294 + }
  295 + $sCe = 2. * asin( .5 * $rho / $this->rq );
  296 + $cCe = cos( $sCe );
  297 + $x *= ($sCe = sin( $sCe ));
  298 + if( $this->mode == $this->OBLIQ ) {
  299 + $ab = $cCe * $this->sinb1 + $y * $sCe * $this->cosb1 / $rho;
  300 + $q = $this->qp * $ab;
  301 + $y = $rho * $this->cosb1 * $cCe - $y * $this->sinb1 * $sCe;
  302 + } else {
  303 + $ab = $y * $sCe / $rho;
  304 + $q = $this->qp * $ab;
  305 + $y = $rho * $cCe;
  306 + }
  307 + break;
  308 + case $this->N_POLE:
  309 + $y = -$y;
  310 + case $this->S_POLE:
  311 + $q = ($x * $x + $y * $y);
  312 + if( !$q ) {
  313 + $p->x = 0.;
  314 + $p->y = $this->phi0;
  315 + return $p;
  316 + }
  317 + /*
  318 + q = $this->qp - q;
  319 + */
  320 + $ab = 1. - $q / $this->qp;
  321 + if( $this->mode == $this->S_POLE ) {
  322 + $ab = - $ab;
  323 + }
  324 + break;
  325 + }
  326 + $lam = atan2( $x, $y );
  327 + $phi = $this->authlat( asin( $ab ), $this->apa );
  328 + }
  329 +
  330 + /*
  331 + $Rh = sqrt($p->x *$p->x +$p->y * $p->y);
  332 + $temp = Rh / (2.0 * $this->a);
  333 +
  334 + if (temp > 1) {
  335 + Proj4php::reportError("laea:Inv:DataError");
  336 + return null;
  337 + }
  338 +
  339 + $z = 2.0 * Proj4php::$common.asinz(temp);
  340 + $sin_z=sin(z);
  341 + $cos_z=cos(z);
  342 +
  343 + $lon =$this->long0;
  344 + if (abs(Rh) > Proj4php::$common->EPSLN) {
  345 + $lat = Proj4php::$common.asinz($this->sin_lat_o * cos_z +$this-> cos_lat_o * sin_z *$p->y / Rh);
  346 + $temp =abs($this->lat0) - Proj4php::$common->HALF_PI;
  347 + if (abs(temp) > Proj4php::$common->EPSLN) {
  348 + temp = cos_z -$this->sin_lat_o * sin(lat);
  349 + if(temp!=0.0) lon=Proj4php::$common->adjust_lon($this->long0+atan2($p->x*sin_z*$this->cos_lat_o,temp*Rh));
  350 + } else if ($this->lat0 < 0.0) {
  351 + lon = Proj4php::$common->adjust_lon($this->long0 - atan2(-$p->x,$p->y));
  352 + } else {
  353 + lon = Proj4php::$common->adjust_lon($this->long0 + atan2($p->x, -$p->y));
  354 + }
  355 + } else {
  356 + lat = $this->lat0;
  357 + }
  358 + */
  359 + //return(OK);
  360 + $p->x = Proj4php::$common->adjust_lon( $this->long0 + $lam );
  361 + $p->y = $phi;
  362 + return $p;
  363 + }
  364 +
  365 + /**
  366 + * determine latitude from authalic latitude
  367 + *
  368 + * @param type $es
  369 + * @return type
  370 + */
  371 + public function authset( $es ) {
  372 + #$t;
  373 + $APA = array( );
  374 + $APA[0] = $es * $this->P00;
  375 + $t = $es * $es;
  376 + $APA[0] += $t * $this->P01;
  377 + $APA[1] = $t * $this->P10;
  378 + $t *= $es;
  379 + $APA[0] += $t * $this->P02;
  380 + $APA[1] += $t * $this->P11;
  381 + $APA[2] = $t * $this->P20;
  382 + return $APA;
  383 + }
  384 +
  385 + /**
  386 + *
  387 + * @param type $beta
  388 + * @param type $APA
  389 + * @return type
  390 + */
  391 + public function authlat( $beta, $APA ) {
  392 + $t = $beta + $beta;
  393 + return($beta + $APA[0] * sin( $t ) + $APA[1] * sin( $t + $t ) + $APA[2] * sin( $t + $t + $t ));
  394 + }
  395 +
  396 +}
  397 +
  398 +Proj4php::$proj['laea'] = new Proj4phpProjLaea();
0 399 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/lcc.php 0 → 100644
... ... @@ -0,0 +1,166 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME LAMBERT CONFORMAL CONIC
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the Lambert Conformal Conic projection. The
  14 + longitude and latitude must be in radians. The Easting
  15 + and Northing values will be returned in meters.
  16 +
  17 +
  18 + ALGORITHM REFERENCES
  19 +
  20 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  21 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  22 + State Government Printing Office, Washington D.C., 1987.
  23 +
  24 + 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  25 + U.S. Geological Survey Professional Paper 1453 , United State Government
  26 + *******************************************************************************/
  27 +
  28 +
  29 +//<2104> +proj=lcc +lat_1=10.16666666666667 +lat_0=10.16666666666667 +lon_0=-71.60561777777777 +k_0=1 +x0=-17044 +x0=-23139.97 +ellps=intl +units=m +no_defs no_defs
  30 +// Initialize the Lambert Conformal conic projection
  31 +// -----------------------------------------------------------------
  32 +//class Proj4phpProjlcc = Class.create();
  33 +class Proj4phpProjLcc {
  34 +
  35 + public function init() {
  36 + // array of: r_maj,r_min,lat1,lat2,c_lon,c_lat,false_east,false_north
  37 + //double c_lat; /* center latitude */
  38 + //double c_lon; /* center longitude */
  39 + //double lat1; /* first standard parallel */
  40 + //double lat2; /* second standard parallel */
  41 + //double r_maj; /* major axis */
  42 + //double r_min; /* minor axis */
  43 + //double false_east; /* x offset in meters */
  44 + //double false_north; /* y offset in meters */
  45 +
  46 + //if lat2 is not defined
  47 + if( !isset($this->lat2) ) {
  48 + $this->lat2 = $this->lat0;
  49 + }
  50 +
  51 + //if k0 is not defined
  52 + if( !isset($this->k0) )
  53 + $this->k0 = 1.0;
  54 +
  55 + // Standard Parallels cannot be equal and on opposite sides of the equator
  56 + if( abs( $this->lat1 + $this->lat2 ) < Proj4php::$common->EPSLN ) {
  57 + Proj4php::reportError( "lcc:init: Equal Latitudes" );
  58 + return;
  59 + }
  60 +
  61 + $temp = $this->b / $this->a;
  62 + $this->e = sqrt( 1.0 - $temp * $temp );
  63 +
  64 + $sin1 = sin( $this->lat1 );
  65 + $cos1 = cos( $this->lat1 );
  66 + $ms1 = Proj4php::$common->msfnz( $this->e, $sin1, $cos1 );
  67 + $ts1 = Proj4php::$common->tsfnz( $this->e, $this->lat1, $sin1 );
  68 +
  69 + $sin2 = sin( $this->lat2 );
  70 + $cos2 = cos( $this->lat2 );
  71 + $ms2 = Proj4php::$common->msfnz( $this->e, $sin2, $cos2 );
  72 + $ts2 = Proj4php::$common->tsfnz( $this->e, $this->lat2, $sin2 );
  73 +
  74 + $ts0 = Proj4php::$common->tsfnz( $this->e, $this->lat0, sin( $this->lat0 ) );
  75 +
  76 + if( abs( $this->lat1 - $this->lat2 ) > Proj4php::$common->EPSLN ) {
  77 + $this->ns = log( $ms1 / $ms2 ) / log( $ts1 / $ts2 );
  78 + } else {
  79 + $this->ns = $sin1;
  80 + }
  81 + $this->f0 = $ms1 / ($this->ns * pow( $ts1, $this->ns ));
  82 + $this->rh = $this->a * $this->f0 * pow( $ts0, $this->ns );
  83 +
  84 + if( !isset($this->title) )
  85 + $this->title = "Lambert Conformal Conic";
  86 + }
  87 +
  88 + // Lambert Conformal conic forward equations--mapping lat,long to x,y
  89 + // -----------------------------------------------------------------
  90 + public function forward( $p ) {
  91 +
  92 + $lon = $p->x;
  93 + $lat = $p->y;
  94 +
  95 + // convert to radians
  96 + if( $lat <= 90.0 && $lat >= -90.0 && $lon <= 180.0 && $lon >= -180.0 ) {
  97 + //lon = lon * Proj4php::$common.D2R;
  98 + //lat = lat * Proj4php::$common.D2R;
  99 + } else {
  100 + Proj4php::reportError( "lcc:forward: llInputOutOfRange: " . $lon . " : " . $lat );
  101 + return null;
  102 + }
  103 +
  104 + $con = abs( abs( $lat ) - Proj4php::$common->HALF_PI );
  105 +
  106 + if( $con > Proj4php::$common->EPSLN ) {
  107 + $ts = Proj4php::$common->tsfnz( $this->e, $lat, sin( $lat ) );
  108 + $rh1 = $this->a * $this->f0 * pow( $ts, $this->ns );
  109 + } else {
  110 + $con = $lat * $this->ns;
  111 + if( $con <= 0 ) {
  112 + Proj4php::reportError( "lcc:forward: No Projection" );
  113 + return null;
  114 + }
  115 + $rh1 = 0;
  116 + }
  117 +
  118 + $theta = $this->ns * Proj4php::$common->adjust_lon( $lon - $this->long0 );
  119 + $p->x = $this->k0 * ($rh1 * sin( $theta )) + $this->x0;
  120 + $p->y = $this->k0 * ($this->rh - $rh1 * cos( $theta )) + $this->y0;
  121 +
  122 + return $p;
  123 + }
  124 +
  125 + /**
  126 + * Lambert Conformal Conic inverse equations--mapping x,y to lat/long
  127 + *
  128 + * @param type $p
  129 + * @return null
  130 + */
  131 + public function inverse( $p ) {
  132 +
  133 + $x = ($p->x - $this->x0) / $this->k0;
  134 + $y = ($this->rh - ($p->y - $this->y0) / $this->k0);
  135 + if( $this->ns > 0 ) {
  136 + $rh1 = sqrt( $x * $x + $y * $y );
  137 + $con = 1.0;
  138 + } else {
  139 + $rh1 = -sqrt( $x * $x + $y * $y );
  140 + $con = -1.0;
  141 + }
  142 + $theta = 0.0;
  143 + if( $rh1 != 0 ) {
  144 + $theta = atan2( ($con * $x ), ($con * $y ) );
  145 + }
  146 + if( ($rh1 != 0) || ($this->ns > 0.0) ) {
  147 + $con = 1.0 / $this->ns;
  148 + $ts = pow( ($rh1 / ($this->a * $this->f0) ), $con );
  149 + $lat = Proj4php::$common->phi2z( $this->e, $ts );
  150 + if( $lat == -9999 )
  151 + return null;
  152 + } else {
  153 + $lat = -Proj4php::$common->HALF_PI;
  154 + }
  155 + $lon = Proj4php::$common->adjust_lon( $theta / $this->ns + $this->long0 );
  156 +
  157 + $p->x = $lon;
  158 + $p->y = $lat;
  159 +
  160 + return $p;
  161 + }
  162 +}
  163 +
  164 +Proj4php::$proj['lcc'] = new Proj4phpProjLcc();
  165 +
  166 +
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/merc.php 0 → 100644
... ... @@ -0,0 +1,129 @@
  1 +<?php
  2 +
  3 +/**
  4 + * Author : Julien Moquet
  5 + *
  6 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  7 + * and Richard Greenwood rich@greenwoodma$p->com
  8 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  9 + */
  10 +/* * *****************************************************************************
  11 + NAME MERCATOR
  12 +
  13 + PURPOSE: Transforms input longitude and latitude to Easting and
  14 + Northing for the Mercator projection. The
  15 + longitude and latitude must be in radians. The Easting
  16 + and Northing values will be returned in meters.
  17 +
  18 + PROGRAMMER DATE
  19 + ---------- ----
  20 + D. Steinwand, EROS Nov, 1991
  21 + T. Mittan Mar, 1993
  22 +
  23 + ALGORITHM REFERENCES
  24 +
  25 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  26 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  27 + State Government Printing Office, Washington D.C., 1987.
  28 +
  29 + 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  30 + U.S. Geological Survey Professional Paper 1453 , United State Government
  31 + Printing Office, Washington D.C., 1989.
  32 + * ***************************************************************************** */
  33 +
  34 +//static double r_major = a; /* major axis */
  35 +//static double r_minor = b; /* minor axis */
  36 +//static double lon_center = long0; /* Center longitude (projection center) */
  37 +//static double lat_origin = lat0; /* center latitude */
  38 +//static double e,es; /* eccentricity constants */
  39 +//static double m1; /* small value m */
  40 +//static double false_northing = y0; /* y offset in meters */
  41 +//static double false_easting = x0; /* x offset in meters */
  42 +//scale_fact = k0
  43 +
  44 +class Proj4phpProjMerc {
  45 +
  46 + public function init() {
  47 + //?$this->temp = $this->r_minor / $this->r_major;
  48 + //$this->temp = $this->b / $this->a;
  49 + //$this->es = 1.0 - sqrt($this->temp);
  50 + //$this->e = sqrt( $this->es );
  51 + //?$this->m1 = cos($this->lat_origin) / (sqrt( 1.0 - $this->es * sin($this->lat_origin) * sin($this->lat_origin)));
  52 + //$this->m1 = cos(0.0) / (sqrt( 1.0 - $this->es * sin(0.0) * sin(0.0)));
  53 + if( $this->lat_ts ) {
  54 + if( $this->sphere ) {
  55 + $this->k0 = cos( $this->lat_ts );
  56 + } else {
  57 + $this->k0 = Proj4php::$common->msfnz( $this->es, sin( $this->lat_ts ), cos( $this->lat_ts ) );
  58 + }
  59 + }
  60 + }
  61 +
  62 + /* Mercator forward equations--mapping lat,long to x,y
  63 + -------------------------------------------------- */
  64 +
  65 + public function forward( $p ) {
  66 +
  67 + //alert("ll2m coords : ".coords);
  68 + $lon = $p->x;
  69 + $lat = $p->y;
  70 + // convert to radians
  71 + if( $lat * Proj4php::$common->R2D > 90.0 &&
  72 + $lat * Proj4php::$common->R2D < -90.0 &&
  73 + $lon * Proj4php::$common->R2D > 180.0 &&
  74 + $lon * Proj4php::$common->R2D < -180.0 ) {
  75 + Proj4php::reportError( "merc:forward: llInputOutOfRange: " . $lon . " : " . $lat );
  76 + return null;
  77 + }
  78 +
  79 + if( abs( abs( $lat ) - Proj4php::$common->HALF_PI ) <= Proj4php::$common->EPSLN ) {
  80 + Proj4php::reportError( "merc:forward: ll2mAtPoles" );
  81 + return null;
  82 + } else {
  83 + if( $this->sphere ) {
  84 + $x = $this->x0 + $this->a * $this->k0 * Proj4php::$common->adjust_lon( $lon - $this->long0 );
  85 + $y = $this->y0 + $this->a * $this->k0 * log( tan( Proj4php::$common->FORTPI + 0.5 * $lat ) );
  86 + } else {
  87 + $sinphi = sin( lat );
  88 + $ts = Proj4php::$common->tsfnz( $this->e, $lat, $sinphi );
  89 + $x = $this->x0 + $this->a * $this->k0 * Proj4php::$common->adjust_lon( $lon - $this->long0 );
  90 + $y = $this->y0 - $this->a * $this->k0 * log( $ts );
  91 + }
  92 +
  93 + $p->x = $x;
  94 + $p->y = $y;
  95 +
  96 + return $p;
  97 + }
  98 + }
  99 +
  100 + /* Mercator inverse equations--mapping x,y to lat/long
  101 + -------------------------------------------------- */
  102 +
  103 + public function inverse( $p ) {
  104 +
  105 + $x = $p->x - $this->x0;
  106 + $y = $p->y - $this->y0;
  107 +
  108 + if( $this->sphere ) {
  109 + $lat = Proj4php::$common->HALF_PI - 2.0 * atan( exp( -$y / $this->a * $this->k0 ) );
  110 + } else {
  111 + $ts = exp( -$y / ($this->a * $this->k0) );
  112 + $lat = Proj4php::$common->phi2z( $this->e, $ts );
  113 + if( $lat == -9999 ) {
  114 + Proj4php::reportError( "merc:inverse: lat = -9999" );
  115 + return null;
  116 + }
  117 + }
  118 + $lon = Proj4php::$common->adjust_lon( $this->long0 + $x / ($this->a * $this->k0) );
  119 +
  120 + $p->x = $lon;
  121 + $p->y = $lat;
  122 + return $p;
  123 + }
  124 +
  125 +}
  126 +
  127 +Proj4php::$proj['merc'] = new Proj4phpProjMerc();
  128 +
  129 +
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/mill.php 0 → 100644
... ... @@ -0,0 +1,82 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME MILLER CYLINDRICAL
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the Miller Cylindrical projection. The
  14 + longitude and latitude must be in radians. The Easting
  15 + and Northing values will be returned in meters.
  16 +
  17 + PROGRAMMER DATE
  18 + ---------- ----
  19 + T. Mittan March, 1993
  20 +
  21 + This function was adapted from the Lambert Azimuthal Equal Area projection
  22 + code (FORTRAN) in the General Cartographic Transformation Package software
  23 + which is available from the U.S. Geological Survey National Mapping Division.
  24 +
  25 + ALGORITHM REFERENCES
  26 +
  27 + 1. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
  28 + The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
  29 +
  30 + 2. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  31 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  32 + State Government Printing Office, Washington D.C., 1987.
  33 +
  34 + 3. "Software Documentation for GCTP General Cartographic Transformation
  35 + Package", U.S. Geological Survey National Mapping Division, May 1982.
  36 + * ***************************************************************************** */
  37 +
  38 +class Proj4phpProjMill {
  39 + /* Initialize the Miller Cylindrical projection
  40 + ------------------------------------------- */
  41 +
  42 + public function init() {
  43 + //no-op
  44 + }
  45 +
  46 + /* Miller Cylindrical forward equations--mapping lat,long to x,y
  47 + ------------------------------------------------------------ */
  48 + public function forward( $p ) {
  49 +
  50 + $lon = $p->x;
  51 + $lat = $p->y;
  52 +
  53 + /* Forward equations
  54 + ----------------- */
  55 + $dlon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  56 + $x = $this->x0 + $this->a * $dlon;
  57 + $y = $this->y0 + $this->a * log( tan( (Proj4php::$common->PI / 4.0) + ($lat / 2.5) ) ) * 1.25;
  58 +
  59 + $p->x = $x;
  60 + $p->y = $y;
  61 +
  62 + return $p;
  63 + }
  64 +
  65 + /* Miller Cylindrical inverse equations--mapping x,y to lat/long
  66 + ------------------------------------------------------------ */
  67 + public function inverse( $p ) {
  68 +
  69 + $p->x -= $this->x0;
  70 + $p->y -= $this->y0;
  71 +
  72 + $lon = Proj4php::$common->adjust_lon( $this->long0 + $p->x / $this->a );
  73 + $lat = 2.5 * (atan( exp( 0.8 * $p->y / $this->a ) ) - Proj4php::$common->PI / 4.0);
  74 +
  75 + $p->x = $lon;
  76 + $p->y = $lat;
  77 +
  78 + return $p;
  79 + }
  80 +}
  81 +
  82 +Proj4php::$proj['mill'] = new Proj4phpProjMill();
0 83 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/moll.php 0 → 100644
... ... @@ -0,0 +1,121 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME MOLLWEIDE
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the MOllweide projection. The
  14 + longitude and latitude must be in radians. The Easting
  15 + and Northing values will be returned in meters.
  16 +
  17 + PROGRAMMER DATE
  18 + ---------- ----
  19 + D. Steinwand, EROS May, 1991; Updated Sept, 1992; Updated Feb, 1993
  20 + S. Nelson, EDC Jun, 2993; Made corrections in precision and
  21 + number of iterations.
  22 +
  23 + ALGORITHM REFERENCES
  24 +
  25 + 1. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  26 + U.S. Geological Survey Professional Paper 1453 , United State Government
  27 + Printing Office, Washington D.C., 1989.
  28 +
  29 + 2. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  30 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  31 + State Government Printing Office, Washington D.C., 1987.
  32 + ****************************************************************************** */
  33 +
  34 +class Proj4phpProjMoll {
  35 + /* Initialize the Mollweide projection
  36 + ------------------------------------ */
  37 +
  38 + public function init() {
  39 + //no-op
  40 + }
  41 +
  42 + /* Mollweide forward equations--mapping lat,long to x,y
  43 + ---------------------------------------------------- */
  44 + public function forward( $p ) {
  45 +
  46 + /* Forward equations
  47 + ----------------- */
  48 + $lon = $p->x;
  49 + $lat = $p->y;
  50 +
  51 + $delta_lon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  52 + $theta = $lat;
  53 + $con = Proj4php::$common->PI * sin( $lat );
  54 +
  55 + /* Iterate using the Newton-Raphson method to find theta
  56 + ----------------------------------------------------- */
  57 + for( $i = 0; true; ++$i ) {
  58 + $delta_theta = -($theta + sin( $theta ) - $con) / (1.0 + cos( $theta ));
  59 + $theta += $delta_theta;
  60 + if( abs( $delta_theta ) < Proj4php::$common->EPSLN )
  61 + break;
  62 + if( $i >= 50 ) {
  63 + Proj4php::reportError( "moll:Fwd:IterationError" );
  64 + //return(241);
  65 + }
  66 + }
  67 + $theta /= 2.0;
  68 +
  69 + /* If the latitude is 90 deg, force the x coordinate to be "0 . false easting"
  70 + this is done here because of precision problems with "cos(theta)"
  71 + -------------------------------------------------------------------------- */
  72 + if( Proj4php::$common->PI / 2 - abs( $lat ) < Proj4php::$common->EPSLN )
  73 + $delta_lon = 0;
  74 + $x = 0.900316316158 * $this->a * $delta_lon * cos( $theta ) + $this->x0;
  75 + $y = 1.4142135623731 * $this->a * sin( $theta ) + $this->y0;
  76 +
  77 + $p->x = $x;
  78 + $p->y = $y;
  79 + return $p;
  80 + }
  81 +
  82 + /**
  83 + *
  84 + * @param type $p
  85 + * @return type
  86 + */
  87 + public function inverse( $p ) {
  88 + #$theta;
  89 + #$arg;
  90 +
  91 + /* Inverse equations
  92 + ----------------- */
  93 + $p->x-= $this->x0;
  94 + //~ $p->y -= $this->y0;
  95 + $arg = $p->y / (1.4142135623731 * $this->a);
  96 +
  97 + /* Because of division by zero problems, 'arg' can not be 1.0. Therefore
  98 + a number very close to one is used instead.
  99 + ------------------------------------------------------------------- */
  100 + if( abs( $arg ) > 0.999999999999 )
  101 + $arg = 0.999999999999;
  102 + $theta = asin( $arg );
  103 + $lon = Proj4php::$common->adjust_lon( $this->long0 + ($p->x / (0.900316316158 * $this->a * cos( $theta ))) );
  104 + if( $lon < (-Proj4php::$common->PI) )
  105 + $lon = -Proj4php::$common->PI;
  106 + if( $lon > Proj4php::$common->PI )
  107 + $lon = Proj4php::$common->PI;
  108 + $arg = (2.0 * $theta + sin( 2.0 * $theta )) / Proj4php::$common->PI;
  109 + if( abs( $arg ) > 1.0 )
  110 + $arg = 1.0;
  111 + $lat = asin( $arg );
  112 + //return(OK);
  113 +
  114 + $p->x = $lon;
  115 + $p->y = $lat;
  116 +
  117 + return $p;
  118 + }
  119 +}
  120 +
  121 +Proj4php::$proj['moll'] = new Proj4phpProjMoll();
0 122 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/nzmg.php 0 → 100644
... ... @@ -0,0 +1,338 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME NEW ZEALAND MAP GRID
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the New Zealand Map Grid projection. The
  14 + longitude and latitude must be in radians. The Easting
  15 + and Northing values will be returned in meters.
  16 +
  17 +
  18 + ALGORITHM REFERENCES
  19 +
  20 + 1. Department of Land and Survey Technical Circular 1973/32
  21 + http://www.linz.govt.nz/docs/miscellaneous/nz-map-definition.pdf
  22 +
  23 + 2. OSG Technical Report 4.1
  24 + http://www.linz.govt.nz/docs/miscellaneous/nzmg.pdf
  25 +
  26 +
  27 + IMPLEMENTATION NOTES
  28 +
  29 + The two references use different symbols for the calculated values. This
  30 + implementation uses the variable names similar to the symbols in reference [1].
  31 +
  32 + The alogrithm uses different units for delta latitude and delta longitude.
  33 + The delta latitude is assumed to be in units of seconds of arc x 10^-5.
  34 + The delta longitude is the usual radians. Look out for these conversions.
  35 +
  36 + The algorithm is described using complex arithmetic. There were three
  37 + options:
  38 + * find and use a Javascript library for complex arithmetic
  39 + * write my own complex library
  40 + * expand the complex arithmetic by hand to simple arithmetic
  41 +
  42 + This implementation has expanded the complex multiplication operations
  43 + into parallel simple arithmetic operations for the real and imaginary parts.
  44 + The imaginary part is way over to the right of the display; this probably
  45 + violates every coding standard in the world, but, to me, it makes it much
  46 + more obvious what is going on.
  47 +
  48 + The following complex operations are used:
  49 + - addition
  50 + - multiplication
  51 + - division
  52 + - complex number raised to integer power
  53 + - summation
  54 +
  55 + A summary of complex arithmetic operations:
  56 + (from http://en.wikipedia.org/wiki/Complex_arithmetic)
  57 + addition: (a + bi) + (c + di) = (a + c) + (b + d)i
  58 + subtraction: (a + bi) - (c + di) = (a - c) + (b - d)i
  59 + multiplication: (a + bi) x (c + di) = (ac - bd) + (bc + ad)i
  60 + division: (a + bi) / (c + di) = [(ac + bd)/(cc + dd)] + [(bc - ad)/(cc + dd)]i
  61 +
  62 + The algorithm needs to calculate summations of simple and complex numbers. This is
  63 + implemented using a for-loop, pre-loading the summed value to zero.
  64 +
  65 + The algorithm needs to calculate theta^2, theta^3, etc while doing a summation.
  66 + There are three possible implementations:
  67 + - use pow in the summation loop - except for complex numbers
  68 + - precalculate the values before running the loop
  69 + - calculate theta^n = theta^(n-1) * theta during the loop
  70 + This implementation uses the third option for both real and complex arithmetic.
  71 +
  72 + For example
  73 + psi_n = 1;
  74 + sum = 0;
  75 + for (n = 1; n <=6; n++) {
  76 + psi_n1 = psi_n * psi; // calculate psi^(n+1)
  77 + psi_n = psi_n1;
  78 + sum = sum + A[n] * psi_n;
  79 + }
  80 +
  81 +
  82 + TEST VECTORS
  83 +
  84 + NZMG E, N: 2487100.638 6751049.719 metres
  85 + NZGD49 long, lat: 172.739194 -34.444066 degrees
  86 +
  87 + NZMG E, N: 2486533.395 6077263.661 metres
  88 + NZGD49 long, lat: 172.723106 -40.512409 degrees
  89 +
  90 + NZMG E, N: 2216746.425 5388508.765 metres
  91 + NZGD49 long, lat: 169.172062 -46.651295 degrees
  92 +
  93 + Note that these test vectors convert from NZMG metres to lat/long referenced
  94 + to NZGD49, not the more usual WGS84. The difference is about 70m N/S and about
  95 + 10m E/W.
  96 +
  97 + These test vectors are provided in reference [1]. Many more test
  98 + vectors are available in
  99 + http://www.linz.govt.nz/docs/topography/topographicdata/placenamesdatabase/nznamesmar08.zip
  100 + which is a catalog of names on the 260-series maps.
  101 +
  102 +
  103 + EPSG CODES
  104 +
  105 + NZMG EPSG:27200
  106 + NZGD49 EPSG:4272
  107 +
  108 + http://spatialreference.org/ defines these as
  109 + Proj4php.defs["EPSG:4272"] = "+proj=longlat +ellps=intl +datum=nzgd49 +no_defs ";
  110 + Proj4php.defs["EPSG:27200"] = "+proj=nzmg +lat_0=-41 +lon_0=173 +x_0=2510000 +y_0=6023150 +ellps=intl +datum=nzgd49 +units=m +no_defs ";
  111 +
  112 +
  113 + LICENSE
  114 + Copyright: Stephen Irons 2008
  115 + Released under terms of the LGPL as per: http://www.gnu.org/copyleft/lesser.html
  116 +
  117 + * ***************************************************************************** */
  118 +
  119 +/**
  120 + Initialize New Zealand Map Grip projection
  121 + */
  122 +class Proj4phpProjNzmg {
  123 +
  124 + /**
  125 + * iterations: Number of iterations to refine inverse transform.
  126 + * 0 -> km accuracy
  127 + * 1 -> m accuracy -- suitable for most mapping applications
  128 + * 2 -> mm accuracy
  129 + */
  130 + protected $iterations = 1;
  131 +
  132 + /**
  133 + *
  134 + */
  135 + public function init() {
  136 + $this->A = array( );
  137 + $this->A[1] = +0.6399175073;
  138 + $this->A[2] = -0.1358797613;
  139 + $this->A[3] = +0.063294409;
  140 + $this->A[4] = -0.02526853;
  141 + $this->A[5] = +0.0117879;
  142 + $this->A[6] = -0.0055161;
  143 + $this->A[7] = +0.0026906;
  144 + $this->A[8] = -0.001333;
  145 + $this->A[9] = +0.00067;
  146 + $this->A[10] = -0.00034;
  147 +
  148 + $this->B_re = array( );
  149 + $this->B_im = array( );
  150 + $this->B_re[1] = +0.7557853228;
  151 + $this->B_im[1] = 0.0;
  152 + $this->B_re[2] = +0.249204646;
  153 + $this->B_im[2] = +0.003371507;
  154 + $this->B_re[3] = -0.001541739;
  155 + $this->B_im[3] = +0.041058560;
  156 + $this->B_re[4] = -0.10162907;
  157 + $this->B_im[4] = +0.01727609;
  158 + $this->B_re[5] = -0.26623489;
  159 + $this->B_im[5] = -0.36249218;
  160 + $this->B_re[6] = -0.6870983;
  161 + $this->B_im[6] = -1.1651967;
  162 +
  163 + $this->C_re = array( );
  164 + $this->C_im = array( );
  165 + $this->C_re[1] = +1.3231270439;
  166 + $this->C_im[1] = 0.0;
  167 + $this->C_re[2] = -0.577245789;
  168 + $this->C_im[2] = -0.007809598;
  169 + $this->C_re[3] = +0.508307513;
  170 + $this->C_im[3] = -0.112208952;
  171 + $this->C_re[4] = -0.15094762;
  172 + $this->C_im[4] = +0.18200602;
  173 + $this->C_re[5] = +1.01418179;
  174 + $this->C_im[5] = +1.64497696;
  175 + $this->C_re[6] = +1.9660549;
  176 + $this->C_im[6] = +2.5127645;
  177 +
  178 + $this->D = array( );
  179 + $this->D[1] = +1.5627014243;
  180 + $this->D[2] = +0.5185406398;
  181 + $this->D[3] = -0.03333098;
  182 + $this->D[4] = -0.1052906;
  183 + $this->D[5] = -0.0368594;
  184 + $this->D[6] = +0.007317;
  185 + $this->D[7] = +0.01220;
  186 + $this->D[8] = +0.00394;
  187 + $this->D[9] = -0.0013;
  188 + }
  189 +
  190 + /**
  191 + New Zealand Map Grid Forward - long/lat to x/y
  192 + long/lat in radians
  193 + */
  194 + public function forward( $p ) {
  195 +
  196 + $lon = $p->x;
  197 + $lat = $p->y;
  198 +
  199 + $delta_lat = $lat - $this->lat0;
  200 + $delta_lon = $lon - $this->long0;
  201 +
  202 + // 1. Calculate d_phi and d_psi ... // and d_lambda
  203 + // For this algorithm, delta_latitude is in seconds of arc x 10-5, so we need to scale to those units. Longitude is radians.
  204 + $d_phi = $delta_lat / Proj4php::$common->SEC_TO_RAD * 1E-5;
  205 + $d_lambda = $delta_lon;
  206 + $d_phi_n = 1; // d_phi^0
  207 +
  208 + $d_psi = 0;
  209 + for( $n = 1; $n <= 10; $n++ ) {
  210 + $d_phi_n = $d_phi_n * $d_phi;
  211 + $d_psi = $d_psi + $this->A[$n] * $d_phi_n;
  212 + }
  213 +
  214 + // 2. Calculate theta
  215 + $th_re = $d_psi;
  216 + $th_im = $d_lambda;
  217 +
  218 + // 3. Calculate z
  219 + $th_n_re = 1;
  220 + $th_n_im = 0; // theta^0
  221 + #$th_n_re1;
  222 + #$th_n_im1;
  223 +
  224 + $z_re = 0;
  225 + $z_im = 0;
  226 + for( $n = 1; $n <= 6; $n++ ) {
  227 + $th_n_re1 = $th_n_re * $th_re - $th_n_im * $th_im;
  228 + $th_n_im1 = $th_n_im * $th_re + $th_n_re * $th_im;
  229 + $th_n_re = $th_n_re1;
  230 + $th_n_im = $th_n_im1;
  231 + $z_re = $z_re + $this->B_re[$n] * $th_n_re - $this->B_im[$n] * $th_n_im;
  232 + $z_im = $z_im + $this->B_im[$n] * $th_n_re + $this->B_re[$n] * $th_n_im;
  233 + }
  234 +
  235 + // 4. Calculate easting and northing
  236 + $p->x = ($z_im * $this->a) + $this->x0;
  237 + $p->y = ($z_re * $this->a) + $this->y0;
  238 +
  239 + return $p;
  240 + }
  241 +
  242 + /**
  243 + New Zealand Map Grid Inverse - x/y to long/lat
  244 + */
  245 + public function inverse( $p ) {
  246 +
  247 + $x = $p->x;
  248 + $y = $p->y;
  249 +
  250 + $delta_x = $x - $this->x0;
  251 + $delta_y = $y - $this->y0;
  252 +
  253 + // 1. Calculate z
  254 + $z_re = $delta_y / $this->a;
  255 + $z_im = $delta_x / $this->a;
  256 +
  257 + // 2a. Calculate theta - first approximation gives km accuracy
  258 + $z_n_re = 1;
  259 + $z_n_im = 0; // z^0
  260 + $z_n_re1;
  261 + $z_n_im1;
  262 +
  263 + $th_re = 0;
  264 + $th_im = 0;
  265 + for( $n = 1; $n <= 6; $n++ ) {
  266 + $z_n_re1 = $z_n_re * $z_re - $z_n_im * $z_im;
  267 + $z_n_im1 = $z_n_im * $z_re + $z_n_re * $z_im;
  268 + $z_n_re = $z_n_re1;
  269 + $z_n_im = $z_n_im1;
  270 + $th_re = $th_re + $this->C_re[$n] * $z_n_re - $this->C_im[$n] * $z_n_im;
  271 + $th_im = $th_im + $this->C_im[$n] * $z_n_re + $this->C_re[$n] * $z_n_im;
  272 + }
  273 +
  274 + // 2b. Iterate to refine the accuracy of the calculation
  275 + // 0 iterations gives km accuracy
  276 + // 1 iteration gives m accuracy -- good enough for most mapping applications
  277 + // 2 iterations bives mm accuracy
  278 + for( $i = 0; $i < $this->iterations; $i++ ) {
  279 + $th_n_re = $th_re;
  280 + $th_n_im = $th_im;
  281 + $th_n_re1;
  282 + $th_n_im1;
  283 +
  284 + $num_re = $z_re;
  285 + $num_im = $z_im;
  286 + for( $n = 2; $n <= 6; $n++ ) {
  287 + $th_n_re1 = $th_n_re * th_re - $th_n_im * $th_im;
  288 + $th_n_im1 = $th_n_im * $th_re + $th_n_re * $th_im;
  289 + $th_n_re = $th_n_re1;
  290 + $th_n_im = $th_n_im1;
  291 + $num_re = $num_re + ($n - 1) * ($this->B_re[$n] * $th_n_re - $this->B_im[$n] * $th_n_im);
  292 + $num_im = $num_im + (n - 1) * ($this->B_im[$n] * $th_n_re + $this->B_re[$n] * $th_n_im);
  293 + }
  294 +
  295 + $th_n_re = 1;
  296 + $th_n_im = 0;
  297 + $den_re = $this->B_re[1];
  298 + $den_im = $this->B_im[1];
  299 + for( $n = 2; $n <= 6; $n++ ) {
  300 + $th_n_re1 = $th_n_re * $th_re - $th_n_im * $th_im;
  301 + $th_n_im1 = $th_n_im * $th_re + $th_n_re * $th_im;
  302 + $th_n_re = $th_n_re1;
  303 + $th_n_im = $th_n_im1;
  304 + $den_re = $den_re + $n * ($this->B_re[$n] * $th_n_re - $this->B_im[$n] * $th_n_im);
  305 + $den_im = $den_im + $n * ($this->B_im[n] * $th_n_re + $this->B_re[$n] * $th_n_im);
  306 + }
  307 +
  308 + // Complex division
  309 + $den2 = $den_re * $den_re + $den_im * $den_im;
  310 + $th_re = ($num_re * $den_re + $num_im * $den_im) / $den2;
  311 + $th_im = ($num_im * $den_re - $num_re * $den_im) / $den2;
  312 + }
  313 +
  314 + // 3. Calculate d_phi ... // and d_lambda
  315 + $d_psi = $th_re;
  316 + $d_lambda = $th_im;
  317 + $d_psi_n = 1; // d_psi^0
  318 +
  319 + $d_phi = 0;
  320 + for( $n = 1; $n <= 9; $n++ ) {
  321 + $d_psi_n = $d_psi_n * $d_psi;
  322 + $d_phi = $d_phi + $this->D[$n] * $d_psi_n;
  323 + }
  324 +
  325 + // 4. Calculate latitude and longitude
  326 + // d_phi is calcuated in second of arc * 10^-5, so we need to scale back to radians. d_lambda is in radians.
  327 + $lat = $this->lat0 + ($d_phi * Proj4php::$common->SEC_TO_RAD * 1E5);
  328 + $lon = $this->long0 + $d_lambda;
  329 +
  330 + $p->x = $lon;
  331 + $p->y = $lat;
  332 +
  333 + return $p;
  334 + }
  335 +
  336 +}
  337 +
  338 +Proj4php::$proj['nzmg'] = new Proj4phpProjNzmg();
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/omerc.php 0 → 100644
... ... @@ -0,0 +1,301 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/* * *****************************************************************************
  10 + NAME OBLIQUE MERCATOR (HOTINE)
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the Oblique Mercator projection. The
  14 + longitude and latitude must be in radians. The Easting
  15 + and Northing values will be returned in meters.
  16 +
  17 + PROGRAMMER DATE
  18 + ---------- ----
  19 + T. Mittan Mar, 1993
  20 +
  21 + ALGORITHM REFERENCES
  22 +
  23 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  24 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  25 + State Government Printing Office, Washington D.C., 1987.
  26 +
  27 + 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  28 + U.S. Geological Survey Professional Paper 1453 , United State Government
  29 + Printing Office, Washington D.C., 1989.
  30 + * ***************************************************************************** */
  31 +
  32 +class Proj4phpProjOmerc {
  33 + /* Initialize the Oblique Mercator projection
  34 + ------------------------------------------ */
  35 +
  36 + public function init() {
  37 + if( !$this->mode )
  38 + $this->mode = 0;
  39 + if( !$this->lon1 ) {
  40 + $this->lon1 = 0;
  41 + $this->mode = 1;
  42 + }
  43 + if( !$this->lon2 )
  44 + $this->lon2 = 0;
  45 + if( !$this->lat2 )
  46 + $this->lat2 = 0;
  47 +
  48 + /* Place parameters in static storage for common use
  49 + ------------------------------------------------- */
  50 + $temp = $this->b / $this->a;
  51 + $es = 1.0 - pow( $temp, 2 );
  52 + $e = sqrt( $es );
  53 +
  54 + $this->sin_p20 = sin( $this->lat0 );
  55 + $this->cos_p20 = cos( $this->lat0 );
  56 +
  57 + $this->con = 1.0 - $this->es * $this->sin_p20 * $this->sin_p20;
  58 + $this->com = sqrt( 1.0 - $es );
  59 + $this->bl = sqrt( 1.0 + $this->es * pow( $this->cos_p20, 4.0 ) / (1.0 - $es) );
  60 + $this->al = $this->a * $this->bl * $this->k0 * $this->com / $this->con;
  61 + if( abs( $this->lat0 ) < Proj4php::$common->EPSLN ) {
  62 + $this->ts = 1.0;
  63 + $this->d = 1.0;
  64 + $this->el = 1.0;
  65 + } else {
  66 + $this->ts = Proj4php::$common->tsfnz( $this->e, $this->lat0, $this->sin_p20 );
  67 + $this->con = sqrt( $this->con );
  68 + $this->d = $this->bl * $this->com / ($this->cos_p20 * $this->con);
  69 + if( ($this->d * $this->d - 1.0) > 0.0 ) {
  70 + if( $this->lat0 >= 0.0 ) {
  71 + $this->f = $this->d + sqrt( $this->d * $this->d - 1.0 );
  72 + } else {
  73 + $this->f = $this->d - sqrt( $this->d * $this->d - 1.0 );
  74 + }
  75 + } else {
  76 + $this->f = $this->d;
  77 + }
  78 + $this->el = $this->f * pow( $this->ts, $this->bl );
  79 + }
  80 +
  81 + //$this->longc=52.60353916666667;
  82 +
  83 + if( $this->mode != 0 ) {
  84 + $this->g = .5 * ($this->f - 1.0 / $this->f);
  85 + $this->gama = Proj4php::$common->asinz( sin( $this->alpha ) / $this->d );
  86 + $this->longc = $this->longc - Proj4php::$common->asinz( $this->g * tan( $this->gama ) ) / $this->bl;
  87 +
  88 + /* Report parameters common to format B
  89 + ------------------------------------- */
  90 + //genrpt(azimuth * R2D,"Azimuth of Central Line: ");
  91 + //cenlon(lon_origin);
  92 + // cenlat(lat_origin);
  93 +
  94 + $this->con = abs( $this->lat0 );
  95 + if( ($this->con > Proj4php::$common->EPSLN) && (abs( $this->con - Proj4php::$common->HALF_PI ) > Proj4php::$common->EPSLN) ) {
  96 + $this->singam = sin( $this->gama );
  97 + $this->cosgam = cos( $this->gama );
  98 +
  99 + $this->sinaz = sin( $this->alpha );
  100 + $this->cosaz = cos( $this->alpha );
  101 +
  102 + if( $this->lat0 >= 0 ) {
  103 + $this->u = ($this->al / $this->bl) * atan( sqrt( $this->d * $this->d - 1.0 ) / $this->cosaz );
  104 + } else {
  105 + $this->u = -($this->al / $this->bl) * atan( sqrt( $this->d * $this->d - 1.0 ) / $this->cosaz );
  106 + }
  107 + } else {
  108 + Proj4php::reportError( "omerc:Init:DataError" );
  109 + }
  110 + } else {
  111 + $this->sinphi = sin( $this->at1 );
  112 + $this->ts1 = Proj4php::$common->tsfnz( $this->e, $this->lat1, $this->sinphi );
  113 + $this->sinphi = sin( $this->lat2 );
  114 + $this->ts2 = Proj4php::$common->tsfnz( $this->e, $this->lat2, $this->sinphi );
  115 + $this->h = pow( $this->ts1, $this->bl );
  116 + $this->l = pow( $this->ts2, $this->bl );
  117 + $this->f = $this->el / $this->h;
  118 + $this->g = .5 * ($this->f - 1.0 / $this->f);
  119 + $this->j = ($this->el * $this->el - $this->l * $this->h) / ($this->el * $this->el + $this->l * $this->h);
  120 + $this->p = ($this->l - $this->h) / ($this->l + $this->h);
  121 + $this->dlon = $this->lon1 - $this->lon2;
  122 + if( $this->dlon < -Proj4php::$common->PI )
  123 + $this->lon2 = $this->lon2 - 2.0 * Proj4php::$common->PI;
  124 + if( $this->dlon > Proj4php::$common->PI )
  125 + $this->lon2 = $this->lon2 + 2.0 * Proj4php::$common->PI;
  126 + $this->dlon = $this->lon1 - $this->lon2;
  127 + $this->longc = .5 * ($this->lon1 + $this->lon2) - atan( $this->j * tan( .5 * $this->bl * $this->dlon ) / $this->p ) / $this->bl;
  128 + $this->dlon = Proj4php::$common->adjust_lon( $this->lon1 - $this->longc );
  129 + $this->gama = atan( sin( $this->bl * $this->dlon ) / $this->g );
  130 + $this->alpha = Proj4php::$common->asinz( $this->d * sin( $this->gama ) );
  131 +
  132 + /* Report parameters common to format A
  133 + ------------------------------------- */
  134 + if( abs( $this->lat1 - $this->lat2 ) <= Proj4php::$common->EPSLN ) {
  135 + Proj4php::reportError( "omercInitDataError" );
  136 + //return(202);
  137 + } else {
  138 + $this->con = abs( $this->lat1 );
  139 + }
  140 + if( ($this->con <= Proj4php::$common->EPSLN) || (abs( $this->con - Proj4php::$common->HALF_PI ) <= Proj4php::$common->EPSLN) ) {
  141 + Proj4php::reportError( "omercInitDataError" );
  142 + //return(202);
  143 + } else {
  144 + if( abs( abs( $this->lat0 ) - Proj4php::$common->HALF_PI ) <= Proj4php::$common->EPSLN ) {
  145 + Proj4php::reportError( "omercInitDataError" );
  146 + //return(202);
  147 + }
  148 + }
  149 +
  150 + $this->singam = sin( $this->gam );
  151 + $this->cosgam = cos( $this->gam );
  152 +
  153 + $this->sinaz = sin( $this->alpha );
  154 + $this->cosaz = cos( $this->alpha );
  155 +
  156 +
  157 + if( $this->lat0 >= 0 ) {
  158 + $this->u = ($this->al / $this->bl) * atan( sqrt( $this->d * $this->d - 1.0 ) / $this->cosaz );
  159 + } else {
  160 + $this->u = -($this->al / $this->bl) * atan( sqrt( $this->d * $this->d - 1.0 ) / $this->cosaz );
  161 + }
  162 + }
  163 + }
  164 +
  165 + /* Oblique Mercator forward equations--mapping lat,long to x,y
  166 + ---------------------------------------------------------- */
  167 + public function forward( $p ) {
  168 +
  169 + /*
  170 + $theta; // angle
  171 + $sin_phi;
  172 + $cos_phi; // sin and cos value
  173 + $b; // temporary values
  174 + $c;
  175 + $t;
  176 + $tq; // temporary values
  177 + $con;
  178 + $n;
  179 + $ml; // cone constant, small m
  180 + $q;
  181 + $us;
  182 + $vl;
  183 + $ul;
  184 + $vs;
  185 + $s;
  186 + $dlon;
  187 + $ts1;
  188 + */
  189 +
  190 + $lon = $p->x;
  191 + $lat = $p->y;
  192 +
  193 + /* Forward equations
  194 + ----------------- */
  195 + $sin_phi = sin( $lat );
  196 + $dlon = Proj4php::$common->adjust_lon( $lon - $this->longc );
  197 + $vl = sin( $this->bl * $dlon );
  198 + if( abs( abs( $lat ) - Proj4php::$common->HALF_PI ) > Proj4php::$common->EPSLN ) {
  199 + $ts1 = Proj4php::$common->tsfnz( $this->e, $lat, $sin_phi );
  200 + $q = $this->el / (pow( $ts1, $this->bl ));
  201 + $s = .5 * ($q - 1.0 / $q);
  202 + $t = .5 * ($q + 1.0 / $q);
  203 + $ul = ($s * $this->singam - $vl * $this->cosgam) / $t;
  204 + $con = cos( $this->bl * $dlon );
  205 + if( abs( con ) < .0000001 ) {
  206 + $us = $this->al * $this->bl * $dlon;
  207 + } else {
  208 + $us = $this->al * atan( ($s * $this->cosgam + $vl * $this->singam) / $con ) / $this->bl;
  209 + if( $con < 0 )
  210 + $us = $us + Proj4php::$common->PI * $this->al / $this->bl;
  211 + }
  212 + } else {
  213 + if( $lat >= 0 ) {
  214 + $ul = $this->singam;
  215 + } else {
  216 + $ul = -$this->singam;
  217 + }
  218 + $us = $this->al * $lat / $this->bl;
  219 + }
  220 + if( abs( abs( $ul ) - 1.0 ) <= Proj4php::$common->EPSLN ) {
  221 + //alert("Point projects into infinity","omer-for");
  222 + Proj4php::reportError( "omercFwdInfinity" );
  223 + //return(205);
  224 + }
  225 + $vs = .5 * $this->al * log( (1.0 - $ul) / (1.0 + $ul) ) / $this->bl;
  226 + $us = $us - $this->u;
  227 + $p->x = $this->x0 + $vs * $this->cosaz + $us * $this->sinaz;
  228 + $p->y = $this->y0 + $us * $this->cosaz - $vs * $this->sinaz;
  229 +
  230 + return $p;
  231 + }
  232 +
  233 + /**
  234 + *
  235 + * @param type $p
  236 + * @return type
  237 + */
  238 + public function inverse( $p ) {
  239 + /*
  240 + $delta_lon; /* Delta longitude (Given longitude - center
  241 + $theta; /* angle
  242 + $delta_theta; /* adjusted longitude
  243 + $sin_phi;
  244 + $cos_phi; /* sin and cos value
  245 + $b; /* temporary values
  246 + $c;
  247 + $t;
  248 + $tq; /* temporary values
  249 + $con;
  250 + $n;
  251 + $ml; /* cone constant, small m
  252 + $vs;
  253 + $us;
  254 + $q;
  255 + $s;
  256 + $ts1;
  257 + $vl;
  258 + $ul;
  259 + $bs;
  260 + $dlon;
  261 + $flag;
  262 + */
  263 +
  264 + /* Inverse equations
  265 + ----------------- */
  266 + $p->x -= $this->x0;
  267 + $p->y -= $this->y0;
  268 + #$flag = 0;
  269 + $vs = $p->x * $this->cosaz - $p->y * $this->sinaz;
  270 + $us = $p->y * $this->cosaz + $p->x * $this->sinaz;
  271 + $us = $us + $this->u;
  272 + $q = exp( -$this->bl * $vs / $this->al );
  273 + $s = .5 * ($q - 1.0 / $q);
  274 + $t = .5 * ($q + 1.0 / $q);
  275 + $vl = sin( $this->bl * $us / $this->al );
  276 + $ul = ($vl * $this->cosgam + $s * $this->singam) / $t;
  277 + if( abs( abs( $ul ) - 1.0 ) <= Proj4php::$common->EPSLN ) {
  278 + $lon = $this->longc;
  279 + if( ul >= 0.0 ) {
  280 + $lat = Proj4php::$common->HALF_PI;
  281 + } else {
  282 + $lat = -Proj4php::$common->HALF_PI;
  283 + }
  284 + } else {
  285 + $con = 1.0 / $this->bl;
  286 + $ts1 = pow( ($this->el / sqrt( (1.0 + $ul) / (1.0 - $ul) ) ), $con );
  287 + $lat = Proj4php::$common->phi2z( $this->e, $ts1 );
  288 + //if ($flag != 0)
  289 + //return($flag);
  290 + //~ con = cos($this->bl * us /al);
  291 + $theta = $this->longc - atan2( ($s * $this->cosgam - $vl * $this->singam ), $con ) / $this->bl;
  292 + $lon = Proj4php::$common->adjust_lon( $theta );
  293 + }
  294 + $p->x = $lon;
  295 + $p->y = $lat;
  296 + return $p;
  297 + }
  298 +
  299 +}
  300 +
  301 +Proj4php::$proj['omerc'] = new Proj4phpProjOmerc();
0 302 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/ortho.php 0 → 100644
... ... @@ -0,0 +1,139 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/* * *****************************************************************************
  10 + NAME ORTHOGRAPHIC
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the Orthographic projection. The
  14 + longitude and latitude must be in radians. The Easting
  15 + and Northing values will be returned in meters.
  16 +
  17 + PROGRAMMER DATE
  18 + ---------- ----
  19 + T. Mittan Mar, 1993
  20 +
  21 + ALGORITHM REFERENCES
  22 +
  23 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  24 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  25 + State Government Printing Office, Washington D.C., 1987.
  26 +
  27 + 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  28 + U.S. Geological Survey Professional Paper 1453 , United State Government
  29 + Printing Office, Washington D.C., 1989.
  30 + * ***************************************************************************** */
  31 +
  32 +class Proj4phpProjOrtho {
  33 +
  34 + /* Initialize the Orthographic projection
  35 + ------------------------------------- */
  36 + public function init( $def ) {
  37 + //double temp; /* temporary variable */
  38 +
  39 + /* Place parameters in static storage for common use
  40 + ------------------------------------------------- */;
  41 + $this->sin_p14 = sin( $this->lat0 );
  42 + $this->cos_p14 = cos( $this->lat0 );
  43 + }
  44 +
  45 + /* Orthographic forward equations--mapping lat,long to x,y
  46 + --------------------------------------------------- */
  47 + public function forward( $p ) {
  48 +
  49 + /*
  50 + $sinphi;
  51 + $cosphi; // sin and cos value
  52 + $dlon; // delta longitude value
  53 + $coslon; // cos of longitude
  54 + $ksp; // scale factor
  55 + $g;
  56 + */
  57 +
  58 + $lon = $p->x;
  59 + $lat = $p->y;
  60 +
  61 + /* Forward equations
  62 + ----------------- */
  63 + $dlon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  64 +
  65 + $sinphi = sin( $lat );
  66 + $cosphi = cos( $lat );
  67 +
  68 + $coslon = cos( $dlon );
  69 + $g = $this->sin_p14 * sinphi + $this->cos_p14 * $cosphi * $coslon;
  70 + $ksp = 1.0;
  71 +
  72 + if( ($g > 0) || (abs( $g ) <= Proj4php::$common->EPSLN) ) {
  73 + $x = $this->a * $ksp * $cosphi * sin( $dlon );
  74 + $y = $this->y0 + $this->a * $ksp * ($this->cos_p14 * $sinphi - $this->sin_p14 * $cosphi * $coslon);
  75 + } else {
  76 + Proj4php::reportError( "orthoFwdPointError" );
  77 + }
  78 +
  79 + $p->x = $x;
  80 + $p->y = $y;
  81 +
  82 + return $p;
  83 + }
  84 +
  85 + /**
  86 + *
  87 + * @param type $p
  88 + * @return type
  89 + */
  90 + public function inverse( $p ) {
  91 +
  92 + /*
  93 + $rh; // height above ellipsoid
  94 + $z; // angle
  95 + $sinz;
  96 + $cosz; // sin of z and cos of z
  97 + $temp;
  98 + $con;
  99 + $lon;
  100 + $lat;
  101 + */
  102 +
  103 + /* Inverse equations
  104 + ----------------- */
  105 + $p->x -= $this->x0;
  106 + $p->y -= $this->y0;
  107 + $rh = sqrt( $p->x * $p->x + $p->y * $p->y );
  108 + if( $rh > $this->a + .0000001 ) {
  109 + Proj4php::reportError( "orthoInvDataError" );
  110 + }
  111 + $z = Proj4php::$common->asinz( $rh / $this->a );
  112 +
  113 + $sinz = sin( $z );
  114 + $cosz = cos( $z );
  115 +
  116 + $lon = $this->long0;
  117 + if( abs( $rh ) <= Proj4php::$common->EPSLN ) {
  118 + $lat = $this->lat0;
  119 + }
  120 + $lat = Proj4php::$common->asinz( $cosz * $this->sin_p14 + ($p->y * $sinz * $this->cos_p14) / $rh );
  121 + $con = abs( $this->lat0 ) - Proj4php::$common->HALF_PI;
  122 + if( abs( con ) <= Proj4php::$common->EPSLN ) {
  123 + if( $this->lat0 >= 0 ) {
  124 + $lon = Proj4php::$common->adjust_lon( $this->long0 + atan2( $p->x, -$p->y ) );
  125 + } else {
  126 + $lon = Proj4php::$common->adjust_lon( $this->long0 - atan2( -$p->x, $p->y ) );
  127 + }
  128 + }
  129 + $con = $cosz - $this->sin_p14 * sin( $lat );
  130 +
  131 + $p->x = $lon;
  132 + $p->y = $lat;
  133 +
  134 + return $p;
  135 + }
  136 +
  137 +}
  138 +
  139 +Proj4php::$proj['ortho'] = new Proj4phpProjOrtho();
0 140 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/poly.php 0 → 100644
... ... @@ -0,0 +1,192 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +
  10 +
  11 +/* Function to compute, phi4, the latitude for the inverse of the
  12 + Polyconic projection.
  13 + ------------------------------------------------------------ */
  14 +function phi4z( $eccent, $e0, $e1, $e2, $e3, $a, $b, &$c, $phi ) {
  15 + /*
  16 + $sinphi;
  17 + $sin2ph;
  18 + $tanph;
  19 + $ml;
  20 + $mlp;
  21 + $con1;
  22 + $con2;
  23 + $con3;
  24 + $dphi;
  25 + $i;
  26 + */
  27 +
  28 + $phi = $a;
  29 + for( $i = 1; $i <= 15; $i++ ) {
  30 + $sinphi = sin( $phi );
  31 + $tanphi = tan( $phi );
  32 + $c = $tanphi * sqrt( 1.0 - $eccent * $sinphi * $sinphi );
  33 + $sin2ph = sin( 2.0 * $phi );
  34 + /*
  35 + ml = e0 * *phi - e1 * sin2ph + e2 * sin (4.0 * *phi);
  36 + mlp = e0 - 2.0 * e1 * cos (2.0 * *phi) + 4.0 * e2 * cos (4.0 * *phi);
  37 + */
  38 + $ml = $e0 * $phi - $e1 * $sin2ph + $e2 * sin( 4.0 * $phi ) - $e3 * sin( 6.0 * $phi );
  39 + $mlp = $e0 - 2.0 * $e1 * cos( 2.0 * $phi ) + 4.0 * $e2 * cos( 4.0 * $phi ) - 6.0 * $e3 * cos( 6.0 * $phi );
  40 + $con1 = 2.0 * $ml + $c * ($ml * $ml + $b) - 2.0 * $a * ($c * $ml + 1.0);
  41 + $con2 = $eccent * $sin2ph * ($ml * $ml + $b - 2.0 * $a * $ml) / (2.0 * $c);
  42 + $con3 = 2.0 * ($a - $ml) * ($c * $mlp - 2.0 / $sin2ph) - 2.0 * $mlp;
  43 + $dphi = $con1 / ($con2 + $con3);
  44 + $phi += $dphi;
  45 + if( abs( $dphi ) <= .0000000001 )
  46 + return($phi);
  47 + }
  48 +
  49 + Proj4php::reportError( "phi4z: No convergence" );
  50 +
  51 + return null;
  52 +}
  53 +
  54 +/* Function to compute the constant e4 from the input of the eccentricity
  55 + of the spheroid, x. This constant is used in the Polar Stereographic
  56 + projection.
  57 + -------------------------------------------------------------------- */
  58 +function e4fn( $x ) {
  59 + #$con;
  60 + #$com;
  61 + $con = 1.0 + $x;
  62 + $com = 1.0 - $x;
  63 + return (sqrt( (pow( $con, $con )) * (pow( $com, $com )) ));
  64 +}
  65 +
  66 +/* * *****************************************************************************
  67 + NAME POLYCONIC
  68 +
  69 + PURPOSE: Transforms input longitude and latitude to Easting and
  70 + Northing for the Polyconic projection. The
  71 + longitude and latitude must be in radians. The Easting
  72 + and Northing values will be returned in meters.
  73 +
  74 + PROGRAMMER DATE
  75 + ---------- ----
  76 + T. Mittan Mar, 1993
  77 +
  78 + ALGORITHM REFERENCES
  79 +
  80 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  81 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  82 + State Government Printing Office, Washington D.C., 1987.
  83 +
  84 + 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  85 + U.S. Geological Survey Professional Paper 1453 , United State Government
  86 + Printing Office, Washington D.C., 1989.
  87 + * ***************************************************************************** */
  88 +
  89 +class Proj4phpProjPoly {
  90 +
  91 + /* Initialize the POLYCONIC projection
  92 + ---------------------------------- */
  93 + public function init() {
  94 + #$temp; /* temporary variable */
  95 + if( $this->lat0 == 0 )
  96 + $this->lat0 = 90; //$this->lat0 ca
  97 +
  98 + /* Place parameters in static storage for common use
  99 + ------------------------------------------------- */
  100 + $this->temp = $this->b / $this->a;
  101 + $this->es = 1.0 - pow( $this->temp, 2 ); // devait etre dans tmerc.js mais n y est pas donc je commente sinon retour de valeurs nulles
  102 + $this->e = sqrt( $this->es );
  103 + $this->e0 = Proj4php::$common->e0fn( $this->es );
  104 + $this->e1 = Proj4php::$common->e1fn( $this->es );
  105 + $this->e2 = Proj4php::$common->e2fn( $this->es );
  106 + $this->e3 = Proj4php::$common->e3fn( $this->es );
  107 + $this->ml0 = Proj4php::$common->mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 ); //si que des zeros le calcul ne se fait pas
  108 + //if (!$this->ml0) {$this->ml0=0;}
  109 + }
  110 +
  111 + /* Polyconic forward equations--mapping lat,long to x,y
  112 + --------------------------------------------------- */
  113 + public function forward( $p ) {
  114 +
  115 + /*
  116 + $sinphi;
  117 + $cosphi; // sin and cos value
  118 + $al; // temporary values
  119 + $c; // temporary values
  120 + $con;
  121 + $ml; // cone constant, small m
  122 + $ms; // small m
  123 + $x;
  124 + $y;
  125 + */
  126 +
  127 + $lon = $p->x;
  128 + $lat = $p->y;
  129 +
  130 + $con = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  131 +
  132 + if( abs( $lat ) <= .0000001 ) {
  133 + $x = $this->x0 + $this->a * $con;
  134 + $y = $this->y0 - $this->a * $this->ml0;
  135 + } else {
  136 + $sinphi = sin( $lat );
  137 + $cosphi = cos( $lat );
  138 +
  139 + $ml = Proj4php::$common->mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $lat );
  140 + $ms = Proj4php::$common->msfnz( $this->e, $sinphi, $cosphi );
  141 +
  142 + $x = $this->x0 + $this->a * $ms * sin( $sinphi ) / $sinphi;
  143 + $y = $this->y0 + $this->a * ($ml - $this->ml0 + $ms * (1.0 - cos( $sinphi )) / $sinphi);
  144 + }
  145 +
  146 + $p->x = $x;
  147 + $p->y = $y;
  148 +
  149 + return $p;
  150 + }
  151 +
  152 + /* Inverse equations
  153 + ----------------- */
  154 + public function inverse( $p ) {
  155 +
  156 + /*
  157 + $sin_phi;
  158 + $cos_phi; // sin and cos values
  159 + $al; // temporary values
  160 + $b; // temporary values
  161 + $c; // temporary values
  162 + $con;
  163 + $ml; // cone constant, small m
  164 + $iflg; // error flag
  165 + $lon;
  166 + $lat;
  167 + */
  168 +
  169 + $p->x -= $this->x0;
  170 + $p->y -= $this->y0;
  171 + $al = $this->ml0 + $p->y / $this->a;
  172 + $iflg = 0;
  173 +
  174 + if( abs( $al ) <= .0000001 ) {
  175 + $lon = $p->x / $this->a + $this->long0;
  176 + $lat = 0.0;
  177 + } else {
  178 + $b = $al * $al + ($p->x / $this->a) * ($p->x / $this->a);
  179 + $iflg = phi4z( $this->es, $this->e0, $this->e1, $this->e2, $this->e3, $this->al, $b, $c, $lat );
  180 + if( $iflg != 1 )
  181 + return($iflg);
  182 + $lon = Proj4php::$common->adjust_lon( (Proj4php::$common->asinz( $p->x * $c / $this->a ) / sin( $lat )) + $this->long0 );
  183 + }
  184 +
  185 + $p->x = $lon;
  186 + $p->y = $lat;
  187 + return $p;
  188 + }
  189 +
  190 +}
  191 +
  192 +Proj4php::$proj['poly'] = new Proj4phpProjPoly();
0 193 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/sinu.php 0 → 100644
... ... @@ -0,0 +1,139 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME SINUSOIDAL
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the Sinusoidal projection. The
  14 + longitude and latitude must be in radians. The Easting
  15 + and Northing values will be returned in meters.
  16 +
  17 + PROGRAMMER DATE
  18 + ---------- ----
  19 + D. Steinwand, EROS May, 1991
  20 +
  21 + This function was adapted from the Sinusoidal projection code (FORTRAN) in the
  22 + General Cartographic Transformation Package software which is available from
  23 + the U.S. Geological Survey National Mapping Division.
  24 +
  25 + ALGORITHM REFERENCES
  26 +
  27 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  28 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  29 + State Government Printing Office, Washington D.C., 1987.
  30 +
  31 + 2. "Software Documentation for GCTP General Cartographic Transformation
  32 + Package", U.S. Geological Survey National Mapping Division, May 1982.
  33 + * ***************************************************************************** */
  34 +
  35 +class Proj4phpProjSinu {
  36 +
  37 + /* Initialize the Sinusoidal projection
  38 + ------------------------------------ */
  39 + public function init() {
  40 + /* Place parameters in static storage for common use
  41 + ------------------------------------------------- */
  42 + #$this->R = 6370997.0; //Radius of earth
  43 +
  44 + if( !$this->sphere ) {
  45 + $this->en = Proj4php::$common->pj_enfn( $this->es );
  46 + } else {
  47 + $this->n = 1.;
  48 + $this->m = 0.;
  49 + $this->es = 0;
  50 + $this->C_y = sqrt( ($this->m + 1.) / $this->n );
  51 + $this->C_x = $this->C_y / ($this->m + 1.);
  52 + }
  53 + }
  54 +
  55 + /* Sinusoidal forward equations--mapping lat,long to x,y
  56 + ----------------------------------------------------- */
  57 + public function forward( $p ) {
  58 +
  59 + #$x,y,delta_lon;
  60 + $lon = $p->x;
  61 + $lat = $p->y;
  62 +
  63 + /* Forward equations
  64 + ----------------- */
  65 + $lon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  66 +
  67 + if( isset($this->sphere) ) {
  68 + if( !$this->m ) {
  69 + $lat = $this->n != 1. ? asin( $this->n * sin( $lat ) ) : $lat;
  70 + } else {
  71 + $k = $this->n * sin( $lat );
  72 + for( $i = Proj4php::$common->MAX_ITER; $i; --$i ) {
  73 + $V = ($this->m * $lat + sin( $lat ) - $k) / ($this->m + cos( $lat ));
  74 + $lat -= $V;
  75 + if( abs( $V ) < Proj4php::$common->EPSLN )
  76 + break;
  77 + }
  78 + }
  79 + $x = $this->a * $this->C_x * $lon * ($this->m + cos( $lat ));
  80 + $y = $this->a * $this->C_y * $lat;
  81 + } else {
  82 +
  83 + $s = sin( $lat );
  84 + $c = cos( $lat );
  85 + $y = $this->a * Proj4php::$common->pj_mlfn( $lat, $s, $c, $this->en );
  86 + $x = $this->a * $lon * $c / sqrt( 1. - $this->es * $s * $s );
  87 + }
  88 +
  89 + $p->x = $x;
  90 + $p->y = $y;
  91 +
  92 + return $p;
  93 + }
  94 +
  95 + /**
  96 + *
  97 + * @param type $p
  98 + * @return type
  99 + */
  100 + public function inverse( $p ) {
  101 + #$lat;
  102 + #$temp;
  103 + #$lon;
  104 +
  105 + /* Inverse equations
  106 + ----------------- */
  107 + $p->x -= $this->x0;
  108 + $p->y -= $this->y0;
  109 + $lat = $p->y / $this->a;
  110 +
  111 + if( isset($this->sphere) ) {
  112 +
  113 + $p->y /= $this->C_y;
  114 + $lat = $this->m ? asin( ($this->m * $p->y + sin( $p->y )) / $this->n ) : ( $this->n != 1. ? asin( sin( $p->y ) / $this->n ) : $p->y );
  115 + $lon = $p->x / ($this->C_x * ($this->m + cos( $p->y )));
  116 + }
  117 + else {
  118 + $lat = Proj4php::$common->pj_inv_mlfn( $p->y / $this->a, $this->es, $this->en );
  119 + $s = abs( $lat );
  120 +
  121 + if( $s < Proj4php::$common->HALF_PI ) {
  122 + $s = sin( $lat );
  123 + $temp = $this->long0 + $p->x * sqrt( 1. - $this->es * $s * $s ) / ($this->a * cos( $lat ));
  124 + //temp = $this->long0 + $p->x / ($this->a * cos($lat));
  125 + $lon = Proj4php::$common->adjust_lon( $temp );
  126 + } else if( ($s - Proj4php::$common->EPSLN) < Proj4php::$common->HALF_PI ) {
  127 + $lon = $this->long0;
  128 + }
  129 + }
  130 +
  131 + $p->x = $lon;
  132 + $p->y = $lat;
  133 +
  134 + return $p;
  135 + }
  136 +
  137 +}
  138 +
  139 +Proj4php::$proj['sinu'] = new Proj4phpProjSinu();
0 140 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/somerc.php 0 → 100644
... ... @@ -0,0 +1,135 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME SWISS OBLIQUE MERCATOR
  11 +
  12 + PURPOSE: Swiss projection.
  13 + WARNING: X and Y are inverted (weird) in the swiss coordinate system. Not
  14 + here, since we want X to be horizontal and Y vertical.
  15 +
  16 + ALGORITHM REFERENCES
  17 + 1. "Formules et constantes pour le Calcul pour la
  18 + projection cylindrique conforme à axe oblique et pour la transformation entre
  19 + des systèmes de référence".
  20 + http://www.swisstopo.admin.ch/internet/swisstopo/fr/home/topics/survey/sys/refsys/switzerland.parsysrelated1.31216.downloadList.77004.DownloadFile.tmp/swissprojectionfr.pdf
  21 +
  22 +*******************************************************************************/
  23 +
  24 +class Proj4phpProjSomerc {
  25 +
  26 + /**
  27 + *
  28 + */
  29 + public function init() {
  30 + $phy0 = $this->lat0;
  31 + $this->lambda0 = $this->long0;
  32 + $sinPhy0 = sin( $phy0 );
  33 + $semiMajorAxis = $this->a;
  34 + $invF = $this->rf;
  35 + $flattening = 1 / $invF;
  36 + $e2 = 2 * $flattening - pow( $flattening, 2 );
  37 + $e = $this->e = sqrt( $e2 );
  38 + $this->R = $this->k0 * $semiMajorAxis * sqrt( 1 - $e2 ) / (1 - $e2 * pow( $sinPhy0, 2.0 ));
  39 + $this->alpha = sqrt( 1 + $e2 / (1 - $e2) * pow( cos( $phy0 ), 4.0 ) );
  40 + $this->b0 = asin( $sinPhy0 / $this->alpha );
  41 + $this->K = log( tan( Proj4php::$common->PI / 4.0 + $this->b0 / 2.0 ) )
  42 + - $this->alpha
  43 + * log( tan( Proj4php::$common->PI / 4.0 + $phy0 / 2.0 ) )
  44 + + $this->alpha
  45 + * $e / 2
  46 + * log( (1 + $e * $sinPhy0)
  47 + / (1 - $e * $sinPhy0) );
  48 + }
  49 +
  50 + /**
  51 + *
  52 + * @param type $p
  53 + * @return type
  54 + */
  55 + public function forward( $p ) {
  56 + $Sa1 = log( tan( Proj4php::$common->PI / 4.0 - $p->y / 2.0 ) );
  57 + $Sa2 = $this->e / 2.0
  58 + * log( (1 + $this->e * sin( $p->y ))
  59 + / (1 - $this->e * sin( $p->y )) );
  60 + $S = -$this->alpha * ($Sa1 + $Sa2) + $this->K;
  61 +
  62 + // spheric latitude
  63 + $b = 2.0 * (atan( exp( $S ) ) - proj4phpCommon::PI / 4.0);
  64 +
  65 + // spheric longitude
  66 + $I = $this->alpha * ($p->x - $this->lambda0);
  67 +
  68 + // psoeudo equatorial rotation
  69 + $rotI = atan( sin( $I )
  70 + / (sin( $this->b0 ) * tan( $b ) +
  71 + cos( $this->b0 ) * cos( $I )) );
  72 +
  73 + $rotB = asin( cos( $this->b0 ) * sin( $b ) -
  74 + sin( $this->b0 ) * cos( $b ) * cos( $I ) );
  75 +
  76 + $p->y = $this->R / 2.0
  77 + * log( (1 + sin( $rotB )) / (1 - sin( $rotB )) )
  78 + + $this->y0;
  79 +
  80 + $p->x = $this->R * $rotI + $this->x0;
  81 +
  82 + return $p;
  83 + }
  84 +
  85 + /**
  86 + *
  87 + * @param type $p
  88 + * @return type
  89 + */
  90 + public function inverse( $p ) {
  91 +
  92 + $Y = $p->x - $this->x0;
  93 + $X = $p->y - $this->y0;
  94 +
  95 + $rotI = $Y / $this->R;
  96 + $rotB = 2 * (atan( exp( $X / $this->R ) ) - Proj4php::$common->PI / 4.0);
  97 +
  98 + $b = asin( cos( $this->b0 ) * sin( $rotB )
  99 + + sin( $this->b0 ) * cos( $rotB ) * cos( $rotI ) );
  100 + $I = atan( sin( $rotI )
  101 + / (cos( $this->b0 ) * cos( $rotI ) - sin( $this->b0 )
  102 + * tan( $rotB )) );
  103 +
  104 + $lambda = $this->lambda0 + $I / $this->alpha;
  105 +
  106 + $S = 0.0;
  107 + $phy = $b;
  108 + $prevPhy = -1000.0;
  109 + $iteration = 0;
  110 + while( abs( $phy - $prevPhy ) > 0.0000001 ) {
  111 + if( ++$iteration > 20 ) {
  112 + Proj4php::reportError( "omercFwdInfinity" );
  113 + return;
  114 + }
  115 + //S = log(tan(PI / 4.0 + phy / 2.0));
  116 + $S = 1.0
  117 + / $this->alpha
  118 + * (log( tan( Proj4php::$common->PI / 4.0 + $b / 2.0 ) ) - $this->K)
  119 + + $this->e
  120 + * log( tan( Proj4php::$common->PI / 4.0
  121 + + asin( $this->e * sin( $phy ) )
  122 + / 2.0 ) );
  123 + $prevPhy = $phy;
  124 + $phy = 2.0 * atan( exp( $S ) ) - Proj4php::$common->PI / 2.0;
  125 + }
  126 +
  127 + $p->x = $lambda;
  128 + $p->y = $phy;
  129 +
  130 + return $p;
  131 + }
  132 +
  133 +}
  134 +
  135 +Proj4php::$proj['somerc'] = new Proj4phpProjSomerc();
0 136 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/stere.php 0 → 100644
... ... @@ -0,0 +1,303 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +
  10 +// Initialize the Stereographic projection
  11 +class Proj4phpProjStere {
  12 +
  13 + protected $TOL = 1.e-8;
  14 + protected $NITER = 8;
  15 + protected $CONV = 1.e-10;
  16 + protected $S_POLE = 0;
  17 + protected $N_POLE = 1;
  18 + protected $OBLIQ = 2;
  19 + protected $EQUIT = 3;
  20 +
  21 + /**
  22 + *
  23 + * @param type $phit
  24 + * @param type $sinphi
  25 + * @param type $eccen
  26 + * @return type
  27 + */
  28 + public function ssfn_( $phit, $sinphi, $eccen ) {
  29 + $sinphi *= $eccen;
  30 + return (tan( .5 * (Proj4php::$common->HALF_PI + $phit) ) * pow( (1. - $sinphi) / (1. + $sinphi), .5 * $eccen ));
  31 + }
  32 +
  33 + /**
  34 + *
  35 + */
  36 + public function init() {
  37 + $this->phits = $this->lat_ts ? $this->lat_ts : Proj4php::$common->HALF_PI;
  38 + $t = abs( $this->lat0 );
  39 + if( (abs( $t ) - Proj4php::$common->HALF_PI) < Proj4php::$common->EPSLN ) {
  40 + $this->mode = $this->lat0 < 0. ? $this->S_POLE : $this->N_POLE;
  41 + } else {
  42 + $this->mode = $t > Proj4php::$common->EPSLN ? $this->OBLIQ : $this->EQUIT;
  43 + }
  44 + $this->phits = abs( $this->phits );
  45 + if( $this->es ) {
  46 + #$X;
  47 +
  48 + switch( $this->mode ) {
  49 + case $this->N_POLE:
  50 + case $this->S_POLE:
  51 + if( abs( $this->phits - Proj4php::$common->HALF_PI ) < Proj4php::$common->EPSLN ) {
  52 + $this->akm1 = 2. * $this->k0 / sqrt( pow( 1 + $this->e, 1 + $this->e ) * pow( 1 - $this->e, 1 - $this->e ) );
  53 + } else {
  54 + $t = sin( $this->phits );
  55 + $this->akm1 = cos( $this->phits ) / Proj4php::$common->tsfnz( $this->e, $this->phits, $t );
  56 + $t *= $this->e;
  57 + $this->akm1 /= sqrt( 1. - $t * $t );
  58 + }
  59 + break;
  60 + case $this->EQUIT:
  61 + $this->akm1 = 2. * $this->k0;
  62 + break;
  63 + case $this->OBLIQ:
  64 + $t = sin( $this->lat0 );
  65 + $X = 2. * atan( $this->ssfn_( $this->lat0, $t, $this->e ) ) - Proj4php::$common->HALF_PI;
  66 + $t *= $this->e;
  67 + $this->akm1 = 2. * $this->k0 * cos( $this->lat0 ) / sqrt( 1. - $t * $t );
  68 + $this->sinX1 = sin( $X );
  69 + $this->cosX1 = cos( $X );
  70 + break;
  71 + }
  72 + } else {
  73 + switch( $this->mode ) {
  74 + case $this->OBLIQ:
  75 + $this->sinph0 = sin( $this->lat0 );
  76 + $this->cosph0 = cos( $this->lat0 );
  77 + case $this->EQUIT:
  78 + $this->akm1 = 2. * $this->k0;
  79 + break;
  80 + case $this->S_POLE:
  81 + case $this->N_POLE:
  82 + $this->akm1 = abs( $this->phits - Proj4php::$common->HALF_PI ) >= Proj4php::$common->EPSLN ?
  83 + cos( $this->phits ) / tan( Proj4php::$common->FORTPI - .5 * $this->phits ) :
  84 + 2. * $this->k0;
  85 + break;
  86 + }
  87 + }
  88 + }
  89 +
  90 + /**
  91 + * Stereographic forward equations--mapping lat,long to x,y
  92 + *
  93 + * @param type $p
  94 + * @return type
  95 + */
  96 + public function forward( $p ) {
  97 +
  98 + $lon = $p->x;
  99 + $lon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  100 + $lat = $p->y;
  101 + #$x;
  102 + #$y;
  103 +
  104 + if( $this->sphere ) {
  105 + /*
  106 + $sinphi;
  107 + $cosphi;
  108 + $coslam;
  109 + $sinlam;
  110 + */
  111 +
  112 + $sinphi = sin( $lat );
  113 + $cosphi = cos( $lat );
  114 + $coslam = cos( $lon );
  115 + $sinlam = sin( $lon );
  116 + switch( $this->mode ) {
  117 + case $this->EQUIT:
  118 + $y = 1. + $cosphi * $coslam;
  119 + if( y <= Proj4php::$common->EPSLN ) {
  120 + Proj4php::reportError("stere:forward:Equit");
  121 + }
  122 + $y = $this->akm1 / $y;
  123 + $x = $y * $cosphi * $sinlam;
  124 + $y *= $sinphi;
  125 + break;
  126 + case $this->OBLIQ:
  127 + $y = 1. + $this->sinph0 * $sinphi + $this->cosph0 * $cosphi * $coslam;
  128 + if( $y <= Proj4php::$common->EPSLN ) {
  129 + Proj4php::reportError("stere:forward:Obliq");
  130 + }
  131 + $y = $this->akm1 / $y;
  132 + $x = $y * $cosphi * $sinlam;
  133 + $y *= $this->cosph0 * $sinphi - $this->sinph0 * $cosphi * $coslam;
  134 + break;
  135 + case $this->N_POLE:
  136 + $coslam = -$coslam;
  137 + $lat = -$lat;
  138 + //Note no break here so it conitnues through S_POLE
  139 + case $this->S_POLE:
  140 + if( abs( $lat - Proj4php::$common->HALF_PI ) < $this->TOL ) {
  141 + Proj4php::reportError("stere:forward:S_POLE");
  142 + }
  143 + $y = $this->akm1 * tan( Proj4php::$common->FORTPI + .5 * $lat );
  144 + $x = $sinlam * $y;
  145 + $y *= $coslam;
  146 + break;
  147 + }
  148 + } else {
  149 + $coslam = cos( $lon );
  150 + $sinlam = sin( $lon );
  151 + $sinphi = sin( $lat );
  152 + if( $this->mode == $this->OBLIQ || $this->mode == $this->EQUIT ) {
  153 + $Xt = 2. * atan( $this->ssfn_( $lat, $sinphi, $this->e ) );
  154 + $sinX = sin( $Xt - Proj4php::$common->HALF_PI );
  155 + $cosX = cos( $Xt );
  156 + }
  157 + switch( $this->mode ) {
  158 + case $this->OBLIQ:
  159 + $A = $this->akm1 / ($this->cosX1 * (1. + $this->sinX1 * $sinX + $this->cosX1 * $cosX * $coslam));
  160 + $y = $A * ($this->cosX1 * $sinX - $this->sinX1 * $cosX * $coslam);
  161 + $x = $A * $cosX;
  162 + break;
  163 + case $this->EQUIT:
  164 + $A = 2. * $this->akm1 / (1. + $cosX * $coslam);
  165 + $y = $A * $sinX;
  166 + $x = $A * $cosX;
  167 + break;
  168 + case $this->S_POLE:
  169 + $lat = -$lat;
  170 + $coslam = - $coslam;
  171 + $sinphi = -$sinphi;
  172 + case $this->N_POLE:
  173 + $x = $this->akm1 * Proj4php::$common->tsfnz( $this->e, $lat, $sinphi );
  174 + $y = - $x * $coslam;
  175 + break;
  176 + }
  177 + $x = $x * $sinlam;
  178 + }
  179 +
  180 + $p->x = $x * $this->a + $this->x0;
  181 + $p->y = $y * $this->a + $this->y0;
  182 +
  183 + return $p;
  184 + }
  185 +
  186 +
  187 + /**
  188 + * Stereographic inverse equations--mapping x,y to lat/long
  189 + *
  190 + * @param type $p
  191 + * @return type
  192 + */
  193 + public function inverse( $p ) {
  194 + $x = ($p->x - $this->x0) / $this->a; /* descale and de-offset */
  195 + $y = ($p->y - $this->y0) / $this->a;
  196 + /*
  197 + $lon;
  198 + $lat;
  199 + $cosphi;
  200 + $sinphi;
  201 + $rho;
  202 + $tp = 0.0;
  203 + $phi_l = 0.0;
  204 + $i;
  205 + */
  206 + $halfe = 0.0;
  207 + $pi2 = 0.0;
  208 +
  209 + if( $this->sphere ) {
  210 + /*
  211 + $c;
  212 + $rh;
  213 + $sinc;
  214 + $cosc;
  215 + */
  216 +
  217 + $rh = sqrt( $x * $x + $y * $y );
  218 + $c = 2. * atan( $rh / $this->akm1 );
  219 + $sinc = sin( $c );
  220 + $cosc = cos( $c );
  221 + $lon = 0.;
  222 +
  223 + switch( $this->mode ) {
  224 + case $this->EQUIT:
  225 + if( abs( $rh ) <= Proj4php::$common->EPSLN ) {
  226 + $lat = 0.;
  227 + } else {
  228 + $lat = asin( $y * $sinc / $rh );
  229 + }
  230 + if( $cosc != 0. || $x != 0. )
  231 + $lon = atan2( $x * $sinc, $cosc * $rh );
  232 + break;
  233 + case $this->OBLIQ:
  234 + if( abs( $rh ) <= Proj4php::$common->EPSLN ) {
  235 + $lat = $this->phi0;
  236 + } else {
  237 + $lat = asin( $cosc * $this->sinph0 + $y * $sinc * $this->cosph0 / $rh );
  238 + }
  239 + $c = $cosc - $this->sinph0 * sin( $lat );
  240 + if( $c != 0. || $x != 0. ) {
  241 + $lon = atan2( $x * $sinc * $this->cosph0, $c * $rh );
  242 + }
  243 + break;
  244 + case $this->N_POLE:
  245 + $y = -$y;
  246 + case $this->S_POLE:
  247 + if( abs( $rh ) <= Proj4php::$common->EPSLN ) {
  248 + $lat = $this->phi0;
  249 + } else {
  250 + $lat = asin( $this->mode == $this->S_POLE ? -$cosc : $cosc );
  251 + }
  252 + $lon = ($x == 0. && $y == 0.) ? 0. : atan2( $x, $y );
  253 + break;
  254 + }
  255 + $p->x = Proj4php::$common->adjust_lon( $lon + $this->long0 );
  256 + $p->y = $lat;
  257 + } else {
  258 + $rho = sqrt( $x * $x + $y * $y );
  259 + switch( $this->mode ) {
  260 + case $this->OBLIQ:
  261 + case $this->EQUIT:
  262 + $tp = 2. * atan2( $rho * $this->cosX1, $this->akm1 );
  263 + $cosphi = cos( $tp );
  264 + $sinphi = sin( $tp );
  265 + if( $rho == 0.0 ) {
  266 + $phi_l = asin( $cosphi * $this->sinX1 );
  267 + } else {
  268 + $phi_l = asin( $cosphi * $this->sinX1 + ($y * $sinphi * $this->cosX1 / $rho) );
  269 + }
  270 +
  271 + $tp = tan( .5 * (Proj4php::$common->HALF_PI + $phi_l) );
  272 + $x *= $sinphi;
  273 + $y = $rho * $this->cosX1 * $cosphi - $y * $this->sinX1 * $sinphi;
  274 + $pi2 = Proj4php::$common->HALF_PI;
  275 + $halfe = .5 * $this->e;
  276 + break;
  277 + case $this->N_POLE:
  278 + $y = -$y;
  279 + case $this->S_POLE:
  280 + $tp = - $rho / $this->akm1;
  281 + $phi_l = Proj4php::$common->HALF_PI - 2. * atan( $tp );
  282 + $pi2 = -Proj4php::$common->HALF_PI;
  283 + $halfe = -.5 * $this->e;
  284 + break;
  285 + }
  286 + for( $i = $this->NITER; $i--; $phi_l = $lat ) { //check this
  287 + $sinphi = $this->e * sin( $phi_l );
  288 + $lat = 2. * atan( $tp * pow( (1. + $sinphi) / (1. - $sinphi), $halfe ) ) - $pi2;
  289 + if( abs( phi_l - lat ) < $this->CONV ) {
  290 + if( $this->mode == $this->S_POLE )
  291 + $lat = -$lat;
  292 + $lon = ($x == 0. && $y == 0.) ? 0. : atan2( $x, $y );
  293 + $p->x = Proj4php::$common->adjust_lon( $lon + $this->long0 );
  294 + $p->y = $lat;
  295 + return $p;
  296 + }
  297 + }
  298 + }
  299 + }
  300 +
  301 +}
  302 +
  303 +Proj4php::$proj['stere'] = new Proj4phpProjStere();
0 304 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/sterea.php 0 → 100644
... ... @@ -0,0 +1,91 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +class Proj4phpProjSterea {
  10 +
  11 + public $dependsOn = 'gauss';
  12 +
  13 + /**
  14 + *
  15 + * @return void
  16 + */
  17 + public function init() {
  18 +
  19 + if( !$this->rc ) {
  20 + Proj4php::reportError( "sterea:init:E_ERROR_0" );
  21 + return;
  22 + }
  23 +
  24 + $this->sinc0 = sin( $this->phic0 );
  25 + $this->cosc0 = cos( $this->phic0 );
  26 + $this->R2 = 2.0 * $this->rc;
  27 +
  28 + if( !$this->title )
  29 + $this->title = "Oblique Stereographic Alternative";
  30 + }
  31 +
  32 + /**
  33 + *
  34 + * @param type $p
  35 + * @return type
  36 + */
  37 + public function forward( $p ) {
  38 +
  39 + $p->x = Proj4php::$common->adjust_lon( $p->x - $this->long0 ); /* adjust del longitude */
  40 + $p = Proj4php::$proj['gauss']->forward( $p );
  41 + $sinc = sin( $p->y );
  42 + $cosc = cos( $p->y );
  43 + $cosl = cos( $p->x );
  44 + $k = $this->k0 * $this->R2 / (1.0 + $this->sinc0 * $sinc + $this->cosc0 * $cosc * $cosl);
  45 +
  46 + $p->x = $k * $cosc * sin( $p->x );
  47 + $p->y = $k * ($this->cosc0 * sinc - $this->sinc0 * $cosc * $cosl);
  48 +
  49 + $p->x = $this->a * $p->x + $this->x0;
  50 + $p->y = $this->a * $p->y + $this->y0;
  51 +
  52 + return $p;
  53 + }
  54 +
  55 + /**
  56 + *
  57 + * @param type $p
  58 + * @return type
  59 + */
  60 + public function inverse( $p ) {
  61 +
  62 + #$lon;
  63 + #$lat;
  64 + $p->x = ($p->x - $this->x0) / $this->a; /* descale and de-offset */
  65 + $p->y = ($p->y - $this->y0) / $this->a;
  66 +
  67 + $p->x /= $this->k0;
  68 + $p->y /= $this->k0;
  69 +
  70 + if( ($rho = sqrt( $p->x * $p->x + $p->y * $p->y ) ) ) {
  71 + $c = 2.0 * atan2( $rho, $this->R2 );
  72 + $sinc = sin( $c );
  73 + $cosc = cos( $c );
  74 + $lat = asin( $cosc * $this->sinc0 + $p->y * $sinc * $this->cosc0 / $rho );
  75 + $lon = atan2( $p->x * $sinc, $rho * $this->cosc0 * $cosc - $p->y * $this->sinc0 * $sinc );
  76 + } else {
  77 + $lat = $this->phic0;
  78 + $lon = 0.;
  79 + }
  80 +
  81 + $p->x = $lon;
  82 + $p->y = $lat;
  83 + $p = Proj4php::$proj['gauss']->inverse( $p );
  84 + $p->x = Proj4php::$common->adjust_lon( $p->x + $this->long0 ); /* adjust longitude to CM */
  85 +
  86 + return $p;
  87 + }
  88 +
  89 +}
  90 +
  91 +Proj4php::$proj['sterea'] = new Proj4phpProjSterea();
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/tmerc.php 0 → 100644
... ... @@ -0,0 +1,166 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME TRANSVERSE MERCATOR
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the Transverse Mercator projection. The
  14 + longitude and latitude must be in radians. The Easting
  15 + and Northing values will be returned in meters.
  16 +
  17 + ALGORITHM REFERENCES
  18 +
  19 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  20 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  21 + State Government Printing Office, Washington D.C., 1987.
  22 +
  23 + 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  24 + U.S. Geological Survey Professional Paper 1453 , United State Government
  25 + Printing Office, Washington D.C., 1989.
  26 +*******************************************************************************/
  27 +
  28 +/**
  29 + Initialize Transverse Mercator projection
  30 + */
  31 +class Proj4phpProjTmerc {
  32 +
  33 + private $e0, $e1, $e2, $e3, $ml0;
  34 +
  35 + /**
  36 + *
  37 + */
  38 + public function init() {
  39 +
  40 + $this->e0 = Proj4php::$common->e0fn( $this->es );
  41 + $this->e1 = Proj4php::$common->e1fn( $this->es );
  42 + $this->e2 = Proj4php::$common->e2fn( $this->es );
  43 + $this->e3 = Proj4php::$common->e3fn( $this->es );
  44 + $this->ml0 = $this->a * Proj4php::$common->mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 );
  45 + }
  46 +
  47 + /**
  48 + Transverse Mercator Forward - long/lat to x/y
  49 + long/lat in radians
  50 + */
  51 + public function forward( $p ) {
  52 +
  53 + $lon = $p->x;
  54 + $lat = $p->y;
  55 +
  56 + $delta_lon = Proj4php::$common->adjust_lon( $lon - $this->long0 ); // Delta longitude
  57 + #$con = 0; // cone constant
  58 + #$x = 0;
  59 + #$y = 0;
  60 + $sin_phi = sin( $lat );
  61 + $cos_phi = cos( $lat );
  62 +
  63 + if( isset($this->sphere) && $this->sphere === true ) { /* spherical form */
  64 + $b = $cos_phi * sin( $delta_lon );
  65 + if( (abs( abs( $b ) - 1.0 )) < .0000000001 ) {
  66 + Proj4php::reportError( "tmerc:forward: Point projects into infinity" );
  67 + return(93);
  68 + } else {
  69 + $x = .5 * $this->a * $this->k0 * log( (1.0 + $b) / (1.0 - $b) );
  70 + $con = acos( $cos_phi * cos( $delta_lon ) / sqrt( 1.0 - $b * $b ) );
  71 + if( $lat < 0 )
  72 + $con = - $con;
  73 + $y = $this->a * $this->k0 * ($con - $this->lat0);
  74 + }
  75 + } else {
  76 + $al = $cos_phi * $delta_lon;
  77 + $als = pow( $al, 2 );
  78 + $c = $this->ep2 * pow( $cos_phi, 2 );
  79 + $tq = tan( $lat );
  80 + $t = pow( $tq, 2 );
  81 + $con = 1.0 - $this->es * pow( $sin_phi, 2 );
  82 + $n = $this->a / sqrt( $con );
  83 +
  84 + $ml = $this->a * Proj4php::$common->mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $lat );
  85 +
  86 + $x = $this->k0 * $n * $al * (1.0 + $als / 6.0 * (1.0 - $t + $c + $als / 20.0 * (5.0 - 18.0 * $t + pow( $t, 2 ) + 72.0 * $c - 58.0 * $this->ep2))) + $this->x0;
  87 + $y = $this->k0 * ($ml - $this->ml0 + $n * $tq * ($als * (0.5 + $als / 24.0 * (5.0 - $t + 9.0 * $c + 4.0 * pow( $c, 2 ) + $als / 30.0 * (61.0 - 58.0 * $t + pow( $t, 2 ) + 600.0 * $c - 330.0 * $this->ep2))))) + $this->y0;
  88 + }
  89 +
  90 + $p->x = $x;
  91 + $p->y = $y;
  92 +
  93 + return $p;
  94 + }
  95 +
  96 + /**
  97 + Transverse Mercator Inverse - x/y to long/lat
  98 + */
  99 + public function inverse( $p ) {
  100 +
  101 + #$phi; /* temporary angles */
  102 + #$delta_phi; /* difference between longitudes */
  103 + $max_iter = 6; /* maximun number of iterations */
  104 +
  105 + if( isset($this->sphere) && $this->sphere === true ) { /* spherical form */
  106 + $f = exp( $p->x / ($this->a * $this->k0) );
  107 + $g = .5 * ($f - 1 / $f);
  108 + $temp = $this->lat0 + $p->y / ($this->a * $this->k0);
  109 + $h = cos( $temp );
  110 + $con = sqrt( (1.0 - $h * $h) / (1.0 + $g * $g) );
  111 + $lat = Proj4php::$common->asinz( $con );
  112 + if( $temp < 0 )
  113 + $lat = -$lat;
  114 + if( ($g == 0) && ($h == 0) ) {
  115 + $lon = $this->long0;
  116 + } else {
  117 + $lon = Proj4php::$common->adjust_lon( atan2( $g, $h ) + $this->long0 );
  118 + }
  119 + } else { // ellipsoidal form
  120 + $x = $p->x - $this->x0;
  121 + $y = $p->y - $this->y0;
  122 +
  123 + $con = ($this->ml0 + $y / $this->k0) / $this->a;
  124 + $phi = $con;
  125 +
  126 + for( $i = 0; true; $i++ ) {
  127 + $delta_phi = (($con + $this->e1 * sin( 2.0 * $phi ) - $this->e2 * sin( 4.0 * $phi ) + $this->e3 * sin( 6.0 * $phi )) / $this->e0) - $phi;
  128 + $phi += $delta_phi;
  129 + if( abs( $delta_phi ) <= Proj4php::$common->EPSLN )
  130 + break;
  131 + if( $i >= $max_iter ) {
  132 + Proj4php::reportError( "tmerc:inverse: Latitude failed to converge" );
  133 + return(95);
  134 + }
  135 + } // for()
  136 + if( abs( $phi ) < Proj4php::$common->HALF_PI ) {
  137 + // sincos(phi, &sin_phi, &cos_phi);
  138 + $sin_phi = sin( $phi );
  139 + $cos_phi = cos( $phi );
  140 + $tan_phi = tan( $phi );
  141 + $c = $this->ep2 * pow( $cos_phi, 2 );
  142 + $cs = pow( $c, 2 );
  143 + $t = pow( $tan_phi, 2 );
  144 + $ts = pow( $t, 2 );
  145 + $con = 1.0 - $this->es * pow( $sin_phi, 2 );
  146 + $n = $this->a / sqrt( $con );
  147 + $r = $n * (1.0 - $this->es) / $con;
  148 + $d = $x / ($n * $this->k0);
  149 + $ds = pow( $d, 2 );
  150 + $lat = $phi - ($n * $tan_phi * $ds / $r) * (0.5 - $ds / 24.0 * (5.0 + 3.0 * $t + 10.0 * $c - 4.0 * $cs - 9.0 * $this->ep2 - $ds / 30.0 * (61.0 + 90.0 * $t + 298.0 * $c + 45.0 * $ts - 252.0 * $this->ep2 - 3.0 * $cs)));
  151 + $lon = Proj4php::$common->adjust_lon( $this->long0 + ($d * (1.0 - $ds / 6.0 * (1.0 + 2.0 * $t + $c - $ds / 20.0 * (5.0 - 2.0 * $c + 28.0 * $t - 3.0 * $cs + 8.0 * $this->ep2 + 24.0 * $ts))) / $cos_phi) );
  152 + } else {
  153 + $lat = Proj4php::$common->HALF_PI * Proj4php::$common->sign( $y );
  154 + $lon = $this->long0;
  155 + }
  156 + }
  157 +
  158 + $p->x = $lon;
  159 + $p->y = $lat;
  160 +
  161 + return $p;
  162 + }
  163 +
  164 +}
  165 +
  166 +Proj4php::$proj['tmerc'] = new Proj4phpProjTmerc();
0 167 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/utm.php 0 → 100644
... ... @@ -0,0 +1,182 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME TRANSVERSE MERCATOR
  11 +
  12 + PURPOSE: Transforms input longitude and latitude to Easting and
  13 + Northing for the Transverse Mercator projection. The
  14 + longitude and latitude must be in radians. The Easting
  15 + and Northing values will be returned in meters.
  16 +
  17 + ALGORITHM REFERENCES
  18 +
  19 + 1. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  20 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  21 + State Government Printing Office, Washington D.C., 1987.
  22 +
  23 + 2. Snyder, John P. and Voxland, Philip M., "An Album of Map Projections",
  24 + U.S. Geological Survey Professional Paper 1453 , United State Government
  25 + Printing Office, Washington D.C., 1989.
  26 +*******************************************************************************/
  27 +
  28 +/**
  29 + Initialize Transverse Mercator projection
  30 + */
  31 +class Proj4phpProjUtm{
  32 +
  33 + //public $dependsOn = 'tmerc';
  34 +
  35 + public $utmSouth = false; // UTM north/south
  36 + private $e0, $e1, $e2, $e3, $ml0;
  37 +
  38 + /**
  39 + *
  40 + * @return void
  41 + */
  42 + public function init() {
  43 +
  44 + if( !isset($this->zone) ) {
  45 + Proj4php::reportError( "utm:init: zone must be specified for UTM" );
  46 + return;
  47 + }
  48 +
  49 + $this->lat0 = 0.0;
  50 + $this->long0 = ((6 * abs( $this->zone )) - 183) * Proj4php::$common->D2R;
  51 + $this->x0 = 500000.0;
  52 + $this->y0 = $this->utmSouth ? 10000000.0 : 0.0;
  53 + $this->k0 = 0.9996;
  54 +
  55 + $this->e0 = Proj4php::$common->e0fn( $this->es );
  56 + $this->e1 = Proj4php::$common->e1fn( $this->es );
  57 + $this->e2 = Proj4php::$common->e2fn( $this->es );
  58 + $this->e3 = Proj4php::$common->e3fn( $this->es );
  59 + $this->ml0 = $this->a * Proj4php::$common->mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $this->lat0 );
  60 + }
  61 +
  62 + /**
  63 + Transverse Mercator Forward - long/lat to x/y
  64 + long/lat in radians
  65 + */
  66 +
  67 + public function forward( $p ) {
  68 +
  69 + $lon = $p->x;
  70 + $lat = $p->y;
  71 +
  72 + $delta_lon = Proj4php::$common->adjust_lon( $lon - $this->long0 ); // Delta longitude
  73 + #$con = 0; // cone constant
  74 + #$x = 0;
  75 + #$y = 0;
  76 + $sin_phi = sin( $lat );
  77 + $cos_phi = cos( $lat );
  78 +
  79 + if( isset($this->sphere) && $this->sphere === true ) { /* spherical form */
  80 + $b = $cos_phi * sin( $delta_lon );
  81 + if( (abs( abs( $b ) - 1.0 )) < .0000000001 ) {
  82 + Proj4php::reportError( "tmerc:forward: Point projects into infinity" );
  83 + return(93);
  84 + } else {
  85 + $x = .5 * $this->a * $this->k0 * log( (1.0 + $b) / (1.0 - $b) );
  86 + $con = acos( $cos_phi * cos( $delta_lon ) / sqrt( 1.0 - $b * $b ) );
  87 + if( $lat < 0 )
  88 + $con = - $con;
  89 + $y = $this->a * $this->k0 * ($con - $this->lat0);
  90 + }
  91 + } else {
  92 + $al = $cos_phi * $delta_lon;
  93 + $als = pow( $al, 2 );
  94 + $c = $this->ep2 * pow( $cos_phi, 2 );
  95 + $tq = tan( $lat );
  96 + $t = pow( $tq, 2 );
  97 + $con = 1.0 - $this->es * pow( $sin_phi, 2 );
  98 + $n = $this->a / sqrt( $con );
  99 +
  100 + $ml = $this->a * Proj4php::$common->mlfn( $this->e0, $this->e1, $this->e2, $this->e3, $lat );
  101 +
  102 + $x = $this->k0 * $n * $al * (1.0 + $als / 6.0 * (1.0 - $t + $c + $als / 20.0 * (5.0 - 18.0 * $t + pow( $t, 2 ) + 72.0 * $c - 58.0 * $this->ep2))) + $this->x0;
  103 + $y = $this->k0 * ($ml - $this->ml0 + $n * $tq * ($als * (0.5 + $als / 24.0 * (5.0 - $t + 9.0 * $c + 4.0 * pow( $c, 2 ) + $als / 30.0 * (61.0 - 58.0 * $t + pow( $t, 2 ) + 600.0 * $c - 330.0 * $this->ep2))))) + $this->y0;
  104 + }
  105 +
  106 + $p->x = $x;
  107 + $p->y = $y;
  108 +
  109 + return $p;
  110 + }
  111 +
  112 + /**
  113 + Transverse Mercator Inverse - x/y to long/lat
  114 + */
  115 + public function inverse( $p ) {
  116 +
  117 + #$phi; /* temporary angles */
  118 + #$delta_phi; /* difference between longitudes */
  119 + $max_iter = 6; /* maximun number of iterations */
  120 + if( isset($this->sphere) && $this->sphere === true ) { /* spherical form */
  121 + $f = exp( $p->x / ($this->a * $this->k0) );
  122 + $g = .5 * ($f - 1 / $f);
  123 + $temp = $this->lat0 + $p->y / ($this->a * $this->k0);
  124 + $h = cos( $temp );
  125 + $con = sqrt( (1.0 - $h * $h) / (1.0 + $g * $g) );
  126 + $lat = Proj4php::$common->asinz( $con );
  127 + if( $temp < 0 )
  128 + $lat = -$lat;
  129 + if( ($g == 0) && ($h == 0) ) {
  130 + $lon = $this->long0;
  131 + } else {
  132 + $lon = Proj4php::$common->adjust_lon( atan2( $g, $h ) + $this->long0 );
  133 + }
  134 + } else { // ellipsoidal form
  135 + $x = $p->x - $this->x0;
  136 + $y = $p->y - $this->y0;
  137 +
  138 + $con = ($this->ml0 + $y / $this->k0) / $this->a;
  139 + $phi = $con;
  140 +
  141 + for( $i = 0; true; $i++ ) {
  142 + $delta_phi = (($con + $this->e1 * sin( 2.0 * $phi ) - $this->e2 * sin( 4.0 * $phi ) + $this->e3 * sin( 6.0 * $phi )) / $this->e0) - $phi;
  143 + $phi += $delta_phi;
  144 + if( abs( $delta_phi ) <= Proj4php::$common->EPSLN )
  145 + break;
  146 + if( $i >= $max_iter ) {
  147 + Proj4php::reportError( "tmerc:inverse: Latitude failed to converge" );
  148 + return(95);
  149 + }
  150 + } // for()
  151 +
  152 +
  153 + if( abs( $phi ) < Proj4php::$common->HALF_PI ) {
  154 + // sincos(phi, &sin_phi, &cos_phi);
  155 + $sin_phi = sin( $phi );
  156 + $cos_phi = cos( $phi );
  157 + $tan_phi = tan( $phi );
  158 + $c = $this->ep2 * pow( $cos_phi, 2 );
  159 + $cs = pow( $c, 2 );
  160 + $t = pow( $tan_phi, 2 );
  161 + $ts = pow( $t, 2 );
  162 + $con = 1.0 - $this->es * pow( $sin_phi, 2 );
  163 + $n = $this->a / sqrt( $con );
  164 + $r = $n * (1.0 - $this->es) / $con;
  165 + $d = $x / ($n * $this->k0);
  166 + $ds = pow( $d, 2 );
  167 + $lat = $phi - ($n * $tan_phi * $ds / $r) * (0.5 - $ds / 24.0 * (5.0 + 3.0 * $t + 10.0 * $c - 4.0 * $cs - 9.0 * $this->ep2 - $ds / 30.0 * (61.0 + 90.0 * $t + 298.0 * $c + 45.0 * $ts - 252.0 * $this->ep2 - 3.0 * $cs)));
  168 + $lon = Proj4php::$common->adjust_lon( $this->long0 + ($d * (1.0 - $ds / 6.0 * (1.0 + 2.0 * $t + $c - $ds / 20.0 * (5.0 - 2.0 * $c + 28.0 * $t - 3.0 * $cs + 8.0 * $this->ep2 + 24.0 * $ts))) / $cos_phi) );
  169 + } else {
  170 + $lat = Proj4php::$common->HALF_PI * Proj4php::$common->sign( $y );
  171 + $lon = $this->long0;
  172 + }
  173 + }
  174 +
  175 + $p->x = $lon;
  176 + $p->y = $lat;
  177 +
  178 + return $p;
  179 + }
  180 +}
  181 +
  182 +Proj4php::$proj['utm'] = new Proj4phpProjUtm();
0 183 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/src/proj4php/projCode/vandg.php 0 → 100644
... ... @@ -0,0 +1,167 @@
  1 +<?php
  2 +/**
  3 + * Author : Julien Moquet
  4 + *
  5 + * Inspired by Proj4php from Mike Adair madairATdmsolutions.ca
  6 + * and Richard Greenwood rich@greenwoodma$p->com
  7 + * License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
  8 + */
  9 +/*******************************************************************************
  10 + NAME VAN DER GRINTEN
  11 +
  12 + PURPOSE: Transforms input Easting and Northing to longitude and
  13 + latitude for the Van der Grinten projection. The
  14 + Easting and Northing must be in meters. The longitude
  15 + and latitude values will be returned in radians.
  16 +
  17 + PROGRAMMER DATE
  18 + ---------- ----
  19 + T. Mittan March, 1993
  20 +
  21 + This function was adapted from the Van Der Grinten projection code
  22 + (FORTRAN) in the General Cartographic Transformation Package software
  23 + which is available from the U.S. Geological Survey National Mapping Division.
  24 +
  25 + ALGORITHM REFERENCES
  26 +
  27 + 1. "New Equal-Area Map Projections for Noncircular Regions", John P. Snyder,
  28 + The American Cartographer, Vol 15, No. 4, October 1988, pp. 341-355.
  29 +
  30 + 2. Snyder, John P., "Map Projections--A Working Manual", U.S. Geological
  31 + Survey Professional Paper 1395 (Supersedes USGS Bulletin 1532), United
  32 + State Government Printing Office, Washington D.C., 1987.
  33 +
  34 + 3. "Software Documentation for GCTP General Cartographic Transformation
  35 + Package", U.S. Geological Survey National Mapping Division, May 1982.
  36 + * ***************************************************************************** */
  37 +
  38 +class Proj4phpProjVandg {
  39 +
  40 + /* Initialize the Van Der Grinten projection
  41 + ---------------------------------------- */
  42 + public function init() {
  43 + $this->R = 6370997.0; //Radius of earth
  44 + }
  45 +
  46 + /**
  47 + *
  48 + * @param type $p
  49 + * @return type
  50 + */
  51 + public function forward( $p ) {
  52 +
  53 + $lon = $p->x;
  54 + $lat = $p->y;
  55 +
  56 + /* Forward equations
  57 + ----------------- */
  58 + $dlon = Proj4php::$common->adjust_lon( $lon - $this->long0 );
  59 + $x;
  60 + $y;
  61 +
  62 + if( abs( $lat ) <= Proj4php::$common->EPSLN ) {
  63 + $x = $this->x0 + $this->R * $dlon;
  64 + $y = $this->y0;
  65 + }
  66 + $theta = Proj4php::$common->asinz( 2.0 * abs( $lat / Proj4php::$common->PI ) );
  67 + if( (abs( $dlon ) <= Proj4php::$common->EPSLN) || (abs( abs( $lat ) - Proj4php::$common->HALF_PI ) <= Proj4php::$common->EPSLN) ) {
  68 + $x = $this->x0;
  69 + if( $lat >= 0 ) {
  70 + $y = $this->y0 + Proj4php::$common->PI * $this->R * tan( .5 * $theta );
  71 + } else {
  72 + $y = $this->y0 + Proj4php::$common->PI * $this->R * - tan( .5 * $theta );
  73 + }
  74 + // return(OK);
  75 + }
  76 + $al = .5 * abs( (Proj4php::$common->PI / $dlon) - ($dlon / Proj4php::$common->PI) );
  77 + $asq = $al * $al;
  78 + $sinth = sin( $theta );
  79 + $costh = cos( $theta );
  80 +
  81 + $g = $costh / ($sinth + $costh - 1.0);
  82 + $gsq = $g * $g;
  83 + $m = $g * (2.0 / $sinth - 1.0);
  84 + $msq = $m * $m;
  85 + $con = Proj4php::$common->PI * $this->R * ($al * ($g - $msq) + sqrt( $asq * ($g - $sq) * ($g - $msq) - ($msq + $asq) * ($gsq - $msq) )) / ($msq + $asq);
  86 + if( $dlon < 0 ) {
  87 + $con = -$con;
  88 + }
  89 + $x = $this->x0 + $con;
  90 + $con = abs( $con / (Proj4php::$common->PI * $this->R) );
  91 + if( $lat >= 0 ) {
  92 + $y = $this->y0 + Proj4php::$common->PI * $this->R * sqrt( 1.0 - $con * $con - 2.0 * $al * $con );
  93 + } else {
  94 + $y = $this->y0 - Proj4php::$common->PI * $this->R * sqrt( 1.0 - $con * $con - 2.0 * $al * $con );
  95 + }
  96 +
  97 + $p->x = $x;
  98 + $p->y = $y;
  99 +
  100 + return $p;
  101 + }
  102 +
  103 + /* Van Der Grinten inverse equations--mapping x,y to lat/long
  104 + --------------------------------------------------------- */
  105 +
  106 + public function inverse( $p ) {
  107 +
  108 + /*
  109 + $dlon;
  110 + $xx;
  111 + $yy;
  112 + $xys;
  113 + $c1;
  114 + $c2;
  115 + $c3;
  116 + $al;
  117 + $asq;
  118 + $a1;
  119 + $m1;
  120 + $con;
  121 + $th1;
  122 + $d;
  123 + */
  124 +
  125 + /* inverse equations
  126 + ----------------- */
  127 + $p->x -= $this->x0;
  128 + $p->y -= $this->y0;
  129 + $con = Proj4php::$common->PI * $this->R;
  130 + $xx = $p->x / $con;
  131 + $yy = $p->y / $con;
  132 + $xys = $xx * $xx + $yy * $yy;
  133 + $c1 = -abs( $yy ) * (1.0 + $xys);
  134 + $c2 = $c1 - 2.0 * $yy * $yy + $xx * $xx;
  135 + $c3 = -2.0 * $c1 + 1.0 + 2.0 * $yy * $yy + $xys * $xys;
  136 + $d = $yy * $yy / $c3 + (2.0 * $c2 * $c2 * $c2 / $c3 / $c3 / $c3 - 9.0 * $c1 * $c2 / $c3 / $c3) / 27.0;
  137 + $a1 = ($c1 - $c2 * $c2 / 3.0 / $c3) / $c3;
  138 + $m1 = 2.0 * sqrt( -$a1 / 3.0 );
  139 + $con = ((3.0 * $d) / $a1) / $m1;
  140 + if( abs( $con ) > 1.0 ) {
  141 + if( $con >= 0.0 ) {
  142 + $con = 1.0;
  143 + } else {
  144 + $con = -1.0;
  145 + }
  146 + }
  147 + $th1 = acos( $con ) / 3.0;
  148 + if( $p->$y >= 0 ) {
  149 + $lat = (-$m1 * cos( $th1 + Proj4php::$common->PI / 3.0 ) - $c2 / 3.0 / $c3) * Proj4php::$common->PI;
  150 + } else {
  151 + $lat = -(-m1 * cos( $th1 + Proj4php::$common->PI / 3.0 ) - $c2 / 3.0 / $c3) * Proj4php::$common->PI;
  152 + }
  153 +
  154 + if( abs( $xx ) < Proj4php::$common->EPSLN ) {
  155 + $lon = $this->$long0;
  156 + }
  157 + $lon = Proj4php::$common->adjust_lon( $this->long0 + Proj4php::$common->PI * ($xys - 1.0 + sqrt( 1.0 + 2.0 * ($xx * $xx - $yy * $yy) + $xys * $xys )) / 2.0 / $xx );
  158 +
  159 + $p->x = $lon;
  160 + $p->y = $lat;
  161 +
  162 + return $p;
  163 + }
  164 +
  165 +}
  166 +
  167 +Proj4php::$proj['vandg'] = new Proj4phpProjVandg();
0 168 \ No newline at end of file
... ...
pacotes/proj4php-proj4php5.2/test/testproj.php 0 → 100644
... ... @@ -0,0 +1,87 @@
  1 +<?php
  2 +include_once("../src/proj4php/proj4php.php");
  3 +
  4 +$proj4 = new Proj4php();
  5 +$projL93 = new Proj4phpProj('EPSG:2154',$proj4);
  6 +$projWGS84 = new Proj4phpProj('EPSG:4326',$proj4);
  7 +$projLI = new Proj4phpProj('EPSG:27571',$proj4);
  8 +$projLSud = new Proj4phpProj('EPSG:27563',$proj4);
  9 +$projL72 = new Proj4phpProj('EPSG:31370',$proj4);
  10 +$proj25833 = new Proj4phpProj('EPSG:25833',$proj4);
  11 +$proj31468 = new Proj4phpProj('EPSG:31468',$proj4);
  12 +$proj5514 = new Proj4phpProj('EPSG:5514',$proj4);
  13 +
  14 +// GPS
  15 +// latitude longitude
  16 +// 48,831938 2,355781
  17 +// 48°49'54.977'' 2°21'20.812''
  18 +//
  19 +// L93
  20 +// 652709.401 6859290.946
  21 +//
  22 +// LI
  23 +// 601413.709 1125717.730
  24 +//
  25 +
  26 +$pointSrc = new proj4phpPoint('652709.401','6859290.946');
  27 +echo "Source : ".$pointSrc->toShortString()." in L93 <br>";
  28 +$pointDest = $proj4->transform($projL93,$projWGS84,$pointSrc);
  29 +echo "Conversion : ".$pointDest->toShortString()." in WGS84<br><br>";
  30 +
  31 +$pointSrc = $pointDest;
  32 +echo "Source : ".$pointSrc->toShortString()." in WGS84<br>";
  33 +$pointDest = $proj4->transform($projWGS84,$projLSud,$pointSrc);
  34 +echo "Conversion : ".$pointDest->toShortString()." in Lambert Sud<br><br>";
  35 +
  36 +$pointSrc = $pointDest;
  37 +echo "Source : ".$pointSrc->toShortString()." in Lambert Sud<br>";
  38 +$pointDest = $proj4->transform($projLSud,$projWGS84,$pointSrc);
  39 +echo "Conversion : ".$pointDest->toShortString()." in WGS84<br><br>";
  40 +
  41 +$pointSrc = $pointDest;
  42 +echo "Source : ".$pointSrc->toShortString()." in WGS84<br>";
  43 +$pointDest = $proj4->transform($projWGS84,$projLI,$pointSrc);
  44 +echo "Conversion : ".$pointDest->toShortString()." in LI <br><br>";
  45 +
  46 +$pointSrc = $pointDest;
  47 +echo "Source : ".$pointSrc->toShortString()." in LI<br>";
  48 +$pointDest = $proj4->transform($projLI,$projL93,$pointSrc);
  49 +echo "Conversion : ".$pointDest->toShortString()." in L93<br><br>";
  50 +
  51 +
  52 +
  53 +$pointSrc = new proj4phpPoint('177329.253543','58176.702191');
  54 +echo "Source : ".$pointSrc->toShortString()." in Lambert 1972<br>";
  55 +$pointDest = $proj4->transform($projL72,$projWGS84,$pointSrc);
  56 +echo "Conversion : ".$pointDest->toShortString()." in WGS84<br><br>";
  57 +
  58 +$pointSrc = $pointDest;
  59 +echo "Source : ".$pointSrc->toShortString()." in WGS84<br>";
  60 +$pointDest = $proj4->transform($projWGS84,$projL72,$pointSrc);
  61 +echo "Conversion : ".$pointDest->toShortString()." in Lambert 1972<br><br>";
  62 +
  63 +
  64 +$pointSrc = $pointDest;
  65 +echo "Source : ".$pointSrc->toShortString()." in Lambert 1972<br>";
  66 +$pointDest = $proj4->transform($projL72,$proj25833,$pointSrc);
  67 +echo "Conversion : ".$pointDest->toShortString()." in EPSG:25833<br><br>";
  68 +
  69 +$pointSrc = $pointDest;
  70 +echo "Source : ".$pointSrc->toShortString()." in EPSG:25833<br>";
  71 +$pointDest = $proj4->transform($proj25833,$projWGS84,$pointSrc);
  72 +echo "Conversion : ".$pointDest->toShortString()." in WGS84<br><br>";
  73 +
  74 +$pointSrc = $pointDest;
  75 +echo "Source : ".$pointSrc->toShortString()." in WGS84<br>";
  76 +$pointDest = $proj4->transform($projWGS84,$proj31468,$pointSrc);
  77 +echo "Conversion : ".$pointDest->toShortString()." in EPSG:31468<br><br>";
  78 +
  79 +$pointSrc = new proj4phpPoint('-868208.53', '-1095793.57');
  80 +echo "Source : ".$pointSrc->toShortString()." in S-JTSK<br>";
  81 +$pointDest = $proj4->transform($proj5514,$projWGS84,$pointSrc);
  82 +echo "Conversion : ".$pointDest->toShortString()." in WGS84<br><br>";
  83 +
  84 +$pointSrc = $pointDest;
  85 +echo "Source : ".$pointSrc->toShortString()." in WGS84<br>";
  86 +$pointDest = $proj4->transform($projWGS84,$proj5514,$pointSrc);
  87 +echo "Conversion : ".$pointDest->toShortString()." in S-JTSK<br><br>";
... ...