Revision: 7935
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7935&view=rev
Author:   jswhit
Date:     2009-11-04 16:26:37 +0000 (Wed, 04 Nov 2009)

Log Message:
-----------
new files in proj4 4.7.0

Added Paths:
-----------
    trunk/toolkits/basemap/src/PJ_gstmerc.c
    trunk/toolkits/basemap/src/pj_initcache.c
    trunk/toolkits/basemap/src/pj_mutex.c

Added: trunk/toolkits/basemap/src/PJ_gstmerc.c
===================================================================
--- trunk/toolkits/basemap/src/PJ_gstmerc.c                             (rev 0)
+++ trunk/toolkits/basemap/src/PJ_gstmerc.c     2009-11-04 16:26:37 UTC (rev 
7935)
@@ -0,0 +1,48 @@
+#define PROJ_PARMS__ \
+       double lamc;\
+       double phic;\
+       double c;\
+       double n1;\
+       double n2;\
+    double XS;\
+    double YS;
+
+#define PJ_LIB__
+# include      <projects.h>
+PROJ_HEAD(gstmerc, "Gauss-Schreiber Transverse Mercator (aka Gauss-Laborde 
Reunion)")
+       "\n\tCyl, Sph&Ell\n\tlat_0= lon_0= k_0=";
+FORWARD(s_forward); /* spheroid */
+       double L, Ls, sinLs1, Ls1;
+       L= P->n1*lp.lam;
+    Ls= P->c+P->n1*log(pj_tsfn(-1.0*lp.phi,-1.0*sin(lp.phi),P->e));
+    sinLs1= sin(L)/cosh(Ls);
+    Ls1= log(pj_tsfn(-1.0*asin(sinLs1),0.0,0.0));
+    xy.x= (P->XS + P->n2*Ls1)*P->ra;
+    xy.y= (P->YS + P->n2*atan(sinh(Ls)/cos(L)))*P->ra;
+    /*fprintf(stderr,"fwd:\nL      =%16.13f\nLs     =%16.13f\nLs1    
=%16.13f\nLP(%16.13f,%16.13f)=XY(%16.4f,%16.4f)\n",L,Ls,Ls1,lp.lam+P->lam0,lp.phi,(xy.x*P->a
 + P->x0)*P->to_meter,(xy.y*P->a + P->y0)*P->to_meter);*/
+       return (xy);
+}
+INVERSE(s_inverse); /* spheroid */
+       double L, LC, sinC;
+       L= atan(sinh((xy.x*P->a - P->XS)/P->n2)/cos((xy.y*P->a - P->YS)/P->n2));
+    sinC= sin((xy.y*P->a - P->YS)/P->n2)/cosh((xy.x*P->a - P->XS)/P->n2);
+    LC= log(pj_tsfn(-1.0*asin(sinC),0.0,0.0));
+    lp.lam= L/P->n1;
+    lp.phi= -1.0*pj_phi2(exp((LC-P->c)/P->n1),P->e);
+    /*fprintf(stderr,"inv:\nL      =%16.13f\nsinC   =%16.13f\nLC     
=%16.13f\nXY(%16.4f,%16.4f)=LP(%16.13f,%16.13f)\n",L,sinC,LC,((xy.x/P->ra)+P->x0)/P->to_meter,((xy.y/P->ra)+P->y0)/P->to_meter,lp.lam+P->lam0,lp.phi);*/
+       return (lp);
+}
+FREEUP; if (P) pj_dalloc(P); }
+ENTRY0(gstmerc)
+    P->lamc= P->lam0;
+    P->n1= sqrt(1.0+P->es*pow(cos(P->phi0),4.0)/(1.0-P->es));
+    P->phic= asin(sin(P->phi0)/P->n1);
+    P->c=       log(pj_tsfn(-1.0*P->phic,0.0,0.0))
+         -P->n1*log(pj_tsfn(-1.0*P->phi0,-1.0*sin(P->phi0),P->e));
+    P->n2= P->k0*P->a*sqrt(1.0-P->es)/(1.0-P->es*sin(P->phi0)*sin(P->phi0));
+    P->XS= 0;/* -P->x0 */
+    P->YS= -1.0*P->n2*P->phic;/* -P->y0 */
+       P->inv= s_inverse;
+       P->fwd= s_forward;
+    /*fprintf(stderr,"a  (m) =%16.4f\ne      
=%16.13f\nl0(rad)=%16.13f\np0(rad)=%16.13f\nk0     =%16.4f\nX0  (m)=%16.4f\nY0  
(m)=%16.4f\n\nlC(rad)=%16.13f\npC(rad)=%16.13f\nc      =%16.13f\nn1     
=%16.13f\nn2 (m) =%16.4f\nXS (m) =%16.4f\nYS (m) =%16.4f\n", P->a, P->e, 
P->lam0, P->phi0, P->k0, P->x0, P->y0, P->lamc, P->phic, P->c, P->n1, P->n2, 
P->XS +P->x0, P->YS + P->y0);*/
+ENDENTRY(P)

Added: trunk/toolkits/basemap/src/pj_initcache.c
===================================================================
--- trunk/toolkits/basemap/src/pj_initcache.c                           (rev 0)
+++ trunk/toolkits/basemap/src/pj_initcache.c   2009-11-04 16:26:37 UTC (rev 
7935)
@@ -0,0 +1,181 @@
+/******************************************************************************
+ * $Id: pj_transform.c 1504 2009-01-06 02:11:57Z warmerdam $
+ *
+ * Project:  PROJ.4
+ * Purpose:  init file definition cache.
+ * Author:   Frank Warmerdam, [email protected]
+ *
+ ******************************************************************************
+ * Copyright (c) 2009, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *****************************************************************************/
+
+#include <projects.h>
+#include <string.h>
+
+PJ_CVSID("$Id: pj_transform.c 1504 2009-01-06 02:11:57Z warmerdam $");
+
+static int cache_count = 0;
+static int cache_alloc = 0;
+static char **cache_key = NULL;
+static paralist **cache_paralist = NULL;
+
+/************************************************************************/
+/*                            pj_clone_paralist()                       */
+/*                                                                      */
+/*     Allocate a copy of a parameter list.                             */
+/************************************************************************/
+
+paralist *pj_clone_paralist( const paralist *list)
+{
+  paralist *list_copy = NULL, *next_copy = NULL;
+
+  for( ; list != NULL; list = list->next )
+    {
+      paralist *newitem = (paralist *)
+       pj_malloc(sizeof(paralist) + strlen(list->param));
+
+      newitem->used = 0;
+      newitem->next = 0;
+      strcpy( newitem->param, list->param );
+      
+      if( list_copy == NULL )
+       list_copy = newitem;
+      else
+       next_copy->next = newitem;
+
+      next_copy = newitem;
+    }
+
+  return list_copy;
+}
+
+/************************************************************************/
+/*                            pj_clear_initcache()                      */
+/*                                                                      */
+/*      Clear out all memory held in the init file cache.               */
+/************************************************************************/
+
+void pj_clear_initcache()
+{
+  if( cache_alloc > 0 )
+  {
+    int i;
+
+    pj_acquire_lock();
+
+    for( i = 0; i < cache_count; i++ )
+      {
+       paralist *n, *t = cache_paralist[i];
+               
+       pj_dalloc( cache_key[i] );
+
+       /* free parameter list elements */
+       for (; t != NULL; t = n) {
+         n = t->next;
+         pj_dalloc(t);
+       }
+      }
+
+    pj_dalloc( cache_key );
+    pj_dalloc( cache_paralist );
+    cache_count = 0;
+    cache_alloc= 0;
+    cache_key = NULL;
+    cache_paralist = NULL;
+
+    pj_release_lock();
+  }
+}
+
+/************************************************************************/
+/*                            pj_search_initcache()                     */
+/*                                                                      */
+/*      Search for a matching definition in the init cache.             */
+/************************************************************************/
+
+paralist *pj_search_initcache( const char *filekey )
+
+{
+  int i;
+  paralist *result = NULL;
+
+  pj_acquire_lock();
+
+  for( i = 0; result == NULL && i < cache_count; i++)
+    {
+      if( strcmp(filekey,cache_key[i]) == 0 )
+       {
+         result = pj_clone_paralist( cache_paralist[i] );
+       }
+    }
+
+  pj_release_lock();
+
+  return result;
+}
+
+/************************************************************************/
+/*                            pj_insert_initcache()                     */
+/*                                                                      */
+/*      Insert a paralist definition in the init file cache.            */
+/************************************************************************/
+
+void pj_insert_initcache( const char *filekey, const paralist *list )
+
+{
+  pj_acquire_lock();
+
+  /* 
+  ** Grow list if required.
+  */
+  if( cache_count == cache_alloc )
+    {
+      char **cache_key_new;
+      paralist **cache_paralist_new;
+
+      cache_alloc = cache_alloc * 2 + 15;
+
+      cache_key_new = (char **) pj_malloc(sizeof(char*) * cache_alloc);
+      memcpy( cache_key, cache_key_new, sizeof(char*) * cache_count);
+      pj_dalloc( cache_key );
+      cache_key = cache_key_new;
+
+      cache_paralist_new = (paralist **) 
+       pj_malloc(sizeof(paralist*) * cache_alloc);
+      memcpy( cache_paralist_new, cache_paralist, 
+             sizeof(paralist*) * cache_count );
+      pj_dalloc( cache_paralist );
+      cache_paralist = cache_paralist_new;
+    }
+
+  /*
+  ** Duplicate the filekey and paralist, and insert in cache.
+  */
+  cache_key[cache_count] = (char *) pj_malloc(strlen(filekey)+1);
+  strcpy( cache_key[cache_count], filekey );
+
+  cache_paralist[cache_count] = pj_clone_paralist( list );
+
+  cache_count++;
+
+  pj_release_lock();
+}
+

Added: trunk/toolkits/basemap/src/pj_mutex.c
===================================================================
--- trunk/toolkits/basemap/src/pj_mutex.c                               (rev 0)
+++ trunk/toolkits/basemap/src/pj_mutex.c       2009-11-04 16:26:37 UTC (rev 
7935)
@@ -0,0 +1,212 @@
+/******************************************************************************
+ * $Id: pj_transform.c 1504 2009-01-06 02:11:57Z warmerdam $
+ *
+ * Project:  PROJ.4
+ * Purpose:  Mutex (thread lock) functions.
+ * Author:   Frank Warmerdam, [email protected]
+ *
+ ******************************************************************************
+ * Copyright (c) 2009, Frank Warmerdam
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *****************************************************************************/
+
+
+/* projects.h and windows.h conflict - avoid this! */
+
+#ifndef _WIN32
+#include <projects.h>
+PJ_CVSID("$Id: pj_transform.c 1504 2009-01-06 02:11:57Z warmerdam $");
+#else
+#include <proj_api.h>
+#endif
+
+#ifdef _WIN32
+#  define MUTEX_win32
+#endif
+
+#if !defined(MUTEX_stub) && !defined(MUTEX_pthread) && !defined(MUTEX_win32)
+#  define MUTEX_stub
+#endif
+
+static void pj_init_lock();
+
+/************************************************************************/
+/* ==================================================================== */
+/*                      stub mutex implementation                       */
+/* ==================================================================== */
+/************************************************************************/
+
+#ifdef MUTEX_stub
+
+/************************************************************************/
+/*                            pj_acquire_lock()                         */
+/*                                                                      */
+/*      Acquire the PROJ.4 lock.                                        */
+/************************************************************************/
+
+void pj_acquire_lock()
+{
+}
+
+/************************************************************************/
+/*                            pj_release_lock()                         */
+/*                                                                      */
+/*      Release the PROJ.4 lock.                                        */
+/************************************************************************/
+
+void pj_release_lock()
+{
+}
+
+/************************************************************************/
+/*                          pj_cleanup_lock()                           */
+/************************************************************************/
+void pj_cleanup_lock()
+{
+}
+
+/************************************************************************/
+/*                            pj_init_lock()                            */
+/************************************************************************/
+
+static void pj_init_lock()
+
+{
+}
+
+#endif // def MUTEX_stub
+
+/************************************************************************/
+/* ==================================================================== */
+/*                    pthread mutex implementation                      */
+/* ==================================================================== */
+/************************************************************************/
+
+#ifdef MUTEX_pthread
+
+#include "pthread.h"
+
+static pthread_mutex_t core_lock = PTHREAD_MUTEX_INITIALIZER;
+
+/************************************************************************/
+/*                          pj_acquire_lock()                           */
+/*                                                                      */
+/*      Acquire the PROJ.4 lock.                                        */
+/************************************************************************/
+
+void pj_acquire_lock()
+{
+    pthread_mutex_lock( &core_lock);
+}
+
+/************************************************************************/
+/*                          pj_release_lock()                           */
+/*                                                                      */
+/*      Release the PROJ.4 lock.                                        */
+/************************************************************************/
+
+void pj_release_lock()
+{
+    pthread_mutex_unlock( &core_lock );
+}
+
+/************************************************************************/
+/*                          pj_cleanup_lock()                           */
+/************************************************************************/
+void pj_cleanup_lock()
+{
+}
+
+/************************************************************************/
+/*                            pj_init_lock()                            */
+/************************************************************************/
+
+static void pj_init_lock()
+
+{
+}
+
+#endif // def MUTEX_pthread
+
+/************************************************************************/
+/* ==================================================================== */
+/*                      win32 mutex implementation                      */
+/* ==================================================================== */
+/************************************************************************/
+
+#ifdef MUTEX_win32
+
+#include <windows.h>
+
+static HANDLE mutex_lock = NULL;
+
+/************************************************************************/
+/*                          pj_acquire_lock()                           */
+/*                                                                      */
+/*      Acquire the PROJ.4 lock.                                        */
+/************************************************************************/
+
+void pj_acquire_lock()
+{
+    if( mutex_lock == NULL )
+        pj_init_lock();
+
+    WaitForSingleObject( mutex_lock, INFINITE );
+}
+
+/************************************************************************/
+/*                          pj_release_lock()                           */
+/*                                                                      */
+/*      Release the PROJ.4 lock.                                        */
+/************************************************************************/
+
+void pj_release_lock()
+{
+    if( mutex_lock == NULL )
+        pj_init_lock();
+
+    ReleaseMutex( mutex_lock );
+}
+
+/************************************************************************/
+/*                          pj_cleanup_lock()                           */
+/************************************************************************/
+void pj_cleanup_lock()
+{
+    if( mutex_lock != NULL )
+    {
+        CloseHandle( mutex_lock );
+        mutex_lock = NULL;
+    }
+}
+
+/************************************************************************/
+/*                            pj_init_lock()                            */
+/************************************************************************/
+
+static void pj_init_lock()
+
+{
+    if( mutex_lock == NULL )
+        mutex_lock = CreateMutex( NULL, TRUE, NULL );
+}
+
+#endif // def MUTEX_win32
+


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to