use of org.opengis.feature.type.AttributeType in project spatial-portal by AtlasOfLivingAustralia.
the class AreaUploadShapefileWizardController method loadShape.
private void loadShape(String filename) {
CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
try {
FileDataStore store = FileDataStoreFinder.getDataStore(new File(filename));
source = store.getFeatureSource();
features = source.getFeatures();
Listhead lhd = new Listhead();
SimpleFeatureType schema = features.getSchema();
Listheader lh = new Listheader(StringConstants.ID);
lh.setParent(lhd);
for (AttributeType at : schema.getTypes()) {
if (schema.getDescriptor(at.getName()) == null) {
continue;
}
lh = new Listheader(at.getName().toString());
lh.setParent(lhd);
}
lhd.setParent(lAttributes);
SimpleFeatureIterator fi = features.features();
while (fi.hasNext()) {
SimpleFeature f = fi.next();
Listitem li = new Listitem();
Listcell lc;
String value;
// add identifier
lc = new Listcell(f.getIdentifier().getID());
lc.setParent(li);
for (AttributeType at : schema.getTypes()) {
if (schema.getDescriptor(at.getName()) == null) {
continue;
}
Object obj = f.getAttribute(at.getName());
if (obj == null) {
value = f.getID();
} else {
value = String.valueOf(obj);
}
lc = new Listcell(value);
lc.setParent(li);
}
li.setValue(f.getIdentifier());
li.setParent(lAttributes);
}
// loadFeatures
// check if only a single feature,
// if so, then select it and map it automatically
LOGGER.debug("features.size(): " + features.size());
if (features.size() > 1) {
executeShapeImageRenderer(null);
} else {
LOGGER.debug("only a single feature, bypassing wizard...");
fi = features.features();
Set<FeatureId> ids = new HashSet<FeatureId>();
ids.add(fi.next().getIdentifier());
loadOnMap(ids, filename);
// echo detach
Events.echoEvent("onClick$btnCancel", this, null);
}
try {
fi.close();
} catch (Exception e) {
}
} catch (IOException e) {
LOGGER.debug("IO Exception ", e);
} catch (Exception e) {
LOGGER.debug("Generic exception", e);
}
}
use of org.opengis.feature.type.AttributeType in project sldeditor by robward-scisys.
the class ExtendedSimpleFeatureTypeBuilder method createAttributeDescriptor.
/**
* Creates the attribute descriptor.
*
* @param name the name
* @param binding the binding
* @return the attribute descriptor
*/
public AttributeDescriptor createAttributeDescriptor(String name, Class<?> binding) {
AttributeDescriptor descriptor = null;
attributeBuilder.setBinding(binding);
attributeBuilder.setName(name);
//
if ((defaultGeometry != null && defaultGeometry.equals(name)) || Geometry.class.isAssignableFrom(binding)) {
// if no crs was set, set to defaultCRS
if (!attributeBuilder.isCRSSet()) {
if (defaultCrs == null && !defaultCrsSet) {
String message = String.format("Creating %s with null CoordinateReferenceSystem - did you mean to setCRS?", name);
LOGGER.fine(message);
}
attributeBuilder.setCRS(defaultCrs);
}
GeometryType type = attributeBuilder.buildGeometryType();
descriptor = attributeBuilder.buildDescriptor(name, type);
} else {
AttributeType type = attributeBuilder.buildType();
descriptor = attributeBuilder.buildDescriptor(name, type);
}
return (descriptor);
}
use of org.opengis.feature.type.AttributeType in project sldeditor by robward-scisys.
the class DataSourceInfo method getPropertyDescriptorList.
/**
* Gets the property descriptor list.
*
* @return the property descriptor list
*/
public Collection<PropertyDescriptor> getPropertyDescriptorList() {
if (schema != null) {
return schema.getDescriptors();
} else {
if (geometryType == GeometryTypeEnum.RASTER) {
if (rasterPropertyDescriptorList == null) {
rasterPropertyDescriptorList = new ArrayList<>();
CoordinateReferenceSystem crs = null;
boolean isIdentifiable = false;
boolean isAbstract = false;
List<Filter> restrictions = null;
AttributeType superType = null;
InternationalString description = null;
GeometryType type = featureTypeFactory.createGeometryType(new NameImpl(RASTER_GEOMETRY_FIELD), GridCoverage2D.class, crs, isIdentifiable, isAbstract, restrictions, superType, description);
GeometryDescriptor descriptor = featureTypeFactory.createGeometryDescriptor(type, new NameImpl(RASTER_GEOMETRY_FIELD), 0, 1, false, null);
rasterPropertyDescriptorList.add(descriptor);
}
return rasterPropertyDescriptorList;
}
}
return null;
}
Aggregations