./geocoder/0040755000076400007640000000000007442033015012274 5ustar gmadergmader./geocoder/geocoder.o0100664000076400007640000001155407441704114014254 0ustar gmadergmaderELF 4( U}t- huh( jE  0EE 0EPE 0EPE 0EPh+h-DDu h@Dj$8P DPPEPEPEPu8P EPEPEPEP8P EPPPPu8P xPPPPu8P E)P$X)P$Xݝp݅݅E@t&݅݅E@t Džl݅݅E@t(݅݅xE@t Džl݅݅E@t'݅݅E@t Džl݅݅E@t(݅݅xE@t Džl݅ܥݝ004`d݅ܥݝ004X\lu4݅`܍p݅ݝP݅X܍p݅ݝHlu6ܥp܍`݅ݝP݅X܍p݅ݝH LHTPhb ÍvU Eh|uE}u h jE u9E|.j uuuPj uuuPj uuuPjuu9E sj uu9E UUЍ H‹EjuuUЍL j uuUЍP  j uuPHU P j uuPHU>P j uuPHUpPEEEE;E|~UЍHEMUЍLM UЍPEzEÐUXEh|uE}u h jE u9E| j uuuPj uuuPj uuuPupjuu9E uVE UЍ ‹EUЍEEE}.Ev u9E| j uuuPj uuuPj uuuPupj uu9EuVUЍ ‹EE UЍEEEEÐUS4Eh|uEu uE}u h jEUE;B|}u8]MEkARS]MEkARSE@H9Eu8]MEkARS]MEkARSEd u u]Ív01.01geocode [add# pre_dir st_name st_type] %dr.geocoder.geocoder defaults file not foundX coord=%f, Y coord =%f rbpath incorrect no match GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98).symtab.strtab.shstrtab.text.rel.text.data.bss.note.rodata.comment4( ! P +\ 1\ 6\ < D 6V M\  ,  ',18>DK /VPg !pxgeocoder.cgcc2_compiled.mainprintfexitatoistrcpyfopenfgetsfclosedbf_searchdirection_searchshp_findDBFOpenDBFGetRecordCountDBFReadStringAttributestrcmpDBFReadIntegerAttributeSHPOpenSHPReadObjectSHPDestroyObjectSHPClose &+ 8 H d {    T  4<RW d w (F! 7a w dl   (9T  0 A ` q     4 J O  \   ./geocoder/geocoder.c0100644000076400007640000002133607441704112014233 0ustar gmadergmader#include #include #include "shapefil.h" #include /* function prototypes*/ int dbf_search(char file[], int addr, char pre_dir[], char st_name[], char st_type[],int *from_addr, int *to_addr); int direction_search(char file[], int to_addr, int from_addr, char pre_dir[], char st_name[], char st_type[],int *flag); void shp_find(char file[],int recno,double *startx, double *starty, double *endx, double *endy); int main( int argc, char ** argv ){ int addr; char pre_dir[10]; char st_name[10]; char st_type[10]; int recno; int adjoin; char file_name[100]; char file_name2[100]; int from_addr; int to_addr; int flag; double startx; double starty; double endx; double endy; double startadjx; double startadjy; double endadjx; double endadjy; double addratio; int flag2; double lengthx; double lengthy; double resultx; double resulty; FILE *defaults1; /* -------------------------------------------------------------------- */ /* Display a usage message. */ /* -------------------------------------------------------------------- */ if( argc != 5 ) { printf("geocode [add# pre_dir st_name st_type]\n" ); printf("%d", argc); exit(1); } /* -------------------------------------------------------------------- */ /* set up user input */ /* -------------------------------------------------------------------- */ addr = atoi(argv[1]); strcpy(pre_dir, argv[2]); strcpy(st_name, argv[3]); strcpy(st_type, argv[4]); if ((defaults1=fopen (".geocoder","r")) == NULL){ printf(".geocoder defaults file not found"); } fgets(file_name, 36, defaults1); fclose(defaults1); recno = dbf_search(file_name, addr, pre_dir, st_name, st_type, &from_addr, &to_addr); adjoin = direction_search(file_name, to_addr, from_addr, pre_dir, st_name, st_type, &flag); shp_find(file_name, recno, &startx, &starty, &endx, &endy); shp_find(file_name, adjoin, &startadjx, &startadjy, &endadjx, &endadjy); /* this part figures the directionality of the arc. It is key, as Shapefiles*/ /* do not maintain directionality. */ addratio = (double)(addr - from_addr)/(double)(to_addr - from_addr); if (flag == 1){ if (endx == startadjx && endy == startadjy){ /* ordered correctly */ flag2 = 1; } if (startx == endadjx && starty == endadjy){ flag2 = 0;} /*ordered backwards */ } if (flag == 0){ if (endx == startadjx && endy == startadjy){ /* ordered backwards */ flag2 = 0; } if (startx == endadjx && starty == endadjy){ flag2 = 1;} /*ordered correctly */ } /* this part figures out the length of the correct arc, and then interpolates the length*/ /* of the address on to the arc. We can get away with applying the address ratio to both*/ /* the x and the y side, as any ratio times zero is zero.*/ /* note: this is currently only for northern hemisphere, lat/long coordinates.*/ /* it will not work right on state plane, UTM, or other coordinate systems. */ lengthx = fabs(startx - endx); lengthy = fabs(endy - starty); if (flag2 ==1){ resultx = startx -(lengthx * addratio); resulty = starty -(lengthy * addratio); } if (flag2 ==0){ resultx = endx +(lengthx * (1 - addratio)); resulty = endy + (lengthy * addratio); } printf("X coord=%f, Y coord =%f\n\n", resultx, resulty); return 0; } /* -------------------------------------------------------------------- */ /*This function searches the DBF for the record that contains the address*/ /* -------------------------------------------------------------------- */ int dbf_search(char file[], int addr, char pre_dir[], char st_name[], char st_type[], int *from_addr, int *to_addr){ DBFHandle handle; int counter2=0; int count; int count2; int iRecord; int holder; int addrange; double addratio; struct address { int recno; int from_address; int to_address; char pre_direction[50]; char street_name[50]; char street_type[50]; }address; struct address candidates[20]; /* need to clean this up and allocate better */ handle = DBFOpen(file,"rb"); if( handle == NULL ) { printf( "path incorrect\n" ); exit( 2 ); } for(iRecord = 0; iRecord < DBFGetRecordCount(handle); iRecord++ ){ /*initial hack at recognizing and loading address struct into array */ if (strcmp(DBFReadStringAttribute(handle, iRecord,12),st_type) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,11),st_name) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,10),pre_dir) == 0){ if (addr >= DBFReadIntegerAttribute(handle, iRecord,8)){ if (addr < DBFReadIntegerAttribute(handle, iRecord,9)){ candidates[counter2].recno = iRecord; candidates[counter2].from_address = DBFReadIntegerAttribute(handle, iRecord,8); candidates[counter2].to_address = DBFReadIntegerAttribute(handle, iRecord,9); strcpy (candidates[counter2].pre_direction,DBFReadStringAttribute(handle, iRecord,10)); strcpy (candidates[counter2].street_name,DBFReadStringAttribute(handle, iRecord,11)); strcpy (candidates[counter2].street_type,DBFReadStringAttribute(handle, iRecord,12)); counter2 = counter2+1; } } } } } } /* -------------------------------------------------------------------- */ /* stuff to pass back to main. */ /* -------------------------------------------------------------------- */ for(iRecord = 0; iRecord < counter2; iRecord++ ){ holder = candidates[iRecord].recno; *from_addr = candidates[iRecord].from_address; *to_addr = candidates[iRecord].to_address; } return holder; } /* -------------------------------------------------------------------- */ /* This function gets the adjoining arc, to determine the direction*/ /* This function sends the result to the next function to get the arc's geometry */ /* -------------------------------------------------------------------- */ int direction_search(char file[], int to_addr, int from_addr, char pre_dir[], char st_name[], char st_type[], int *flag){ DBFHandle handle; int counter2=0; int count; int count2; int iRecord; int holder; int addrange; double addratio; struct address { int recno; int from_address; int to_address; char pre_direction[50]; char street_name[50]; char street_type[50]; }address; struct address candidates[10]; handle = DBFOpen(file,"rb"); if( handle == NULL ) { printf( "path incorrect\n" ); exit( 2 ); } for(iRecord = 0; iRecord < DBFGetRecordCount(handle); iRecord++ ){ /*initial hack at recognizing and loading address struct into array */ if (strcmp(DBFReadStringAttribute(handle, iRecord,12),st_type) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,11),st_name) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,10),pre_dir) == 0){ if (to_addr == DBFReadIntegerAttribute(handle, iRecord,8)){ /* looking for adjacent arc. so, to_addr from desired should equal from_addr on next*/ *flag = 1; /*forward, or the block has the next chunk of addresses */ candidates[counter2].recno = iRecord; holder = candidates[counter2].recno; counter2 = counter2+1; } } } } } /* this is if there is no arc on the one side. We will look for arc on the other side now.*/ if (counter2 == 0){ for(iRecord = 0; iRecord < DBFGetRecordCount(handle); iRecord++ ){ if (strcmp(DBFReadStringAttribute(handle, iRecord,12),st_type) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,11),st_name) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,10),pre_dir) == 0){ if (from_addr == DBFReadIntegerAttribute(handle, iRecord,9)){ /*looking for adjacent arc. so, from_addr from desired should equal to_addr on next*/ candidates[counter2].recno = iRecord; *flag = 0; /*backwards or the block has the last block of addresses. */ holder = candidates[counter2].recno; counter2 = counter2+1; } } } } } } return holder;} /* -------------------------------------------------------------------- */ /* Finds the correct arc */ /* This function takes the record number and returns the geometry of the arc*/ /* -------------------------------------------------------------------- */ void shp_find(char file[],int recno,double *startx, double *starty, double *endx, double *endy){ SHPHandle hSHP; SHPObject *psShape; const char *pszPlus; const char *pszPartType = ""; int j; double xrange; double yrange; hSHP = SHPOpen(file, "rb" ); psShape = SHPReadObject( hSHP, recno ); if( psShape == NULL ) { printf( "no match\n" ); exit( 2 ); } for( j = 0; j < psShape->nVertices; j++ ){ if( j==0){ *startx = psShape->padfX[j]; *starty = psShape->padfY[j]; } if (j==(psShape->nVertices-1)) { *endx = psShape->padfX[j]; *endy = psShape->padfY[j]; } } SHPDestroyObject( psShape ); SHPClose( hSHP ); } ./geocoder/shpopen.o0100644000076400007640000005207007403015037014132 0ustar gmadergmaderELF @4( UEE9E|Gt&E UЊUE UЋUM)ʉM Q EU)ЉU BUE띉]ÐU}uE P‰%#vE PEP‰t&]UVSDž||c~t&E||E'E UB xjxPEPR=uEPRjDžxjxPEPR=tEPRj^EPxjxPEP R=tEP RjE@ ݝpjpPEP$R=tEP$RjE@(ݝpjpPEP,R=tEP,RjE@@ݝpjpPEP4R=tEP4RjNE@HݝpjpPEPE@XݝpjpPEP\R=tEP\RjjjERERjjdEPEPЍB2xjxPEPR=uEPRjjjEPREPRjjdEPEPЍRlDž|E|;P||lM|4Y 3 |lAU|J =u%|lRjb=u(|lBPj1|vEPREPRjlPlPX[^]ÍvU4ShE Pt6hE PthE Pu E E E}u  jdEE@`EPPREEPEPEPPU}~)EUЀ8.tEUЀ8/tEUЀ8\u Mʐt&EUЀ8.u EUEPPREEPhEPE PEPUE8u2EPhEPE PEPUE8u4EPEPEP1AEPhEPE PEPUBExu3EPh#EPE PEPUBExuFEPREPEPEP1EPEPjdEERjjdEPEU1Ɋ ˉM1ۊىڋM1ۊىڋM1ۊڍ H EPRjjdEPE8u,E@8u#E8'uE8 tME8 u@EREPREP1m&EM1ҊM1ۊىڋM1ۊىڋM1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P0Uj< PE(Pj<PE0Pj<PEHPj<$PEPP=tE(Pj}=tE0Pj`=tEHPjC=tEPPj&E8j<UPE8Pj<UЍPREXP=tE8Pj=tEXPjEt&E;E|vj<UЋUэJPEUэH P=t#EUэH PjE뀋EUэ MEU P UэJU9j<UPE@Pj<UЍPRE`P=tE@Pjk=tE`PjNEvE;E|vj<UЋUэJPEUэH$P=t#EUэH$PjEE8tE8t E8 tE@jj‹EPjj‹EPjj‹EP jj‹EP$j< PEPRj<PEPR=tEPRj=tEPRjEE8 u@j<UPEP R=tEP RjtEEU @E9|nSHPType == psSHP->nShapeType || psObject->nSHPType == 0nShapeId == -1 || (nShapeId >= 0 && nShapeId < psSHP->nRecords)0Error in fseek() or fwrite(). ?Y@NullShapePointArcPolygonMultiPointPointZArcZPolygonZMultiPointZPointMArcMPolygonMMultiPointMMultiPatchUnknownShapeTypeq:x:::::::::::::::::::::::::::::::TriangleStripTriangleFanOuterRingInnerRingFirstRingRingUnknownPartType;; ;';0;7;GCC: (GNU) 2.95.1 19990816 (release).symtab.strtab.shstrtab.text.rel.text.data.bss.note.rodata.rel.rodata.comment@<! XF +`<D 1<6<<< D S0 P?&?YB  D 9 <(@1w:xLDYS^ls{ ](t\{ !<7FM+9[P:g:_wL;shpopen.cgcc2_compiled.rcsidpabyRecnBufSizeSwapWordSfReallocSHPWriteHeaderbBigEndian_SHPSetBoundsmallocreallocmemcpyfseekfwritefreeSHPOpenstrcmpstrlenstrcpysprintffopenfclosefreadSHPCloseSHPGetInfoSHPCreateSHPComputeExtentsSHPCreateObjectcalloc__assert_failSHPCreateSimpleObjectSHPWriteObjectprintfSHPReadObjectSHPTypeNameSHPPartTypeNameSHPDestroyObject?H MV"]f-`iu + 4E N_ hz  s   '= FYy   2           L ^       D V      4 a     h+:     'HW@I+4bq k$Gl4$O$j$$   %   %< F K P%   %  =U";D{V _    !q!!! ")"R""""#e#n###$$i$r$$$$%U%^%%%% % % %%&&&'"'K'b''' '(''O+m+u+{++++++$,,,v,,,,,,,,,- -=-^-k-x-----$-$ .$$.$H.$c.$...P/b///00E0N0z00011#1@1v11102B2O2d2m22223X3e3n33$3$3$3$&4B4_4~4444 55(555E5R5b5k5555566#6,6I6666@7R7_7t7}77788t8$8$8$8$8889 9)9Y9k9t9999k: r: y: : : : : : : : : : : : : : ; ; ; !; (; 1; 8; A; t;;;;;; <  $(,048<@DHLPTX\`dhlpt./geocoder/test_results.txt0100755000076400007640000000050207401750470015600 0ustar gmadergmaderxfield yfield address -84.39576 33.792952 330 n jones ave -84.39576 33.791962 230 n jones ave -84.393089 33.791125 120 n smith ave -84.393089 33.791459 175 n smith ave -84.394424 33.791611 650 w elm st -84.392017 33.791611 505 w elm st -84.396483 33.791611 781 w elm st -84.392574 33.792782 550 w oak st./geocoder/shapefil.h0100644000076400007640000003146107401744223014247 0ustar gmadergmader#ifndef _SHAPEFILE_H_INCLUDED #define _SHAPEFILE_H_INCLUDED /****************************************************************************** * $Id: shapefil.h,v 1.20 2001/07/20 13:06:02 warmerda Exp $ * * Project: Shapelib * Purpose: Primary include file for Shapelib. * Author: Frank Warmerdam, warmerda@home.com * ****************************************************************************** * Copyright (c) 1999, Frank Warmerdam * * This software is available under the following "MIT Style" license, * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This * option is discussed in more detail in shapelib.html. * * -- * * 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. ****************************************************************************** * * $Log: shapefil.h,v $ * Revision 1.20 2001/07/20 13:06:02 warmerda * fixed SHPAPI attribute for SHPTreeFindLikelyShapes * * Revision 1.19 2001/05/31 19:20:13 warmerda * added DBFGetFieldIndex() * * Revision 1.18 2001/05/31 18:15:40 warmerda * Added support for NULL fields in DBF files * * Revision 1.17 2001/05/23 13:36:52 warmerda * added use of SHPAPI_CALL * * Revision 1.16 2000/09/25 14:15:59 warmerda * added DBFGetNativeFieldType() * * Revision 1.15 2000/02/16 16:03:51 warmerda * added null shape support * * Revision 1.14 1999/11/05 14:12:05 warmerda * updated license terms * * Revision 1.13 1999/06/02 18:24:21 warmerda * added trimming code * * Revision 1.12 1999/06/02 17:56:12 warmerda * added quad'' subnode support for trees * * Revision 1.11 1999/05/18 19:11:11 warmerda * Added example searching capability * * Revision 1.10 1999/05/18 17:49:38 warmerda * added initial quadtree support * * Revision 1.9 1999/05/11 03:19:28 warmerda * added new Tuple api, and improved extension handling - add from candrsn * * Revision 1.8 1999/03/23 17:22:27 warmerda * Added extern "C" protection for C++ users of shapefil.h. * * Revision 1.7 1998/12/31 15:31:07 warmerda * Added the TRIM_DBF_WHITESPACE and DISABLE_MULTIPATCH_MEASURE options. * * Revision 1.6 1998/12/03 15:48:15 warmerda * Added SHPCalculateExtents(). * * Revision 1.5 1998/11/09 20:57:16 warmerda * Altered SHPGetInfo() call. * * Revision 1.4 1998/11/09 20:19:33 warmerda * Added 3D support, and use of SHPObject. * * Revision 1.3 1995/08/23 02:24:05 warmerda * Added support for reading bounds. * * Revision 1.2 1995/08/04 03:17:39 warmerda * Added header. * */ #include #ifdef USE_DBMALLOC #include #endif #ifdef __cplusplus extern "C" { #endif #ifndef SHPAPI_CALL #define SHPAPI_CALL #endif #define SHPAPI_CALL1(x) * SHPAPI_CALL /************************************************************************/ /* Configuration options. */ /************************************************************************/ /* -------------------------------------------------------------------- */ /* Should the DBFReadStringAttribute() strip leading and */ /* trailing white space? */ /* -------------------------------------------------------------------- */ #define TRIM_DBF_WHITESPACE /* -------------------------------------------------------------------- */ /* Should we write measure values to the Multipatch object? */ /* Reportedly ArcView crashes if we do write it, so for now it */ /* is disabled. */ /* -------------------------------------------------------------------- */ #define DISABLE_MULTIPATCH_MEASURE /************************************************************************/ /* SHP Support. */ /************************************************************************/ typedef struct { FILE *fpSHP; FILE *fpSHX; int nShapeType; /* SHPT_* */ int nFileSize; /* SHP file */ int nRecords; int nMaxRecords; int *panRecOffset; int *panRecSize; double adBoundsMin[4]; double adBoundsMax[4]; int bUpdated; } SHPInfo; typedef SHPInfo * SHPHandle; /* -------------------------------------------------------------------- */ /* Shape types (nSHPType) */ /* -------------------------------------------------------------------- */ #define SHPT_NULL 0 #define SHPT_POINT 1 #define SHPT_ARC 3 #define SHPT_POLYGON 5 #define SHPT_MULTIPOINT 8 #define SHPT_POINTZ 11 #define SHPT_ARCZ 13 #define SHPT_POLYGONZ 15 #define SHPT_MULTIPOINTZ 18 #define SHPT_POINTM 21 #define SHPT_ARCM 23 #define SHPT_POLYGONM 25 #define SHPT_MULTIPOINTM 28 #define SHPT_MULTIPATCH 31 /* -------------------------------------------------------------------- */ /* Part types - everything but SHPT_MULTIPATCH just uses */ /* SHPP_RING. */ /* -------------------------------------------------------------------- */ #define SHPP_TRISTRIP 0 #define SHPP_TRIFAN 1 #define SHPP_OUTERRING 2 #define SHPP_INNERRING 3 #define SHPP_FIRSTRING 4 #define SHPP_RING 5 /* -------------------------------------------------------------------- */ /* SHPObject - represents on shape (without attributes) read */ /* from the .shp file. */ /* -------------------------------------------------------------------- */ typedef struct { int nSHPType; int nShapeId; /* -1 is unknown/unassigned */ int nParts; int *panPartStart; int *panPartType; int nVertices; double *padfX; double *padfY; double *padfZ; double *padfM; double dfXMin; double dfYMin; double dfZMin; double dfMMin; double dfXMax; double dfYMax; double dfZMax; double dfMMax; } SHPObject; /* -------------------------------------------------------------------- */ /* SHP API Prototypes */ /* -------------------------------------------------------------------- */ SHPHandle SHPAPI_CALL SHPOpen( const char * pszShapeFile, const char * pszAccess ); SHPHandle SHPAPI_CALL SHPCreate( const char * pszShapeFile, int nShapeType ); void SHPAPI_CALL SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType, double * padfMinBound, double * padfMaxBound ); SHPObject SHPAPI_CALL1(*) SHPReadObject( SHPHandle hSHP, int iShape ); int SHPAPI_CALL SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject ); void SHPAPI_CALL SHPDestroyObject( SHPObject * psObject ); void SHPAPI_CALL SHPComputeExtents( SHPObject * psObject ); SHPObject SHPAPI_CALL1(*) SHPCreateObject( int nSHPType, int nShapeId, int nParts, int * panPartStart, int * panPartType, int nVertices, double * padfX, double * padfY, double * padfZ, double * padfM ); SHPObject SHPAPI_CALL1(*) SHPCreateSimpleObject( int nSHPType, int nVertices, double * padfX, double * padfY, double * padfZ ); void SHPAPI_CALL SHPClose( SHPHandle hSHP ); const char SHPAPI_CALL1(*) SHPTypeName( int nSHPType ); const char SHPAPI_CALL1(*) SHPPartTypeName( int nPartType ); /* -------------------------------------------------------------------- */ /* Shape quadtree indexing API. */ /* -------------------------------------------------------------------- */ /* this can be two or four for binary or quad tree */ #define MAX_SUBNODE 4 typedef struct shape_tree_node { /* region covered by this node */ double adfBoundsMin[4]; double adfBoundsMax[4]; /* list of shapes stored at this node. The papsShapeObj pointers or the whole list can be NULL */ int nShapeCount; int *panShapeIds; SHPObject **papsShapeObj; int nSubNodes; struct shape_tree_node *apsSubNode[MAX_SUBNODE]; } SHPTreeNode; typedef struct { SHPHandle hSHP; int nMaxDepth; int nDimension; SHPTreeNode *psRoot; } SHPTree; SHPTree SHPAPI_CALL1(*) SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth, double *padfBoundsMin, double *padfBoundsMax ); void SHPAPI_CALL SHPDestroyTree( SHPTree * hTree ); int SHPAPI_CALL SHPWriteTree( SHPTree *hTree, const char * pszFilename ); SHPTree SHPAPI_CALL SHPReadTree( const char * pszFilename ); int SHPAPI_CALL SHPTreeAddObject( SHPTree * hTree, SHPObject * psObject ); int SHPAPI_CALL SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject ); int SHPAPI_CALL SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId ); void SHPAPI_CALL SHPTreeTrimExtraNodes( SHPTree * hTree ); int SHPAPI_CALL1(*) SHPTreeFindLikelyShapes( SHPTree * hTree, double * padfBoundsMin, double * padfBoundsMax, int * ); int SHPAPI_CALL SHPCheckBoundsOverlap( double *, double *, double *, double *, int ); /************************************************************************/ /* DBF Support. */ /************************************************************************/ typedef struct { FILE *fp; int nRecords; int nRecordLength; int nHeaderLength; int nFields; int *panFieldOffset; int *panFieldSize; int *panFieldDecimals; char *pachFieldType; char *pszHeader; int nCurrentRecord; int bCurrentRecordModified; char *pszCurrentRecord; int bNoHeader; int bUpdated; } DBFInfo; typedef DBFInfo * DBFHandle; typedef enum { FTString, FTInteger, FTDouble, FTInvalid } DBFFieldType; #define XBASE_FLDHDR_SZ 32 DBFHandle SHPAPI_CALL DBFOpen( const char * pszDBFFile, const char * pszAccess ); DBFHandle SHPAPI_CALL DBFCreate( const char * pszDBFFile ); int SHPAPI_CALL DBFGetFieldCount( DBFHandle psDBF ); int SHPAPI_CALL DBFGetRecordCount( DBFHandle psDBF ); int SHPAPI_CALL DBFAddField( DBFHandle hDBF, const char * pszFieldName, DBFFieldType eType, int nWidth, int nDecimals ); DBFFieldType SHPAPI_CALL DBFGetFieldInfo( DBFHandle psDBF, int iField, char * pszFieldName, int * pnWidth, int * pnDecimals ); int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName); int SHPAPI_CALL DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField ); double SHPAPI_CALL DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField ); const char SHPAPI_CALL1(*) DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField ); int SHPAPI_CALL DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField ); int SHPAPI_CALL DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField, int nFieldValue ); int SHPAPI_CALL DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField, double dFieldValue ); int SHPAPI_CALL DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField, const char * pszFieldValue ); int SHPAPI_CALL DBFWriteNULLAttribute( DBFHandle hDBF, int iShape, int iField ); const char SHPAPI_CALL1(*) DBFReadTuple(DBFHandle psDBF, int hEntity ); int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple ); DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename ); void SHPAPI_CALL DBFClose( DBFHandle hDBF ); char SHPAPI_CALL DBFGetNativeFieldType( DBFHandle hDBF, int iField ); #ifdef __cplusplus } #endif #endif /* ndef _SHAPEFILE_H_INCLUDED */ ./geocoder/dbfopen.c0100644000076400007640000013202007401744240014054 0ustar gmadergmader/****************************************************************************** * $Id: dbfopen.c,v 1.37 2001/07/04 05:18:09 warmerda Exp $ * * Project: Shapelib * Purpose: Implementation of .dbf access API documented in dbf_api.html. * Author: Frank Warmerdam, warmerda@home.com * ****************************************************************************** * Copyright (c) 1999, Frank Warmerdam * * This software is available under the following "MIT Style" license, * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This * option is discussed in more detail in shapelib.html. * * -- * * 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. ****************************************************************************** * * $Log: dbfopen.c,v $ * Revision 1.37 2001/07/04 05:18:09 warmerda * do last fix properly * * Revision 1.36 2001/07/04 05:16:09 warmerda * fixed fieldname comparison in DBFGetFieldIndex * * Revision 1.35 2001/06/22 02:10:06 warmerda * fixed NULL shape support with help from Jim Matthews * * Revision 1.33 2001/05/31 19:20:13 warmerda * added DBFGetFieldIndex() * * Revision 1.32 2001/05/31 18:15:40 warmerda * Added support for NULL fields in DBF files * * Revision 1.31 2001/05/23 13:36:52 warmerda * added use of SHPAPI_CALL * * Revision 1.30 2000/12/05 14:43:38 warmerda * DBReadAttribute() white space trimming bug fix * * Revision 1.29 2000/10/05 14:36:44 warmerda * fix bug with writing very wide numeric fields * * Revision 1.28 2000/09/25 14:18:07 warmerda * Added some casts of strlen() return result to fix warnings on some * systems, as submitted by Daniel. * * Revision 1.27 2000/09/25 14:15:51 warmerda * added DBFGetNativeFieldType() * * Revision 1.26 2000/07/07 13:39:45 warmerda * removed unused variables, and added system include files * * Revision 1.25 2000/05/29 18:19:13 warmerda * avoid use of uchar, and adding casting fix * * Revision 1.24 2000/05/23 13:38:27 warmerda * Added error checks on return results of fread() and fseek(). * * Revision 1.23 2000/05/23 13:25:49 warmerda * Avoid crashing if field or record are out of range in dbfread*attribute(). * * Revision 1.22 1999/12/15 13:47:24 warmerda * Added stdlib.h to ensure that atof() is prototyped. * * Revision 1.21 1999/12/13 17:25:46 warmerda * Added support for upper case .DBF extention. * * Revision 1.20 1999/11/30 16:32:11 warmerda * Use atof() instead of sscanf(). * * Revision 1.19 1999/11/05 14:12:04 warmerda * updated license terms * * Revision 1.18 1999/07/27 00:53:28 warmerda * ensure that whole old field value clear on write of string * * Revision 1.1 1999/07/05 18:58:07 warmerda * New * * Revision 1.17 1999/06/11 19:14:12 warmerda * Fixed some memory leaks. * * Revision 1.16 1999/06/11 19:04:11 warmerda * Remoted some unused variables. * * Revision 1.15 1999/05/11 03:19:28 warmerda * added new Tuple api, and improved extension handling - add from candrsn * * Revision 1.14 1999/05/04 15:01:48 warmerda * Added 'F' support. * * Revision 1.13 1999/03/23 17:38:59 warmerda * DBFAddField() now actually does return the new field number, or -1 if * it fails. * * Revision 1.12 1999/03/06 02:54:46 warmerda * Added logic to convert shapefile name to dbf filename in DBFOpen() * for convenience. * * Revision 1.11 1998/12/31 15:30:34 warmerda * Improved the interchangability of numeric and string attributes. Add * white space trimming option for attributes. * * Revision 1.10 1998/12/03 16:36:44 warmerda * Use r+b instead of rb+ for binary access. * * Revision 1.9 1998/12/03 15:34:23 warmerda * Updated copyright message. * * Revision 1.8 1997/12/04 15:40:15 warmerda * Added newline character after field definitions. * * Revision 1.7 1997/03/06 14:02:10 warmerda * Ensure bUpdated is initialized. * * Revision 1.6 1996/02/12 04:54:41 warmerda * Ensure that DBFWriteAttribute() returns TRUE if it succeeds. * * Revision 1.5 1995/10/21 03:15:12 warmerda * Changed to use binary file access, and ensure that the * field name field is zero filled, and limited to 10 chars. * * Revision 1.4 1995/08/24 18:10:42 warmerda * Added use of SfRealloc() to avoid pre-ANSI realloc() functions such * as on the Sun. * * Revision 1.3 1995/08/04 03:15:16 warmerda * Fixed up header. * * Revision 1.2 1995/08/04 03:14:43 warmerda * Added header. */ static char rcsid[] = "$Id: dbfopen.c,v 1.37 2001/07/04 05:18:09 warmerda Exp $"; #include "shapefil.h" #include #include #include #include #ifndef FALSE # define FALSE 0 # define TRUE 1 #endif static int nStringFieldLen = 0; static char * pszStringField = NULL; /************************************************************************/ /* SfRealloc() */ /* */ /* A realloc cover function that will access a NULL pointer as */ /* a valid input. */ /************************************************************************/ static void * SfRealloc( void * pMem, int nNewSize ) { if( pMem == NULL ) return( (void *) malloc(nNewSize) ); else return( (void *) realloc(pMem,nNewSize) ); } /************************************************************************/ /* DBFWriteHeader() */ /* */ /* This is called to write out the file header, and field */ /* descriptions before writing any actual data records. This */ /* also computes all the DBFDataSet field offset/size/decimals */ /* and so forth values. */ /************************************************************************/ static void DBFWriteHeader(DBFHandle psDBF) { unsigned char abyHeader[XBASE_FLDHDR_SZ]; int i; if( !psDBF->bNoHeader ) return; psDBF->bNoHeader = FALSE; /* -------------------------------------------------------------------- */ /* Initialize the file header information. */ /* -------------------------------------------------------------------- */ for( i = 0; i < XBASE_FLDHDR_SZ; i++ ) abyHeader[i] = 0; abyHeader[0] = 0x03; /* memo field? - just copying */ /* date updated on close, record count preset at zero */ abyHeader[8] = psDBF->nHeaderLength % 256; abyHeader[9] = psDBF->nHeaderLength / 256; abyHeader[10] = psDBF->nRecordLength % 256; abyHeader[11] = psDBF->nRecordLength / 256; /* -------------------------------------------------------------------- */ /* Write the initial 32 byte file header, and all the field */ /* descriptions. */ /* -------------------------------------------------------------------- */ fseek( psDBF->fp, 0, 0 ); fwrite( abyHeader, XBASE_FLDHDR_SZ, 1, psDBF->fp ); fwrite( psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields, psDBF->fp ); /* -------------------------------------------------------------------- */ /* Write out the newline character if there is room for it. */ /* -------------------------------------------------------------------- */ if( psDBF->nHeaderLength > 32*psDBF->nFields + 32 ) { char cNewline; cNewline = 0x0d; fwrite( &cNewline, 1, 1, psDBF->fp ); } } /************************************************************************/ /* DBFFlushRecord() */ /* */ /* Write out the current record if there is one. */ /************************************************************************/ static void DBFFlushRecord( DBFHandle psDBF ) { int nRecordOffset; if( psDBF->bCurrentRecordModified && psDBF->nCurrentRecord > -1 ) { psDBF->bCurrentRecordModified = FALSE; nRecordOffset = psDBF->nRecordLength * psDBF->nCurrentRecord + psDBF->nHeaderLength; fseek( psDBF->fp, nRecordOffset, 0 ); fwrite( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp ); } } /************************************************************************/ /* DBFOpen() */ /* */ /* Open a .dbf file. */ /************************************************************************/ DBFHandle SHPAPI_CALL DBFOpen( const char * pszFilename, const char * pszAccess ) { DBFHandle psDBF; unsigned char *pabyBuf; int nFields, nRecords, nHeadLen, nRecLen, iField, i; char *pszBasename, *pszFullname; /* -------------------------------------------------------------------- */ /* We only allow the access strings "rb" and "r+". */ /* -------------------------------------------------------------------- */ if( strcmp(pszAccess,"r") != 0 && strcmp(pszAccess,"r+") != 0 && strcmp(pszAccess,"rb") != 0 && strcmp(pszAccess,"rb+") != 0 && strcmp(pszAccess,"r+b") != 0 ) return( NULL ); if( strcmp(pszAccess,"r") == 0 ) pszAccess = "rb"; if( strcmp(pszAccess,"r+") == 0 ) pszAccess = "rb+"; /* -------------------------------------------------------------------- */ /* Compute the base (layer) name. If there is any extension */ /* on the passed in filename we will strip it off. */ /* -------------------------------------------------------------------- */ pszBasename = (char *) malloc(strlen(pszFilename)+5); strcpy( pszBasename, pszFilename ); for( i = strlen(pszBasename)-1; i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/' && pszBasename[i] != '\\'; i-- ) {} if( pszBasename[i] == '.' ) pszBasename[i] = '\0'; pszFullname = (char *) malloc(strlen(pszBasename) + 5); sprintf( pszFullname, "%s.dbf", pszBasename ); psDBF = (DBFHandle) calloc( 1, sizeof(DBFInfo) ); psDBF->fp = fopen( pszFullname, pszAccess ); if( psDBF->fp == NULL ) { sprintf( pszFullname, "%s.DBF", pszBasename ); psDBF->fp = fopen(pszFullname, pszAccess ); } free( pszBasename ); free( pszFullname ); if( psDBF->fp == NULL ) { free( psDBF ); return( NULL ); } psDBF->bNoHeader = FALSE; psDBF->nCurrentRecord = -1; psDBF->bCurrentRecordModified = FALSE; /* -------------------------------------------------------------------- */ /* Read Table Header info */ /* -------------------------------------------------------------------- */ pabyBuf = (unsigned char *) malloc(500); fread( pabyBuf, 32, 1, psDBF->fp ); psDBF->nRecords = nRecords = pabyBuf[4] + pabyBuf[5]*256 + pabyBuf[6]*256*256 + pabyBuf[7]*256*256*256; psDBF->nHeaderLength = nHeadLen = pabyBuf[8] + pabyBuf[9]*256; psDBF->nRecordLength = nRecLen = pabyBuf[10] + pabyBuf[11]*256; psDBF->nFields = nFields = (nHeadLen - 32) / 32; psDBF->pszCurrentRecord = (char *) malloc(nRecLen); /* -------------------------------------------------------------------- */ /* Read in Field Definitions */ /* -------------------------------------------------------------------- */ pabyBuf = (unsigned char *) SfRealloc(pabyBuf,nHeadLen); psDBF->pszHeader = (char *) pabyBuf; fseek( psDBF->fp, 32, 0 ); fread( pabyBuf, nHeadLen, 1, psDBF->fp ); psDBF->panFieldOffset = (int *) malloc(sizeof(int) * nFields); psDBF->panFieldSize = (int *) malloc(sizeof(int) * nFields); psDBF->panFieldDecimals = (int *) malloc(sizeof(int) * nFields); psDBF->pachFieldType = (char *) malloc(sizeof(char) * nFields); for( iField = 0; iField < nFields; iField++ ) { unsigned char *pabyFInfo; pabyFInfo = pabyBuf+iField*32; if( pabyFInfo[11] == 'N' || pabyFInfo[11] == 'F' ) { psDBF->panFieldSize[iField] = pabyFInfo[16]; psDBF->panFieldDecimals[iField] = pabyFInfo[17]; } else { psDBF->panFieldSize[iField] = pabyFInfo[16] + pabyFInfo[17]*256; psDBF->panFieldDecimals[iField] = 0; } psDBF->pachFieldType[iField] = (char) pabyFInfo[11]; if( iField == 0 ) psDBF->panFieldOffset[iField] = 1; else psDBF->panFieldOffset[iField] = psDBF->panFieldOffset[iField-1] + psDBF->panFieldSize[iField-1]; } return( psDBF ); } /************************************************************************/ /* DBFClose() */ /************************************************************************/ void SHPAPI_CALL DBFClose(DBFHandle psDBF) { /* -------------------------------------------------------------------- */ /* Write out header if not already written. */ /* -------------------------------------------------------------------- */ if( psDBF->bNoHeader ) DBFWriteHeader( psDBF ); DBFFlushRecord( psDBF ); /* -------------------------------------------------------------------- */ /* Update last access date, and number of records if we have */ /* write access. */ /* -------------------------------------------------------------------- */ if( psDBF->bUpdated ) { unsigned char abyFileHeader[32]; fseek( psDBF->fp, 0, 0 ); fread( abyFileHeader, 32, 1, psDBF->fp ); abyFileHeader[1] = 95; /* YY */ abyFileHeader[2] = 7; /* MM */ abyFileHeader[3] = 26; /* DD */ abyFileHeader[4] = psDBF->nRecords % 256; abyFileHeader[5] = (psDBF->nRecords/256) % 256; abyFileHeader[6] = (psDBF->nRecords/(256*256)) % 256; abyFileHeader[7] = (psDBF->nRecords/(256*256*256)) % 256; fseek( psDBF->fp, 0, 0 ); fwrite( abyFileHeader, 32, 1, psDBF->fp ); } /* -------------------------------------------------------------------- */ /* Close, and free resources. */ /* -------------------------------------------------------------------- */ fclose( psDBF->fp ); if( psDBF->panFieldOffset != NULL ) { free( psDBF->panFieldOffset ); free( psDBF->panFieldSize ); free( psDBF->panFieldDecimals ); free( psDBF->pachFieldType ); } free( psDBF->pszHeader ); free( psDBF->pszCurrentRecord ); free( psDBF ); if( pszStringField != NULL ) { free( pszStringField ); pszStringField = NULL; nStringFieldLen = 0; } } /************************************************************************/ /* DBFCreate() */ /* */ /* Create a new .dbf file. */ /************************************************************************/ DBFHandle SHPAPI_CALL DBFCreate( const char * pszFilename ) { DBFHandle psDBF; FILE *fp; char *pszFullname, *pszBasename; int i; /* -------------------------------------------------------------------- */ /* Compute the base (layer) name. If there is any extension */ /* on the passed in filename we will strip it off. */ /* -------------------------------------------------------------------- */ pszBasename = (char *) malloc(strlen(pszFilename)+5); strcpy( pszBasename, pszFilename ); for( i = strlen(pszBasename)-1; i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/' && pszBasename[i] != '\\'; i-- ) {} if( pszBasename[i] == '.' ) pszBasename[i] = '\0'; pszFullname = (char *) malloc(strlen(pszBasename) + 5); sprintf( pszFullname, "%s.dbf", pszBasename ); free( pszBasename ); /* -------------------------------------------------------------------- */ /* Create the file. */ /* -------------------------------------------------------------------- */ fp = fopen( pszFullname, "wb" ); if( fp == NULL ) return( NULL ); fputc( 0, fp ); fclose( fp ); fp = fopen( pszFullname, "rb+" ); if( fp == NULL ) return( NULL ); free( pszFullname ); /* -------------------------------------------------------------------- */ /* Create the info structure. */ /* -------------------------------------------------------------------- */ psDBF = (DBFHandle) malloc(sizeof(DBFInfo)); psDBF->fp = fp; psDBF->nRecords = 0; psDBF->nFields = 0; psDBF->nRecordLength = 1; psDBF->nHeaderLength = 33; psDBF->panFieldOffset = NULL; psDBF->panFieldSize = NULL; psDBF->panFieldDecimals = NULL; psDBF->pachFieldType = NULL; psDBF->pszHeader = NULL; psDBF->nCurrentRecord = -1; psDBF->bCurrentRecordModified = FALSE; psDBF->pszCurrentRecord = NULL; psDBF->bNoHeader = TRUE; return( psDBF ); } /************************************************************************/ /* DBFAddField() */ /* */ /* Add a field to a newly created .dbf file before any records */ /* are written. */ /************************************************************************/ int SHPAPI_CALL DBFAddField(DBFHandle psDBF, const char * pszFieldName, DBFFieldType eType, int nWidth, int nDecimals ) { char *pszFInfo; int i; /* -------------------------------------------------------------------- */ /* Do some checking to ensure we can add records to this file. */ /* -------------------------------------------------------------------- */ if( psDBF->nRecords > 0 ) return( -1 ); if( !psDBF->bNoHeader ) return( -1 ); if( eType != FTDouble && nDecimals != 0 ) return( -1 ); /* -------------------------------------------------------------------- */ /* SfRealloc all the arrays larger to hold the additional field */ /* information. */ /* -------------------------------------------------------------------- */ psDBF->nFields++; psDBF->panFieldOffset = (int *) SfRealloc( psDBF->panFieldOffset, sizeof(int) * psDBF->nFields ); psDBF->panFieldSize = (int *) SfRealloc( psDBF->panFieldSize, sizeof(int) * psDBF->nFields ); psDBF->panFieldDecimals = (int *) SfRealloc( psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields ); psDBF->pachFieldType = (char *) SfRealloc( psDBF->pachFieldType, sizeof(char) * psDBF->nFields ); /* -------------------------------------------------------------------- */ /* Assign the new field information fields. */ /* -------------------------------------------------------------------- */ psDBF->panFieldOffset[psDBF->nFields-1] = psDBF->nRecordLength; psDBF->nRecordLength += nWidth; psDBF->panFieldSize[psDBF->nFields-1] = nWidth; psDBF->panFieldDecimals[psDBF->nFields-1] = nDecimals; if( eType == FTString ) psDBF->pachFieldType[psDBF->nFields-1] = 'C'; else psDBF->pachFieldType[psDBF->nFields-1] = 'N'; /* -------------------------------------------------------------------- */ /* Extend the required header information. */ /* -------------------------------------------------------------------- */ psDBF->nHeaderLength += 32; psDBF->bUpdated = FALSE; psDBF->pszHeader = (char *) SfRealloc(psDBF->pszHeader,psDBF->nFields*32); pszFInfo = psDBF->pszHeader + 32 * (psDBF->nFields-1); for( i = 0; i < 32; i++ ) pszFInfo[i] = '\0'; if( (int) strlen(pszFieldName) < 10 ) strncpy( pszFInfo, pszFieldName, strlen(pszFieldName)); else strncpy( pszFInfo, pszFieldName, 10); pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields-1]; if( eType == FTString ) { pszFInfo[16] = nWidth % 256; pszFInfo[17] = nWidth / 256; } else { pszFInfo[16] = nWidth; pszFInfo[17] = nDecimals; } /* -------------------------------------------------------------------- */ /* Make the current record buffer appropriately larger. */ /* -------------------------------------------------------------------- */ psDBF->pszCurrentRecord = (char *) SfRealloc(psDBF->pszCurrentRecord, psDBF->nRecordLength); return( psDBF->nFields-1 ); } /************************************************************************/ /* DBFReadAttribute() */ /* */ /* Read one of the attribute fields of a record. */ /************************************************************************/ static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField, char chReqType ) { int nRecordOffset; unsigned char *pabyRec; void *pReturnField = NULL; static double dDoubleField; /* -------------------------------------------------------------------- */ /* Verify selection. */ /* -------------------------------------------------------------------- */ if( hEntity < 0 || hEntity >= psDBF->nRecords ) return( NULL ); if( iField < 0 || iField >= psDBF->nFields ) return( NULL ); /* -------------------------------------------------------------------- */ /* Have we read the record? */ /* -------------------------------------------------------------------- */ if( psDBF->nCurrentRecord != hEntity ) { DBFFlushRecord( psDBF ); nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength; if( fseek( psDBF->fp, nRecordOffset, 0 ) != 0 ) { fprintf( stderr, "fseek(%d) failed on DBF file.\n", nRecordOffset ); return NULL; } if( fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp ) != 1 ) { fprintf( stderr, "fread(%d) failed on DBF file.\n", psDBF->nRecordLength ); return NULL; } psDBF->nCurrentRecord = hEntity; } pabyRec = (unsigned char *) psDBF->pszCurrentRecord; /* -------------------------------------------------------------------- */ /* Ensure our field buffer is large enough to hold this buffer. */ /* -------------------------------------------------------------------- */ if( psDBF->panFieldSize[iField]+1 > nStringFieldLen ) { nStringFieldLen = psDBF->panFieldSize[iField]*2 + 10; pszStringField = (char *) SfRealloc(pszStringField,nStringFieldLen); } /* -------------------------------------------------------------------- */ /* Extract the requested field. */ /* -------------------------------------------------------------------- */ strncpy( pszStringField, ((const char *) pabyRec) + psDBF->panFieldOffset[iField], psDBF->panFieldSize[iField] ); pszStringField[psDBF->panFieldSize[iField]] = '\0'; pReturnField = pszStringField; /* -------------------------------------------------------------------- */ /* Decode the field. */ /* -------------------------------------------------------------------- */ if( chReqType == 'N' ) { dDoubleField = atof(pszStringField); pReturnField = &dDoubleField; } /* -------------------------------------------------------------------- */ /* Should we trim white space off the string attribute value? */ /* -------------------------------------------------------------------- */ #ifdef TRIM_DBF_WHITESPACE else { char *pchSrc, *pchDst; pchDst = pchSrc = pszStringField; while( *pchSrc == ' ' ) pchSrc++; while( *pchSrc != '\0' ) *(pchDst++) = *(pchSrc++); *pchDst = '\0'; while( pchDst != pszStringField && *(--pchDst) == ' ' ) *pchDst = '\0'; } #endif return( pReturnField ); } /************************************************************************/ /* DBFReadIntAttribute() */ /* */ /* Read an integer attribute. */ /************************************************************************/ int SHPAPI_CALL DBFReadIntegerAttribute( DBFHandle psDBF, int iRecord, int iField ) { double *pdValue; pdValue = (double *) DBFReadAttribute( psDBF, iRecord, iField, 'N' ); if( pdValue == NULL ) return 0; else return( (int) *pdValue ); } /************************************************************************/ /* DBFReadDoubleAttribute() */ /* */ /* Read a double attribute. */ /************************************************************************/ double SHPAPI_CALL DBFReadDoubleAttribute( DBFHandle psDBF, int iRecord, int iField ) { double *pdValue; pdValue = (double *) DBFReadAttribute( psDBF, iRecord, iField, 'N' ); if( pdValue == NULL ) return 0.0; else return( *pdValue ); } /************************************************************************/ /* DBFReadStringAttribute() */ /* */ /* Read a string attribute. */ /************************************************************************/ const char SHPAPI_CALL1(*) DBFReadStringAttribute( DBFHandle psDBF, int iRecord, int iField ) { return( (const char *) DBFReadAttribute( psDBF, iRecord, iField, 'C' ) ); } /************************************************************************/ /* DBFIsAttributeNULL() */ /* */ /* Return TRUE if value for field is NULL. */ /* */ /* Contributed by Jim Matthews. */ /************************************************************************/ int SHPAPI_CALL DBFIsAttributeNULL( DBFHandle psDBF, int iRecord, int iField ) { const char *pszValue; pszValue = DBFReadStringAttribute( psDBF, iRecord, iField ); switch(psDBF->pachFieldType[iField]) { case 'N': case 'F': /* NULL numeric fields have value "****************" */ return pszValue[0] == '*'; case 'D': /* NULL date fields have value "00000000" */ return strncmp(pszValue,"00000000",8) == 0; case 'L': /* NULL boolean fields have value "?" */ return pszValue[0] == '?'; default: /* empty string fields are considered NULL */ return strlen(pszValue) == 0; } return FALSE; } /************************************************************************/ /* DBFGetFieldCount() */ /* */ /* Return the number of fields in this table. */ /************************************************************************/ int SHPAPI_CALL DBFGetFieldCount( DBFHandle psDBF ) { return( psDBF->nFields ); } /************************************************************************/ /* DBFGetRecordCount() */ /* */ /* Return the number of records in this table. */ /************************************************************************/ int SHPAPI_CALL DBFGetRecordCount( DBFHandle psDBF ) { return( psDBF->nRecords ); } /************************************************************************/ /* DBFGetFieldInfo() */ /* */ /* Return any requested information about the field. */ /************************************************************************/ DBFFieldType SHPAPI_CALL DBFGetFieldInfo( DBFHandle psDBF, int iField, char * pszFieldName, int * pnWidth, int * pnDecimals ) { if( iField < 0 || iField >= psDBF->nFields ) return( FTInvalid ); if( pnWidth != NULL ) *pnWidth = psDBF->panFieldSize[iField]; if( pnDecimals != NULL ) *pnDecimals = psDBF->panFieldDecimals[iField]; if( pszFieldName != NULL ) { int i; strncpy( pszFieldName, (char *) psDBF->pszHeader+iField*32, 11 ); pszFieldName[11] = '\0'; for( i = 10; i > 0 && pszFieldName[i] == ' '; i-- ) pszFieldName[i] = '\0'; } if( psDBF->pachFieldType[iField] == 'N' || psDBF->pachFieldType[iField] == 'F' || psDBF->pachFieldType[iField] == 'D' ) { if( psDBF->panFieldDecimals[iField] > 0 ) return( FTDouble ); else return( FTInteger ); } else { return( FTString ); } } /************************************************************************/ /* DBFWriteAttribute() */ /* */ /* Write an attribute record to the file. */ /************************************************************************/ static int DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField, void * pValue ) { int nRecordOffset, i, j; unsigned char *pabyRec; char szSField[400], szFormat[20]; /* -------------------------------------------------------------------- */ /* Is this a valid record? */ /* -------------------------------------------------------------------- */ if( hEntity < 0 || hEntity > psDBF->nRecords ) return( FALSE ); if( psDBF->bNoHeader ) DBFWriteHeader(psDBF); /* -------------------------------------------------------------------- */ /* Is this a brand new record? */ /* -------------------------------------------------------------------- */ if( hEntity == psDBF->nRecords ) { DBFFlushRecord( psDBF ); psDBF->nRecords++; for( i = 0; i < psDBF->nRecordLength; i++ ) psDBF->pszCurrentRecord[i] = ' '; psDBF->nCurrentRecord = hEntity; } /* -------------------------------------------------------------------- */ /* Is this an existing record, but different than the last one */ /* we accessed? */ /* -------------------------------------------------------------------- */ if( psDBF->nCurrentRecord != hEntity ) { DBFFlushRecord( psDBF ); nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength; fseek( psDBF->fp, nRecordOffset, 0 ); fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp ); psDBF->nCurrentRecord = hEntity; } pabyRec = (unsigned char *) psDBF->pszCurrentRecord; psDBF->bCurrentRecordModified = TRUE; psDBF->bUpdated = TRUE; /* -------------------------------------------------------------------- */ /* Translate NULL value to valid DBF file representation. */ /* */ /* Contributed by Jim Matthews. */ /* -------------------------------------------------------------------- */ if( pValue == NULL ) { switch(psDBF->pachFieldType[iField]) { case 'N': case 'F': /* NULL numeric fields have value "****************" */ memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '*', psDBF->panFieldSize[iField] ); break; case 'D': /* NULL date fields have value "00000000" */ memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '0', psDBF->panFieldSize[iField] ); break; case 'L': /* NULL boolean fields have value "?" */ memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '?', psDBF->panFieldSize[iField] ); break; default: /* empty string fields are considered NULL */ memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]), '\0', psDBF->panFieldSize[iField] ); break; } return TRUE; } /* -------------------------------------------------------------------- */ /* Assign all the record fields. */ /* -------------------------------------------------------------------- */ switch( psDBF->pachFieldType[iField] ) { case 'D': case 'N': case 'F': if( psDBF->panFieldDecimals[iField] == 0 ) { int nWidth = psDBF->panFieldSize[iField]; if( sizeof(szSField)-2 < nWidth ) nWidth = sizeof(szSField)-2; sprintf( szFormat, "%%%dd", nWidth ); sprintf(szSField, szFormat, (int) *((double *) pValue) ); if( (int)strlen(szSField) > psDBF->panFieldSize[iField] ) szSField[psDBF->panFieldSize[iField]] = '\0'; strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]), szSField, strlen(szSField) ); } else { int nWidth = psDBF->panFieldSize[iField]; if( sizeof(szSField)-2 < nWidth ) nWidth = sizeof(szSField)-2; sprintf( szFormat, "%%%d.%df", nWidth, psDBF->panFieldDecimals[iField] ); sprintf(szSField, szFormat, *((double *) pValue) ); if( (int) strlen(szSField) > psDBF->panFieldSize[iField] ) szSField[psDBF->panFieldSize[iField]] = '\0'; strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]), szSField, strlen(szSField) ); } break; default: if( (int) strlen((char *) pValue) > psDBF->panFieldSize[iField] ) j = psDBF->panFieldSize[iField]; else { memset( pabyRec+psDBF->panFieldOffset[iField], ' ', psDBF->panFieldSize[iField] ); j = strlen((char *) pValue); } strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]), (char *) pValue, j ); break; } return( TRUE ); } /************************************************************************/ /* DBFWriteDoubleAttribute() */ /* */ /* Write a double attribute. */ /************************************************************************/ int SHPAPI_CALL DBFWriteDoubleAttribute( DBFHandle psDBF, int iRecord, int iField, double dValue ) { return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) &dValue ) ); } /************************************************************************/ /* DBFWriteIntegerAttribute() */ /* */ /* Write a integer attribute. */ /************************************************************************/ int SHPAPI_CALL DBFWriteIntegerAttribute( DBFHandle psDBF, int iRecord, int iField, int nValue ) { double dValue = nValue; return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) &dValue ) ); } /************************************************************************/ /* DBFWriteStringAttribute() */ /* */ /* Write a string attribute. */ /************************************************************************/ int SHPAPI_CALL DBFWriteStringAttribute( DBFHandle psDBF, int iRecord, int iField, const char * pszValue ) { return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) pszValue ) ); } /************************************************************************/ /* DBFWriteNULLAttribute() */ /* */ /* Write a string attribute. */ /************************************************************************/ int SHPAPI_CALL DBFWriteNULLAttribute( DBFHandle psDBF, int iRecord, int iField ) { return( DBFWriteAttribute( psDBF, iRecord, iField, NULL ) ); } /************************************************************************/ /* DBFWriteTuple() */ /* */ /* Write an attribute record to the file. */ /************************************************************************/ int SHPAPI_CALL DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple ) { int nRecordOffset, i; unsigned char *pabyRec; /* -------------------------------------------------------------------- */ /* Is this a valid record? */ /* -------------------------------------------------------------------- */ if( hEntity < 0 || hEntity > psDBF->nRecords ) return( FALSE ); if( psDBF->bNoHeader ) DBFWriteHeader(psDBF); /* -------------------------------------------------------------------- */ /* Is this a brand new record? */ /* -------------------------------------------------------------------- */ if( hEntity == psDBF->nRecords ) { DBFFlushRecord( psDBF ); psDBF->nRecords++; for( i = 0; i < psDBF->nRecordLength; i++ ) psDBF->pszCurrentRecord[i] = ' '; psDBF->nCurrentRecord = hEntity; } /* -------------------------------------------------------------------- */ /* Is this an existing record, but different than the last one */ /* we accessed? */ /* -------------------------------------------------------------------- */ if( psDBF->nCurrentRecord != hEntity ) { DBFFlushRecord( psDBF ); nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength; fseek( psDBF->fp, nRecordOffset, 0 ); fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp ); psDBF->nCurrentRecord = hEntity; } pabyRec = (unsigned char *) psDBF->pszCurrentRecord; memcpy ( pabyRec, pRawTuple, psDBF->nRecordLength ); psDBF->bCurrentRecordModified = TRUE; psDBF->bUpdated = TRUE; return( TRUE ); } /************************************************************************/ /* DBFReadTuple() */ /* */ /* Read one of the attribute fields of a record. */ /************************************************************************/ const char SHPAPI_CALL1(*) DBFReadTuple(DBFHandle psDBF, int hEntity ) { int nRecordOffset; unsigned char *pabyRec; static char *pReturnTuple = NULL; static int nTupleLen = 0; /* -------------------------------------------------------------------- */ /* Have we read the record? */ /* -------------------------------------------------------------------- */ if( hEntity < 0 || hEntity >= psDBF->nRecords ) return( NULL ); if( psDBF->nCurrentRecord != hEntity ) { DBFFlushRecord( psDBF ); nRecordOffset = psDBF->nRecordLength * hEntity + psDBF->nHeaderLength; fseek( psDBF->fp, nRecordOffset, 0 ); fread( psDBF->pszCurrentRecord, psDBF->nRecordLength, 1, psDBF->fp ); psDBF->nCurrentRecord = hEntity; } pabyRec = (unsigned char *) psDBF->pszCurrentRecord; if ( nTupleLen < psDBF->nRecordLength) { nTupleLen = psDBF->nRecordLength; pReturnTuple = (char *) SfRealloc(pReturnTuple, psDBF->nRecordLength); } memcpy ( pReturnTuple, pabyRec, psDBF->nRecordLength ); return( pReturnTuple ); } /************************************************************************/ /* DBFCloneEmpty() */ /* */ /* Read one of the attribute fields of a record. */ /************************************************************************/ DBFHandle SHPAPI_CALL DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename ) { DBFHandle newDBF; newDBF = DBFCreate ( pszFilename ); if ( newDBF == NULL ) return ( NULL ); newDBF->pszHeader = (void *) malloc ( 32 * psDBF->nFields ); memcpy ( newDBF->pszHeader, psDBF->pszHeader, 32 * psDBF->nFields ); newDBF->nFields = psDBF->nFields; newDBF->nRecordLength = psDBF->nRecordLength; newDBF->nHeaderLength = psDBF->nHeaderLength; newDBF->panFieldOffset = (void *) malloc ( sizeof(int) * psDBF->nFields ); memcpy ( newDBF->panFieldOffset, psDBF->panFieldOffset, sizeof(int) * psDBF->nFields ); newDBF->panFieldSize = (void *) malloc ( sizeof(int) * psDBF->nFields ); memcpy ( newDBF->panFieldSize, psDBF->panFieldSize, sizeof(int) * psDBF->nFields ); newDBF->panFieldDecimals = (void *) malloc ( sizeof(int) * psDBF->nFields ); memcpy ( newDBF->panFieldDecimals, psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields ); newDBF->pachFieldType = (void *) malloc ( sizeof(int) * psDBF->nFields ); memcpy ( newDBF->pachFieldType, psDBF->pachFieldType, sizeof(int) * psDBF->nFields ); newDBF->bNoHeader = TRUE; newDBF->bUpdated = TRUE; DBFWriteHeader ( newDBF ); DBFClose ( newDBF ); newDBF = DBFOpen ( pszFilename, "rb+" ); return ( newDBF ); } /************************************************************************/ /* DBFGetNativeFieldType() */ /* */ /* Return the DBase field type for the specified field. */ /* */ /* Value can be one of: 'C' (String), 'D' (Date), 'F' (Float), */ /* 'N' (Numeric, with or without decimal), */ /* 'L' (Logical), */ /* 'M' (Memo: 10 digits .DBT block ptr) */ /************************************************************************/ char SHPAPI_CALL DBFGetNativeFieldType( DBFHandle psDBF, int iField ) { if( iField >=0 && iField < psDBF->nFields ) return psDBF->pachFieldType[iField]; return ' '; } /************************************************************************/ /* str_to_upper() */ /************************************************************************/ static void str_to_upper (char *string) { int len; short i = -1; len = strlen (string); while (++i < len) if (isalpha(string[i]) && islower(string[i])) string[i] = toupper ((int)string[i]); } /************************************************************************/ /* DBFGetFieldIndex() */ /* */ /* Get the index number for a field in a .dbf file. */ /* */ /* Contributed by Jim Matthews. */ /************************************************************************/ int SHPAPI_CALL DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName) { char name[12], name1[12], name2[12]; int i; strncpy(name1, pszFieldName,11); str_to_upper(name1); for( i = 0; i < DBFGetFieldCount(psDBF); i++ ) { DBFGetFieldInfo( psDBF, i, name, NULL, NULL ); strncpy(name2,name,11); str_to_upper(name2); if(!strncmp(name1,name2,10)) return(i); } return(-1); } ./geocoder/shpopen.c0100644000076400007640000017104407401744250014125 0ustar gmadergmader/****************************************************************************** * $Id: shpopen.c,v 1.33 2001/07/03 12:18:15 warmerda Exp $ * * Project: Shapelib * Purpose: Implementation of core Shapefile read/write functions. * Author: Frank Warmerdam, warmerdam@pobox.com * ****************************************************************************** * Copyright (c) 1999, 2001, Frank Warmerdam * * This software is available under the following "MIT Style" license, * or at the option of the licensee under the LGPL (see LICENSE.LGPL). This * option is discussed in more detail in shapelib.html. * * -- * * 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. ****************************************************************************** * * $Log: shpopen.c,v $ * Revision 1.33 2001/07/03 12:18:15 warmerda * Improved cleanup if SHX not found, provied by Riccardo Cohen. * * Revision 1.32 2001/06/22 01:58:07 warmerda * be more careful about establishing initial bounds in face of NULL shapes * * Revision 1.31 2001/05/31 19:35:29 warmerda * added support for writing null shapes * * Revision 1.30 2001/05/28 12:46:29 warmerda * Add some checking on reasonableness of record count when opening. * * Revision 1.29 2001/05/23 13:36:52 warmerda * added use of SHPAPI_CALL * * Revision 1.28 2001/02/06 22:25:06 warmerda * fixed memory leaks when SHPOpen() fails * * Revision 1.27 2000/07/18 15:21:33 warmerda * added better enforcement of -1 for append in SHPWriteObject * * Revision 1.26 2000/02/16 16:03:51 warmerda * added null shape support * * Revision 1.25 1999/12/15 13:47:07 warmerda * Fixed record size settings in .shp file (was 4 words too long) * Added stdlib.h. * * Revision 1.24 1999/11/05 14:12:04 warmerda * updated license terms * * Revision 1.23 1999/07/27 00:53:46 warmerda * added support for rewriting shapes * * Revision 1.22 1999/06/11 19:19:11 warmerda * Cleanup pabyRec static buffer on SHPClose(). * * Revision 1.21 1999/06/02 14:57:56 kshih * Remove unused variables * * Revision 1.20 1999/04/19 21:04:17 warmerda * Fixed syntax error. * * Revision 1.19 1999/04/19 21:01:57 warmerda * Force access string to binary in SHPOpen(). * * Revision 1.18 1999/04/01 18:48:07 warmerda * Try upper case extensions if lower case doesn't work. * * Revision 1.17 1998/12/31 15:29:39 warmerda * Disable writing measure values to multipatch objects if * DISABLE_MULTIPATCH_MEASURE is defined. * * Revision 1.16 1998/12/16 05:14:33 warmerda * Added support to write MULTIPATCH. Fixed reading Z coordinate of * MULTIPATCH. Fixed record size written for all feature types. * * Revision 1.15 1998/12/03 16:35:29 warmerda * r+b is proper binary access string, not rb+. * * Revision 1.14 1998/12/03 15:47:56 warmerda * Fixed setting of nVertices in SHPCreateObject(). * * Revision 1.13 1998/12/03 15:33:54 warmerda * Made SHPCalculateExtents() separately callable. * * Revision 1.12 1998/11/11 20:01:50 warmerda * Fixed bug writing ArcM/Z, and PolygonM/Z for big endian machines. * * Revision 1.11 1998/11/09 20:56:44 warmerda * Fixed up handling of file wide bounds. * * Revision 1.10 1998/11/09 20:18:51 warmerda * Converted to support 3D shapefiles, and use of SHPObject. * * Revision 1.9 1998/02/24 15:09:05 warmerda * Fixed memory leak. * * Revision 1.8 1997/12/04 15:40:29 warmerda * Fixed byte swapping of record number, and record length fields in the * .shp file. * * Revision 1.7 1995/10/21 03:15:58 warmerda * Added support for binary file access, the magic cookie 9997 * and tried to improve the int32 selection logic for 16bit systems. * * Revision 1.6 1995/09/04 04:19:41 warmerda * Added fix for file bounds. * * Revision 1.5 1995/08/25 15:16:44 warmerda * Fixed a couple of problems with big endian systems ... one with bounds * and the other with multipart polygons. * * Revision 1.4 1995/08/24 18:10:17 warmerda * Switch to use SfRealloc() to avoid problems with pre-ANSI realloc() * functions (such as on the Sun). * * Revision 1.3 1995/08/23 02:23:15 warmerda * Added support for reading bounds, and fixed up problems in setting the * file wide bounds. * * Revision 1.2 1995/08/04 03:16:57 warmerda * Added header. * */ static char rcsid[] = "$Id: shpopen.c,v 1.33 2001/07/03 12:18:15 warmerda Exp $"; #include "shapefil.h" #include #include #include #include #include typedef unsigned char uchar; #if UINT_MAX == 65535 typedef long int32; #else typedef int int32; #endif #ifndef FALSE # define FALSE 0 # define TRUE 1 #endif #define ByteCopy( a, b, c ) memcpy( b, a, c ) #ifndef MAX # define MIN(a,b) ((ab) ? a : b) #endif static int bBigEndian; static uchar *pabyRec = NULL; static int nBufSize = 0; /************************************************************************/ /* SwapWord() */ /* */ /* Swap a 2, 4 or 8 byte word. */ /************************************************************************/ static void SwapWord( int length, void * wordP ) { int i; uchar temp; for( i=0; i < length/2; i++ ) { temp = ((uchar *) wordP)[i]; ((uchar *)wordP)[i] = ((uchar *) wordP)[length-i-1]; ((uchar *) wordP)[length-i-1] = temp; } } /************************************************************************/ /* SfRealloc() */ /* */ /* A realloc cover function that will access a NULL pointer as */ /* a valid input. */ /************************************************************************/ static void * SfRealloc( void * pMem, int nNewSize ) { if( pMem == NULL ) return( (void *) malloc(nNewSize) ); else return( (void *) realloc(pMem,nNewSize) ); } /************************************************************************/ /* SHPWriteHeader() */ /* */ /* Write out a header for the .shp and .shx files as well as the */ /* contents of the index (.shx) file. */ /************************************************************************/ static void SHPWriteHeader( SHPHandle psSHP ) { uchar abyHeader[100]; int i; int32 i32; double dValue; int32 *panSHX; /* -------------------------------------------------------------------- */ /* Prepare header block for .shp file. */ /* -------------------------------------------------------------------- */ for( i = 0; i < 100; i++ ) abyHeader[i] = 0; abyHeader[2] = 0x27; /* magic cookie */ abyHeader[3] = 0x0a; i32 = psSHP->nFileSize/2; /* file size */ ByteCopy( &i32, abyHeader+24, 4 ); if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); i32 = 1000; /* version */ ByteCopy( &i32, abyHeader+28, 4 ); if( bBigEndian ) SwapWord( 4, abyHeader+28 ); i32 = psSHP->nShapeType; /* shape type */ ByteCopy( &i32, abyHeader+32, 4 ); if( bBigEndian ) SwapWord( 4, abyHeader+32 ); dValue = psSHP->adBoundsMin[0]; /* set bounds */ ByteCopy( &dValue, abyHeader+36, 8 ); if( bBigEndian ) SwapWord( 8, abyHeader+36 ); dValue = psSHP->adBoundsMin[1]; ByteCopy( &dValue, abyHeader+44, 8 ); if( bBigEndian ) SwapWord( 8, abyHeader+44 ); dValue = psSHP->adBoundsMax[0]; ByteCopy( &dValue, abyHeader+52, 8 ); if( bBigEndian ) SwapWord( 8, abyHeader+52 ); dValue = psSHP->adBoundsMax[1]; ByteCopy( &dValue, abyHeader+60, 8 ); if( bBigEndian ) SwapWord( 8, abyHeader+60 ); dValue = psSHP->adBoundsMin[2]; /* z */ ByteCopy( &dValue, abyHeader+68, 8 ); if( bBigEndian ) SwapWord( 8, abyHeader+68 ); dValue = psSHP->adBoundsMax[2]; ByteCopy( &dValue, abyHeader+76, 8 ); if( bBigEndian ) SwapWord( 8, abyHeader+76 ); dValue = psSHP->adBoundsMin[3]; /* m */ ByteCopy( &dValue, abyHeader+84, 8 ); if( bBigEndian ) SwapWord( 8, abyHeader+84 ); dValue = psSHP->adBoundsMax[3]; ByteCopy( &dValue, abyHeader+92, 8 ); if( bBigEndian ) SwapWord( 8, abyHeader+92 ); /* -------------------------------------------------------------------- */ /* Write .shp file header. */ /* -------------------------------------------------------------------- */ fseek( psSHP->fpSHP, 0, 0 ); fwrite( abyHeader, 100, 1, psSHP->fpSHP ); /* -------------------------------------------------------------------- */ /* Prepare, and write .shx file header. */ /* -------------------------------------------------------------------- */ i32 = (psSHP->nRecords * 2 * sizeof(int32) + 100)/2; /* file size */ ByteCopy( &i32, abyHeader+24, 4 ); if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); fseek( psSHP->fpSHX, 0, 0 ); fwrite( abyHeader, 100, 1, psSHP->fpSHX ); /* -------------------------------------------------------------------- */ /* Write out the .shx contents. */ /* -------------------------------------------------------------------- */ panSHX = (int32 *) malloc(sizeof(int32) * 2 * psSHP->nRecords); for( i = 0; i < psSHP->nRecords; i++ ) { panSHX[i*2 ] = psSHP->panRecOffset[i]/2; panSHX[i*2+1] = psSHP->panRecSize[i]/2; if( !bBigEndian ) SwapWord( 4, panSHX+i*2 ); if( !bBigEndian ) SwapWord( 4, panSHX+i*2+1 ); } fwrite( panSHX, sizeof(int32) * 2, psSHP->nRecords, psSHP->fpSHX ); free( panSHX ); } /************************************************************************/ /* SHPOpen() */ /* */ /* Open the .shp and .shx files based on the basename of the */ /* files or either file name. */ /************************************************************************/ SHPHandle SHPAPI_CALL SHPOpen( const char * pszLayer, const char * pszAccess ) { char *pszFullname, *pszBasename; SHPHandle psSHP; uchar *pabyBuf; int i; double dValue; /* -------------------------------------------------------------------- */ /* Ensure the access string is one of the legal ones. We */ /* ensure the result string indicates binary to avoid common */ /* problems on Windows. */ /* -------------------------------------------------------------------- */ if( strcmp(pszAccess,"rb+") == 0 || strcmp(pszAccess,"r+b") == 0 || strcmp(pszAccess,"r+") == 0 ) pszAccess = "r+b"; else pszAccess = "rb"; /* -------------------------------------------------------------------- */ /* Establish the byte order on this machine. */ /* -------------------------------------------------------------------- */ i = 1; if( *((uchar *) &i) == 1 ) bBigEndian = FALSE; else bBigEndian = TRUE; /* -------------------------------------------------------------------- */ /* Initialize the info structure. */ /* -------------------------------------------------------------------- */ psSHP = (SHPHandle) malloc(sizeof(SHPInfo)); psSHP->bUpdated = FALSE; /* -------------------------------------------------------------------- */ /* Compute the base (layer) name. If there is any extension */ /* on the passed in filename we will strip it off. */ /* -------------------------------------------------------------------- */ pszBasename = (char *) malloc(strlen(pszLayer)+5); strcpy( pszBasename, pszLayer ); for( i = strlen(pszBasename)-1; i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/' && pszBasename[i] != '\\'; i-- ) {} if( pszBasename[i] == '.' ) pszBasename[i] = '\0'; /* -------------------------------------------------------------------- */ /* Open the .shp and .shx files. Note that files pulled from */ /* a PC to Unix with upper case filenames won't work! */ /* -------------------------------------------------------------------- */ pszFullname = (char *) malloc(strlen(pszBasename) + 5); sprintf( pszFullname, "%s.shp", pszBasename ); psSHP->fpSHP = fopen(pszFullname, pszAccess ); if( psSHP->fpSHP == NULL ) { sprintf( pszFullname, "%s.SHP", pszBasename ); psSHP->fpSHP = fopen(pszFullname, pszAccess ); } if( psSHP->fpSHP == NULL ) { free( psSHP ); free( pszBasename ); free( pszFullname ); return( NULL ); } sprintf( pszFullname, "%s.shx", pszBasename ); psSHP->fpSHX = fopen(pszFullname, pszAccess ); if( psSHP->fpSHX == NULL ) { sprintf( pszFullname, "%s.SHX", pszBasename ); psSHP->fpSHX = fopen(pszFullname, pszAccess ); } if( psSHP->fpSHX == NULL ) { fclose( psSHP->fpSHX ); free( psSHP ); free( pszBasename ); free( pszFullname ); return( NULL ); } free( pszFullname ); free( pszBasename ); /* -------------------------------------------------------------------- */ /* Read the file size from the SHP file. */ /* -------------------------------------------------------------------- */ pabyBuf = (uchar *) malloc(100); fread( pabyBuf, 100, 1, psSHP->fpSHP ); psSHP->nFileSize = (pabyBuf[24] * 256 * 256 * 256 + pabyBuf[25] * 256 * 256 + pabyBuf[26] * 256 + pabyBuf[27]) * 2; /* -------------------------------------------------------------------- */ /* Read SHX file Header info */ /* -------------------------------------------------------------------- */ fread( pabyBuf, 100, 1, psSHP->fpSHX ); if( pabyBuf[0] != 0 || pabyBuf[1] != 0 || pabyBuf[2] != 0x27 || (pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d) ) { fclose( psSHP->fpSHP ); fclose( psSHP->fpSHX ); free( psSHP ); return( NULL ); } psSHP->nRecords = pabyBuf[27] + pabyBuf[26] * 256 + pabyBuf[25] * 256 * 256 + pabyBuf[24] * 256 * 256 * 256; psSHP->nRecords = (psSHP->nRecords*2 - 100) / 8; psSHP->nShapeType = pabyBuf[32]; if( psSHP->nRecords < 0 || psSHP->nRecords > 256000000 ) { /* this header appears to be corrupt. Give up. */ fclose( psSHP->fpSHP ); fclose( psSHP->fpSHX ); free( psSHP ); return( NULL ); } /* -------------------------------------------------------------------- */ /* Read the bounds. */ /* -------------------------------------------------------------------- */ if( bBigEndian ) SwapWord( 8, pabyBuf+36 ); memcpy( &dValue, pabyBuf+36, 8 ); psSHP->adBoundsMin[0] = dValue; if( bBigEndian ) SwapWord( 8, pabyBuf+44 ); memcpy( &dValue, pabyBuf+44, 8 ); psSHP->adBoundsMin[1] = dValue; if( bBigEndian ) SwapWord( 8, pabyBuf+52 ); memcpy( &dValue, pabyBuf+52, 8 ); psSHP->adBoundsMax[0] = dValue; if( bBigEndian ) SwapWord( 8, pabyBuf+60 ); memcpy( &dValue, pabyBuf+60, 8 ); psSHP->adBoundsMax[1] = dValue; if( bBigEndian ) SwapWord( 8, pabyBuf+68 ); /* z */ memcpy( &dValue, pabyBuf+68, 8 ); psSHP->adBoundsMin[2] = dValue; if( bBigEndian ) SwapWord( 8, pabyBuf+76 ); memcpy( &dValue, pabyBuf+76, 8 ); psSHP->adBoundsMax[2] = dValue; if( bBigEndian ) SwapWord( 8, pabyBuf+84 ); /* z */ memcpy( &dValue, pabyBuf+84, 8 ); psSHP->adBoundsMin[3] = dValue; if( bBigEndian ) SwapWord( 8, pabyBuf+92 ); memcpy( &dValue, pabyBuf+92, 8 ); psSHP->adBoundsMax[3] = dValue; free( pabyBuf ); /* -------------------------------------------------------------------- */ /* Read the .shx file to get the offsets to each record in */ /* the .shp file. */ /* -------------------------------------------------------------------- */ psSHP->nMaxRecords = psSHP->nRecords; psSHP->panRecOffset = (int *) malloc(sizeof(int) * MAX(1,psSHP->nMaxRecords) ); psSHP->panRecSize = (int *) malloc(sizeof(int) * MAX(1,psSHP->nMaxRecords) ); pabyBuf = (uchar *) malloc(8 * MAX(1,psSHP->nRecords) ); fread( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX ); for( i = 0; i < psSHP->nRecords; i++ ) { int32 nOffset, nLength; memcpy( &nOffset, pabyBuf + i * 8, 4 ); if( !bBigEndian ) SwapWord( 4, &nOffset ); memcpy( &nLength, pabyBuf + i * 8 + 4, 4 ); if( !bBigEndian ) SwapWord( 4, &nLength ); psSHP->panRecOffset[i] = nOffset*2; psSHP->panRecSize[i] = nLength*2; } free( pabyBuf ); return( psSHP ); } /************************************************************************/ /* SHPClose() */ /* */ /* Close the .shp and .shx files. */ /************************************************************************/ void SHPAPI_CALL SHPClose(SHPHandle psSHP ) { /* -------------------------------------------------------------------- */ /* Update the header if we have modified anything. */ /* -------------------------------------------------------------------- */ if( psSHP->bUpdated ) { SHPWriteHeader( psSHP ); } /* -------------------------------------------------------------------- */ /* Free all resources, and close files. */ /* -------------------------------------------------------------------- */ free( psSHP->panRecOffset ); free( psSHP->panRecSize ); fclose( psSHP->fpSHX ); fclose( psSHP->fpSHP ); free( psSHP ); if( pabyRec != NULL ) { free( pabyRec ); pabyRec = NULL; nBufSize = 0; } } /************************************************************************/ /* SHPGetInfo() */ /* */ /* Fetch general information about the shape file. */ /************************************************************************/ void SHPAPI_CALL SHPGetInfo(SHPHandle psSHP, int * pnEntities, int * pnShapeType, double * padfMinBound, double * padfMaxBound ) { int i; if( pnEntities != NULL ) *pnEntities = psSHP->nRecords; if( pnShapeType != NULL ) *pnShapeType = psSHP->nShapeType; for( i = 0; i < 4; i++ ) { if( padfMinBound != NULL ) padfMinBound[i] = psSHP->adBoundsMin[i]; if( padfMaxBound != NULL ) padfMaxBound[i] = psSHP->adBoundsMax[i]; } } /************************************************************************/ /* SHPCreate() */ /* */ /* Create a new shape file and return a handle to the open */ /* shape file with read/write access. */ /************************************************************************/ SHPHandle SHPAPI_CALL SHPCreate( const char * pszLayer, int nShapeType ) { char *pszBasename, *pszFullname; int i; FILE *fpSHP, *fpSHX; uchar abyHeader[100]; int32 i32; double dValue; /* -------------------------------------------------------------------- */ /* Establish the byte order on this system. */ /* -------------------------------------------------------------------- */ i = 1; if( *((uchar *) &i) == 1 ) bBigEndian = FALSE; else bBigEndian = TRUE; /* -------------------------------------------------------------------- */ /* Compute the base (layer) name. If there is any extension */ /* on the passed in filename we will strip it off. */ /* -------------------------------------------------------------------- */ pszBasename = (char *) malloc(strlen(pszLayer)+5); strcpy( pszBasename, pszLayer ); for( i = strlen(pszBasename)-1; i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/' && pszBasename[i] != '\\'; i-- ) {} if( pszBasename[i] == '.' ) pszBasename[i] = '\0'; /* -------------------------------------------------------------------- */ /* Open the two files so we can write their headers. */ /* -------------------------------------------------------------------- */ pszFullname = (char *) malloc(strlen(pszBasename) + 5); sprintf( pszFullname, "%s.shp", pszBasename ); fpSHP = fopen(pszFullname, "wb" ); if( fpSHP == NULL ) return( NULL ); sprintf( pszFullname, "%s.shx", pszBasename ); fpSHX = fopen(pszFullname, "wb" ); if( fpSHX == NULL ) return( NULL ); free( pszFullname ); free( pszBasename ); /* -------------------------------------------------------------------- */ /* Prepare header block for .shp file. */ /* -------------------------------------------------------------------- */ for( i = 0; i < 100; i++ ) abyHeader[i] = 0; abyHeader[2] = 0x27; /* magic cookie */ abyHeader[3] = 0x0a; i32 = 50; /* file size */ ByteCopy( &i32, abyHeader+24, 4 ); if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); i32 = 1000; /* version */ ByteCopy( &i32, abyHeader+28, 4 ); if( bBigEndian ) SwapWord( 4, abyHeader+28 ); i32 = nShapeType; /* shape type */ ByteCopy( &i32, abyHeader+32, 4 ); if( bBigEndian ) SwapWord( 4, abyHeader+32 ); dValue = 0.0; /* set bounds */ ByteCopy( &dValue, abyHeader+36, 8 ); ByteCopy( &dValue, abyHeader+44, 8 ); ByteCopy( &dValue, abyHeader+52, 8 ); ByteCopy( &dValue, abyHeader+60, 8 ); /* -------------------------------------------------------------------- */ /* Write .shp file header. */ /* -------------------------------------------------------------------- */ fwrite( abyHeader, 100, 1, fpSHP ); /* -------------------------------------------------------------------- */ /* Prepare, and write .shx file header. */ /* -------------------------------------------------------------------- */ i32 = 50; /* file size */ ByteCopy( &i32, abyHeader+24, 4 ); if( !bBigEndian ) SwapWord( 4, abyHeader+24 ); fwrite( abyHeader, 100, 1, fpSHX ); /* -------------------------------------------------------------------- */ /* Close the files, and then open them as regular existing files. */ /* -------------------------------------------------------------------- */ fclose( fpSHP ); fclose( fpSHX ); return( SHPOpen( pszLayer, "r+b" ) ); } /************************************************************************/ /* _SHPSetBounds() */ /* */ /* Compute a bounds rectangle for a shape, and set it into the */ /* indicated location in the record. */ /************************************************************************/ static void _SHPSetBounds( uchar * pabyRec, SHPObject * psShape ) { ByteCopy( &(psShape->dfXMin), pabyRec + 0, 8 ); ByteCopy( &(psShape->dfYMin), pabyRec + 8, 8 ); ByteCopy( &(psShape->dfXMax), pabyRec + 16, 8 ); ByteCopy( &(psShape->dfYMax), pabyRec + 24, 8 ); if( bBigEndian ) { SwapWord( 8, pabyRec + 0 ); SwapWord( 8, pabyRec + 8 ); SwapWord( 8, pabyRec + 16 ); SwapWord( 8, pabyRec + 24 ); } } /************************************************************************/ /* SHPComputeExtents() */ /* */ /* Recompute the extents of a shape. Automatically done by */ /* SHPCreateObject(). */ /************************************************************************/ void SHPAPI_CALL SHPComputeExtents( SHPObject * psObject ) { int i; /* -------------------------------------------------------------------- */ /* Build extents for this object. */ /* -------------------------------------------------------------------- */ if( psObject->nVertices > 0 ) { psObject->dfXMin = psObject->dfXMax = psObject->padfX[0]; psObject->dfYMin = psObject->dfYMax = psObject->padfY[0]; psObject->dfZMin = psObject->dfZMax = psObject->padfZ[0]; psObject->dfMMin = psObject->dfMMax = psObject->padfM[0]; } for( i = 0; i < psObject->nVertices; i++ ) { psObject->dfXMin = MIN(psObject->dfXMin, psObject->padfX[i]); psObject->dfYMin = MIN(psObject->dfYMin, psObject->padfY[i]); psObject->dfZMin = MIN(psObject->dfZMin, psObject->padfZ[i]); psObject->dfMMin = MIN(psObject->dfMMin, psObject->padfM[i]); psObject->dfXMax = MAX(psObject->dfXMax, psObject->padfX[i]); psObject->dfYMax = MAX(psObject->dfYMax, psObject->padfY[i]); psObject->dfZMax = MAX(psObject->dfZMax, psObject->padfZ[i]); psObject->dfMMax = MAX(psObject->dfMMax, psObject->padfM[i]); } } /************************************************************************/ /* SHPCreateObject() */ /* */ /* Create a shape object. It should be freed with */ /* SHPDestroyObject(). */ /************************************************************************/ SHPObject SHPAPI_CALL1(*) SHPCreateObject( int nSHPType, int nShapeId, int nParts, int * panPartStart, int * panPartType, int nVertices, double * padfX, double * padfY, double * padfZ, double * padfM ) { SHPObject *psObject; int i, bHasM, bHasZ; psObject = (SHPObject *) calloc(1,sizeof(SHPObject)); psObject->nSHPType = nSHPType; psObject->nShapeId = nShapeId; /* -------------------------------------------------------------------- */ /* Establish whether this shape type has M, and Z values. */ /* -------------------------------------------------------------------- */ if( nSHPType == SHPT_ARCM || nSHPType == SHPT_POINTM || nSHPType == SHPT_POLYGONM || nSHPType == SHPT_MULTIPOINTM ) { bHasM = TRUE; bHasZ = FALSE; } else if( nSHPType == SHPT_ARCZ || nSHPType == SHPT_POINTZ || nSHPType == SHPT_POLYGONZ || nSHPType == SHPT_MULTIPOINTZ || nSHPType == SHPT_MULTIPATCH ) { bHasM = TRUE; bHasZ = TRUE; } else { bHasM = FALSE; bHasZ = FALSE; } /* -------------------------------------------------------------------- */ /* Capture parts. Note that part type is optional, and */ /* defaults to ring. */ /* -------------------------------------------------------------------- */ if( nSHPType == SHPT_ARC || nSHPType == SHPT_POLYGON || nSHPType == SHPT_ARCM || nSHPType == SHPT_POLYGONM || nSHPType == SHPT_ARCZ || nSHPType == SHPT_POLYGONZ || nSHPType == SHPT_MULTIPATCH ) { psObject->nParts = MAX(1,nParts); psObject->panPartStart = (int *) malloc(sizeof(int) * psObject->nParts); psObject->panPartType = (int *) malloc(sizeof(int) * psObject->nParts); psObject->panPartStart[0] = 0; psObject->panPartType[0] = SHPP_RING; for( i = 0; i < nParts; i++ ) { psObject->panPartStart[i] = panPartStart[i]; if( panPartType != NULL ) psObject->panPartType[i] = panPartType[i]; else psObject->panPartType[i] = SHPP_RING; } } /* -------------------------------------------------------------------- */ /* Capture vertices. Note that Z and M are optional, but X and */ /* Y are not. */ /* -------------------------------------------------------------------- */ if( nVertices > 0 ) { psObject->padfX = (double *) calloc(sizeof(double),nVertices); psObject->padfY = (double *) calloc(sizeof(double),nVertices); psObject->padfZ = (double *) calloc(sizeof(double),nVertices); psObject->padfM = (double *) calloc(sizeof(double),nVertices); assert( padfX != NULL ); assert( padfY != NULL ); for( i = 0; i < nVertices; i++ ) { psObject->padfX[i] = padfX[i]; psObject->padfY[i] = padfY[i]; if( padfZ != NULL && bHasZ ) psObject->padfZ[i] = padfZ[i]; if( padfM != NULL && bHasM ) psObject->padfM[i] = padfM[i]; } } /* -------------------------------------------------------------------- */ /* Compute the extents. */ /* -------------------------------------------------------------------- */ psObject->nVertices = nVertices; SHPComputeExtents( psObject ); return( psObject ); } /************************************************************************/ /* SHPCreateSimpleObject() */ /* */ /* Create a simple (common) shape object. Destroy with */ /* SHPDestroyObject(). */ /************************************************************************/ SHPObject SHPAPI_CALL1(*) SHPCreateSimpleObject( int nSHPType, int nVertices, double * padfX, double * padfY, double * padfZ ) { return( SHPCreateObject( nSHPType, -1, 0, NULL, NULL, nVertices, padfX, padfY, padfZ, NULL ) ); } /************************************************************************/ /* SHPWriteObject() */ /* */ /* Write out the vertices of a new structure. Note that it is */ /* only possible to write vertices at the end of the file. */ /************************************************************************/ int SHPAPI_CALL SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject ) { int nRecordOffset, i, nRecordSize; uchar *pabyRec; int32 i32; psSHP->bUpdated = TRUE; /* -------------------------------------------------------------------- */ /* Ensure that shape object matches the type of the file it is */ /* being written to. */ /* -------------------------------------------------------------------- */ assert( psObject->nSHPType == psSHP->nShapeType || psObject->nSHPType == SHPT_NULL ); /* -------------------------------------------------------------------- */ /* Ensure that -1 is used for appends. Either blow an */ /* assertion, or if they are disabled, set the shapeid to -1 */ /* for appends. */ /* -------------------------------------------------------------------- */ assert( nShapeId == -1 || (nShapeId >= 0 && nShapeId < psSHP->nRecords) ); if( nShapeId != -1 && nShapeId >= psSHP->nRecords ) nShapeId = -1; /* -------------------------------------------------------------------- */ /* Add the new entity to the in memory index. */ /* -------------------------------------------------------------------- */ if( nShapeId == -1 && psSHP->nRecords+1 > psSHP->nMaxRecords ) { psSHP->nMaxRecords =(int) ( psSHP->nMaxRecords * 1.3 + 100); psSHP->panRecOffset = (int *) SfRealloc(psSHP->panRecOffset,sizeof(int) * psSHP->nMaxRecords ); psSHP->panRecSize = (int *) SfRealloc(psSHP->panRecSize,sizeof(int) * psSHP->nMaxRecords ); } /* -------------------------------------------------------------------- */ /* Initialize record. */ /* -------------------------------------------------------------------- */ pabyRec = (uchar *) malloc(psObject->nVertices * 4 * sizeof(double) + psObject->nParts * 8 + 128); /* -------------------------------------------------------------------- */ /* Extract vertices for a Polygon or Arc. */ /* -------------------------------------------------------------------- */ if( psObject->nSHPType == SHPT_POLYGON || psObject->nSHPType == SHPT_POLYGONZ || psObject->nSHPType == SHPT_POLYGONM || psObject->nSHPType == SHPT_ARC || psObject->nSHPType == SHPT_ARCZ || psObject->nSHPType == SHPT_ARCM || psObject->nSHPType == SHPT_MULTIPATCH ) { int32 nPoints, nParts; int i; nPoints = psObject->nVertices; nParts = psObject->nParts; _SHPSetBounds( pabyRec + 12, psObject ); if( bBigEndian ) SwapWord( 4, &nPoints ); if( bBigEndian ) SwapWord( 4, &nParts ); ByteCopy( &nPoints, pabyRec + 40 + 8, 4 ); ByteCopy( &nParts, pabyRec + 36 + 8, 4 ); nRecordSize = 52; /* * Write part start positions. */ ByteCopy( psObject->panPartStart, pabyRec + 44 + 8, 4 * psObject->nParts ); for( i = 0; i < psObject->nParts; i++ ) { if( bBigEndian ) SwapWord( 4, pabyRec + 44 + 8 + 4*i ); nRecordSize += 4; } /* * Write multipatch part types if needed. */ if( psObject->nSHPType == SHPT_MULTIPATCH ) { memcpy( pabyRec + nRecordSize, psObject->panPartType, 4*psObject->nParts ); for( i = 0; i < psObject->nParts; i++ ) { if( bBigEndian ) SwapWord( 4, pabyRec + nRecordSize ); nRecordSize += 4; } } /* * Write the (x,y) vertex values. */ for( i = 0; i < psObject->nVertices; i++ ) { ByteCopy( psObject->padfX + i, pabyRec + nRecordSize, 8 ); ByteCopy( psObject->padfY + i, pabyRec + nRecordSize + 8, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize + 8 ); nRecordSize += 2 * 8; } /* * Write the Z coordinates (if any). */ if( psObject->nSHPType == SHPT_POLYGONZ || psObject->nSHPType == SHPT_ARCZ || psObject->nSHPType == SHPT_MULTIPATCH ) { ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; for( i = 0; i < psObject->nVertices; i++ ) { ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; } } /* * Write the M values, if any. */ if( psObject->nSHPType == SHPT_POLYGONM || psObject->nSHPType == SHPT_ARCM #ifndef DISABLE_MULTIPATCH_MEASURE || psObject->nSHPType == SHPT_MULTIPATCH #endif || psObject->nSHPType == SHPT_POLYGONZ || psObject->nSHPType == SHPT_ARCZ ) { ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; for( i = 0; i < psObject->nVertices; i++ ) { ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; } } } /* -------------------------------------------------------------------- */ /* Extract vertices for a MultiPoint. */ /* -------------------------------------------------------------------- */ else if( psObject->nSHPType == SHPT_MULTIPOINT || psObject->nSHPType == SHPT_MULTIPOINTZ || psObject->nSHPType == SHPT_MULTIPOINTM ) { int32 nPoints; int i; nPoints = psObject->nVertices; _SHPSetBounds( pabyRec + 12, psObject ); if( bBigEndian ) SwapWord( 4, &nPoints ); ByteCopy( &nPoints, pabyRec + 44, 4 ); for( i = 0; i < psObject->nVertices; i++ ) { ByteCopy( psObject->padfX + i, pabyRec + 48 + i*16, 8 ); ByteCopy( psObject->padfY + i, pabyRec + 48 + i*16 + 8, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 ); if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 + 8 ); } nRecordSize = 48 + 16 * psObject->nVertices; if( psObject->nSHPType == SHPT_MULTIPOINTZ ) { ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; for( i = 0; i < psObject->nVertices; i++ ) { ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; } } if( psObject->nSHPType == SHPT_MULTIPOINTZ || psObject->nSHPType == SHPT_MULTIPOINTM ) { ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; for( i = 0; i < psObject->nVertices; i++ ) { ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; } } } /* -------------------------------------------------------------------- */ /* Write point. */ /* -------------------------------------------------------------------- */ else if( psObject->nSHPType == SHPT_POINT || psObject->nSHPType == SHPT_POINTZ || psObject->nSHPType == SHPT_POINTM ) { ByteCopy( psObject->padfX, pabyRec + 12, 8 ); ByteCopy( psObject->padfY, pabyRec + 20, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + 12 ); if( bBigEndian ) SwapWord( 8, pabyRec + 20 ); nRecordSize = 28; if( psObject->nSHPType == SHPT_POINTZ ) { ByteCopy( psObject->padfZ, pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; } if( psObject->nSHPType == SHPT_POINTZ || psObject->nSHPType == SHPT_POINTM ) { ByteCopy( psObject->padfM, pabyRec + nRecordSize, 8 ); if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize ); nRecordSize += 8; } } /* -------------------------------------------------------------------- */ /* Not much to do for null geometries. */ /* -------------------------------------------------------------------- */ else if( psObject->nSHPType == SHPT_NULL ) { nRecordSize = 12; } else { /* unknown type */ assert( FALSE ); } /* -------------------------------------------------------------------- */ /* Establish where we are going to put this record. If we are */ /* rewriting and existing record, and it will fit, then put it */ /* back where the original came from. Otherwise write at the end. */ /* -------------------------------------------------------------------- */ if( nShapeId == -1 || psSHP->panRecSize[nShapeId] < nRecordSize-8 ) { if( nShapeId == -1 ) nShapeId = psSHP->nRecords++; psSHP->panRecOffset[nShapeId] = nRecordOffset = psSHP->nFileSize; psSHP->panRecSize[nShapeId] = nRecordSize-8; psSHP->nFileSize += nRecordSize; } else { nRecordOffset = psSHP->panRecOffset[nShapeId]; } /* -------------------------------------------------------------------- */ /* Set the shape type, record number, and record size. */ /* -------------------------------------------------------------------- */ i32 = nShapeId+1; /* record # */ if( !bBigEndian ) SwapWord( 4, &i32 ); ByteCopy( &i32, pabyRec, 4 ); i32 = (nRecordSize-8)/2; /* record size */ if( !bBigEndian ) SwapWord( 4, &i32 ); ByteCopy( &i32, pabyRec + 4, 4 ); i32 = psObject->nSHPType; /* shape type */ if( bBigEndian ) SwapWord( 4, &i32 ); ByteCopy( &i32, pabyRec + 8, 4 ); /* -------------------------------------------------------------------- */ /* Write out record. */ /* -------------------------------------------------------------------- */ if( fseek( psSHP->fpSHP, nRecordOffset, 0 ) != 0 || fwrite( pabyRec, nRecordSize, 1, psSHP->fpSHP ) < 1 ) { printf( "Error in fseek() or fwrite().\n" ); free( pabyRec ); return -1; } free( pabyRec ); /* -------------------------------------------------------------------- */ /* Expand file wide bounds based on this shape. */ /* -------------------------------------------------------------------- */ if( psSHP->adBoundsMin[0] == 0.0 && psSHP->adBoundsMax[0] == 0.0 && psSHP->adBoundsMin[1] == 0.0 && psSHP->adBoundsMax[1] == 0.0 && psObject->nSHPType != SHPT_NULL ) { psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0]; psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0]; psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ[0]; psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = psObject->padfM[0]; } for( i = 0; i < psObject->nVertices; i++ ) { psSHP->adBoundsMin[0] = MIN(psSHP->adBoundsMin[0],psObject->padfX[i]); psSHP->adBoundsMin[1] = MIN(psSHP->adBoundsMin[1],psObject->padfY[i]); psSHP->adBoundsMin[2] = MIN(psSHP->adBoundsMin[2],psObject->padfZ[i]); psSHP->adBoundsMin[3] = MIN(psSHP->adBoundsMin[3],psObject->padfM[i]); psSHP->adBoundsMax[0] = MAX(psSHP->adBoundsMax[0],psObject->padfX[i]); psSHP->adBoundsMax[1] = MAX(psSHP->adBoundsMax[1],psObject->padfY[i]); psSHP->adBoundsMax[2] = MAX(psSHP->adBoundsMax[2],psObject->padfZ[i]); psSHP->adBoundsMax[3] = MAX(psSHP->adBoundsMax[3],psObject->padfM[i]); } return( nShapeId ); } /************************************************************************/ /* SHPReadObject() */ /* */ /* Read the vertices, parts, and other non-attribute information */ /* for one shape. */ /************************************************************************/ SHPObject SHPAPI_CALL1(*) SHPReadObject( SHPHandle psSHP, int hEntity ) { SHPObject *psShape; /* -------------------------------------------------------------------- */ /* Validate the record/entity number. */ /* -------------------------------------------------------------------- */ if( hEntity < 0 || hEntity >= psSHP->nRecords ) return( NULL ); /* -------------------------------------------------------------------- */ /* Ensure our record buffer is large enough. */ /* -------------------------------------------------------------------- */ if( psSHP->panRecSize[hEntity]+8 > nBufSize ) { nBufSize = psSHP->panRecSize[hEntity]+8; pabyRec = (uchar *) SfRealloc(pabyRec,nBufSize); } /* -------------------------------------------------------------------- */ /* Read the record. */ /* -------------------------------------------------------------------- */ fseek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 ); fread( pabyRec, psSHP->panRecSize[hEntity]+8, 1, psSHP->fpSHP ); /* -------------------------------------------------------------------- */ /* Allocate and minimally initialize the object. */ /* -------------------------------------------------------------------- */ psShape = (SHPObject *) calloc(1,sizeof(SHPObject)); psShape->nShapeId = hEntity; memcpy( &psShape->nSHPType, pabyRec + 8, 4 ); if( bBigEndian ) SwapWord( 4, &(psShape->nSHPType) ); /* ==================================================================== */ /* Extract vertices for a Polygon or Arc. */ /* ==================================================================== */ if( psShape->nSHPType == SHPT_POLYGON || psShape->nSHPType == SHPT_ARC || psShape->nSHPType == SHPT_POLYGONZ || psShape->nSHPType == SHPT_POLYGONM || psShape->nSHPType == SHPT_ARCZ || psShape->nSHPType == SHPT_ARCM || psShape->nSHPType == SHPT_MULTIPATCH ) { int32 nPoints, nParts; int i, nOffset; /* -------------------------------------------------------------------- */ /* Get the X/Y bounds. */ /* -------------------------------------------------------------------- */ memcpy( &(psShape->dfXMin), pabyRec + 8 + 4, 8 ); memcpy( &(psShape->dfYMin), pabyRec + 8 + 12, 8 ); memcpy( &(psShape->dfXMax), pabyRec + 8 + 20, 8 ); memcpy( &(psShape->dfYMax), pabyRec + 8 + 28, 8 ); if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) ); if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) ); if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) ); if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) ); /* -------------------------------------------------------------------- */ /* Extract part/point count, and build vertex and part arrays */ /* to proper size. */ /* -------------------------------------------------------------------- */ memcpy( &nPoints, pabyRec + 40 + 8, 4 ); memcpy( &nParts, pabyRec + 36 + 8, 4 ); if( bBigEndian ) SwapWord( 4, &nPoints ); if( bBigEndian ) SwapWord( 4, &nParts ); psShape->nVertices = nPoints; psShape->padfX = (double *) calloc(nPoints,sizeof(double)); psShape->padfY = (double *) calloc(nPoints,sizeof(double)); psShape->padfZ = (double *) calloc(nPoints,sizeof(double)); psShape->padfM = (double *) calloc(nPoints,sizeof(double)); psShape->nParts = nParts; psShape->panPartStart = (int *) calloc(nParts,sizeof(int)); psShape->panPartType = (int *) calloc(nParts,sizeof(int)); for( i = 0; i < nParts; i++ ) psShape->panPartType[i] = SHPP_RING; /* -------------------------------------------------------------------- */ /* Copy out the part array from the record. */ /* -------------------------------------------------------------------- */ memcpy( psShape->panPartStart, pabyRec + 44 + 8, 4 * nParts ); for( i = 0; i < nParts; i++ ) { if( bBigEndian ) SwapWord( 4, psShape->panPartStart+i ); } nOffset = 44 + 8 + 4*nParts; /* -------------------------------------------------------------------- */ /* If this is a multipatch, we will also have parts types. */ /* -------------------------------------------------------------------- */ if( psShape->nSHPType == SHPT_MULTIPATCH ) { memcpy( psShape->panPartType, pabyRec + nOffset, 4*nParts ); for( i = 0; i < nParts; i++ ) { if( bBigEndian ) SwapWord( 4, psShape->panPartType+i ); } nOffset += 4*nParts; } /* -------------------------------------------------------------------- */ /* Copy out the vertices from the record. */ /* -------------------------------------------------------------------- */ for( i = 0; i < nPoints; i++ ) { memcpy(psShape->padfX + i, pabyRec + nOffset + i * 16, 8 ); memcpy(psShape->padfY + i, pabyRec + nOffset + i * 16 + 8, 8 ); if( bBigEndian ) SwapWord( 8, psShape->padfX + i ); if( bBigEndian ) SwapWord( 8, psShape->padfY + i ); } nOffset += 16*nPoints; /* -------------------------------------------------------------------- */ /* If we have a Z coordinate, collect that now. */ /* -------------------------------------------------------------------- */ if( psShape->nSHPType == SHPT_POLYGONZ || psShape->nSHPType == SHPT_ARCZ || psShape->nSHPType == SHPT_MULTIPATCH ) { memcpy( &(psShape->dfZMin), pabyRec + nOffset, 8 ); memcpy( &(psShape->dfZMax), pabyRec + nOffset + 8, 8 ); if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) ); if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) ); for( i = 0; i < nPoints; i++ ) { memcpy( psShape->padfZ + i, pabyRec + nOffset + 16 + i*8, 8 ); if( bBigEndian ) SwapWord( 8, psShape->padfZ + i ); } nOffset += 16 + 8*nPoints; } /* -------------------------------------------------------------------- */ /* If we have a M measure value, then read it now. We assume */ /* that the measure can be present for any shape if the size is */ /* big enough, but really it will only occur for the Z shapes */ /* (options), and the M shapes. */ /* -------------------------------------------------------------------- */ if( psSHP->panRecSize[hEntity]+8 >= nOffset + 16 + 8*nPoints ) { memcpy( &(psShape->dfMMin), pabyRec + nOffset, 8 ); memcpy( &(psShape->dfMMax), pabyRec + nOffset + 8, 8 ); if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) ); if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) ); for( i = 0; i < nPoints; i++ ) { memcpy( psShape->padfM + i, pabyRec + nOffset + 16 + i*8, 8 ); if( bBigEndian ) SwapWord( 8, psShape->padfM + i ); } } } /* ==================================================================== */ /* Extract vertices for a MultiPoint. */ /* ==================================================================== */ else if( psShape->nSHPType == SHPT_MULTIPOINT || psShape->nSHPType == SHPT_MULTIPOINTM || psShape->nSHPType == SHPT_MULTIPOINTZ ) { int32 nPoints; int i, nOffset; memcpy( &nPoints, pabyRec + 44, 4 ); if( bBigEndian ) SwapWord( 4, &nPoints ); psShape->nVertices = nPoints; psShape->padfX = (double *) calloc(nPoints,sizeof(double)); psShape->padfY = (double *) calloc(nPoints,sizeof(double)); psShape->padfZ = (double *) calloc(nPoints,sizeof(double)); psShape->padfM = (double *) calloc(nPoints,sizeof(double)); for( i = 0; i < nPoints; i++ ) { memcpy(psShape->padfX+i, pabyRec + 48 + 16 * i, 8 ); memcpy(psShape->padfY+i, pabyRec + 48 + 16 * i + 8, 8 ); if( bBigEndian ) SwapWord( 8, psShape->padfX + i ); if( bBigEndian ) SwapWord( 8, psShape->padfY + i ); } nOffset = 48 + 16*nPoints; /* -------------------------------------------------------------------- */ /* Get the X/Y bounds. */ /* -------------------------------------------------------------------- */ memcpy( &(psShape->dfXMin), pabyRec + 8 + 4, 8 ); memcpy( &(psShape->dfYMin), pabyRec + 8 + 12, 8 ); memcpy( &(psShape->dfXMax), pabyRec + 8 + 20, 8 ); memcpy( &(psShape->dfYMax), pabyRec + 8 + 28, 8 ); if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) ); if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) ); if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) ); if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) ); /* -------------------------------------------------------------------- */ /* If we have a Z coordinate, collect that now. */ /* -------------------------------------------------------------------- */ if( psShape->nSHPType == SHPT_MULTIPOINTZ ) { memcpy( &(psShape->dfZMin), pabyRec + nOffset, 8 ); memcpy( &(psShape->dfZMax), pabyRec + nOffset + 8, 8 ); if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) ); if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) ); for( i = 0; i < nPoints; i++ ) { memcpy( psShape->padfZ + i, pabyRec + nOffset + 16 + i*8, 8 ); if( bBigEndian ) SwapWord( 8, psShape->padfZ + i ); } nOffset += 16 + 8*nPoints; } /* -------------------------------------------------------------------- */ /* If we have a M measure value, then read it now. We assume */ /* that the measure can be present for any shape if the size is */ /* big enough, but really it will only occur for the Z shapes */ /* (options), and the M shapes. */ /* -------------------------------------------------------------------- */ if( psSHP->panRecSize[hEntity]+8 >= nOffset + 16 + 8*nPoints ) { memcpy( &(psShape->dfMMin), pabyRec + nOffset, 8 ); memcpy( &(psShape->dfMMax), pabyRec + nOffset + 8, 8 ); if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) ); if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) ); for( i = 0; i < nPoints; i++ ) { memcpy( psShape->padfM + i, pabyRec + nOffset + 16 + i*8, 8 ); if( bBigEndian ) SwapWord( 8, psShape->padfM + i ); } } } /* ==================================================================== */ /* Extract vertices for a point. */ /* ==================================================================== */ else if( psShape->nSHPType == SHPT_POINT || psShape->nSHPType == SHPT_POINTM || psShape->nSHPType == SHPT_POINTZ ) { int nOffset; psShape->nVertices = 1; psShape->padfX = (double *) calloc(1,sizeof(double)); psShape->padfY = (double *) calloc(1,sizeof(double)); psShape->padfZ = (double *) calloc(1,sizeof(double)); psShape->padfM = (double *) calloc(1,sizeof(double)); memcpy( psShape->padfX, pabyRec + 12, 8 ); memcpy( psShape->padfY, pabyRec + 20, 8 ); if( bBigEndian ) SwapWord( 8, psShape->padfX ); if( bBigEndian ) SwapWord( 8, psShape->padfY ); nOffset = 20 + 8; /* -------------------------------------------------------------------- */ /* If we have a Z coordinate, collect that now. */ /* -------------------------------------------------------------------- */ if( psShape->nSHPType == SHPT_POINTZ ) { memcpy( psShape->padfZ, pabyRec + nOffset, 8 ); if( bBigEndian ) SwapWord( 8, psShape->padfZ ); nOffset += 8; } /* -------------------------------------------------------------------- */ /* If we have a M measure value, then read it now. We assume */ /* that the measure can be present for any shape if the size is */ /* big enough, but really it will only occur for the Z shapes */ /* (options), and the M shapes. */ /* -------------------------------------------------------------------- */ if( psSHP->panRecSize[hEntity]+8 >= nOffset + 8 ) { memcpy( psShape->padfM, pabyRec + nOffset, 8 ); if( bBigEndian ) SwapWord( 8, psShape->padfM ); } /* -------------------------------------------------------------------- */ /* Since no extents are supplied in the record, we will apply */ /* them from the single vertex. */ /* -------------------------------------------------------------------- */ psShape->dfXMin = psShape->dfXMax = psShape->padfX[0]; psShape->dfYMin = psShape->dfYMax = psShape->padfY[0]; psShape->dfZMin = psShape->dfZMax = psShape->padfZ[0]; psShape->dfMMin = psShape->dfMMax = psShape->padfM[0]; } return( psShape ); } /************************************************************************/ /* SHPTypeName() */ /************************************************************************/ const char SHPAPI_CALL1(*) SHPTypeName( int nSHPType ) { switch( nSHPType ) { case SHPT_NULL: return "NullShape"; case SHPT_POINT: return "Point"; case SHPT_ARC: return "Arc"; case SHPT_POLYGON: return "Polygon"; case SHPT_MULTIPOINT: return "MultiPoint"; case SHPT_POINTZ: return "PointZ"; case SHPT_ARCZ: return "ArcZ"; case SHPT_POLYGONZ: return "PolygonZ"; case SHPT_MULTIPOINTZ: return "MultiPointZ"; case SHPT_POINTM: return "PointM"; case SHPT_ARCM: return "ArcM"; case SHPT_POLYGONM: return "PolygonM"; case SHPT_MULTIPOINTM: return "MultiPointM"; case SHPT_MULTIPATCH: return "MultiPatch"; default: return "UnknownShapeType"; } } /************************************************************************/ /* SHPPartTypeName() */ /************************************************************************/ const char SHPAPI_CALL1(*) SHPPartTypeName( int nPartType ) { switch( nPartType ) { case SHPP_TRISTRIP: return "TriangleStrip"; case SHPP_TRIFAN: return "TriangleFan"; case SHPP_OUTERRING: return "OuterRing"; case SHPP_INNERRING: return "InnerRing"; case SHPP_FIRSTRING: return "FirstRing"; case SHPP_RING: return "Ring"; default: return "UnknownPartType"; } } /************************************************************************/ /* SHPDestroyObject() */ /************************************************************************/ void SHPAPI_CALL SHPDestroyObject( SHPObject * psShape ) { if( psShape == NULL ) return; if( psShape->padfX != NULL ) free( psShape->padfX ); if( psShape->padfY != NULL ) free( psShape->padfY ); if( psShape->padfZ != NULL ) free( psShape->padfZ ); if( psShape->padfM != NULL ) free( psShape->padfM ); if( psShape->panPartStart != NULL ) free( psShape->panPartStart ); if( psShape->panPartType != NULL ) free( psShape->panPartType ); free( psShape ); } ./geocoder/Makefile0100644000076400007640000000077307441720543013750 0ustar gmadergmadergeocoder: geocoder.o shpopen.o dbfopen.o gcc -o geocoder geocoder.o shpopen.o dbfopen.o geocoder.o: geocoder.c gcc -c geocoder.c shpopen.o: shpopen.c gcc -c shpopen.c dbfopen.o: dbfopen.c gcc -c dbfopen.c indexer.o: indexer.c gcc -c indexer.c indexer: indexer.o dbfopen.o gcc -o indexer indexer.o dbfopen.o geocoder_soundex: geocoder_soundex.o shpopen.o dbfopen.o gcc -o geocoder_soundex geocoder_soundex.o shpopen.o dbfopen.o geocoder_soundex.o: geocoder_soundex.c gcc -c geocoder_soundex.c ./geocoder/dbfopen.o0100644000076400007640000003003407403015037014067 0ustar gmadergmaderELFl"4( U}uE P‰E PEP‰]U8Ex4uE@4E&}~EUEEUB …}щ)ЈEEP Ѕ}EUB…}щ)ЈEEPЅ}EjjERERjj EPEREPRj EP$REUJʉQ 9P ~E ERjjEP]ÉUEx,t`Ex(~WE@,EU@B(UJ MjEPERERjEPREP0R]ÐUs 4 4EvUe[^_]ÍvU(Ex4tEPEPEx8jjERERjj EPE_EEUB…}щ)ЈEEPЅ}…}щ)ЈEEPЅ}…}щ)ЈEEPЅ}…}щ)ЈEjjERERjj EPERExtHEPREPREPREP REP$REP0REP=@t%@P@<]ÍvU(EPPREEPEPEPPUv}~*EUЀ8.tEUЀ8/tEUЀ8\uMɋEUЀ8.u EUEPPREEPhEPEPhEPE}u1EPjEPhEPE}u1EPj<EEUE@E@E@E@ !E@E@E@E@ E@$E@(E@,E@0E@4U&]USEx~ Ex4u }t}t&E@EPЍREPRUBEPЍREPRUBEPЍREPRgUBEPREP RFUB EUJHAUJEUJU XEUJHPEEUJXPE}uEUJP  PCEUJP  PNEUJ H E@8EPЉREP$ReUB$EUJIʉX$ˉ]E}~EUEE P *E PPE PEPvj E PEPE UMYJ J}u?EUх}ˉ)ʈEMʅ}EUEUEPREP0R>UB0EPJ]]ÐU(EEE} | EU ;P} 1Jv}| EU;P} 1-EP(;U EP1EPU EH щMjEPERt!EPh@P1ERjEPREP0Rt*EPRh`P1mEU P(EP0UEU @B;<~'9 '] /./geocoder/geocoder0100775000076400007640000013154707441704114014027 0ustar gmadergmaderELF0404 (444vvv0`(x(( /lib/ld-linux.so.2GNU#  " ! $H"X&ah-xNpi"2ȇ@؇\)(48]!H28Xqh?x"+U:Ȉh(؈-d __gmon_start__libc.so.6strcpyprintf__ctype_bfgetsmemcpy__cxa_finalizemalloccallocatoffprintf__deregister_frame_infofseekstrncmpstrncpyreallocfreadmemset__assert_failstrcmpsprintffclosestderrfputcfwriteexitfopenatoi_IO_stdin_used__libc_start_mainstrlentoupper__register_frame_infofreeGLIBC_2.1.3GLIBC_2.1GLIBC_2.0si ?ii Kii U$!       "U)j5%%h%h%h%h%h %h(%h0%h8p%h@`%hH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PEUэHPjUЋUщЍPREUэHP= t#EUэHPj= t#EUэHPj_Et&E‰EE8tE8 tE8t jUPE8PjUЍPREXP= tE8Pj= tEXPjEE;E|svjUЋUэJPEUэH PL= t#EUэH Pj(E냋EUэ MEU P UэJU9jUPE@PjUЍPRE`P= tE@Pj{= tE`Pj^EvE;E|vjUЋUэJPEUэH$P= t#EUэH$PjE E8tE8t E8tj,PEP菿= tEPj}EUPjEP諿‹EPjEP萿‹EPjEPu‹EP jEPZ‹EP$EE;E|jE‰P0PEUэHP貾jE‰P0PREUэHPv= t#EUэHPjR= t#EUэHPj&EE‰P0Uj PE(PjPE0P̽jPEHP诽j$PEPP蒽= tE(Pj}= tE0Pj`= tEHPjC= tEPPj&E8jUPE8PjUЍPREXPѼ= tE8Pj= tEXPjEt&E;E|vjUЋUэJPEUэH P<= t#EUэH PjE뀋EUэ MEU P UэJU9jUPE@P袻jUЍPRE`P耻= tE@Pjk= tE`PjNEvE;E|vjUЋUэJPEUэH$P= t#EUэH$PjEE8tE8t E8 tE@jjк‹EPjj跺‹EPjj螺‹EP jj腺‹EP$j PEPRjPEPR= tEPRj= tEPRjEE8 u@jUPEP R艹= tEP RjtEEU @E9|s 4 4EvUe[^_]ÍvU(Ex4tEPEPEx8jjERHERjj EPE_EEUB…}щ)ЈEEPЅ}…}щ)ЈEEPЅ}…}щ)ЈEEPЅ}…}щ)ЈEjjERcERjj EP蝮ERExtHEPR!EPREPREP REP$R٭EP0RǭEP踭=t%P螭|]ÍvU(EP苬PR-EEPEP襭EPVPUv}~*EUЀ8.tEUЀ8/tEUЀ8\uMɋEUЀ8.u EUEPPR茫EEPh0EP߬EP萬h>EP謬E}u1EPj詫EPh(EPfE}u1EPj<تEEUE@E@E@E@ !E@E@E@E@ E@$E@(E@,E@0E@4U&]USEx~ Ex4u }t}t&E@EPЍREPRUBEPЍREPRUBEPЍREPRgUBEPREP RFUB EUJHAUJEUJU XEUJHPEEUJXPE}uEUJP  PCEUJP  PNEUJ H E@8EPЉREP$ReUB$EUJIʉX$ˉ]E}~EUEE Pl *E PSPE PEP@vj E PEP&E UMYJ J}u?EUх}ˉ)ʈEMʅ}EUEUEPREP0R>UB0EPJ]]ÐU(EEE} | EU ;P} 1Jv}| EU;P} 1-EP(;U EP1EPU EH щMjEPERt!EPh`PQ1ERjEPREP0R\t*EPRhP1mEU P(EP0UEU @B;|~nSHPType == psSHP->nShapeType || psObject->nSHPType == 0nShapeId == -1 || (nShapeId >= 0 && nShapeId < psSHP->nRecords)0Error in fseek() or fwrite(). ?Y@NullShapePointArcPolygonMultiPointPointZArcZPolygonZMultiPointZPointMArcMPolygonMMultiPointMMultiPatchUnknownShapeType@@@@@@@@@@@@@ @'@@0@@7TriangleStripTriangleFanOuterRingInnerRingFirstRingRingUnknownPartTypepwrr+rbrb+r+b%s.dbf%s.DBFwbfseek(%d) failed on DBF file. fread(%d) failed on DBF file. 00000000%%%dd%%%d.%df$Id: shpopen.c,v 1.33 2001/07/03 12:18:15 warmerda Exp $$Id: dbfopen.c,v 1.37 2001/07/04 05:18:09 warmerda Exp $(N^n~·އ.>N^n~Έވ  P(0 ? 0o؅oodTdT9<Hr0,V1V cV$[Lby !"#3%K&a1x234568 9";B=X>n?@ABCDE F$G;HTIiNQRST9UUVmX[^ehl q r5 uP vm y z } & @ ˔t F  #V Y 4u < C F S Z ^ltMyn4 Lb8wbKL#5LwH8KgLUZ^?awb\r5 7!899S:m dTinit.c/usr/src/build/53700-i386/BUILD/glibc-2.2.4/csu/gcc2_compiled.int:t(0,1)=r(0,1);-2147483648;2147483647;char:t(0,2)=r(0,2);0;127;long int:t(0,3)=r(0,3);-2147483648;2147483647;unsigned int:t(0,4)=r(0,4);0000000000000;0037777777777;long unsigned int:t(0,5)=r(0,5);0000000000000;0037777777777;long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;long long unsigned int:t(0,7)=@s64;r(0,7);0000000000000;01777777777777777777777;short int:t(0,8)=@s16;r(0,8);-32768;32767;short unsigned int:t(0,9)=@s16;r(0,9);0;65535;signed char:t(0,10)=@s8;r(0,10);-128;127;unsigned char:t(0,11)=@s8;r(0,11);0;255;float:t(0,12)=r(0,1);4;0;double:t(0,13)=r(0,1);8;0;long double:t(0,14)=r(0,1);12;0;complex int:t(0,15)=s8real:(0,1),0,32;imag:(0,1),32,32;;complex float:t(0,16)=r(0,16);8;0;complex double:t(0,17)=r(0,17);16;0;complex long double:t(0,18)=r(0,18);24;0;__builtin_va_list:t(0,19)=*(0,20)=(0,20)../include/libc-symbols.h/usr/src/build/53700-i386/BUILD/glibc-2.2.4/build-i386-linux/config.h../sysdeps/gnu/_G_config.h../sysdeps/unix/sysv/linux/bits/types.h../include/features.h../include/sys/cdefs.h../misc/sys/cdefs.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.hsize_t:t(8,1)=(0,4)__u_char:t(4,1)=(0,11)__u_short:t(4,2)=(0,9)__u_int:t(4,3)=(0,4)__u_long:t(4,4)=(0,5)__u_quad_t:t(4,5)=(0,7)__quad_t:t(4,6)=(0,6)__int8_t:t(4,7)=(0,10)__uint8_t:t(4,8)=(0,11)__int16_t:t(4,9)=(0,8)__uint16_t:t(4,10)=(0,9)__int32_t:t(4,11)=(0,1)__uint32_t:t(4,12)=(0,4)__int64_t:t(4,13)=(0,6)__uint64_t:t(4,14)=(0,7)__qaddr_t:t(4,15)=(4,16)=*(4,6)__dev_t:t(4,17)=(4,5)__uid_t:t(4,18)=(4,3)__gid_t:t(4,19)=(4,3)__ino_t:t(4,20)=(4,4)__mode_t:t(4,21)=(4,3)__nlink_t:t(4,22)=(4,3)__off_t:t(4,23)=(0,3)__loff_t:t(4,24)=(4,6)__pid_t:t(4,25)=(0,1)__ssize_t:t(4,26)=(0,1)__rlim_t:t(4,27)=(4,4)__rlim64_t:t(4,28)=(4,5)__id_t:t(4,29)=(4,3)__fsid_t:t(4,30)=(4,31)=s8__val:(4,32)=ar(4,33)=r(4,33);0000000000000;0037777777777;;0;1;(0,1),0,64;;__daddr_t:t(4,34)=(0,1)__caddr_t:t(4,35)=(4,36)=*(0,2)__time_t:t(4,37)=(0,3)__useconds_t:t(4,38)=(0,4)__suseconds_t:t(4,39)=(0,3)__swblk_t:t(4,40)=(0,3)__clock_t:t(4,41)=(0,3)__clockid_t:t(4,42)=(0,1)__timer_t:t(4,43)=(0,1)__key_t:t(4,44)=(0,1)__ipc_pid_t:t(4,45)=(0,9)__blksize_t:t(4,46)=(0,3)__blkcnt_t:t(4,47)=(0,3)__blkcnt64_t:t(4,48)=(4,6)__fsblkcnt_t:t(4,49)=(4,4)__fsblkcnt64_t:t(4,50)=(4,5)__fsfilcnt_t:t(4,51)=(4,4)__fsfilcnt64_t:t(4,52)=(4,5)__ino64_t:t(4,53)=(4,5)__off64_t:t(4,54)=(4,24)__t_scalar_t:t(4,55)=(0,3)__t_uscalar_t:t(4,56)=(0,5)__intptr_t:t(4,57)=(0,1)__socklen_t:t(4,58)=(0,4)../linuxthreads/sysdeps/pthread/bits/pthreadtypes.h../sysdeps/unix/sysv/linux/bits/sched.h__sched_param:T(10,1)=s4__sched_priority:(0,1),0,32;;_pthread_fastlock:T(9,1)=s8__status:(0,3),0,32;__spinlock:(0,1),32,32;;_pthread_descr:t(9,2)=(9,3)=*(9,4)=xs_pthread_descr_struct:__pthread_attr_s:T(9,5)=s36__detachstate:(0,1),0,32;__schedpolicy:(0,1),32,32;__schedparam:(10,1),64,32;__inheritsched:(0,1),96,32;__scope:(0,1),128,32;__guardsize:(8,1),160,32;__stackaddr_set:(0,1),192,32;__stackaddr:(0,19),224,32;__stacksize:(8,1),256,32;;pthread_attr_t:t(9,6)=(9,5)pthread_cond_t:t(9,7)=(9,8)=s12__c_lock:(9,1),0,64;__c_waiting:(9,2),64,32;;pthread_condattr_t:t(9,9)=(9,10)=s4__dummy:(0,1),0,32;;pthread_key_t:t(9,11)=(0,4)pthread_mutex_t:t(9,12)=(9,13)=s24__m_reserved:(0,1),0,32;__m_count:(0,1),32,32;__m_owner:(9,2),64,32;__m_kind:(0,1),96,32;__m_lock:(9,1),128,64;;pthread_mutexattr_t:t(9,14)=(9,15)=s4__mutexkind:(0,1),0,32;;pthread_once_t:t(9,16)=(0,1)_pthread_rwlock_t:T(9,17)=s32__rw_lock:(9,1),0,64;__rw_readers:(0,1),64,32;__rw_writer:(9,2),96,32;__rw_read_waiting:(9,2),128,32;__rw_write_waiting:(9,2),160,32;__rw_kind:(0,1),192,32;__rw_pshared:(0,1),224,32;;pthread_rwlock_t:t(9,18)=(9,17)pthread_rwlockattr_t:t(9,19)=(9,20)=s8__lockkind:(0,1),0,32;__pshared:(0,1),32,32;;pthread_spinlock_t:t(9,21)=(0,1)pthread_barrier_t:t(9,22)=(9,23)=s20__ba_lock:(9,1),0,64;__ba_required:(0,1),64,32;__ba_present:(0,1),96,32;__ba_waiting:(9,2),128,32;;pthread_barrierattr_t:t(9,24)=(9,25)=s4__pshared:(0,1),0,32;;pthread_t:t(9,26)=(0,5)wchar_t:t(11,1)=(0,3)wint_t:t(11,2)=(0,4)../include/wchar.h../wcsmbs/wchar.h../sysdeps/unix/sysv/linux/i386/bits/wchar.h__mbstate_t:t(13,1)=(13,2)=s8__count:(0,1),0,32;__value:(13,3)=u4__wch:(11,2),0,32;__wchb:(13,4)=ar(4,33);0;3;(0,2),0,32;;,32,32;;_G_fpos_t:t(3,1)=(3,2)=s12__pos:(4,23),0,32;__state:(13,1),32,64;;_G_fpos64_t:t(3,3)=(3,4)=s16__pos:(4,54),0,64;__state:(13,1),64,64;;../include/gconv.h../iconv/gconv.h :T(17,1)=e__GCONV_OK:0,__GCONV_NOCONV:1,__GCONV_NODB:2,__GCONV_NOMEM:3,__GCONV_EMPTY_INPUT:4,__GCONV_FULL_OUTPUT:5,__GCONV_ILLEGAL_INPUT:6,__GCONV_INCOMPLETE_INPUT:7,__GCONV_ILLEGAL_DESCRIPTOR:8,__GCONV_INTERNAL_ERROR:9,; :T(17,2)=e__GCONV_IS_LAST:1,__GCONV_IGNORE_ERRORS:2,;__gconv_fct:t(17,3)=(17,4)=*(17,5)=f(0,1)__gconv_init_fct:t(17,6)=(17,7)=*(17,8)=f(0,1)__gconv_end_fct:t(17,9)=(17,10)=*(17,11)=f(0,20)__gconv_trans_fct:t(17,12)=(17,13)=*(17,14)=f(0,1)__gconv_trans_context_fct:t(17,15)=(17,16)=*(17,17)=f(0,1)__gconv_trans_query_fct:t(17,18)=(17,19)=*(17,20)=f(0,1)__gconv_trans_init_fct:t(17,21)=(17,22)=*(17,23)=f(0,1)__gconv_trans_end_fct:t(17,24)=(17,25)=*(17,26)=f(0,20)__gconv_trans_data:T(17,27)=s20__trans_fct:(17,12),0,32;__trans_context_fct:(17,15),32,32;__trans_end_fct:(17,24),64,32;__data:(0,19),96,32;__next:(17,28)=*(17,27),128,32;;__gconv_step:T(17,29)=s56__shlib_handle:(17,30)=*(17,31)=xs__gconv_loaded_object:,0,32;__modname:(17,32)=*(0,2),32,32;__counter:(0,1),64,32;__from_name:(4,36),96,32;__to_name:(4,36),128,32;__fct:(17,3),160,32;__init_fct:(17,6),192,32;__end_fct:(17,9),224,32;__min_needed_from:(0,1),256,32;__max_needed_from:(0,1),288,32;__min_needed_to:(0,1),320,32;__max_needed_to:(0,1),352,32;__stateful:(0,1),384,32;__data:(0,19),416,32;;__gconv_step_data:T(17,33)=s36__outbuf:(17,34)=*(0,11),0,32;__outbufend:(17,34),32,32;__flags:(0,1),64,32;__invocation_counter:(0,1),96,32;__internal_use:(0,1),128,32;__statep:(17,35)=*(13,1),160,32;__state:(13,1),192,64;__trans:(17,28),256,32;;__gconv_info:T(17,36)=s8__nsteps:(8,1),0,32;__steps:(17,37)=*(17,29),32,32;__data:(17,38)=ar(4,33);0;-1;(17,33),64,0;;__gconv_t:t(17,39)=(17,40)=*(17,36)_G_iconv_t:t(3,5)=(3,6)=u44__cd:(17,36),0,64;__combined:(3,7)=s44__cd:(17,36),0,64;__data:(17,33),64,288;;,0,352;;_G_int16_t:t(3,8)=(0,8)_G_int32_t:t(3,9)=(0,1)_G_uint16_t:t(3,10)=(0,9)_G_uint32_t:t(3,11)=(0,4)_IO_stdin_used:G(0,1)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.95.1 19990816 (release)GCC: (GNU) 2.95.1 19990816 (release)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)01.0101.0101.0101.0101.0101.0101.0101.01.symtab.strtab.shstrtab.interp.note.ABI-tag.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.plt.text.fini.rodata.data.eh_frame.ctors.dtors.got.dynamic.sbss.bss.stab.stabstr.comment.note# 1((7 0?00_GoFTo؅@c l 00 u  {8800 iPPrr7 v wwww((xxx0x G@ S  G(0؅0  8 0 P ( T T +2  =AO[ q   2   @  P  0  ` 9$, 5`w >ؕL H$Y W b p  @9z|>D 6 s  `{    %(. ?H"`X&ryh-l( x8 ԩ D 8< 47 L_ &  ,. E Nh `pr @ "0  ȇ@؇$ )-@{ Pam0 rT  4! (4P/ 8]d(  H2 P Xq"h4, >x"ZH$ h(  L X +t9   "|1 2ȈhDY& o؈t l8 p T - d] & 5initfini.cgcc2_compiled.call_gmon_startinit.ccrtstuff.cp.0__DTOR_LIST__completed.1__do_global_dtors_aux__EH_FRAME_BEGIN__fini_dummyobject.2frame_dummyinit_dummyforce_to_data__CTOR_LIST____do_global_ctors_aux__CTOR_END____DTOR_END____FRAME_END__geocoder.cshpopen.crcsidpabyRecnBufSizeSwapWordSfReallocSHPWriteHeaderbBigEndian_SHPSetBoundsdbfopen.cnStringFieldLenpszStringFieldDBFWriteHeaderDBFFlushRecorddDoubleField.24DBFReadAttributeDBFWriteAttributepReturnTuple.67nTupleLen.68str_to_upperdirection_search_DYNAMICSHPDestroyObject__register_frame_info@@GLIBC_2.0strcmp@@GLIBC_2.0_fp_hwfprintf@@GLIBC_2.0DBFReadStringAttribute__assert_fail@@GLIBC_2.0DBFCreateSHPComputeExtentsDBFGetFieldIndexSHPCreateSimpleObjectDBFReadDoubleAttributeSHPPartTypeName_initDBFWriteIntegerAttributeSHPCloseDBFGetRecordCountmalloc@@GLIBC_2.0DBFWriteTuplefread@@GLIBC_2.0__deregister_frame_info@@GLIBC_2.0stderr@@GLIBC_2.0fseek@@GLIBC_2.0_startDBFIsAttributeNULLfgets@@GLIBC_2.0strlen@@GLIBC_2.0DBFCloseatof@@GLIBC_2.0strncmp@@GLIBC_2.0SHPCreateObjectfputc@@GLIBC_2.0__bss_startmain__libc_start_main@@GLIBC_2.0DBFAddFieldshp_findtoupper@@GLIBC_2.0dbf_searchrealloc@@GLIBC_2.0DBFWriteDoubleAttributedata_startprintf@@GLIBC_2.0_finimemcpy@@GLIBC_2.0fclose@@GLIBC_2.1SHPCreate__cxa_finalize@@GLIBC_2.1.3DBFCloneEmptyDBFWriteStringAttributeSHPGetInfoDBFReadTupleexit@@GLIBC_2.0DBFReadIntegerAttributeatoi@@GLIBC_2.0calloc@@GLIBC_2.0SHPReadObject_edata_GLOBAL_OFFSET_TABLE_free@@GLIBC_2.0_endDBFGetFieldInfomemset@@GLIBC_2.0__ctype_b@@GLIBC_2.0DBFWriteNULLAttributestrncpy@@GLIBC_2.0SHPWriteObjectfopen@@GLIBC_2.1DBFGetNativeFieldTypeDBFOpenDBFGetFieldCount_IO_stdin_usedsprintf@@GLIBC_2.0SHPTypeNamefwrite@@GLIBC_2.0__data_startSHPOpen__gmon_start__strcpy@@GLIBC_2.0./geocoder/testscript.sh0100755000076400007640000000031407401751341015036 0ustar gmadergmader./geocoder 330 n jones ave ./geocoder 230 n jones ave ./geocoder 120 n smith ave ./geocoder 175 n smith ave ./geocoder 650 w elm st ./geocoder 505 w elm st ./geocoder 781 w elm st ./geocoder 550 w oak st ./geocoder/shpfile/0040755000076400007640000000000007401745715013742 5ustar gmadergmader./geocoder/shpfile/test4.dbf0100755000076400007640000000467207401745612015467 0ustar gmadergmadere  WFNODE_N TNODE_N LPOLY_N RPOLY_N LENGTHN TEST1_N TEST1_IDN IDN FROM_ADDNTO_ADDNPRE_DIRECTCSTR_NAMECSTR_TYPEC 2 4 0 0 0.001 1 3 0 300 400n jones ave 4 3 0 0 0.001 2 1 0 700 800w oak st 1 5 0 0 0.001 3 4 0 300 400n smith ave 6 5 0 0 0.001 5 1 0 500 600w oak st 4 8 0 0 0.001 6 3 0 200 300n jones ave 8 7 0 0 0.001 7 2 0 700 800w elm st 5 9 0 0 0.001 8 4 0 200 300n smith ave 9 8 0 0 0.003 9 2 0 600 700w elm st 10 9 0 0 0.001 10 2 0 500 600w elm st 8 11 0 0 0.001 11 3 0 100 200n jones ave 9 12 0 0 0.001 12 4 0 100 200n smith ave 0 0 0 0 0.000 0 0 0 600 700w oak st ./geocoder/shpfile/test4.sbn0100755000076400007640000000037407401745612015511 0ustar gmadergmader' p~ Ue`@@?U@@@@ 7=>7ĵ => =ĵô> ô78> 878=8>7=8./geocoder/shpfile/test4.sbx0100755000076400007640000000020407401745612015513 0ustar gmadergmader' pB Ue`@@?U@@@@2 BNf./geocoder/shpfile/test4.shp0100755000076400007640000000222407401745612015515 0ustar gmadergmader' J`eU?@@U@@( TUy@@ TU@@ TU@@ TUy@@(`eUy@@ TUy@@ TUy@@`eUy@@(`(Uy@@`(U@@`(U@@`(Uy@@(`(Uy@@Uy@@Uy@@`(Uy@@( TUS@@ TUy@@ TUy@@ TUS@@(bUS@@ TUS@@ TUS@@bUS@@(`(US@@`(Uy@@`(Uy@@`(US@@( TUS@@`(US@@`(US@@ TUS@@ (`(US@@US@@US@@`(US@@ ( TUA@@ TUS@@ TUS@@ TUA@@ (`(U?@@`(US@@`(US@@`(U?@@ 0 TUy@@`(Uy@@`(Uy@@TUy@@ TUy@@./geocoder/shpfile/test4.shx0100755000076400007640000000030407401745612015522 0ustar gmadergmader' b`eU?@@U@@2(^(((((:(f((((0./geocoder/.geocoder0100644000076400007640000000004407403017507014064 0ustar gmadergmader/home/gmader/geocoder/shpfile/test4 ./geocoder/indexer.c0100664000076400007640000000602107441747736014121 0ustar gmadergmader#include #include #include "shapefil.h" #include /* function prototypes*/ void dbf_search(char file[]); char *Soundex(char *In); int main( int argc, char ** argv ){ int addr; char file_name[100]; char file_name2[100]; FILE *defaults1; /* -------------------------------------------------------------------- */ /* Display a usage message. */ /* -------------------------------------------------------------------- */ if( argc != 2 ) { printf("indexer [shapefile]\n" ); printf("%d", argc); exit(1); } /* -------------------------------------------------------------------- */ /* set up user input */ /* -------------------------------------------------------------------- */ strcpy(file_name, argv[1]); /*if ((defaults1=fopen (".geocoder","r")) == NULL){ printf(".geocoder defaults file not found"); } fgets(file_name, 36, defaults1); fclose(defaults1); */ dbf_search(file_name); } /* -------------------------------------------------------------------- */ /*This function searches the DBF for the record that contains the address*/ /* -------------------------------------------------------------------- */ void dbf_search(char file[]){ DBFHandle handle; FILE *fp; char street_name[10]; int iRecord; fp = fopen("test.idx", "w"); handle = DBFOpen(file,"rb"); if( handle == NULL ) { printf( "path incorrect\n" ); exit( 2 ); } for(iRecord = 0; iRecord < DBFGetRecordCount(handle); iRecord++ ){ /*initial hack at recognizing and loading address struct into array */ strcpy(street_name,DBFReadStringAttribute(handle, iRecord,11)); fprintf(fp , "%s ",Soundex(street_name)); fprintf(fp ,"\t"); fprintf(fp , street_name); fprintf(fp ,"\n");} fclose(fp); } /* -------------------------------------------------------------------- */ /*Soundex Function. Used NIST examples to test for correctness, after Knuth*/ /* -------------------------------------------------------------------- */ char *Soundex(char *In){ int Iin, Iout; char C, PrevDig, *Out = (char *)malloc(10); int FullFlag = 0; if (FullFlag) {Iin = 0; Iout = 0; PrevDig = '*';} else {Iin = 1; Iout = 1; Out[0] = tolower(In[0]); PrevDig = Out[0];} while ((In[Iin] != (char)NULL) && (Iout <= 4)) { In[Iin] = tolower(In[Iin]); switch (In[Iin]) { case 'b' : C = '1'; break; case 'p' : C = '1'; break; case 'f' : C = '1'; break; case 'v' : C = '1'; break; case 'c' : C = '2'; break; case 's' : C = '2'; break; case 'k' : C = '2'; break; case 'g' : C = '2'; break; case 'j' : C = '2'; break; case 'q' : C = '2'; break; case 'x' : C = '2'; break; case 'z' : C = '2'; break; case 'd' : C = '3'; break; case 't' : C = '3'; break; case 'l' : C = '4'; break; case 'm' : C = '5'; break; case 'n' : C = '5'; break; case 'r' : C = '6'; break; default : C = '*'; } if ((C != PrevDig) && (C != '*')){ Out[Iout] = C; PrevDig = Out[Iout]; Iout++;} Iin++; } if (Iout < 4)for (Iin=Iout; Iin<4; Iin++)Out[Iin] = '0'; Out[4] = NULL; return Out; } ./geocoder/Geocoding_C_Program.ppt0100664000076400007640000024400007442032621016651 0ustar gmadergmaderࡱ;   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~Root Entry  dO)MS PowerPoint 97$_ Current UserOh+'0(\ Geocoding C Program Gregory A. Mader Greg Mader@1k |՜.+,D՜.+,nu+TPNG  IHDRKm)+IDATxc9/0]f1I8 WZvXIENDB`n'$wR` W#PNG  IHDR9Bt PLTEGG\\pp)Rz"31J@`Ow^n}"Df3M"f+3<DMUh|:Wu3Pm33MMff3Mf"+3<DMUh:|Wu3"J1`@wO^n}Ҍ"Df̈ת33MMff:Wu3(P7mETbq3Mf3Uw--DD[[qq3&M3f@MYfs:WuȒׯ33MMff:Wu3M&f3@MYfs:WuiίbKGDH pHYsod IDATx @QŋZ_ FۀM8IʃlߊdEuQd:fQ28( @I( %P$J@I( %P$J@I( P%P$J@I( P%J$J@I( P%J$@IJ@I( P%[Iw$np*'J t3)&0r=Τ[Pᱸ^8M( P%P$%J$@I( P%P$J$@I( P%JR$J@I( |AI*߲mk) dܴKi-%(z??o>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[?@oezFkJ'4l'F\h^mFc=:ɗ7~q5Zk4K}rݹx7&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2L&d2l*p!N:l?0N:l?0 fxKh\UlRAjAZ\ K\TZ 慝)..̢nDID]".*E%b+sg2x;B 3{snnT:E"=r }k~ֽ&)|n8}Hi{ǥjCK9|^\/׷jcaTz~dYp9?[7^7WsYmK87vZ[];q1n/Yyް~ӳ~t$ww)7q;c}CcCdž;ؑѲd; *w9ObR;dه ڇRrg5Tͪ1;!umѐnXQUnˍ9Un g4UdUdUdUd ppp@ <4 g4;d;d;d;d (p@ pp~:@Geocoding C Program and Soundex *!Odffff ! (What is a Geocoder? *Odffff  Geocoding is the process of assigning an X/Y coordinate to an address record. Most Geocoding software works within databases, and requires preprocessing to create an index of the records. Widely used within business and Government http://www.geocode.com/ http://www.esricanada.com/k12/tutorials/geocode/ http://www.sgsi.com/geoc0198.htmNp-`oZnp-`oZ+p-`oZp$;@EZ1p$;@EZ!p$;@EZNn+1!0 Q BThe Itch that I needed to scratch"Od"ff " I had been working on a free/open source internet mapserver technology, MapServer from the U of Minnesota, and it didnt have a means of address matching. I used an exact SQL query to select parcels based on addresses. Problems: This approach requires a fairly exact selection. It doesnt work with linear data (streets) `-`o `-`o1`$;@E+`$;@E`-move 1" D BThe Itch that I needed to scratch"Od"ff " I wanted to be able to select address that may lay on a street, and return an X/Y coordinate. This coordinate could be used to create a point on a map. I wanted to contribute back to the Mapserver community. http://mapserver.gis.umn.edu/j`-no8`-no`$<@E 8    BThe Itch that I needed to scratch"Od"ff " DI decided on a C program that would read an address from standard in, and return an X/Y to standard out. Reasons to use C. Faster. Independent of database implementation. Technically sound. This class afforded me the opportunity to extend it with Soundex error correction for street names. ip-`oZp-`oZp$;@EZ(p$;@EZp$;@EZdp-`oZp-`oZi(d #  $Technical approachOdff  Here was my original approach. I didnt take into account some significant problems with determining directionality. It turns out that Shapefiles do not have a bit set to show the direction of the individual linear elements.:`-mo%   $Technical approachOdff  This is the test spatial dataset that I used. The format is known as a Shapefile, and it contains the spatial components in two files (.shx, .shp), and the attributes in a DBF file. Each linear element has a from_address and to_address field in the DBF file. $`-mo   $Technical approachOdff  I discovered that Shapefiles do not maintain directionality. This means that the from_ and To_address fields essentially could not work, as is. I got around this problem by selecting an adjoining segment, comparing the address ranges, and deciding what the direction is. Additionally, in the western hemisphere, X coordinates are negative. This means that if addresses grow in an east-to-west direction, we must subtract the appropriate amount from a negative number. This has consequences that can change and vary considerably, depending on the coordinate system and projection.`-mo`-mo9`-mon  M   Functionality *Od ffff  (The software takes one style of US standard address: House Number, Pre_Direction, Street Name, Street Type. Could be extended to include Zip codes 5`-no7`-no'`-no`-no`-no57'   8330 n jones ave 550 w oak st@O`n O`n    Functionality *Od ffff  The software parses this address and searches the DBF file for a record that matches. Matches are put into a struct. hv`-no`-no`-nov x  8330 n jones ave 550 w oak st@O`n O`n    Functionality *Od ffff  fThe record number of this struct is then used to grab the correct graphic linear element. The house number is interpolated as a proportion of the length of the linear element. \p-noZVp-noZp-noZp-noZ\V   FunctionalityOdff  rThe program then returns the X/Y from this interpolation.$:`-no: :  bxfield yfield address -84.395760 33.792952 330 n jones ave -84.395760 33.791962 230 n jones ave -84.393089 33.791125 120 n smith ave -84.393089 33.791459 175 n smith ave -84.394424 33.791611 650 w elm st -84.392017 33.791611 505 w elm st -84.396483 33.791611 781 w elm st -84.392574 33.792782 550 w oak st``-lo%`-lo%`-lo%`-lo%`-lo"`-lo"`-lo"`-lo"`-lo                     2  FunctionalityOdff  I extended this by implementing the Soundex algorithm. I created an indexing program that reads the base map data file, and creates a text index file that maps correct street names to a soundex value. The geocoder_soundex program creates the soundex value of the user input, and matches it against this index before attempting the geocode function.l7`-no`-no`-no7 ]  FunctionalityOdff  *The index file is called test.idx. The program to create this is indexer. There is a test script to run the geocoder called testscript_soundex.sh. %`-no'`-noI`-no`-no%'I  ,Limitations of SoundexOdff  xSoundex is a very clever algorithm to fix surname spelling issues. For street names, it may not be as appropriate. I am concerned that it is likely that people will miss the first letter of a street name, such as Seraphim Lane or Ceraphim Lane Soundex cannot cope with compound names, such as Burr Oak Lane. `-noB`-no`-no  1  = ResultsOdff  Here are the coordinates from the test sample imported into ArcView, a GIS (Geographic Information Systems) program&tp-noZt  t ResultsOdff  &I intend on developing this further, and then releasing it to the open source mapping community. Hopefully, it will be of use to others as well. l`-no`-no`-no     /   ! " # $%&P&` ̙33` ` ff3333f` 333MMM` f` f` 3?dffd ,ff}dffd,}dffd,}dffd,}dffd,?-nod  @E}$<@Ed @E}-_od@@E}$A@Ed`@E}$<od@E ?" dd  } dd  }" dd@ } dd` }dd @?" dd } dd }" dd@} dd`}ddP}" dd } dd }" dd@} dd`}dd`}" dd,} dd ,}" dd@,} dd`,}dd,p}" dd } dd }" dd@} dd`}dd}" dd } dd }" dd@} dd`}dd ph<B(  H8  8  8  RB  s *D0$$RB  s *D0$$RB  s *D0$$@@RB  s *D0$$RB  s *D0$$RB   s *D0$$RB   s *D0$$@@RB   s *D0$$RB   s *D0$$RB   s *D0$$RB  s *D0$$@@RB  s *D0$$  RB  s *D0$$  RB  s *D0$$  RB  s *D0$$@ @ RB  s *D0$$  RB  s *D0$$  RB  s *D0$$  RB  s *D0$$@@RB  s *D0$$RB  s *D0$$RB  s *D0$$r 8  RB  s *D0$$RB  s *D0$$RB  s *D0$$@@RB  s *D0$$RB  s *D0$$RB   s *D0$$RB ! s *D0$$@@RB " s *D0$$RB # s *D0$$RB $ s *D0$$RB % s *D0$$@@RB & s *D0$$ RB ' s *D0$$ RB ( s *D0$$ RB ) s *D0$$@ @ RB * s *D0$$ RB + s *D0$$ RB , s *D0$$ RB - s *D0$$@@RB . s *D0$$RB / s *D0$$RB 0 s *D0$$RB 1 s *D0$$@@RB 2 s *D0$$RB 3 s *D0$$RB 4 s *D0$$RB 5 s *D0$$@@RB 6 s *D0$$RB 7 s *D0$$d" 8 <GA @_RB 9 s *Dov$t8 |h3  :|h3 RB ;B s *Dov$iRB < s *Dov$~4 x = PBCDEFov$`` #|*q1f9\BRKIT@^8h0s)~"  $1>K Xeq}&-4=ENXbmx  )6CP] jvyl `SF9,@|CL > c $ `_L ? c $ `" @  `$0zhh   zFClick to edit the title text format$ $ A  `0zhh /  Click to edit the outline text format Second Outline Level Third Outline Level Fourth Outline Level Fifth Outline Level Sixth Outline Level Seventh Outline Level Eighth Outline Level Ninth Outline Level6& N B 6h ? ̙33  :(  ^ S     HD1z t  H  0޽h ? ̙33 VN0AD (   8   68   ^"   6G0$ @_.8   RB   s *D0$$RB   s *D0$$RB   s *D0$$@@RB   s *D0$$RB   s *D0$$RB   s *D0$$RB   s *D0$$@@RB   s *D0$$RB   s *D0$$RB   s *D0$$RB   s *D0$$@@RB   s *D0$$  RB   s *D0$$  RB   s *D0$$  RB   s *D0$$@ @ RB   s *D0$$  RB   s *D0$$  RB   s *D0$$  RB   s *D0$$@@RB   s *D0$$RB   s *D0$$RB   s *D0$$RB   s *D0$$RB   s *D0$$RB   s *D0$$@@RB   s *D0$$RB   s *D0$$RB   s *D0$$RB !  s *D0$$@@RB "  s *D0$$RB #  s *D0$$RB $  s *D0$$RB %  s *D0$$@@RB &  s *D0$$ RB '  s *D0$$ RB (  s *D0$$ RB )  s *D0$$@ @ RB *  s *D0$$ RB +  s *D0$$ RB ,  s *D0$$ RB -  s *D0$$@@RB .  s *D0$$RB /  s *D0$$RB 0  s *D0$$RB 1  s *D0$$@@RB 2  s *D0$$RB 3  s *D0$$RB 4  s *D0$$RB 5  s *D0$$@@RB 6  s *D0$$RB 7  s *D0$$RB 8  s *Dov$8 /b2  9 /b2 B :  s *Dov$/3 ,$D RB ; s *Dov$ RB < s *Dov$cv =  NBCDE|Fov$___N<+   '09CMrYfdZqN~D:1(  +<M_p $-5?"I/T=`JlVyalw#4FWhy x(n5cBXNKZ?e1p$yra@]Dr8  > RB ?  s *Dov$r r RB @  s *Dov$44v A  NZBCDE|Fov$__ar &.7@$K1V?bKnX{cnx&7HYj| w*l7aDVPJ\=g/q"{p_M<+ vlb~VqJd>Y1M#C90'  tbQ@  L B c $ `_L C c $ `N D 6h ? ̙33  vn@(     N1zhh @p   $  H2zhh %p/u  From Greg Mader"O`R @E  6 @ @ @H  0 ? ̙33  h`P(     Nd2zhh @   F2 @ @ @   N2zhh A  F2 >~> ~ >~H  0 ? ̙33  ld`(     N$3zhh @   J6 @ @ @   N3zhh A/  F2 >~> ~ >~H  0 ? ̙33  ldp(     N3zhh @   J6 @ @ @   ND4zhh A/  F2 >~> ~ >~H  0 ? ̙33  ld (      N4zhh @   J6 @ @ @   N5zhh A/  F2 >~> ~ >~H  0 ? ̙33  $8(  $ $  Nd5zhh @   J6 @ @ @ $  N5zhh A    F2 >~> ~ >~4 $ # A` H $ 0 ? ̙33  (8(  ( (  N$6zhh @   J6 @ @ @ (  N6zhh A _O   F2 >~> ~ >~4 ( # AH ( 0 ? ̙33f  ,(  , ,  N6zhh @   J6 @ @ @ ,  ND7zhh A   F2 >~> ~ >~ ,  N7z A/>   H , 0 ? ̙33  LD0(  0 0  N8zhh @   F2 @ @ @ 0  Nd8zhh Ao   F2 >~> ~ >~ 0  N8zhh A /  F2 >~> ~ >~H 0 0 ? ̙33   LD4(  4 4  N$9zhh @   F2 @ @ @ 4  N9zhh Ao   F2 >~> ~ >~ 4  N9zhh A /  F2 >~> ~ >~H 4 0 ? ̙33   8N(  8 8  ND:zhh @   F2 @ @ @ 8  N:zhh Ao   F2 >~> ~ >~N 8 3 A & /Y  H 8 0 ? ̙33   PH<(  < <  N;zhh @   J6 @ @ @ <  Nd;zhh A  F2 >~> ~ >~ <  N;zhh A@  F2 >~> ~ >~H < 0 ? ̙33   ld@(  @ @  N$~> ~ >~H @ 0 ? ̙33   ldD(  D D  N~> ~ >~H D 0 ? ̙33  ld H(  H H  N=zhh @   J6 @ @ @ H  N>zhh A   F2 >~> ~ >~H H 0 ? ̙33  0L8(  L L  Nd>zhh @   J6 @ @ @ L  N>zhh ApO  F2 >~> ~ >~4 L # A0"H L 0 ? ̙33  ld@P(  P P  N$?zhh @   J6 @ @ @ P  N?zhh A  F2 >~> ~ >~H P 0 ? ̙33 PT:(  T^ T S  ?   T H?z  =   H T 0޽h ? ̙33 `X:(  X^ X S  ?   X HD@z  =   H X 0޽h ? ̙33 p\:(  \^ \ S  ?   \ H@z  =   H \ 0޽h ? ̙33 `:(  `^ ` S  ?   ` HAz  =   H ` 0޽h ? ̙33 d:(  d^ d S  ?   d HdAz  =   H d 0޽h ? ̙33 h:(  h^ h S  ?   h HAz  =   H h 0޽h ? ̙33 l:(  l^ l S  ?   l H$Bz  =   H l 0޽h ? ̙33 p:(  p^ p S  ?   p HBz  =   H p 0޽h ? ̙33 t:(  t^ t S  ?   t HBz  =   H t 0޽h ? ̙33  x:(  x^ x S  ?   x HDCz  =   H x 0޽h ? ̙33  |:(  |^ | S  ?   | HCz  =   H | 0޽h ? ̙33  :(  ^  S  ?    HDz  =   H  0޽h ? ̙33  :(  ^  S  ?    HdDz  =   H  0޽h ? ̙33   :(  ^  S  ?    HDz  =   H  0޽h ? ̙33 0:(  ^  S  ?    H$Ez  =   H  0޽h ? ̙33 @:(  ^  S  ?    HEz  =   H  0޽h ? ̙33 P:(  ^  S  ?    HEz  =   H  0޽h ? ̙33!xX XSǷ?& q岹@U T5@łKZQ mԢZ+ jZQ[_Qo@͂׶{s3̜9g̙3ԹT-Nepq[+mip3a yQO/n6}} >A BpCpG@4B/!$fzE/o/"`fΡEvqųο39llyg "!DGB_~H@0a xS`ko 2Ѵ&Q&vOMLUJ%e$fN{ϸeƾ>ud`@d̤)ƽd`0?k6'gy{IoC_gVh:,_Xh00ݟS89`:GsKt^VۗyojbrJuHf_t5ٹsR|V6{rv6nwC>P$S/6rYKpK 1V1R0#fr1gڵX-7K>n788*0 nfgilu0q1cp{H?el)[sh1i{-sHMO.ٵ v;=#2S%a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dd9<Hr0,V1V cV$[Lby !"#3%K&a1x234568 9";B=X>n?@ABCDE F$G;HTIiNQRST9UUVmX[^ehl q r5 uP vm y z } & @ ˔t F  #V Y 4u < C F S Z ^ltMyn4 Lb8wbKL#5LwH8KgLUZ^?awb\r5 7!899S:m dinit.c/usr/src/build/53700-i386/BUILD/glibc-2.2.4/csu/gcc2_compiled.int:t(0,1)=r(0,1);-2147483648;2147483647;char:t(0,2)=r(0,2);0;127;long int:t(0,3)=r(0,3);-2147483648;2147483647;unsigned int:t(0,4)=r(0,4);0000000000000;0037777777777;long unsigned int:t(0,5)=r(0,5);0000000000000;0037777777777;long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;long long unsigned int:t(0,7)=@s64;r(0,7);0000000000000;01777777777777777777777;short int:t(0,8)=@s16;r(0,8);-32768;32767;short unsigned int:t(0,9)=@s16;r(0,9);0;65535;signed char:t(0,10)=@s8;r(0,10);-128;127;unsigned char:t(0,11)=@s8;r(0,11);0;255;float:t(0,12)=r(0,1);4;0;double:t(0,13)=r(0,1);8;0;long double:t(0,14)=r(0,1);12;0;complex int:t(0,15)=s8real:(0,1),0,32;imag:(0,1),32,32;;complex float:t(0,16)=r(0,16);8;0;complex double:t(0,17)=r(0,17);16;0;complex long double:t(0,18)=r(0,18);24;0;__builtin_va_list:t(0,19)=*(0,20)=(0,20)../include/libc-symbols.h/usr/src/build/53700-i386/BUILD/glibc-2.2.4/build-i386-linux/config.h../sysdeps/gnu/_G_config.h../sysdeps/unix/sysv/linux/bits/types.h../include/features.h../include/sys/cdefs.h../misc/sys/cdefs.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.hsize_t:t(8,1)=(0,4)__u_char:t(4,1)=(0,11)__u_short:t(4,2)=(0,9)__u_int:t(4,3)=(0,4)__u_long:t(4,4)=(0,5)__u_quad_t:t(4,5)=(0,7)__quad_t:t(4,6)=(0,6)__int8_t:t(4,7)=(0,10)__uint8_t:t(4,8)=(0,11)__int16_t:t(4,9)=(0,8)__uint16_t:t(4,10)=(0,9)__int32_t:t(4,11)=(0,1)__uint32_t:t(4,12)=(0,4)__int64_t:t(4,13)=(0,6)__uint64_t:t(4,14)=(0,7)__qaddr_t:t(4,15)=(4,16)=*(4,6)__dev_t:t(4,17)=(4,5)__uid_t:t(4,18)=(4,3)__gid_t:t(4,19)=(4,3)__ino_t:t(4,20)=(4,4)__mode_t:t(4,21)=(4,3)__nlink_t:t(4,22)=(4,3)__off_t:t(4,23)=(0,3)__loff_t:t(4,24)=(4,6)__pid_t:t(4,25)=(0,1)__ssize_t:t(4,26)=(0,1)__rlim_t:t(4,27)=(4,4)__rlim64_t:t(4,28)=(4,5)__id_t:t(4,29)=(4,3)__fsid_t:t(4,30)=(4,31)=s8__val:(4,32)=ar(4,33)=r(4,33);0000000000000;0037777777777;;0;1;(0,1),0,64;;__daddr_t:t(4,34)=(0,1)__caddr_t:t(4,35)=(4,36)=*(0,2)__time_t:t(4,37)=(0,3)__useconds_t:t(4,38)=(0,4)__suseconds_t:t(4,39)=(0,3)__swblk_t:t(4,40)=(0,3)__clock_t:t(4,41)=(0,3)__clockid_t:t(4,42)=(0,1)__timer_t:t(4,43)=(0,1)__key_t:t(4,44)=(0,1)__ipc_pid_t:t(4,45)=(0,9)__blksize_t:t(4,46)=(0,3)__blkcnt_t:t(4,47)=(0,3)__blkcnt64_t:t(4,48)=(4,6)__fsblkcnt_t:t(4,49)=(4,4)__fsblkcnt64_t:t(4,50)=(4,5)__fsfilcnt_t:t(4,51)=(4,4)__fsfilcnt64_t:t(4,52)=(4,5)__ino64_t:t(4,53)=(4,5)__off64_t:t(4,54)=(4,24)__t_scalar_t:t(4,55)=(0,3)__t_uscalar_t:t(4,56)=(0,5)__intptr_t:t(4,57)=(0,1)__socklen_t:t(4,58)=(0,4)../linuxthreads/sysdeps/pthread/bits/pthreadtypes.h../sysdeps/unix/sysv/linux/bits/sched.h__sched_param:T(10,1)=s4__sched_priority:(0,1),0,32;;_pthread_fastlock:T(9,1)=s8__status:(0,3),0,32;__spinlock:(0,1),32,32;;_pthread_descr:t(9,2)=(9,3)=*(9,4)=xs_pthread_descr_struct:__pthread_attr_s:T(9,5)=s36__detachstate:(0,1),0,32;__schedpolicy:(0,1),32,32;__schedparam:(10,1),64,32;__inheritsched:(0,1),96,32;__scope:(0,1),128,32;__guardsize:(8,1),160,32;__stackaddr_set:(0,1),192,32;__stackaddr:(0,19),224,32;__stacksize:(8,1),256,32;;pthread_attr_t:t(9,6)=(9,5)pthread_cond_t:t(9,7)=(9,8)=s12__c_lock:(9,1),0,64;__c_waiting:(9,2),64,32;;pthread_condattr_t:t(9,9)=(9,10)=s4__dummy:(0,1),0,32;;pthread_key_t:t(9,11)=(0,4)pthread_mutex_t:t(9,12)=(9,13)=s24__m_reserved:(0,1),0,32;__m_count:(0,1),32,32;__m_owner:(9,2),64,32;__m_kind:(0,1),96,32;__m_lock:(9,1),128,64;;pthread_mutexattr_t:t(9,14)=(9,15)=s4__mutexkind:(0,1),0,32;;pthread_once_t:t(9,16)=(0,1)_pthread_rwlock_t:T(9,17)=s32__rw_lock:(9,1),0,64;__rw_readers:(0,1),64,32;__rw_writer:(9,2),96,32;__rw_read_waiting:(9,2),128,32;__rw_write_waiting:(9,2),160,32;__rw_kind:(0,1),192,32;__rw_pshared:(0,1),224,32;;pthread_rwlock_t:t(9,18)=(9,17)pthread_rwlockattr_t:t(9,19)=(9,20)=s8__lockkind:(0,1),0,32;__pshared:(0,1),32,32;;pthread_spinlock_t:t(9,21)=(0,1)pthread_barrier_t:t(9,22)=(9,23)=s20__ba_lock:(9,1),0,64;__ba_required:(0,1),64,32;__ba_present:(0,1),96,32;__ba_waiting:(9,2),128,32;;pthread_barrierattr_t:t(9,24)=(9,25)=s4__pshared:(0,1),0,32;;pthread_t:t(9,26)=(0,5)wchar_t:t(11,1)=(0,3)wint_t:t(11,2)=(0,4)../include/wchar.h../wcsmbs/wchar.h../sysdeps/unix/sysv/linux/i386/bits/wchar.h__mbstate_t:t(13,1)=(13,2)=s8__count:(0,1),0,32;__value:(13,3)=u4__wch:(11,2),0,32;__wchb:(13,4)=ar(4,33);0;3;(0,2),0,32;;,32,32;;_G_fpos_t:t(3,1)=(3,2)=s12__pos:(4,23),0,32;__state:(13,1),32,64;;_G_fpos64_t:t(3,3)=(3,4)=s16__pos:(4,54),0,64;__state:(13,1),64,64;;../include/gconv.h../iconv/gconv.h :T(17,1)=e__GCONV_OK:0,__GCONV_NOCONV:1,__GCONV_NODB:2,__GCONV_NOMEM:3,__GCONV_EMPTY_INPUT:4,__GCONV_FULL_OUTPUT:5,__GCONV_ILLEGAL_INPUT:6,__GCONV_INCOMPLETE_INPUT:7,__GCONV_ILLEGAL_DESCRIPTOR:8,__GCONV_INTERNAL_ERROR:9,; :T(17,2)=e__GCONV_IS_LAST:1,__GCONV_IGNORE_ERRORS:2,;__gconv_fct:t(17,3)=(17,4)=*(17,5)=f(0,1)__gconv_init_fct:t(17,6)=(17,7)=*(17,8)=f(0,1)__gconv_end_fct:t(17,9)=(17,10)=*(17,11)=f(0,20)__gconv_trans_fct:t(17,12)=(17,13)=*(17,14)=f(0,1)__gconv_trans_context_fct:t(17,15)=(17,16)=*(17,17)=f(0,1)__gconv_trans_query_fct:t(17,18)=(17,19)=*(17,20)=f(0,1)__gconv_trans_init_fct:t(17,21)=(17,22)=*(17,23)=f(0,1)__gconv_trans_end_fct:t(17,24)=(17,25)=*(17,26)=f(0,20)__gconv_trans_data:T(17,27)=s20__trans_fct:(17,12),0,32;__trans_context_fct:(17,15),32,32;__trans_end_fct:(17,24),64,32;__data:(0,19),96,32;__next:(17,28)=*(17,27),128,32;;__gconv_step:T(17,29)=s56__shlib_handle:(17,30)=*(17,31)=xs__gconv_loaded_object:,0,32;__modname:(17,32)=*(0,2),32,32;__counter:(0,1),64,32;__from_name:(4,36),96,32;__to_name:(4,36),128,32;__fct:(17,3),160,32;__init_fct:(17,6),192,32;__end_fct:(17,9),224,32;__min_needed_from:(0,1),256,32;__max_needed_from:(0,1),288,32;__min_needed_to:(0,1),320,32;__max_needed_to:(0,1),352,32;__stateful:(0,1),384,32;__data:(0,19),416,32;;__gconv_step_data:T(17,33)=s36__outbuf:(17,34)=*(0,11),0,32;__outbufend:(17,34),32,32;__flags:(0,1),64,32;__invocation_counter:(0,1),96,32;__internal_use:(0,1),128,32;__statep:(17,35)=*(13,1),160,32;__state:(13,1),192,64;__trans:(17,28),256,32;;__gconv_info:T(17,36)=s8__nsteps:(8,1),0,32;__steps:(17,37)=*(17,29),32,32;__data:(17,38)=ar(4,33);0;-1;(17,33),64,0;;__gconv_t:t(17,39)=(17,40)=*(17,36)_G_iconv_t:t(3,5)=(3,6)=u44__cd:(17,36),0,64;__combined:(3,7)=s44__cd:(17,36),0,64;__data:(17,33),64,288;;,0,352;;_G_int16_t:t(3,8)=(0,8)_G_int32_t:t(3,9)=(0,1)_G_uint16_t:t(3,10)=(0,9)_G_uint32_t:t(3,11)=(0,4)_IO_stdin_used:G(0,1)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.95.1 19990816 (release)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)01.0101.0101.0101.0101.0101.0101.01.symtab.strtab.shstrtab.interp.note.ABI-tag.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.plt.text.fini.rodata.data.eh_frame.ctors.dtors.got.dynamic.sbss.bss.stab.stabstr.comment.note# 1((7 ?NGoVVBTo@c ؅l  uІ{0%-  .W /l ///00HH1HH1(H1 8oRjSeTZI b(V؅ І    HH   +2  =AO[ qp P  2          9#ܿ3B D Ld6 [s jhz{ P D "&  - ( 4ؖ > OԞ7 f(4yІ ,.  8p@ HX"Hh! (4 ;xMĔ V)fyHj   ȇ4, ؇](  2* 0qBT"p$ ~\(  (|X 8HH pD 1 'Xh9LN& dhwx 8   $-d initfini.cgcc2_compiled.call_gmon_startinit.ccrtstuff.cp.0__DTOR_LIST__completed.1__do_global_dtors_aux__EH_FRAME_BEGIN__fini_dummyobject.2frame_dummyinit_dummyforce_to_data__CTOR_LIST____do_global_ctors_aux__CTOR_END____DTOR_END____FRAME_END__indexer.cdbfopen.crcsidnStringFieldLenpszStringFieldSfReallocDBFWriteHeaderDBFFlushRecorddDoubleField.24DBFReadAttributeDBFWriteAttributepReturnTuple.67nTupleLen.68str_to_upper_DYNAMIC__register_frame_info@@GLIBC_2.0strcmp@@GLIBC_2.0_fp_hwfprintf@@GLIBC_2.0DBFReadStringAttributeDBFCreateDBFGetFieldIndexDBFReadDoubleAttributetolower@@GLIBC_2.0_initDBFWriteIntegerAttributeDBFGetRecordCountmalloc@@GLIBC_2.0DBFWriteTuplefread@@GLIBC_2.0__deregister_frame_info@@GLIBC_2.0stderr@@GLIBC_2.0fseek@@GLIBC_2.0_startDBFIsAttributeNULLstrlen@@GLIBC_2.0DBFCloseatof@@GLIBC_2.0strncmp@@GLIBC_2.0fputc@@GLIBC_2.0__bss_startmain__libc_start_main@@GLIBC_2.0DBFAddFieldtoupper@@GLIBC_2.0dbf_searchrealloc@@GLIBC_2.0DBFWriteDoubleAttributedata_startprintf@@GLIBC_2.0_finimemcpy@@GLIBC_2.0fclose@@GLIBC_2.1__cxa_finalize@@GLIBC_2.1.3DBFCloneEmptyDBFWriteStringAttributeDBFReadTupleexit@@GLIBC_2.0DBFReadIntegerAttributecalloc@@GLIBC_2.0_edata_GLOBAL_OFFSET_TABLE_free@@GLIBC_2.0_endSoundexDBFGetFieldInfomemset@@GLIBC_2.0__ctype_b@@GLIBC_2.0DBFWriteNULLAttributestrncpy@@GLIBC_2.0fopen@@GLIBC_2.1DBFGetNativeFieldTypeDBFOpenDBFGetFieldCount_IO_stdin_usedsprintf@@GLIBC_2.0fwrite@@GLIBC_2.0__data_start__gmon_start__strcpy@@GLIBC_2.0./geocoder/test.idx0100664000076400007640000000020407441747770013777 0ustar gmadergmaderj520 jones o200 oak s530 smith o200 oak j520 jones e450 elm s530 smith e450 elm e450 elm j520 jones s530 smith o200 oak ./geocoder/indexer.o0100664000076400007640000000521407441747745014140 0ustar gmadergmaderELF4( U}t- huh jE 0xP xPÉU8hhEh#uE}u h& jE u9E| j uuPEPEP Ph6uh:uEPuh<uEX uU j EE}tEEE*2vEE EP‹EEEEE8%}~ EEP‹EEEEbE}U@E1vE1vE1~E1vE2nE2fE2^E2VE2NE2FE2>E26E3.E3&E4E5E5E6E*E:Et#}*tEUŠEEEEEEv}EE}~EE0EEE01.01indexer [shapefile] %dwtest.idxrbpath incorrect %s Pxh\pGCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98).symtab.strtab.shstrtab.text.rel.text.data.bss.note.rodata.rel.rodata.comment4X!  +16<D PP6Yp  0 j&+2l=CK]t|indexer.cgcc2_compiled.mainprintfexitstrcpydbf_searchfopenDBFOpenDBFGetRecordCountDBFReadStringAttributeSoundexfprintffclosemalloctolower &+ 8 O a v{   #+6>P[c{J@DHLPTX\`dhlptx|./geocoder/geocoder_soundex.c0100664000076400007640000002475607442022345016015 0ustar gmadergmader#include #include #include "shapefil.h" #include /* function prototypes*/ int dbf_search(char file[], int addr, char pre_dir[], char st_name[], char st_type[],int *from_addr, int *to_addr); int direction_search(char file[], int to_addr, int from_addr, char pre_dir[], char st_name[], char st_type[],int *flag); void shp_find(char file[],int recno,double *startx, double *starty, double *endx, double *endy); char *Soundex(char *In); char street_soundex[4]; int main( int argc, char ** argv ){ int addr; char pre_dir[10]; char st_name[10]; char st_type[10]; int recno; int adjoin; char file_name[100]; char file_name2[100]; int from_addr; int to_addr; int flag; double startx; double starty; double endx; double endy; double startadjx; double startadjy; double endadjx; double endadjy; double addratio; int flag2; double lengthx; double lengthy; double resultx; double resulty; FILE *defaults1; /* -------------------------------------------------------------------- */ /* Display a usage message. */ /* -------------------------------------------------------------------- */ if( argc != 5 ) { printf("geocode [add# pre_dir st_name st_type]\n" ); printf("%d", argc); exit(1); } /* -------------------------------------------------------------------- */ /* set up user input */ /* -------------------------------------------------------------------- */ addr = atoi(argv[1]); strcpy(pre_dir, argv[2]); strcpy(st_name, argv[3]); strcpy(st_type, argv[4]); if ((defaults1=fopen (".geocoder","r")) == NULL){ printf(".geocoder defaults file not found"); } fgets(file_name, 36, defaults1); fclose(defaults1); recno = dbf_search(file_name, addr, pre_dir, st_name, st_type, &from_addr, &to_addr); adjoin = direction_search(file_name, to_addr, from_addr, pre_dir, st_name, st_type, &flag); shp_find(file_name, recno, &startx, &starty, &endx, &endy); shp_find(file_name, adjoin, &startadjx, &startadjy, &endadjx, &endadjy); /* this part figures the directionality of the arc. It is key, as Shapefiles*/ /* do not maintain directionality. */ addratio = (double)(addr - from_addr)/(double)(to_addr - from_addr); if (flag == 1){ if (endx == startadjx && endy == startadjy){ /* ordered correctly */ flag2 = 1; } if (startx == endadjx && starty == endadjy){ flag2 = 0;} /*ordered backwards */ } if (flag == 0){ if (endx == startadjx && endy == startadjy){ /* ordered backwards */ flag2 = 0; } if (startx == endadjx && starty == endadjy){ flag2 = 1;} /*ordered correctly */ } /* this part figures out the length of the correct arc, and then interpolates the length*/ /* of the address on to the arc. We can get away with applying the address ratio to both*/ /* the x and the y side, as any ratio times zero is zero.*/ /* note: this is currently only for northern hemisphere, lat/long coordinates.*/ /* it will not work right on state plane, UTM, or other coordinate systems. */ lengthx = fabs(startx - endx); lengthy = fabs(endy - starty); if (flag2 ==1){ resultx = startx -(lengthx * addratio); resulty = starty -(lengthy * addratio); } if (flag2 ==0){ resultx = endx +(lengthx * (1 - addratio)); resulty = endy + (lengthy * addratio); } printf("X coord=%f, Y coord =%f\n\n", resultx, resulty); return 0; } /* -------------------------------------------------------------------- */ /*This function searches the DBF for the record that contains the address*/ /* -------------------------------------------------------------------- */ int dbf_search(char file[], int addr, char pre_dir[], char st_name[], char st_type[], int *from_addr, int *to_addr){ DBFHandle handle; int counter2=0; int count; int count2; int iRecord; int holder; int addrange; double addratio; char index_soundex[4]; char index_street[10]; char word[10]; char line[30]; FILE *fp; int counterx = 12; struct address { int recno; int from_address; int to_address; char pre_direction[50]; char street_name[50]; char street_type[50]; }address; struct address candidates[20]; /* need to clean this up and allocate better */ handle = DBFOpen(file,"rb"); if( handle == NULL ) { printf( "path incorrect\n" ); exit( 2 ); } /* open soundex index file */ fp = fopen("test.idx", "r"); strcpy(street_soundex,Soundex(st_name)); printf("%s input soundex\n",street_soundex); while(fgets(line,sizeof(line)-1,fp) !=NULL){ sscanf(line,"%s %s", index_soundex, index_street); if (strcmp(index_soundex,street_soundex)== 0){ strcpy(st_name,index_street);} } fclose(fp); for(iRecord = 0; iRecord < DBFGetRecordCount(handle); iRecord++ ){ /*initial hack at recognizing and loading address struct into array */ if (strcmp(DBFReadStringAttribute(handle, iRecord,12),st_type) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,11),st_name) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,10),pre_dir) == 0){ if (addr >= DBFReadIntegerAttribute(handle, iRecord,8)){ if (addr < DBFReadIntegerAttribute(handle, iRecord,9)){ candidates[counter2].recno = iRecord; candidates[counter2].from_address = DBFReadIntegerAttribute(handle, iRecord,8); candidates[counter2].to_address = DBFReadIntegerAttribute(handle, iRecord,9); strcpy (candidates[counter2].pre_direction,DBFReadStringAttribute(handle, iRecord,10)); strcpy (candidates[counter2].street_name,DBFReadStringAttribute(handle, iRecord,11)); strcpy (candidates[counter2].street_type,DBFReadStringAttribute(handle, iRecord,12)); counter2 = counter2+1; } } } } } } /* -------------------------------------------------------------------- */ /* stuff to pass back to main. */ /* -------------------------------------------------------------------- */ for(iRecord = 0; iRecord < counter2; iRecord++ ){ holder = candidates[iRecord].recno; *from_addr = candidates[iRecord].from_address; *to_addr = candidates[iRecord].to_address; } return holder; } /* -------------------------------------------------------------------- */ /* This function gets the adjoining arc, to determine the direction*/ /* This function sends the result to the next function to get the arc's geometry */ /* -------------------------------------------------------------------- */ int direction_search(char file[], int to_addr, int from_addr, char pre_dir[], char st_name[], char st_type[], int *flag){ DBFHandle handle; int counter2=0; int count; int count2; int iRecord; int holder; int addrange; double addratio; struct address { int recno; int from_address; int to_address; char pre_direction[50]; char street_name[50]; char street_type[50]; }address; struct address candidates[10]; handle = DBFOpen(file,"rb"); if( handle == NULL ) { printf( "path incorrect\n" ); exit( 2 ); } for(iRecord = 0; iRecord < DBFGetRecordCount(handle); iRecord++ ){ /*initial hack at recognizing and loading address struct into array */ if (strcmp(DBFReadStringAttribute(handle, iRecord,12),st_type) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,11),st_name) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,10),pre_dir) == 0){ if (to_addr == DBFReadIntegerAttribute(handle, iRecord,8)){ /* looking for adjacent arc. so, to_addr from desired should equal from_addr on next*/ *flag = 1; /*forward, or the block has the next chunk of addresses */ candidates[counter2].recno = iRecord; holder = candidates[counter2].recno; counter2 = counter2+1; } } } } } /* this is if there is no arc on the one side. We will look for arc on the other side now.*/ if (counter2 == 0){ for(iRecord = 0; iRecord < DBFGetRecordCount(handle); iRecord++ ){ if (strcmp(DBFReadStringAttribute(handle, iRecord,12),st_type) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,11),st_name) == 0){ if (strcmp(DBFReadStringAttribute(handle, iRecord,10),pre_dir) == 0){ if (from_addr == DBFReadIntegerAttribute(handle, iRecord,9)){ /*looking for adjacent arc. so, from_addr from desired should equal to_addr on next*/ candidates[counter2].recno = iRecord; *flag = 0; /*backwards or the block has the last block of addresses. */ holder = candidates[counter2].recno; counter2 = counter2+1; } } } } } } return holder;} /* -------------------------------------------------------------------- */ /* Finds the correct arc */ /* This function takes the record number and returns the geometry of the arc*/ /* -------------------------------------------------------------------- */ void shp_find(char file[],int recno,double *startx, double *starty, double *endx, double *endy){ SHPHandle hSHP; SHPObject *psShape; const char *pszPlus; const char *pszPartType = ""; int j; double xrange; double yrange; hSHP = SHPOpen(file, "rb" ); psShape = SHPReadObject( hSHP, recno ); if( psShape == NULL ) { printf( "no match\n" ); exit( 2 ); } for( j = 0; j < psShape->nVertices; j++ ){ if( j==0){ *startx = psShape->padfX[j]; *starty = psShape->padfY[j]; } if (j==(psShape->nVertices-1)) { *endx = psShape->padfX[j]; *endy = psShape->padfY[j]; } } SHPDestroyObject( psShape ); SHPClose( hSHP ); } /* -------------------------------------------------------------------- */ /*Soundex Function. Used NIST examples to test for correctness, after Knuth*/ /* -------------------------------------------------------------------- */ char *Soundex(char *In){ int Iin, Iout; char C, PrevDig, *Out = (char *)malloc(10); int FullFlag = 0; if (FullFlag) {Iin = 0; Iout = 0; PrevDig = '*';} else {Iin = 1; Iout = 1; Out[0] = tolower(In[0]); PrevDig = Out[0];} while ((In[Iin] != (char)NULL) && (Iout <= 4)) { In[Iin] = tolower(In[Iin]); switch (In[Iin]) { case 'b' : C = '1'; break; case 'p' : C = '1'; break; case 'f' : C = '1'; break; case 'v' : C = '1'; break; case 'c' : C = '2'; break; case 's' : C = '2'; break; case 'k' : C = '2'; break; case 'g' : C = '2'; break; case 'j' : C = '2'; break; case 'q' : C = '2'; break; case 'x' : C = '2'; break; case 'z' : C = '2'; break; case 'd' : C = '3'; break; case 't' : C = '3'; break; case 'l' : C = '4'; break; case 'm' : C = '5'; break; case 'n' : C = '5'; break; case 'r' : C = '6'; break; default : C = '*'; } if ((C != PrevDig) && (C != '*')){ Out[Iout] = C; PrevDig = Out[Iout]; Iout++;} Iin++; } if (Iout < 4)for (Iin=Iout; Iin<4; Iin++)Out[Iin] = '0'; Out[4] = NULL; return Out; } ./geocoder/geocoder_soundex.o0100664000076400007640000001432007442022410016004 0ustar gmadergmaderELF4( U}t- huh( jE  0EE 0EPE 0EPE 0EPh+h-DDu h@Dj$8P DPPEPEPEPu8P EPEPEPEP8P EPPPPu8P xPPPPu8P E)P$X)P$Xݝp݅݅E@t&݅݅E@t Džl݅݅E@t(݅݅xE@t Džl݅݅E@t'݅݅E@t Džl݅݅E@t(݅݅xE@t Džl݅ܥݝ004`d݅ܥݝ004X\lu4݅`܍p݅ݝP݅X܍p݅ݝHlu6ܥp܍`݅ݝP݅X܍p݅ݝH LHTPhb ÍvUEE h|uE}u h jh+hEuPhhhujEPuLEPEPhEPẼhPuEPu뛍v uEv u9E|.j uuuPj uuuPj uuuPjuu9E sj uu9E UUЍ ‹EjuuUЍ j uuUЍ  j uuPU P j uuPU>P j uuPUpPEEEE;E|~UЍEMUЍM UЍEzEÐUXEh|uE}u h jE u9E| j uuuPj uuuPj uuuPupjuu9E uVE UЍ ‹EUЍEEE}.Ev u9E| j uuuPj uuuPj uuuPupj uu9EuVUЍ ‹EE UЍEEEEÐUS4Eh|uEu uE}u h jEUE;B|}u8]MEkARS]MEkARSE@H9Eu8]MEkARS]MEkARSEd u u]ÍvU j EE}tEEE*2vEE EP‹EEEEE8%}~ EEP‹EEEEbE}UE1vE1vE1~E1vE2nE2fE2^E2VE2NE2FE2>E26E3.E3&E4E5E5E6E*E:Et#}*tEUŠEEEEEEv}EE}~EE0EEE01.01geocode [add# pre_dir st_name st_type] %dr.geocoder.geocoder defaults file not foundX coord=%f, Y coord =%f rbpath incorrect test.idx%s input soundex %s %sno match , \  \ \ < D L \  T 4 \ \  \ $ GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98).symtab.strtab.shstrtab.text.rel.text.data.bss.note.rodata.rel.rodata.comment4 !  +16< @ D  P`6Y   %#(/49@FLS ^ o !x  geocoder_soundex.cgcc2_compiled.mainprintfexitatoistrcpyfopenfgetsfclosedbf_searchdirection_searchshp_findDBFOpenSoundexstreet_soundexsscanfstrcmpDBFGetRecordCountDBFReadStringAttributeDBFReadIntegerAttributeSHPOpenSHPReadObjectSHPDestroyObjectSHPClosemalloctolower &+ 8 H d {    T  ;CY^ k ty~   /GhyX 1 Gq 4<RW d w $      0 A \        ,     M ! !   ./geocoder/geocoder_soundex0100775000076400007640000013372307442022410015563 0ustar gmadergmaderELF44 (444zzz  8l|   /lib/ld-linux.so.2GNU%%# "!$    3"&i-N 4V0p@qP" `2p@$d)+Ј4]!28q? "0@+]P`-Iph( -d Љ__gmon_start__libc.so.6strcpyprintf__ctype_bfgetsmemcpy__cxa_finalizetolowermalloccallocatoffprintf__deregister_frame_infofseekstrncmpstrncpyreallocsscanffreadmemset__assert_failstrcmpsprintffclosestderrfputcfwriteexitfopenatoi_IO_stdin_used__libc_start_mainstrlentoupper__register_frame_infofreeGLIBC_2.1.3GLIBC_2.1GLIBC_2.0si Nii Zii d #                                ! " $UAm5 % % h% h% h% h% h % h(% h0% h8p% h@`% hHP% hP@% hX0% h` % hh% hp% hx% h% h% h% h% h% h% h% hp% h`% hP% h@% h0% h % h% h% h1^PTRhhQVhUSP[rtЋ]ÉU uI tt&B   uPt hl  ]ÍvU]ÍUth hl ]Ð&U]ÍU}t- huh jE  0EE 0EPE 0EPqE 0EPZh h DDu h FDj$8P D;PPEPEPEPu8P EPEPEPEP8P EPPPPu8PH xPPPPu8P E)P$X)P$Xݝp݅݅E@t&݅݅E@t Džl݅݅E@t(݅݅xE@t Džl݅݅E@t'݅݅E@t Džl݅݅E@t(݅݅xE@t Džl݅ܥݝ004`d݅ܥݝ004X\lu4݅`܍p݅ݝP݅X܍p݅ݝHlu6ܥp܍`݅ݝP݅X܍p݅ݝH LHTPhB ÍvUEE h\uGE}u h_ jh ho>Eu`Ph Hh hxSujEPuLEPEPhEPẼh P uEPu뛍v uEv uW9E|.j uupVuPj uu@VuPcj uuVuP3juuPU9E sj uu2U9E UUЍ ‹EjuuTUЍ j uuTUЍ  j uuUPU P j uuTPU>P j uuTPUpP{EEEE;E|~UЍEMUЍM UЍEzEÐUXEh\uCE}u h_ jE u]T9E| j uu@SuPcj uuSuP3j uuRuPupjuu$R9E uVE UЍ ‹EUЍEEE}.Ev u%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@ fD@E@@fD@E@(fD@umE@HfD@uXE8tPEUMYR@X EUMYRHX(EUMY RPX0EUMY$RXX8Et&EU;P|aUŰUMuIB fEuUB UMRUZ MM̋UMuIB(fEu UB(vUMRUZ(MM̋UMuI B0fEu UB0t&UMR UZ0MM̋UMuI$B8fEu UB8t&UMR$UZ8MM̋UMuIB@fEuUB@UMRUZ@MM̋UMuIBHfEuUBHUMRUZHMM̋UMuI BPfEuUBPUMR UZPMM̋UMuI$BXfEuUBXUMR$UZXEU e[^]ÍvU$S} |EU ;P} 1EU @; ~8EU @  P P jEU @RERERjEU @R PjhjEEU Pj PEP;= tEPjE8t6E8t.E8t&E8tE8 tE8tE8tj  PE(Pj PE0Pj PEHPj $PEPPo= tE(Pj= tE0Pj= tEHPj= tEPPjj 0PEPj ,PEP= tEPj]= tEPjCEUPjEP‹EPjEP‹EPjEP‹EP jEPx‹EP$EUPjEPT‹EP jEP9‹EPEt&E;E|&EU @Eԍt&EP 4PEP R{EE;E|7= t#EUэH PjE뿋EP4UE8EP UPEPREE;E|7= t#EUэHPjWE뿋EEEE;E|j UЋUщPEUэHPDj UЋUщЍPREUэHP= t#EUэHPj= t#EUэHPj_Et&E‰EE8tE8 tE8t j UPE8PTj UЍPREXP2= tE8Pj= tEXPjEE;E|svj UЋUэJPEUэH P褾= t#EUэH Pj(E냋EUэ MEU P UэJU9j UPE@P j UЍPRE`P= tE@Pj{= tE`Pj^EvE;E|vj UЋUэJPEUэH$PT= t#EUэH$PjE E8tE8t E8tj ,PEP= tEPj}EUPjEP‹EPjEP‹EPjEPͼ‹EP jEP貼‹EP$EE;E|jE‰P0 PEUэHP jE‰P0 PREUэHPλ= t#EUэHPjR= t#EUэHPj&EE‰P0Uj  PE(PAj PE0P$j PEHPj $PEPP= tE(Pj}= tE0Pj`= tEHPjC= tEPPj&E8j UPE8PKj UЍPREXP)= tE8Pj= tEXPjEt&E;E|vj UЋUэJPEUэH P蔹= t#EUэH PjE뀋EUэ MEU P UэJU9j UPE@Pj UЍPRE`Pظ= tE@Pjk= tE`PjNEvE;E|vj UЋUэJPEUэH$PD= t#EUэH$PjEE8tE8t E8 tE@jj(‹EPjj‹EPjj‹EP jjݷ‹EP$j  PEPRfj PEPRI= tEPRj= tEPRjEE8 u@j UPEP R= tEP RjtEEU @E9|js 4 4EvUe[^_]ÍvU(Ex4tEPEPEx8jjER蠫ERjj EPjE_EEUB…}щ)ЈEEPЅ}…}щ)ЈEEPЅ}…}щ)ЈEEPЅ}…}щ)ЈEjjER軪ERjj EPERDExtHEPR艫EPRwEPReEP RSEP$RAEP0R/EP =` t%` P` \ ]ÍvU(EPPR腩EEPEP EP让PUv}~*EUЀ8.tEUЀ8/tEUЀ8\uMɋEUЀ8.u EUEPBPREEPhEPGEPhEPE}u1EPjEPRhEPΩE}u1EP}j<0EEUE@E@E@E@ !E@E@E@E@ E@$E@(E@,E@0E@4U&]USEx~ Ex4u }t}t&E@EPЍREPRUBEPЍREPRUBEPЍREPRgUBEPREP RFUB EUJHAUJEUJU XEUJHPEEUJXPE}uEUJP  PCEUJP  PNEUJ H E@8EPЉREP$ReUB$EUJIʉX$ˉ]E}~EUEE Pĥ *E P諥PE PEP訦vj E PEP莦E UMYJ J}u?EUх}ˉ)ʈEMʅ}EUEUEPREP0R>UB0EPJ]]ÐU(EEE} | EU ;P} 1Jv}| EU;P} 1-EP(;U EP1EPU EH щMjEPERt!EPh@ P虣1ERjEPREP0R责t*EPRh` PP1mEU P(EP0UEU @B;\ ~nSHPType == psSHP->nShapeType || psObject->nSHPType == 0nShapeId == -1 || (nShapeId >= 0 && nShapeId < psSHP->nRecords)0Error in fseek() or fwrite(). ?Y@NullShapePointArcPolygonMultiPointPointZArcZPolygonZMultiPointZPointMArcMPolygonMMultiPointMMultiPatchUnknownShapeType!(07@GPW`gpwTriangleStripTriangleFanOuterRingInnerRingFirstRingRingUnknownPartTyperr+rbrb+r+b%s.dbf%s.DBFwbfseek(%d) failed on DBF file. fread(%d) failed on DBF file. 00000000%%%dd%%%d.%df| $Id: shpopen.c,v 1.33 2001/07/03 12:18:15 warmerda Exp $$Id: dbfopen.c,v 1.37 2001/07/04 05:18:09 warmerda Exp $ &6FVfvƈֈ&6FVfvƉ։  (X N  o`oodd9<Hr0,V1V cV$[Lby !"#3%K&a1x234568 9";B=X>n?@ABCDE F$G;HTIiNQRST9UUVmX[^ehl q r5 uP vm y z } & @ ˔t F  #V Y 4u < C F S Z ^ltMyn4 Lb8wbKL#5LwH8KgLUZ^?awb\r5 7!899S:m dinit.c/usr/src/build/53700-i386/BUILD/glibc-2.2.4/csu/gcc2_compiled.int:t(0,1)=r(0,1);-2147483648;2147483647;char:t(0,2)=r(0,2);0;127;long int:t(0,3)=r(0,3);-2147483648;2147483647;unsigned int:t(0,4)=r(0,4);0000000000000;0037777777777;long unsigned int:t(0,5)=r(0,5);0000000000000;0037777777777;long long int:t(0,6)=@s64;r(0,6);01000000000000000000000;0777777777777777777777;long long unsigned int:t(0,7)=@s64;r(0,7);0000000000000;01777777777777777777777;short int:t(0,8)=@s16;r(0,8);-32768;32767;short unsigned int:t(0,9)=@s16;r(0,9);0;65535;signed char:t(0,10)=@s8;r(0,10);-128;127;unsigned char:t(0,11)=@s8;r(0,11);0;255;float:t(0,12)=r(0,1);4;0;double:t(0,13)=r(0,1);8;0;long double:t(0,14)=r(0,1);12;0;complex int:t(0,15)=s8real:(0,1),0,32;imag:(0,1),32,32;;complex float:t(0,16)=r(0,16);8;0;complex double:t(0,17)=r(0,17);16;0;complex long double:t(0,18)=r(0,18);24;0;__builtin_va_list:t(0,19)=*(0,20)=(0,20)../include/libc-symbols.h/usr/src/build/53700-i386/BUILD/glibc-2.2.4/build-i386-linux/config.h../sysdeps/gnu/_G_config.h../sysdeps/unix/sysv/linux/bits/types.h../include/features.h../include/sys/cdefs.h../misc/sys/cdefs.h/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/stddef.hsize_t:t(8,1)=(0,4)__u_char:t(4,1)=(0,11)__u_short:t(4,2)=(0,9)__u_int:t(4,3)=(0,4)__u_long:t(4,4)=(0,5)__u_quad_t:t(4,5)=(0,7)__quad_t:t(4,6)=(0,6)__int8_t:t(4,7)=(0,10)__uint8_t:t(4,8)=(0,11)__int16_t:t(4,9)=(0,8)__uint16_t:t(4,10)=(0,9)__int32_t:t(4,11)=(0,1)__uint32_t:t(4,12)=(0,4)__int64_t:t(4,13)=(0,6)__uint64_t:t(4,14)=(0,7)__qaddr_t:t(4,15)=(4,16)=*(4,6)__dev_t:t(4,17)=(4,5)__uid_t:t(4,18)=(4,3)__gid_t:t(4,19)=(4,3)__ino_t:t(4,20)=(4,4)__mode_t:t(4,21)=(4,3)__nlink_t:t(4,22)=(4,3)__off_t:t(4,23)=(0,3)__loff_t:t(4,24)=(4,6)__pid_t:t(4,25)=(0,1)__ssize_t:t(4,26)=(0,1)__rlim_t:t(4,27)=(4,4)__rlim64_t:t(4,28)=(4,5)__id_t:t(4,29)=(4,3)__fsid_t:t(4,30)=(4,31)=s8__val:(4,32)=ar(4,33)=r(4,33);0000000000000;0037777777777;;0;1;(0,1),0,64;;__daddr_t:t(4,34)=(0,1)__caddr_t:t(4,35)=(4,36)=*(0,2)__time_t:t(4,37)=(0,3)__useconds_t:t(4,38)=(0,4)__suseconds_t:t(4,39)=(0,3)__swblk_t:t(4,40)=(0,3)__clock_t:t(4,41)=(0,3)__clockid_t:t(4,42)=(0,1)__timer_t:t(4,43)=(0,1)__key_t:t(4,44)=(0,1)__ipc_pid_t:t(4,45)=(0,9)__blksize_t:t(4,46)=(0,3)__blkcnt_t:t(4,47)=(0,3)__blkcnt64_t:t(4,48)=(4,6)__fsblkcnt_t:t(4,49)=(4,4)__fsblkcnt64_t:t(4,50)=(4,5)__fsfilcnt_t:t(4,51)=(4,4)__fsfilcnt64_t:t(4,52)=(4,5)__ino64_t:t(4,53)=(4,5)__off64_t:t(4,54)=(4,24)__t_scalar_t:t(4,55)=(0,3)__t_uscalar_t:t(4,56)=(0,5)__intptr_t:t(4,57)=(0,1)__socklen_t:t(4,58)=(0,4)../linuxthreads/sysdeps/pthread/bits/pthreadtypes.h../sysdeps/unix/sysv/linux/bits/sched.h__sched_param:T(10,1)=s4__sched_priority:(0,1),0,32;;_pthread_fastlock:T(9,1)=s8__status:(0,3),0,32;__spinlock:(0,1),32,32;;_pthread_descr:t(9,2)=(9,3)=*(9,4)=xs_pthread_descr_struct:__pthread_attr_s:T(9,5)=s36__detachstate:(0,1),0,32;__schedpolicy:(0,1),32,32;__schedparam:(10,1),64,32;__inheritsched:(0,1),96,32;__scope:(0,1),128,32;__guardsize:(8,1),160,32;__stackaddr_set:(0,1),192,32;__stackaddr:(0,19),224,32;__stacksize:(8,1),256,32;;pthread_attr_t:t(9,6)=(9,5)pthread_cond_t:t(9,7)=(9,8)=s12__c_lock:(9,1),0,64;__c_waiting:(9,2),64,32;;pthread_condattr_t:t(9,9)=(9,10)=s4__dummy:(0,1),0,32;;pthread_key_t:t(9,11)=(0,4)pthread_mutex_t:t(9,12)=(9,13)=s24__m_reserved:(0,1),0,32;__m_count:(0,1),32,32;__m_owner:(9,2),64,32;__m_kind:(0,1),96,32;__m_lock:(9,1),128,64;;pthread_mutexattr_t:t(9,14)=(9,15)=s4__mutexkind:(0,1),0,32;;pthread_once_t:t(9,16)=(0,1)_pthread_rwlock_t:T(9,17)=s32__rw_lock:(9,1),0,64;__rw_readers:(0,1),64,32;__rw_writer:(9,2),96,32;__rw_read_waiting:(9,2),128,32;__rw_write_waiting:(9,2),160,32;__rw_kind:(0,1),192,32;__rw_pshared:(0,1),224,32;;pthread_rwlock_t:t(9,18)=(9,17)pthread_rwlockattr_t:t(9,19)=(9,20)=s8__lockkind:(0,1),0,32;__pshared:(0,1),32,32;;pthread_spinlock_t:t(9,21)=(0,1)pthread_barrier_t:t(9,22)=(9,23)=s20__ba_lock:(9,1),0,64;__ba_required:(0,1),64,32;__ba_present:(0,1),96,32;__ba_waiting:(9,2),128,32;;pthread_barrierattr_t:t(9,24)=(9,25)=s4__pshared:(0,1),0,32;;pthread_t:t(9,26)=(0,5)wchar_t:t(11,1)=(0,3)wint_t:t(11,2)=(0,4)../include/wchar.h../wcsmbs/wchar.h../sysdeps/unix/sysv/linux/i386/bits/wchar.h__mbstate_t:t(13,1)=(13,2)=s8__count:(0,1),0,32;__value:(13,3)=u4__wch:(11,2),0,32;__wchb:(13,4)=ar(4,33);0;3;(0,2),0,32;;,32,32;;_G_fpos_t:t(3,1)=(3,2)=s12__pos:(4,23),0,32;__state:(13,1),32,64;;_G_fpos64_t:t(3,3)=(3,4)=s16__pos:(4,54),0,64;__state:(13,1),64,64;;../include/gconv.h../iconv/gconv.h :T(17,1)=e__GCONV_OK:0,__GCONV_NOCONV:1,__GCONV_NODB:2,__GCONV_NOMEM:3,__GCONV_EMPTY_INPUT:4,__GCONV_FULL_OUTPUT:5,__GCONV_ILLEGAL_INPUT:6,__GCONV_INCOMPLETE_INPUT:7,__GCONV_ILLEGAL_DESCRIPTOR:8,__GCONV_INTERNAL_ERROR:9,; :T(17,2)=e__GCONV_IS_LAST:1,__GCONV_IGNORE_ERRORS:2,;__gconv_fct:t(17,3)=(17,4)=*(17,5)=f(0,1)__gconv_init_fct:t(17,6)=(17,7)=*(17,8)=f(0,1)__gconv_end_fct:t(17,9)=(17,10)=*(17,11)=f(0,20)__gconv_trans_fct:t(17,12)=(17,13)=*(17,14)=f(0,1)__gconv_trans_context_fct:t(17,15)=(17,16)=*(17,17)=f(0,1)__gconv_trans_query_fct:t(17,18)=(17,19)=*(17,20)=f(0,1)__gconv_trans_init_fct:t(17,21)=(17,22)=*(17,23)=f(0,1)__gconv_trans_end_fct:t(17,24)=(17,25)=*(17,26)=f(0,20)__gconv_trans_data:T(17,27)=s20__trans_fct:(17,12),0,32;__trans_context_fct:(17,15),32,32;__trans_end_fct:(17,24),64,32;__data:(0,19),96,32;__next:(17,28)=*(17,27),128,32;;__gconv_step:T(17,29)=s56__shlib_handle:(17,30)=*(17,31)=xs__gconv_loaded_object:,0,32;__modname:(17,32)=*(0,2),32,32;__counter:(0,1),64,32;__from_name:(4,36),96,32;__to_name:(4,36),128,32;__fct:(17,3),160,32;__init_fct:(17,6),192,32;__end_fct:(17,9),224,32;__min_needed_from:(0,1),256,32;__max_needed_from:(0,1),288,32;__min_needed_to:(0,1),320,32;__max_needed_to:(0,1),352,32;__stateful:(0,1),384,32;__data:(0,19),416,32;;__gconv_step_data:T(17,33)=s36__outbuf:(17,34)=*(0,11),0,32;__outbufend:(17,34),32,32;__flags:(0,1),64,32;__invocation_counter:(0,1),96,32;__internal_use:(0,1),128,32;__statep:(17,35)=*(13,1),160,32;__state:(13,1),192,64;__trans:(17,28),256,32;;__gconv_info:T(17,36)=s8__nsteps:(8,1),0,32;__steps:(17,37)=*(17,29),32,32;__data:(17,38)=ar(4,33);0;-1;(17,33),64,0;;__gconv_t:t(17,39)=(17,40)=*(17,36)_G_iconv_t:t(3,5)=(3,6)=u44__cd:(17,36),0,64;__combined:(3,7)=s44__cd:(17,36),0,64;__data:(17,33),64,288;;,0,352;;_G_int16_t:t(3,8)=(0,8)_G_int32_t:t(3,9)=(0,1)_G_uint16_t:t(3,10)=(0,9)_G_uint32_t:t(3,11)=(0,4)_IO_stdin_used:G(0,1)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.95.1 19990816 (release)GCC: (GNU) 2.95.1 19990816 (release)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)01.0101.0101.0101.0101.0101.0101.0101.01.symtab.strtab.shstrtab.interp.note.ABI-tag.hash.dynsym.dynstr.gnu.version.gnu.version_r.rel.dyn.rel.plt.init.plt.text.fini.rodata.data.eh_frame.ctors.dtors.got.dynamic.sbss.bss.stab.stabstr.comment.note# 1((07 XXP?nGoJTo``@c l  u{Ї kuu  z l l{p p{x x{ { | | |4| |/ȥ S H(X`  Ї    l p x        +2 0 = Ax O [0 ql   Њ p 2 ` ` t  l | l       & 9, 4 =w F(L PtY _ jX x  & 9\ ` FD 6 Ls  {  d h   - 6 G"h&z-(  $  < 7  41_ A G. `0 i {0p\@ @P"  `  p@,>t G)Wj { z    ! Ј4 ](   "24 :qL^| h "$  ( ا  0,X @+P 9 `-, 3 IpY ^ؖ f1 vh 4& ij 8   $-7 CdU bО] j yЉinitfini.cgcc2_compiled.call_gmon_startinit.ccrtstuff.cp.0__DTOR_LIST__completed.1__do_global_dtors_aux__EH_FRAME_BEGIN__fini_dummyobject.2frame_dummyinit_dummyforce_to_data__CTOR_LIST____do_global_ctors_aux__CTOR_END____DTOR_END____FRAME_END__geocoder_soundex.cshpopen.crcsidpabyRecnBufSizeSwapWordSfReallocSHPWriteHeaderbBigEndian_SHPSetBoundsdbfopen.cnStringFieldLenpszStringFieldDBFWriteHeaderDBFFlushRecorddDoubleField.24DBFReadAttributeDBFWriteAttributepReturnTuple.67nTupleLen.68str_to_upperdirection_search_DYNAMICSHPDestroyObject__register_frame_info@@GLIBC_2.0strcmp@@GLIBC_2.0_fp_hwfprintf@@GLIBC_2.0DBFReadStringAttribute__assert_fail@@GLIBC_2.0DBFCreateSHPComputeExtentsDBFGetFieldIndexSHPCreateSimpleObjectDBFReadDoubleAttributetolower@@GLIBC_2.0SHPPartTypeName_initDBFWriteIntegerAttributeSHPCloseDBFGetRecordCountmalloc@@GLIBC_2.0DBFWriteTuplefread@@GLIBC_2.0__deregister_frame_info@@GLIBC_2.0stderr@@GLIBC_2.0street_soundexfseek@@GLIBC_2.0_startDBFIsAttributeNULLfgets@@GLIBC_2.0strlen@@GLIBC_2.0DBFCloseatof@@GLIBC_2.0strncmp@@GLIBC_2.0SHPCreateObjectfputc@@GLIBC_2.0__bss_startmain__libc_start_main@@GLIBC_2.0DBFAddFieldshp_findtoupper@@GLIBC_2.0dbf_searchrealloc@@GLIBC_2.0DBFWriteDoubleAttributedata_startprintf@@GLIBC_2.0_finimemcpy@@GLIBC_2.0fclose@@GLIBC_2.1SHPCreate__cxa_finalize@@GLIBC_2.1.3DBFCloneEmptyDBFWriteStringAttributeSHPGetInfoDBFReadTupleexit@@GLIBC_2.0DBFReadIntegerAttributeatoi@@GLIBC_2.0calloc@@GLIBC_2.0SHPReadObjectsscanf@@GLIBC_2.0_edata_GLOBAL_OFFSET_TABLE_free@@GLIBC_2.0_endSoundexDBFGetFieldInfomemset@@GLIBC_2.0__ctype_b@@GLIBC_2.0DBFWriteNULLAttributestrncpy@@GLIBC_2.0SHPWriteObjectfopen@@GLIBC_2.1DBFGetNativeFieldTypeDBFOpenDBFGetFieldCount_IO_stdin_usedsprintf@@GLIBC_2.0SHPTypeNamefwrite@@GLIBC_2.0__data_startSHPOpen__gmon_start__strcpy@@GLIBC_2.0./geocoder/testscript_soundex.sh0100777000076400007640000000056207442021274016614 0ustar gmadergmader./geocoder_soundex 330 n jones ave ./geocoder_soundex 330 n janas ave ./geocoder_soundex 230 n jones ave ./geocoder_soundex 120 n smith ave ./geocoder_soundex 120 n smeth ave ./geocoder_soundex 175 n smith ave ./geocoder_soundex 650 w elm st ./geocoder_soundex 505 w elm st ./geocoder_soundex 781 w elm st ./geocoder_soundex 550 w oak st ./geocoder_soundex 550 w oek st