@Override public boolean canRead(ImportData data) throws IOException { File file = getFileFromData(data); return file.canRead() && "kml".equalsIgnoreCase(FilenameUtils.getExtension(file.getName())); }
@Override public boolean canRead(ImportData data) throws IOException { File file = getFileFromData(data); return file.canRead() && "kml".equalsIgnoreCase(FilenameUtils.getExtension(file.getName())); }
@SuppressWarnings("rawtypes") @Override public FeatureReader read(ImportData data, ImportTask task) throws IOException { File file = getFileFromData(data); // we need to get the feature type, to use for the particular parse through the file // since we put it on the metadata from the list method, we first check if that's still // available SimpleFeatureType ft = (SimpleFeatureType) task.getMetadata().get(FeatureType.class); if (ft == null) { // if the type is not available, we can generate one from the resource // we aren't able to ask for the feature type from the resource directly, // because we don't have a backing store FeatureTypeInfo fti = (FeatureTypeInfo) task.getLayer().getResource(); ft = buildFeatureTypeFromInfo(fti); MetadataMap metadata = fti.getMetadata(); if (metadata.containsKey("importschemanames")) { Map<Object, Object> userData = ft.getUserData(); userData.put("schemanames", metadata.get("importschemanames")); } } return read(ft, file); }
@Override public List<ImportTask> list(ImportData data, Catalog catalog, ProgressMonitor monitor) throws IOException { File file = getFileFromData(data); CatalogBuilder cb = new CatalogBuilder(catalog); String baseName = typeNameFromFile(file);
@Override public List<ImportTask> list(ImportData data, Catalog catalog, ProgressMonitor monitor) throws IOException { File file = getFileFromData(data); CatalogBuilder cb = new CatalogBuilder(catalog); String baseName = typeNameFromFile(file);
@SuppressWarnings("rawtypes") @Override public FeatureReader read(ImportData data, ImportTask task) throws IOException { File file = getFileFromData(data); // we need to get the feature type, to use for the particular parse through the file // since we put it on the metadata from the list method, we first check if that's still available SimpleFeatureType ft = (SimpleFeatureType) task.getMetadata().get(FeatureType.class); if (ft == null) { // if the type is not available, we can generate one from the resource // we aren't able to ask for the feature type from the resource directly, // because we don't have a backing store FeatureTypeInfo fti = (FeatureTypeInfo) task.getLayer().getResource(); SimpleFeatureTypeBuilder ftb = new SimpleFeatureTypeBuilder(); ftb.setName(fti.getName()); List<AttributeTypeInfo> attributes = fti.getAttributes(); for (AttributeTypeInfo attr : attributes) { ftb.add(attr.getName(), attr.getBinding()); } ft = ftb.buildFeatureType(); MetadataMap metadata = fti.getMetadata(); if (metadata.containsKey("importschemanames")) { Map<Object, Object> userData = ft.getUserData(); userData.put("schemanames", metadata.get("importschemanames")); } } return read(ft, file); }