if (!file.exists()) {
logger.info("Creating shapefile " + file.getAbsolutePath());
} else {
logger.info("Using shapefile " + file.getAbsolutePath());
}
IndexedShapefileDataStore ids = new IndexedShapefileDataStore(file.toURI().toURL(), new URI("http://geonetwork.org"), false, false, IndexType.QIX, Charset.forName(Constants.ENCODING));
CoordinateReferenceSystem crs = CRS.decode("EPSG:4326");
if (crs != null) {
ids.forceSchemaCRS(crs);
}
if (!file.exists()) {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
AttributeDescriptor geomDescriptor = new AttributeTypeBuilder().crs(DefaultGeographicCRS.WGS84).binding(MultiPolygon.class).buildDescriptor("the_geom");
builder.setName(SpatialIndexWriter._SPATIAL_INDEX_TYPENAME);
builder.add(geomDescriptor);
builder.add(SpatialIndexWriter._IDS_ATTRIBUTE_NAME, String.class);
ids.createSchema(builder.buildFeatureType());
}
logger.info("NOTE: Using shapefile for spatial index, this can be slow for larger catalogs");
return ids;
}