shp 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +34 -0
- data/.travis.yml +4 -0
- data/Gemfile +3 -0
- data/LICENSE +28 -0
- data/README.md +30 -0
- data/Rakefile +23 -0
- data/ext/shp/base.hpp +113 -0
- data/ext/shp/dbf.cpp +381 -0
- data/ext/shp/dbf.hpp +44 -0
- data/ext/shp/extconf.rb +13 -0
- data/ext/shp/shape_object.cpp +58 -0
- data/ext/shp/shape_object.hpp +27 -0
- data/ext/shp/shapefile.cpp +299 -0
- data/ext/shp/shapefile.hpp +35 -0
- data/ext/shp/shapelib/.cvsignore +15 -0
- data/ext/shp/shapelib/ChangeLog +450 -0
- data/ext/shp/shapelib/HOWTO-RELEASE +16 -0
- data/ext/shp/shapelib/LICENSE.LGPL +483 -0
- data/ext/shp/shapelib/Makefile +113 -0
- data/ext/shp/shapelib/README +41 -0
- data/ext/shp/shapelib/README.tree +172 -0
- data/ext/shp/shapelib/contrib/.cvsignore +12 -0
- data/ext/shp/shapelib/contrib/Makefile +66 -0
- data/ext/shp/shapelib/contrib/ShapeFileII.pas +234 -0
- data/ext/shp/shapelib/contrib/Shape_PointInPoly.cpp +238 -0
- data/ext/shp/shapelib/contrib/Shape_PointInPoly_README.txt +59 -0
- data/ext/shp/shapelib/contrib/csv2shp.c +558 -0
- data/ext/shp/shapelib/contrib/dbfcat.c +166 -0
- data/ext/shp/shapelib/contrib/dbfinfo.c +106 -0
- data/ext/shp/shapelib/contrib/makefile.vc +34 -0
- data/ext/shp/shapelib/contrib/my_nan.h +46 -0
- data/ext/shp/shapelib/contrib/shpcat.c +100 -0
- data/ext/shp/shapelib/contrib/shpcentrd.c +159 -0
- data/ext/shp/shapelib/contrib/shpdata.c +129 -0
- data/ext/shp/shapelib/contrib/shpdxf.c +340 -0
- data/ext/shp/shapelib/contrib/shpfix.c +110 -0
- data/ext/shp/shapelib/contrib/shpgeo.c +1595 -0
- data/ext/shp/shapelib/contrib/shpgeo.h +154 -0
- data/ext/shp/shapelib/contrib/shpinfo.c +113 -0
- data/ext/shp/shapelib/contrib/shpproj.c +260 -0
- data/ext/shp/shapelib/contrib/shpsort.c +605 -0
- data/ext/shp/shapelib/contrib/shpsort.txt +44 -0
- data/ext/shp/shapelib/contrib/shpwkb.c +123 -0
- data/ext/shp/shapelib/contrib/tests/shpproj.sh +38 -0
- data/ext/shp/shapelib/dbfopen.c +2221 -0
- data/ext/shp/shapelib/makefile.vc +86 -0
- data/ext/shp/shapelib/makeshape.sh +21 -0
- data/ext/shp/shapelib/mkdist.sh +37 -0
- data/ext/shp/shapelib/mkinstalldirs +38 -0
- data/ext/shp/shapelib/mkrelease.sh +55 -0
- data/ext/shp/shapelib/safileio.c +286 -0
- data/ext/shp/shapelib/shapefil.h +647 -0
- data/ext/shp/shapelib/shapelib.def +46 -0
- data/ext/shp/shapelib/shpopen.c +2388 -0
- data/ext/shp/shapelib/shptree.c +1187 -0
- data/ext/shp/shapelib/shputils.c +1072 -0
- data/ext/shp/shapelib/stream1.out +1465 -0
- data/ext/shp/shapelib/stream1.sh +28 -0
- data/ext/shp/shapelib/stream2.out +530 -0
- data/ext/shp/shapelib/stream2.sh +11 -0
- data/ext/shp/shapelib/stream3.out +37 -0
- data/ext/shp/shapelib/web/.cvsignore +2 -0
- data/ext/shp/shapelib/web/codepage.html +403 -0
- data/ext/shp/shapelib/web/dbf_api.html +436 -0
- data/ext/shp/shapelib/web/index.html +235 -0
- data/ext/shp/shapelib/web/license.html +78 -0
- data/ext/shp/shapelib/web/manifest.html +87 -0
- data/ext/shp/shapelib/web/release.html +80 -0
- data/ext/shp/shapelib/web/shapelib-tools.html +352 -0
- data/ext/shp/shapelib/web/shp_api.html +376 -0
- data/ext/shp/shp.cpp +19 -0
- data/ext/shp/shp.hpp +47 -0
- data/lib/shp.rb +35 -0
- data/lib/shp/version.rb +3 -0
- data/shp.gemspec +23 -0
- data/spec/shp_spec.rb +127 -0
- metadata +176 -0
@@ -0,0 +1,166 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 1995 Frank Warmerdam
|
3
|
+
*
|
4
|
+
* This code is in the public domain.
|
5
|
+
*
|
6
|
+
* $Log: dbfcat.c,v $
|
7
|
+
* Revision 1.2 2011-07-24 03:17:46 fwarmerdam
|
8
|
+
* include string.h and stdlib.h where needed in contrib (#2146)
|
9
|
+
*
|
10
|
+
* Revision 1.1 1999-05-26 02:56:31 candrsn
|
11
|
+
* updates to shpdxf, dbfinfo, port from Shapelib 1.1.5 of dbfcat and shpinfo
|
12
|
+
*
|
13
|
+
* Revision 1.3 1995/10/21 03:15:01 warmerda
|
14
|
+
* Changed to use binary file access.
|
15
|
+
*
|
16
|
+
* Revision 1.2 1995/08/04 03:16:22 warmerda
|
17
|
+
* Added header.
|
18
|
+
*
|
19
|
+
*/
|
20
|
+
|
21
|
+
static char rcsid[] =
|
22
|
+
"$Id: dbfcat.c,v 1.2 2011-07-24 03:17:46 fwarmerdam Exp $";
|
23
|
+
|
24
|
+
#include <stdlib.h>
|
25
|
+
#include <string.h>
|
26
|
+
#include "shapefil.h"
|
27
|
+
|
28
|
+
int main( int argc, char ** argv )
|
29
|
+
|
30
|
+
{
|
31
|
+
DBFHandle hDBF;
|
32
|
+
int *panWidth, i, iRecord;
|
33
|
+
char szFormat[32], szField[1024];
|
34
|
+
char cTitle[32], nTitle[32];
|
35
|
+
int nWidth, nDecimals;
|
36
|
+
int cnWidth, cnDecimals;
|
37
|
+
DBFHandle cDBF;
|
38
|
+
DBFFieldType hType,cType;
|
39
|
+
int ci, ciRecord;
|
40
|
+
char tfile[160];
|
41
|
+
int hflds, j, cflds;
|
42
|
+
int verbose = 0;
|
43
|
+
int force = 0;
|
44
|
+
int mismatch = 0;
|
45
|
+
int matches = 0;
|
46
|
+
char fld_m[256];
|
47
|
+
int shift = 0;
|
48
|
+
char type_names[4][15] = {"integer", "string", "double", "double"};
|
49
|
+
|
50
|
+
if( argc < 3 )
|
51
|
+
{
|
52
|
+
printf( "dbfcat [-v] [-f] from_DBFfile to_DBFfile\n" );
|
53
|
+
exit( 1 );
|
54
|
+
}
|
55
|
+
|
56
|
+
|
57
|
+
if ( strcmp ("-v", argv[1] ) == 0 ) { shift = 1; verbose = 1; }
|
58
|
+
if ( strcmp ("-f", argv[1 + shift] ) == 0 ) { shift ++; force = 1; }
|
59
|
+
if ( strcmp ("-v", argv[1 + shift] ) == 0 ) { shift ++; verbose = 1; }
|
60
|
+
strcpy (tfile, argv[1 + shift]);
|
61
|
+
strcat (tfile, ".dbf");
|
62
|
+
hDBF = DBFOpen( tfile, "rb" );
|
63
|
+
if( hDBF == NULL )
|
64
|
+
{
|
65
|
+
printf( "DBFOpen(%s.dbf,\"r\") failed for From_DBF.\n", tfile );
|
66
|
+
exit( 2 );
|
67
|
+
}
|
68
|
+
|
69
|
+
strcpy (tfile, argv[2 + shift]);
|
70
|
+
strcat (tfile, ".dbf");
|
71
|
+
|
72
|
+
cDBF = DBFOpen( tfile, "rb+" );
|
73
|
+
if( cDBF == NULL )
|
74
|
+
{
|
75
|
+
printf( "DBFOpen(%s.dbf,\"rb+\") failed for To_DBF.\n", tfile );
|
76
|
+
exit( 2 );
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
if( DBFGetFieldCount(hDBF) == 0 )
|
81
|
+
{
|
82
|
+
printf( "There are no fields in this table!\n" );
|
83
|
+
exit( 3 );
|
84
|
+
}
|
85
|
+
|
86
|
+
hflds = DBFGetFieldCount(hDBF);
|
87
|
+
cflds = DBFGetFieldCount(cDBF);
|
88
|
+
|
89
|
+
matches = 0;
|
90
|
+
for( i = 0; i < hflds; i++ )
|
91
|
+
{
|
92
|
+
char szTitle[18];
|
93
|
+
char cname[18];
|
94
|
+
int j;
|
95
|
+
hType = DBFGetFieldInfo( hDBF, i, szTitle, &nWidth, &nDecimals );
|
96
|
+
fld_m[i] = -1;
|
97
|
+
for ( j = 0; j < cflds; j ++ )
|
98
|
+
{
|
99
|
+
cType = DBFGetFieldInfo( cDBF, j, cname, &cnWidth, &cnDecimals );
|
100
|
+
if ( strcmp (cname, szTitle) == 0 )
|
101
|
+
{
|
102
|
+
if ( hType != cType )
|
103
|
+
{ printf ("Incompatible fields %s(%s) != %s(%s),\n",
|
104
|
+
type_names[hType],nTitle,type_names[cType],cTitle);
|
105
|
+
mismatch = 1;
|
106
|
+
}
|
107
|
+
fld_m[i] = j;
|
108
|
+
if ( verbose )
|
109
|
+
{ printf("%s %s(%d,%d) <- %s %s(%d,%d)\n", cname, type_names[cType],
|
110
|
+
cnWidth, cnDecimals,
|
111
|
+
szTitle, type_names[hType], nWidth, nDecimals); }
|
112
|
+
j = cflds;
|
113
|
+
matches = 1;
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
if ( (matches == 0 ) && !force ) {
|
119
|
+
printf ("ERROR: No field names match for tables, cannot proceed\n use -f to force processing using blank records\n");
|
120
|
+
exit(-1); }
|
121
|
+
if ( mismatch && !force ) {
|
122
|
+
printf ("ERROR: field type mismatch cannot proceed\n use -f to force processing using attempted conversions\n");
|
123
|
+
exit(-1); }
|
124
|
+
|
125
|
+
for( iRecord = 0; iRecord < DBFGetRecordCount(hDBF); iRecord++ )
|
126
|
+
{
|
127
|
+
ciRecord = DBFGetRecordCount( cDBF );
|
128
|
+
for ( i = 0; i < hflds;i ++ )
|
129
|
+
{
|
130
|
+
double cf;
|
131
|
+
ci = fld_m[i];
|
132
|
+
if ( ci != -1 )
|
133
|
+
{
|
134
|
+
cType = DBFGetFieldInfo( cDBF, ci, cTitle, &cnWidth, &cnDecimals );
|
135
|
+
hType = DBFGetFieldInfo( hDBF, i, nTitle, &nWidth, &nDecimals );
|
136
|
+
|
137
|
+
switch( cType )
|
138
|
+
{
|
139
|
+
case FTString:
|
140
|
+
DBFWriteStringAttribute(cDBF, ciRecord, ci,
|
141
|
+
(char *) DBFReadStringAttribute( hDBF, iRecord, i ) );
|
142
|
+
break;
|
143
|
+
|
144
|
+
case FTInteger:
|
145
|
+
DBFWriteIntegerAttribute(cDBF, ciRecord, ci,
|
146
|
+
(int) DBFReadIntegerAttribute( hDBF, iRecord, i ) );
|
147
|
+
break;
|
148
|
+
|
149
|
+
case FTDouble:
|
150
|
+
/* cf = DBFReadDoubleAttribute( hDBF, iRecord, i );
|
151
|
+
printf ("%s <- %s (%f)\n", cTitle, nTitle, cf);
|
152
|
+
*/
|
153
|
+
DBFWriteDoubleAttribute(cDBF, ciRecord, ci,
|
154
|
+
(double) DBFReadDoubleAttribute( hDBF, iRecord, i ) );
|
155
|
+
break;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
} /* fields names match */
|
159
|
+
}
|
160
|
+
|
161
|
+
if ( verbose ) { printf (" %d records appended \n\n", iRecord); }
|
162
|
+
DBFClose( hDBF );
|
163
|
+
DBFClose( cDBF );
|
164
|
+
|
165
|
+
return( 0 );
|
166
|
+
}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
/*
|
2
|
+
* Copyright (c) 1999 Carl Anderson
|
3
|
+
*
|
4
|
+
* This code is in the public domain.
|
5
|
+
*
|
6
|
+
* This code is based in part on the earlier work of Frank Warmerdam
|
7
|
+
*
|
8
|
+
* requires shapelib 1.2
|
9
|
+
* gcc dbfinfo dbfopen.o dbfinfo
|
10
|
+
*
|
11
|
+
*
|
12
|
+
* $Log: dbfinfo.c,v $
|
13
|
+
* Revision 1.3 2011-07-24 03:17:46 fwarmerdam
|
14
|
+
* include string.h and stdlib.h where needed in contrib (#2146)
|
15
|
+
*
|
16
|
+
* Revision 1.2 1999-05-26 02:56:31 candrsn
|
17
|
+
* updates to shpdxf, dbfinfo, port from Shapelib 1.1.5 of dbfcat and shpinfo
|
18
|
+
*
|
19
|
+
*
|
20
|
+
*/
|
21
|
+
|
22
|
+
#include <stdlib.h>
|
23
|
+
#include <string.h>
|
24
|
+
#include "shapefil.h"
|
25
|
+
|
26
|
+
int main( int argc, char ** argv )
|
27
|
+
|
28
|
+
{
|
29
|
+
DBFHandle hDBF;
|
30
|
+
int *panWidth, i, iRecord;
|
31
|
+
char szFormat[32], szField[1024];
|
32
|
+
char ftype[15], cTitle[32], nTitle[32];
|
33
|
+
int nWidth, nDecimals;
|
34
|
+
int cnWidth, cnDecimals;
|
35
|
+
DBFHandle cDBF;
|
36
|
+
DBFFieldType hType,cType;
|
37
|
+
int ci, ciRecord;
|
38
|
+
|
39
|
+
/* -------------------------------------------------------------------- */
|
40
|
+
/* Display a usage message. */
|
41
|
+
/* -------------------------------------------------------------------- */
|
42
|
+
if( argc != 2 )
|
43
|
+
{
|
44
|
+
printf( "dbfinfo xbase_file\n" );
|
45
|
+
exit( 1 );
|
46
|
+
}
|
47
|
+
|
48
|
+
/* -------------------------------------------------------------------- */
|
49
|
+
/* Open the file. */
|
50
|
+
/* -------------------------------------------------------------------- */
|
51
|
+
hDBF = DBFOpen( argv[1], "rb" );
|
52
|
+
if( hDBF == NULL )
|
53
|
+
{
|
54
|
+
printf( "DBFOpen(%s,\"r\") failed.\n", argv[1] );
|
55
|
+
exit( 2 );
|
56
|
+
}
|
57
|
+
|
58
|
+
printf ("Info for %s\n",argv[1]);
|
59
|
+
|
60
|
+
/* -------------------------------------------------------------------- */
|
61
|
+
/* If there is no data in this file let the user know. */
|
62
|
+
/* -------------------------------------------------------------------- */
|
63
|
+
i = DBFGetFieldCount(hDBF);
|
64
|
+
printf ("%ld Columns, %ld Records in file\n",i,DBFGetRecordCount(hDBF));
|
65
|
+
|
66
|
+
/* -------------------------------------------------------------------- */
|
67
|
+
/* Compute offsets to use when printing each of the field */
|
68
|
+
/* values. We make each field as wide as the field title+1, or */
|
69
|
+
/* the field value + 1. */
|
70
|
+
/* -------------------------------------------------------------------- */
|
71
|
+
panWidth = (int *) malloc( DBFGetFieldCount( hDBF ) * sizeof(int) );
|
72
|
+
|
73
|
+
for( i = 0; i < DBFGetFieldCount(hDBF); i++ )
|
74
|
+
{
|
75
|
+
char szTitle[12];
|
76
|
+
DBFFieldType eType;
|
77
|
+
|
78
|
+
switch ( DBFGetFieldInfo( hDBF, i, szTitle, &nWidth, &nDecimals )) {
|
79
|
+
case FTString:
|
80
|
+
strcpy (ftype, "string");;
|
81
|
+
break;
|
82
|
+
|
83
|
+
case FTInteger:
|
84
|
+
strcpy (ftype, "integer");
|
85
|
+
break;
|
86
|
+
|
87
|
+
case FTDouble:
|
88
|
+
strcpy (ftype, "float");
|
89
|
+
break;
|
90
|
+
|
91
|
+
case FTInvalid:
|
92
|
+
strcpy (ftype, "invalid/unsupported");
|
93
|
+
break;
|
94
|
+
|
95
|
+
default:
|
96
|
+
strcpy (ftype, "unknown");
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
printf ("%15.15s\t%15s (%d,%d)\n",szTitle, ftype, nWidth, nDecimals);
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
DBFClose( hDBF );
|
104
|
+
|
105
|
+
return( 0 );
|
106
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
CFLAGS = /Ox /MD /nologo /I.. /IC:\OSGeo4W\include \
|
3
|
+
/D_LITTLE_ENDIAN -DPROJ4
|
4
|
+
|
5
|
+
LINKARGS = ..\shapelib_i.lib C:\OSGeo4W\lib\proj_i.lib
|
6
|
+
|
7
|
+
default: all
|
8
|
+
|
9
|
+
all: shpcat.exe shpcentrd.exe shpdxf.exe shpinfo.exe shpproj.exe
|
10
|
+
|
11
|
+
shpcat.exe: shpcat.obj shpgeo.obj
|
12
|
+
$(CC) $(CFLAGS) shpcat.obj $(LINKARGS)
|
13
|
+
if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
|
14
|
+
|
15
|
+
shpcentrd.exe: shpcentrd.obj shpgeo.obj
|
16
|
+
$(CC) $(CFLAGS) shpcentrd.obj shpgeo.obj $(LINKARGS)
|
17
|
+
if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
|
18
|
+
|
19
|
+
shpproj.exe: shpproj.obj shpgeo.obj
|
20
|
+
$(CC) $(CFLAGS) shpproj.obj shpgeo.obj $(LINKARGS)
|
21
|
+
if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
|
22
|
+
|
23
|
+
shpdxf.exe: shpdxf.obj shpgeo.obj
|
24
|
+
$(CC) $(CFLAGS) shpdxf.obj $(LINKARGS)
|
25
|
+
if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
|
26
|
+
|
27
|
+
shpinfo.exe: shpinfo.obj shpgeo.obj
|
28
|
+
$(CC) $(CFLAGS) shpinfo.obj $(LINKARGS)
|
29
|
+
if exist $@.manifest mt -manifest $@.manifest -outputresource:$@;1
|
30
|
+
|
31
|
+
clean:
|
32
|
+
-del *.obj
|
33
|
+
-del *.exe
|
34
|
+
-del *.manifest
|
@@ -0,0 +1,46 @@
|
|
1
|
+
/* `NAN' constant for IEEE 754 machines.
|
2
|
+
Copyright (C) 1992, 1996 Free Software Foundation, Inc.
|
3
|
+
This file is part of the GNU C Library.
|
4
|
+
|
5
|
+
The GNU C Library is free software; you can redistribute it and/or
|
6
|
+
modify it under the terms of the GNU Library General Public License as
|
7
|
+
published by the Free Software Foundation; either version 2 of the
|
8
|
+
License, or (at your option) any later version.
|
9
|
+
|
10
|
+
The GNU C Library is distributed in the hope that it will be useful,
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
Library General Public License for more details.
|
14
|
+
|
15
|
+
You should have received a copy of the GNU Library General Public
|
16
|
+
License along with the GNU C Library; see the file COPYING.LIB. If not,
|
17
|
+
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
18
|
+
Boston, MA 02111-1307, USA. */
|
19
|
+
|
20
|
+
#ifndef _GNU_NAN_H
|
21
|
+
|
22
|
+
#define _GNU_NAN_H 1
|
23
|
+
|
24
|
+
|
25
|
+
/* hacked to define NAN on Solaris 2.7 if it wasn't defined */
|
26
|
+
|
27
|
+
/* IEEE Not A Number. */
|
28
|
+
|
29
|
+
#ifdef _BIG_ENDIAN
|
30
|
+
# define __nan_bytes { 0x7f, 0xf8, 0, 0, 0, 0, 0, 0 }
|
31
|
+
#endif
|
32
|
+
#ifdef _LITTLE_ENDIAN
|
33
|
+
# define __nan_bytes { 0, 0, 0, 0, 0, 0, 0xf8, 0x7f }
|
34
|
+
#endif
|
35
|
+
|
36
|
+
#ifdef __GNUC__
|
37
|
+
# define NAN \
|
38
|
+
(__extension__ ((union { unsigned char __c[8]; \
|
39
|
+
double __d; }) \
|
40
|
+
{ __nan_bytes }).__d)
|
41
|
+
#else /* Not GCC. */
|
42
|
+
static const char __nan[8] = __nan_bytes;
|
43
|
+
# define NAN (*(const double *) __nan)
|
44
|
+
#endif
|
45
|
+
|
46
|
+
#endif /* gnu_nan.h */
|
@@ -0,0 +1,100 @@
|
|
1
|
+
/******************************************************************************
|
2
|
+
* Copyright (c) 1999, Carl Anderson
|
3
|
+
*
|
4
|
+
* This code is based in part on the earlier work of Frank Warmerdam
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a
|
7
|
+
* copy of this software and associated documentation files (the "Software"),
|
8
|
+
* to deal in the Software without restriction, including without limitation
|
9
|
+
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
10
|
+
* and/or sell copies of the Software, and to permit persons to whom the
|
11
|
+
* Software is furnished to do so, subject to the following conditions:
|
12
|
+
*
|
13
|
+
* The above copyright notice and this permission notice shall be included
|
14
|
+
* in all copies or substantial portions of the Software.
|
15
|
+
*
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
17
|
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19
|
+
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
22
|
+
* DEALINGS IN THE SOFTWARE.
|
23
|
+
******************************************************************************
|
24
|
+
*
|
25
|
+
* shpcat
|
26
|
+
*
|
27
|
+
* gcc shpcat.c ../shpopen.o -o shpcat
|
28
|
+
*
|
29
|
+
* Utility program to concatenate two shapefiles
|
30
|
+
* Must be used in concert with dbfcat
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
|
34
|
+
#include <stdlib.h>
|
35
|
+
#include <string.h>
|
36
|
+
#include "shapefil.h"
|
37
|
+
|
38
|
+
int dbfcat_main( int argc, char ** argv );
|
39
|
+
|
40
|
+
int main( int argc, char ** argv )
|
41
|
+
|
42
|
+
{
|
43
|
+
SHPHandle hSHP, cSHP;
|
44
|
+
int nShapeType, i, nEntities, nShpInFile;
|
45
|
+
SHPObject *shape;
|
46
|
+
|
47
|
+
/* -------------------------------------------------------------------- */
|
48
|
+
/* Display a usage message. */
|
49
|
+
/* -------------------------------------------------------------------- */
|
50
|
+
if( argc != 3 )
|
51
|
+
{
|
52
|
+
printf( "shpcat from_shpfile to_shpfile\n" );
|
53
|
+
exit( 1 );
|
54
|
+
}
|
55
|
+
|
56
|
+
/* -------------------------------------------------------------------- */
|
57
|
+
/* Open the passed shapefile. */
|
58
|
+
/* -------------------------------------------------------------------- */
|
59
|
+
hSHP = SHPOpen( argv[1], "rb" );
|
60
|
+
|
61
|
+
if( hSHP == NULL )
|
62
|
+
{
|
63
|
+
printf( "Unable to open:%s\n", argv[1] );
|
64
|
+
exit( 1 );
|
65
|
+
}
|
66
|
+
|
67
|
+
SHPGetInfo( hSHP, &nEntities, &nShapeType, NULL, NULL );
|
68
|
+
fprintf(stderr,"Opened From File %s, with %d shapes\n",argv[1],nEntities);
|
69
|
+
|
70
|
+
/* -------------------------------------------------------------------- */
|
71
|
+
/* Open the passed shapefile. */
|
72
|
+
/* -------------------------------------------------------------------- */
|
73
|
+
cSHP = SHPOpen( argv[2], "rb+" );
|
74
|
+
|
75
|
+
if( cSHP == NULL )
|
76
|
+
{
|
77
|
+
printf( "Unable to open:%s\n", argv[2] );
|
78
|
+
exit( 1 );
|
79
|
+
}
|
80
|
+
|
81
|
+
SHPGetInfo( cSHP, &nShpInFile, NULL, NULL, NULL );
|
82
|
+
fprintf(stderr,"Opened to file %s with %d shapes, ready to add %d\n",
|
83
|
+
argv[2],nShpInFile,nEntities);
|
84
|
+
|
85
|
+
/* -------------------------------------------------------------------- */
|
86
|
+
/* Skim over the list of shapes, printing all the vertices. */
|
87
|
+
/* -------------------------------------------------------------------- */
|
88
|
+
for( i = 0; i < nEntities; i++ )
|
89
|
+
{
|
90
|
+
shape = SHPReadObject( hSHP, i );
|
91
|
+
SHPWriteObject( cSHP, -1, shape );
|
92
|
+
SHPDestroyObject ( shape );
|
93
|
+
|
94
|
+
}
|
95
|
+
|
96
|
+
SHPClose( hSHP );
|
97
|
+
SHPClose( cSHP );
|
98
|
+
|
99
|
+
exit( 0 );
|
100
|
+
}
|