~ubuntu-branches/ubuntu/saucy/mapserver/saucy-security

« back to all changes in this revision

Viewing changes to shptreetst.c

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2011-12-23 14:02:06 UTC
  • mfrom: (26.1.2 sid)
  • Revision ID: package-import@ubuntu.com-20111223140206-n3h9t2hsa8hyslmu
Tags: 6.0.1-2
Added missed stuff for libmapscript-perl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: shptreetst.c 8774 2009-03-10 21:04:16Z tomkralidis $
 
2
 * $Id: shptreetst.c 10881 2011-01-21 18:21:22Z jmckenna $
3
3
 *
4
4
 * Project:  MapServer
5
5
 * Purpose:  Utility program to visualize a quadtree search
15
15
 * and/or sell copies of the Software, and to permit persons to whom the
16
16
 * Software is furnished to do so, subject to the following conditions:
17
17
 *
18
 
 * The above copyright notice and this permission notice shall be included in 
 
18
 * The above copyright notice and this permission notice shall be included in
19
19
 * all copies of this Software or works derived from this Software.
20
20
 *
21
21
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
29
29
 
30
30
#include "mapserver.h"
31
31
#include <string.h>
 
32
#ifndef _WIN32
32
33
#include <unistd.h>
 
34
#endif
33
35
#include <stdlib.h>
34
36
 
35
 
MS_CVSID("$Id: shptreetst.c 8774 2009-03-10 21:04:16Z tomkralidis $")
 
37
MS_CVSID("$Id: shptreetst.c 10881 2011-01-21 18:21:22Z jmckenna $")
36
38
 
37
39
#ifdef SHPT_POLYGON
38
40
   #undef MAPSERVER
45
47
char* AddFileSuffix ( const char * Filename, const char * Suffix ) {
46
48
    char        *pszFullname, *pszBasename;
47
49
    int i;
48
 
      
 
50
 
49
51
  /* -------------------------------------------------------------------- */
50
52
  /*    Compute the base (layer) name.  If there is any extension           */
51
53
  /*    on the passed in filename we will strip it off.                     */
52
54
  /* -------------------------------------------------------------------- */
53
 
    pszBasename = (char *) malloc(strlen(Filename)+5);
 
55
    pszBasename = (char *) msSmallMalloc(strlen(Filename)+5);
54
56
    strcpy( pszBasename, Filename );
55
 
    for( i = strlen(pszBasename)-1; 
 
57
    for( i = strlen(pszBasename)-1;
56
58
       i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
57
59
         && pszBasename[i] != '\\';
58
60
       i-- ) {}
59
 
  
 
61
 
60
62
    if( pszBasename[i] == '.' )
61
63
      pszBasename[i] = '\0';
62
 
  
 
64
 
63
65
  /* -------------------------------------------------------------------- */
64
66
  /*    Open the .shp and .shx files.  Note that files pulled from          */
65
67
  /*    a PC to Unix with upper case filenames won't work!                  */
66
68
  /* -------------------------------------------------------------------- */
67
 
    pszFullname = (char *) malloc(strlen(pszBasename) + 5);
68
 
    sprintf( pszFullname, "%s%s", pszBasename, Suffix); 
69
 
      
 
69
    pszFullname = (char *) msSmallMalloc(strlen(pszBasename) + 5);
 
70
    sprintf( pszFullname, "%s%s", pszBasename, Suffix);
 
71
 
70
72
    return (pszFullname);
71
73
}
72
74
 
75
77
 
76
78
{
77
79
    SHPTreeHandle       qix;
78
 
    
 
80
 
79
81
    int         i, j;
80
82
    rectObj     rect;
81
 
 
 
83
 
82
84
    int         pos;
83
85
    ms_bitarray bitmap = NULL;
84
 
     
 
86
 
85
87
    char        mBigEndian;
86
88
    treeNodeObj *node = NULL;
87
89
 
129
131
      if (node )
130
132
      {
131
133
        fprintf (stdout,"shapes %d, node %d, %f,%f,%f,%f \n",(int) node->numshapes,node->numsubnodes,node->rect.minx, node->rect.miny, node->rect.maxx, node->rect.maxy);
132
 
            
 
134
 
133
135
      }
134
 
      else 
 
136
      else
135
137
      { pos = 0; }
136
138
    }
137
 
    
 
139
 
138
140
    printf ("read entire file now at quad box rec %d file pos %ld\n", j, ftell (qix->fp));
139
141
 
140
142
    j = qix->nShapes;
141
143
    msSHPDiskTreeClose (qix);
142
 
    
 
144
 
143
145
    if( argc >= 5 )
144
146
    {
145
147
      rect.minx = atof (argv[2]);
155
157
      rect.maxx =  node->rect.maxx;
156
158
      rect.maxy =  node->rect.maxy;
157
159
    }
158
 
    
 
160
 
159
161
    bitmap = msSearchDiskTree( argv[1], rect, 0 /* no debug*/ );
160
162
 
161
163
    if ( bitmap )
165
167
      {
166
168
        if ( msGetBit(bitmap,i) )
167
169
        {
168
 
          printf(" %d,",i); 
 
170
          printf(" %d,",i);
169
171
        }
170
172
      }
171
173
    }