use of org.geotools.feature.NameImpl in project ddf by codice.
the class TestCswRecordMapperFilterVisitor method testVisitWithBoundingBoxProperty.
@Test
public void testVisitWithBoundingBoxProperty() {
AttributeExpressionImpl propName = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, CswConstants.OWS_BOUNDING_BOX, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
CswRecordMapperFilterVisitor visitor = new CswRecordMapperFilterVisitor(metacardType, mockMetacardTypeList);
PropertyName propertyName = (PropertyName) visitor.visit(propName, null);
assertThat(propertyName.getPropertyName(), is(Metacard.ANY_GEO));
}
use of org.geotools.feature.NameImpl in project GeoGig by boundlessgeo.
the class GeoGigDataStoreTest method testGetSchemaProvidedNamespace.
@Test
public void testGetSchemaProvidedNamespace() throws Exception {
String namespace = "http://www.geogig.org/test";
dataStore.setNamespaceURI(namespace);
insertAndAdd(lines1);
commit();
SimpleFeatureType lines = dataStore.getSchema(RepositoryTestCase.linesTypeName);
Name expectedName = new NameImpl(namespace, linesName);
assertEquals(expectedName, lines.getName());
assertEquals(super.linesType.getAttributeDescriptors(), lines.getAttributeDescriptors());
insertAndAdd(points1);
commit();
SimpleFeatureType points = dataStore.getSchema(RepositoryTestCase.pointsTypeName);
assertEquals(new NameImpl(namespace, pointsName), points.getName());
assertEquals(super.pointsType.getAttributeDescriptors(), points.getAttributeDescriptors());
}
use of org.geotools.feature.NameImpl in project GeoGig by boundlessgeo.
the class ImportOp method forceFeatureTypeName.
private SimpleFeatureType forceFeatureTypeName(SimpleFeatureType featureType, String path) {
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setAttributes(featureType.getAttributeDescriptors());
builder.setName(new NameImpl(featureType.getName().getNamespaceURI(), path));
builder.setCRS(featureType.getCoordinateReferenceSystem());
featureType = builder.buildFeatureType();
return featureType;
}
use of org.geotools.feature.NameImpl in project GeoGig by boundlessgeo.
the class OracleExport method runInternal.
/**
* Executes the export command using the provided options.
*
* @param cli
*/
@Override
protected void runInternal(GeogigCLI cli) throws IOException {
if (args.isEmpty()) {
printUsage(cli);
throw new CommandFailedException();
}
String path = args.get(0);
String tableName = args.get(1);
checkParameter(tableName != null && !tableName.isEmpty(), "No table name specified");
DataStore dataStore = getDataStore();
ObjectId featureTypeId = null;
if (!Arrays.asList(dataStore.getTypeNames()).contains(tableName)) {
SimpleFeatureType outputFeatureType;
if (sFeatureTypeId != null) {
// Check the feature type id string is a correct id
Optional<ObjectId> id = cli.getGeogig().command(RevParse.class).setRefSpec(sFeatureTypeId).call();
checkParameter(id.isPresent(), "Invalid feature type reference", sFeatureTypeId);
TYPE type = cli.getGeogig().command(ResolveObjectType.class).setObjectId(id.get()).call();
checkParameter(type.equals(TYPE.FEATURETYPE), "Provided reference does not resolve to a feature type: ", sFeatureTypeId);
outputFeatureType = (SimpleFeatureType) cli.getGeogig().command(RevObjectParse.class).setObjectId(id.get()).call(RevFeatureType.class).get().type();
featureTypeId = id.get();
} else {
try {
SimpleFeatureType sft = getFeatureType(path, cli);
outputFeatureType = new SimpleFeatureTypeImpl(new NameImpl(tableName), sft.getAttributeDescriptors(), sft.getGeometryDescriptor(), sft.isAbstract(), sft.getRestrictions(), sft.getSuper(), sft.getDescription());
} catch (GeoToolsOpException e) {
throw new CommandFailedException("No features to export.", e);
}
}
try {
dataStore.createSchema(outputFeatureType);
} catch (IOException e) {
throw new CommandFailedException("Cannot create new table in database", e);
}
} else {
if (!overwrite) {
throw new CommandFailedException("The selected table already exists. Use -o to overwrite");
}
}
SimpleFeatureSource featureSource = dataStore.getFeatureSource(tableName);
if (!(featureSource instanceof SimpleFeatureStore)) {
throw new CommandFailedException("Can't write to the selected table");
}
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
if (overwrite) {
try {
featureStore.removeFeatures(Filter.INCLUDE);
} catch (IOException e) {
throw new CommandFailedException("Error accessing table: " + e.getMessage(), e);
}
}
ExportOp op = cli.getGeogig().command(ExportOp.class).setFeatureStore(featureStore).setPath(path).setFilterFeatureTypeId(featureTypeId).setAlter(alter);
if (defaultType) {
op.exportDefaultFeatureType();
}
try {
op.setProgressListener(cli.getProgressListener()).call();
} catch (IllegalArgumentException iae) {
throw new org.locationtech.geogig.cli.InvalidParameterException(iae.getMessage(), iae);
} catch (GeoToolsOpException e) {
switch(e.statusCode) {
case MIXED_FEATURE_TYPES:
throw new CommandFailedException("The selected tree contains mixed feature types. Use --defaulttype or --featuretype <feature_type_ref> to export.", e);
default:
throw new CommandFailedException("Could not export. Error:" + e.statusCode.name(), e);
}
}
cli.getConsole().println(path + " exported successfully to " + tableName);
}
use of org.geotools.feature.NameImpl in project polymap4-core by Polymap4.
the class SchemaCoder method gmlDecode.
public FeatureType gmlDecode(String input) throws Exception {
GML coder = new GML(GML.Version.WFS1_1);
coder.setEncoding(ENCODING);
File f = File.createTempFile(getClass().getName(), "xsd");
try {
FileUtils.write(f, input, ENCODING);
URL url = f.toURI().toURL();
// find name
Matcher match = COMPLEX_TYPE.matcher(input);
if (!match.find()) {
throw new IllegalStateException("No <xsd:complexType name=... found.");
}
String name = match.group(1);
return coder.decodeSimpleFeatureType(url, new NameImpl(name));
} finally {
f.delete();
}
}
Aggregations