public void createIndex(String inFile){
  String ssxFile=null;
  String shpFile=null;
  if (inFile.endsWith(".shp")) {
    shpFile=inFile;
    ssxFile=ssx(shpFile);
  }
 else   if (inFile.endsWith(".ssx")) {
    ssxFile=inFile;
    shpFile=ssxFile.substring(0,ssxFile.indexOf(".ssx")) + ".shp";
  }
 else {
    return;
  }
  byte fileHeader[]=new byte[SHAPE_FILE_HEADER_LENGTH];
  FileInputStream shp=null;
  FileOutputStream ssx=null;
  int shapeType;
  try {
    shp=new FileInputStream(shpFile);
    ssx=new FileOutputStream(ssxFile);
    shp.read(fileHeader,0,SHAPE_FILE_HEADER_LENGTH);
    ssx.write(fileHeader,0,SHAPE_FILE_HEADER_LENGTH);
    shapeType=readLEInt(fileHeader,32);
switch (shapeType) {
case SHAPE_TYPE_NULL:
      indexNulls(shp,SHAPE_FILE_HEADER_LENGTH,ssx);
    break;
case SHAPE_TYPE_POINT:
case SHAPE_TYPE_POINTZ:
case SHAPE_TYPE_POINTM:
  indexPoints(shp,SHAPE_FILE_HEADER_LENGTH,ssx);
break;
case SHAPE_TYPE_MULTIPOINT:
case SHAPE_TYPE_MULTIPOINTZ:
case SHAPE_TYPE_MULTIPOINTM:
case SHAPE_TYPE_POLYLINE:
case SHAPE_TYPE_POLYLINEZ:
case SHAPE_TYPE_POLYLINEM:
case SHAPE_TYPE_POLYGON:
case SHAPE_TYPE_POLYGONZ:
case SHAPE_TYPE_POLYGONM:
indexPolygons(shp,SHAPE_FILE_HEADER_LENGTH,ssx);
break;
default :
logger.warning("Unknown shape type: " + shapeType);
}
}
 catch (java.io.IOException e) {
e.printStackTrace();
}
 finally {
try {
if (shp != null) shp.close();
if (ssx != null) ssx.close();
}
 catch (java.io.IOException e) {
}
}
}

public void createIndex ( String inFile ) { String ssxFile = null ; String shpFile = null ; if ( inFile . endsWith ( ".shp" ) ) { shpFile = inFile ; ssxFile = ssx ( shpFile ) ; } else if ( inFile . endsWith ( ".ssx" ) ) { ssxFile = inFile ; shpFile = ssxFile . substring ( 0 , ssxFile . indexOf ( ".ssx" ) ) + ".shp" ; } else { return ; } byte fileHeader [ ] = new byte [ SHAPE_FILE_HEADER_LENGTH ] ; FileInputStream shp = null ; FileOutputStream ssx = null ; int shapeType ; try { shp = new FileInputStream ( shpFile ) ; ssx = new FileOutputStream ( ssxFile ) ; shp . read ( fileHeader , 0 , SHAPE_FILE_HEADER_LENGTH ) ; ssx . write ( fileHeader , 0 , SHAPE_FILE_HEADER_LENGTH ) ; shapeType = readLEInt ( fileHeader , 32 ) ; switch ( shapeType ) { case SHAPE_TYPE_NULL : indexNulls ( shp , SHAPE_FILE_HEADER_LENGTH , ssx ) ; break ; case SHAPE_TYPE_POINT : case SHAPE_TYPE_POINTZ : case SHAPE_TYPE_POINTM : indexPoints ( shp , SHAPE_FILE_HEADER_LENGTH , ssx ) ; break ; case SHAPE_TYPE_MULTIPOINT : case SHAPE_TYPE_MULTIPOINTZ : case SHAPE_TYPE_MULTIPOINTM : case SHAPE_TYPE_POLYLINE : case SHAPE_TYPE_POLYLINEZ : case SHAPE_TYPE_POLYLINEM : case SHAPE_TYPE_POLYGON : case SHAPE_TYPE_POLYGONZ : case SHAPE_TYPE_POLYGONM : indexPolygons ( shp , SHAPE_FILE_HEADER_LENGTH , ssx ) ; break ; default : logger . warning ( "Unknown shape type: " + shapeType ) ; } } catch ( java . io . IOException e ) { e . printStackTrace ( ) ; } finally { try { if ( shp != null ) shp . close ( ) ; if ( ssx != null ) ssx . close ( ) ; } catch ( java . io . IOException e ) { } } }
creates a spatial index for a shape file . reads the records from the shape file , writing appropriate index records to the spatial index file .
