LCOV - code coverage report
Current view: directory - frmts/hdf4/hdf-eos - gctp_wrap.c (source / functions) Found Hit Coverage
Test: gdal_filtered.info Lines: 38 0 0.0 %
Date: 2010-01-09 Functions: 4 0 0.0 %

       1                 : /******************************************************************************
       2                 :  * $Id: gctp_wrap.c 10645 2007-01-18 02:22:39Z warmerdam $
       3                 :  *
       4                 :  * Project:  Hierarchical Data Format Release 4 (HDF4)
       5                 :  * Purpose:  This is the wrapper code to use OGR Coordinate Transformation
       6                 :  *           services instead of GCTP library
       7                 :  * Author:   Andrey Kiselev, dron@ak4719.spb.edu
       8                 :  *
       9                 :  ******************************************************************************
      10                 :  * Copyright (c) 2004, Andrey Kiselev <dron@ak4719.spb.edu>
      11                 :  *
      12                 :  * Permission is hereby granted, free of charge, to any person obtaining a
      13                 :  * copy of this software and associated documentation files (the "Software"),
      14                 :  * to deal in the Software without restriction, including without limitation
      15                 :  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      16                 :  * and/or sell copies of the Software, and to permit persons to whom the
      17                 :  * Software is furnished to do so, subject to the following conditions:
      18                 :  *
      19                 :  * The above copyright notice and this permission notice shall be included
      20                 :  * in all copies or substantial portions of the Software.
      21                 :  *
      22                 :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      23                 :  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      24                 :  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
      25                 :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      26                 :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      27                 :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      28                 :  * DEALINGS IN THE SOFTWARE.
      29                 :  ****************************************************************************/
      30                 : 
      31                 : #include "ogr_srs_api.h"
      32                 : #include "mfhdf.h"
      33                 : 
      34                 : static int iOutsys, iOutzone, iOutdatum, iInsys, iInzone, iIndatum;
      35                 : static double *pdfOutparm, *pdfInparm;
      36                 : 
      37               0 : int32 osr_for(
      38                 : double lon,     /* (I) Longitude    */
      39                 : double lat,     /* (I) Latitude     */
      40                 : double *x,      /* (O) X projection coordinate  */
      41                 : double *y)      /* (O) Y projection coordinate  */
      42                 : {
      43                 :     OGRSpatialReferenceH hSourceSRS, hLatLong;
      44                 :     OGRCoordinateTransformationH hCT;
      45               0 :     double dfX, dfY, dfZ = 0.0;
      46                 : 
      47               0 :     hSourceSRS = OSRNewSpatialReference( NULL );
      48               0 :     OSRImportFromUSGS( hSourceSRS, iOutsys, iOutzone, pdfOutparm, iOutdatum );
      49               0 :     hLatLong = OSRCloneGeogCS( hSourceSRS );
      50               0 :     hCT = OCTNewCoordinateTransformation( hLatLong, hSourceSRS );
      51                 :     if( hCT == NULL )
      52                 :     {
      53                 :         ;
      54                 :     }
      55                 : 
      56               0 :     dfY = lon, dfX = lat;
      57               0 :     if( !OCTTransform( hCT, 1, &dfX, &dfY, &dfZ ) )
      58                 :         ;
      59                 : 
      60               0 :     *x = dfX, *y = dfY;
      61                 : 
      62               0 :     OSRDestroySpatialReference( hSourceSRS );
      63               0 :     OSRDestroySpatialReference( hLatLong );
      64                 : 
      65               0 :     return 0;
      66                 : }
      67                 : 
      68               0 : void for_init(
      69                 : int32 outsys,   /* output system code       */
      70                 : int32 outzone,    /* output zone number       */
      71                 : float64 *outparm, /* output array of projection parameters  */
      72                 : int32 outdatum,   /* output datum         */
      73                 : char *fn27,   /* NAD 1927 parameter file      */
      74                 : char *fn83,   /* NAD 1983 parameter file      */
      75                 : int32 *iflg,    /* status flag          */
      76                 : int32 (*for_trans[])(double, double, double *, double *))
      77                 :                         /* forward function pointer     */
      78                 : {
      79               0 :     iflg = 0;
      80               0 :     iOutsys = outsys;
      81               0 :     iOutzone = outzone;
      82               0 :     pdfOutparm = outparm;
      83               0 :     iOutdatum = outdatum;
      84               0 :     for_trans[iOutsys] = osr_for;
      85               0 : }
      86                 : 
      87               0 : int32 osr_inv(
      88                 : double x,     /* (O) X projection coordinate  */
      89                 : double y,     /* (O) Y projection coordinate  */
      90                 : double *lon,      /* (I) Longitude    */
      91                 : double *lat)      /* (I) Latitude     */
      92                 : {
      93                 :     OGRSpatialReferenceH hSourceSRS, hLatLong;
      94                 :     OGRCoordinateTransformationH hCT;
      95               0 :     double dfX, dfY, dfZ = 0.0;
      96                 : 
      97               0 :     hSourceSRS = OSRNewSpatialReference( NULL );
      98               0 :     OSRImportFromUSGS( hSourceSRS, iInsys, iInzone, pdfInparm, iIndatum );
      99               0 :     hLatLong = OSRCloneGeogCS( hSourceSRS );
     100               0 :     hCT = OCTNewCoordinateTransformation( hSourceSRS, hLatLong );
     101                 :     if( hCT == NULL )
     102                 :     {
     103                 :         ;
     104                 :     }
     105                 : 
     106                 :     //OSRDestroySpatialReference();
     107                 : 
     108               0 :     dfX = x, dfY = x;
     109               0 :     if( !OCTTransform( hCT, 1, &dfX, &dfY, &dfZ ) )
     110                 :         ;
     111                 : 
     112               0 :     *lon = dfX, *lat = dfY;
     113                 : 
     114               0 :     return 0;
     115                 : }
     116                 : 
     117               0 : void inv_init(
     118                 : int32 insys,    /* input system code        */
     119                 : int32 inzone,   /* input zone number        */
     120                 : float64 *inparm,  /* input array of projection parameters         */
     121                 : int32 indatum,          /* input datum code             */
     122                 : char *fn27,   /* NAD 1927 parameter file      */
     123                 : char *fn83,   /* NAD 1983 parameter file      */
     124                 : int32 *iflg,    /* status flag          */
     125                 : int32 (*inv_trans[])(double, double, double*, double*)) 
     126                 :                         /* inverse function pointer     */
     127                 : {
     128               0 :     iflg = 0;
     129               0 :     iInsys = insys;
     130               0 :     iInzone = inzone;
     131               0 :     pdfInparm = inparm; 
     132               0 :     iIndatum = indatum;
     133               0 :     inv_trans[insys] = osr_inv;
     134               0 : }
     135                 : 

Generated by: LCOV version 1.7