Search in sources :

Example 26 with NameImpl

use of org.geotools.feature.NameImpl in project hale by halestudio.

the class StyleHelper method getRandomStyles.

/**
 * Returns a default style for the given type.
 *
 * @param dataSetTypes type definitions associated to their data set
 * @return the style
 */
public static Style getRandomStyles(SetMultimap<DataSet, TypeDefinition> dataSetTypes) {
    int defWidth = StylePreferences.getDefaultWidth();
    Style style = styleFactory.createStyle();
    for (Entry<DataSet, TypeDefinition> entry : dataSetTypes.entries()) {
        DataSet dataSet = entry.getKey();
        TypeDefinition typeDef = entry.getValue();
        FeatureTypeStyle fts;
        // TODO based on default geometry?
        // polygon is always OK as it contains stroke and fill
        // Color color = generateRandomColor(Color.WHITE);
        float saturation;
        float brightness;
        switch(dataSet) {
            case TRANSFORMED:
                saturation = 0.8f;
                brightness = 0.6f;
                break;
            case SOURCE:
            default:
                saturation = 0.75f;
                brightness = 0.8f;
                break;
        }
        Color color = generateRandomColor(saturation, brightness);
        fts = createPolygonStyle(color, defWidth);
        fts.featureTypeNames().add(new NameImpl(getFeatureTypeName(typeDef)));
        style.featureTypeStyles().add(fts);
    }
    return style;
}
Also used : NameImpl(org.geotools.feature.NameImpl) DataSet(eu.esdihumboldt.hale.common.instance.model.DataSet) Color(java.awt.Color) Style(org.geotools.styling.Style) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle) TypeDefinition(eu.esdihumboldt.hale.common.schema.model.TypeDefinition)

Example 27 with NameImpl

use of org.geotools.feature.NameImpl in project hale by halestudio.

the class StyleHelper method getDefaultStyle.

/**
 * Returns a default style for the given type.
 *
 * @param typeDef the type definition
 * @param dataSet the data set (if known)
 * @return the style
 */
public static FeatureTypeStyle getDefaultStyle(TypeDefinition typeDef, @Nullable DataSet dataSet) {
    // GeometrySchemaService gss = (GeometrySchemaService) PlatformUI.getWorkbench().getService(GeometrySchemaService.class);
    // List<QName> geomPath = gss.getDefaultGeometry(typeDef);
    // TODO determine default style from default geometry?
    Color defColor;
    if (dataSet != null) {
        defColor = StylePreferences.getDefaultColor(dataSet);
    } else {
        defColor = Color.DARK_GRAY;
    }
    int defWidth = StylePreferences.getDefaultWidth();
    FeatureTypeStyle result;
    // XXX for now create a polygon style in any case, as it contains fill
    // and stroke
    // if (type != null) {
    // if (type.isAssignableFrom(Polygon.class)
    // || type.isAssignableFrom(MultiPolygon.class)) {
    result = createPolygonStyle(defColor, defWidth);
    // } else if (type.isAssignableFrom(LineString.class)
    // || type.isAssignableFrom(MultiLineString.class)) {
    // result = createLineStyle(defColor, defWidth);
    // } else {
    // result = createPointStyle(defColor, defWidth);
    // }
    // }
    // else {
    // result = createPointStyle(defColor, defWidth);
    // }
    // XXX StyleBuilder does not support feature type names with namespace
    // QName name = getFeatureTypeName(typeDef);
    // result.featureTypeNames().add(new NameImpl(name.getNamespaceURI(), name.getLocalPart()));
    result.featureTypeNames().add(new NameImpl(getFeatureTypeName(typeDef)));
    return result;
}
Also used : NameImpl(org.geotools.feature.NameImpl) Color(java.awt.Color) FeatureTypeStyle(org.geotools.styling.FeatureTypeStyle)

Example 28 with NameImpl

use of org.geotools.feature.NameImpl in project ddf by codice.

the class CswQueryFactory method normalizeSortBy.

private SortBy normalizeSortBy(SortBy cswSortBy) {
    if (cswSortBy == null || cswSortBy.getPropertyName() == null) {
        return null;
    }
    String propertyName = cswSortBy.getPropertyName().getPropertyName();
    if (propertyName == null) {
        LOGGER.debug("Property in SortBy Field is null");
        return null;
    }
    NamespaceSupport namespaceContext = cswSortBy.getPropertyName().getNamespaceContext();
    if (!attributeRegistry.lookup(propertyName).isPresent() && !cswRecordMap.hasProperty(propertyName, namespaceContext)) {
        LOGGER.debug("Property {} is not a valid SortBy Field", propertyName);
        return null;
    }
    String name = cswRecordMap.getProperty(propertyName, namespaceContext);
    PropertyName propName = new AttributeExpressionImpl(new NameImpl(name));
    return new SortByImpl(propName, cswSortBy.getSortOrder());
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) NameImpl(org.geotools.feature.NameImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) SortByImpl(ddf.catalog.filter.impl.SortByImpl) NamespaceSupport(org.xml.sax.helpers.NamespaceSupport)

Example 29 with NameImpl

use of org.geotools.feature.NameImpl in project ddf by codice.

the class CswQueryFactory method buildSort.

private SortBy[] buildSort(SortByType sort) throws CswException {
    if (sort == null || sort.getSortProperty() == null) {
        return null;
    }
    SortBy[] sortByArr = parseSortBy(sort);
    if (sortByArr == null || sortByArr.length == 0) {
        return null;
    }
    List<SortBy> sortBys = new ArrayList<>(sortByArr.length);
    for (SortBy cswSortBy : sortByArr) {
        if (cswSortBy.getPropertyName() == null) {
            LOGGER.debug("No property name in primary sort criteria");
            return null;
        }
        String name = cswSortBy.getPropertyName().getPropertyName();
        PropertyName propName = new AttributeExpressionImpl(new NameImpl(name));
        SortBy sortBy = new SortByImpl(propName, cswSortBy.getSortOrder());
        sortBys.add(sortBy);
    }
    if (sortBys.isEmpty()) {
        return null;
    }
    return sortBys.toArray(new SortBy[0]);
}
Also used : PropertyName(org.opengis.filter.expression.PropertyName) NameImpl(org.geotools.feature.NameImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) SortByImpl(ddf.catalog.filter.impl.SortByImpl) SortBy(org.opengis.filter.sort.SortBy) ArrayList(java.util.ArrayList)

Example 30 with NameImpl

use of org.geotools.feature.NameImpl in project sldeditor by robward-scisys.

the class FieldConfigBase method attributeUpdated.

/**
 * Attribute updated.
 *
 * @param attributeName the attribute name
 */
@Override
public void attributeUpdated(String attributeName) {
    expressionType = ExpressionTypeEnum.E_ATTRIBUTE;
    NameImpl name = new NameImpl(attributeName);
    setCachedExpression(new AttributeExpressionImpl(name));
    setValueFieldState();
    fireDataChanged();
}
Also used : NameImpl(org.geotools.feature.NameImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl)

Aggregations

NameImpl (org.geotools.feature.NameImpl)34 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)13 QName (javax.xml.namespace.QName)9 Test (org.junit.Test)7 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)6 Expression (org.opengis.filter.expression.Expression)6 PropertyName (org.opengis.filter.expression.PropertyName)6 IOException (java.io.IOException)5 SimpleFeatureType (org.opengis.feature.simple.SimpleFeatureType)5 DataStore (org.geotools.data.DataStore)4 SimpleFeatureSource (org.geotools.data.simple.SimpleFeatureSource)4 SimpleFeatureStore (org.geotools.data.simple.SimpleFeatureStore)4 FeatureTypeStyle (org.geotools.styling.FeatureTypeStyle)4 Name (org.opengis.feature.type.Name)4 Color (java.awt.Color)3 SimpleFeatureTypeImpl (org.geotools.feature.simple.SimpleFeatureTypeImpl)3 Test (org.junit.jupiter.api.Test)3 ObjectId (org.locationtech.geogig.api.ObjectId)3 TYPE (org.locationtech.geogig.api.RevObject.TYPE)3 CommandFailedException (org.locationtech.geogig.cli.CommandFailedException)3