Search in sources :

Example 21 with NameImpl

use of org.geotools.feature.NameImpl in project polymap4-core by Polymap4.

the class P4DataStoreInfo method canHandle.

/**
 * Returns a newly created {@link P4DataStoreInfo}, or null if the layer is not
 * connected to a {@link FeatureStore}.
 *
 * @throws Exception
 */
public static P4DataStoreInfo canHandle(Catalog catalog, ILayer layer) throws Exception {
    GeoServerServlet server = GeoServerServlet.instance.get();
    Optional<Pipeline> pipeline = server.getOrCreatePipeline(layer, FeaturesProducer.class);
    if (pipeline.isPresent()) {
        PipelineFeatureSource fs = new PipelineDataStore(pipeline.get()).getFeatureSource();
        // check with P4FeatureTypeInfo
        Name name = new NameImpl(GeoServerUtils.defaultNsInfo.get().getName(), GeoServerUtils.simpleName(layer.label.get()));
        Params params = new Params();
        FeatureRenameProcessor.NAME.rawput(params, name);
        PipelineProcessorSite procSite = new PipelineProcessorSite(params);
        ProcessorDescriptor proc = new ProcessorDescriptor(FeatureRenameProcessor.class, params);
        proc.processor().init(procSite);
        fs.pipeline().addFirst(proc);
        return new P4DataStoreInfo(catalog, layer, fs);
    } else {
        return null;
    }
}
Also used : NameImpl(org.geotools.feature.NameImpl) PipelineProcessorSite(org.polymap.core.data.pipeline.PipelineProcessorSite) PipelineFeatureSource(org.polymap.core.data.PipelineFeatureSource) GeoServerServlet(org.polymap.service.geoserver.GeoServerServlet) Params(org.polymap.core.data.pipeline.PipelineProcessorSite.Params) ProcessorDescriptor(org.polymap.core.data.pipeline.ProcessorDescriptor) Pipeline(org.polymap.core.data.pipeline.Pipeline) PipelineDataStore(org.polymap.core.data.PipelineDataStore) Name(org.opengis.feature.type.Name)

Example 22 with NameImpl

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

the class CswRecordMapperFilterVisitorTest method setUpBeforeClass.

@BeforeClass
public static void setUpBeforeClass() throws Exception {
    factory = new FilterFactoryImpl();
    attrExpr = factory.property(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, UNMAPPED_PROPERTY, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
    created = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, Core.CREATED, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
    attributeRegistry = new AttributeRegistryImpl();
    attributeRegistry.registerMetacardType(CswQueryFactoryTest.getCswMetacardType());
    visitor = new CswRecordMapperFilterVisitor(DEFAULT_CSW_RECORD_MAP, attributeRegistry);
}
Also used : NameImpl(org.geotools.feature.NameImpl) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) QName(javax.xml.namespace.QName) AttributeRegistryImpl(ddf.catalog.data.impl.AttributeRegistryImpl) FilterFactoryImpl(org.geotools.filter.FilterFactoryImpl) BeforeClass(org.junit.BeforeClass)

Example 23 with NameImpl

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

the class CswRecordMapperFilterVisitorTest method testVisitWithMappedName.

@Test
public void testVisitWithMappedName() {
    AttributeExpressionImpl propName = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, CswConstants.CSW_ALTERNATIVE, CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
    CswRecordMapperFilterVisitor visitor = new CswRecordMapperFilterVisitor(DEFAULT_CSW_RECORD_MAP, attributeRegistry);
    PropertyName propertyName = (PropertyName) visitor.visit(propName, null);
    assertThat(propertyName.getPropertyName(), is(Core.TITLE));
    assertThat(propertyName.getPropertyName(), not(is(CswConstants.CSW_ALTERNATIVE)));
}
Also used : NameImpl(org.geotools.feature.NameImpl) PropertyName(org.opengis.filter.expression.PropertyName) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) QName(javax.xml.namespace.QName) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 24 with NameImpl

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

the class CswRecordMapperFilterVisitorTest method testVisitPropertyIsGreaterThanTemporal.

@Test
public void testVisitPropertyIsGreaterThanTemporal() {
    Expression val = factory.literal(new Date(System.currentTimeMillis() - 1000));
    Expression test = new AttributeExpressionImpl(new NameImpl(new QName(CswConstants.DUBLIN_CORE_SCHEMA, "TestDate", CswConstants.DUBLIN_CORE_NAMESPACE_PREFIX)));
    PropertyIsGreaterThan filter = factory.greater(test, val);
    Object obj = visitor.visit(filter, null);
    assertThat(obj, instanceOf(PropertyIsGreaterThan.class));
    PropertyIsGreaterThan duplicate = (PropertyIsGreaterThan) obj;
    assertThat(duplicate.getExpression1(), is(test));
    assertThat(duplicate.getExpression2(), is(val));
}
Also used : NameImpl(org.geotools.feature.NameImpl) Expression(org.opengis.filter.expression.Expression) AttributeExpressionImpl(org.geotools.filter.AttributeExpressionImpl) QName(javax.xml.namespace.QName) Date(java.util.Date) PropertyIsGreaterThan(org.opengis.filter.PropertyIsGreaterThan) CswQueryFactoryTest(org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest) Test(org.junit.Test)

Example 25 with NameImpl

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

the class StyleServiceImpl method getSelectedStyle.

/**
 * Convert the given style for selection
 *
 * @param fts the feature type style to convert
 *
 * @return the converted feature type style
 */
private FeatureTypeStyle getSelectedStyle(FeatureTypeStyle fts) {
    List<Rule> rules = fts.rules();
    List<Rule> newRules = new ArrayList<Rule>();
    for (Rule rule : rules) {
        Symbolizer[] symbolizers = rule.getSymbolizers();
        List<Symbolizer> newSymbolizers = new ArrayList<Symbolizer>();
        for (Symbolizer symbolizer : symbolizers) {
            // get symbolizers
            List<Symbolizer> addSymbolizers = getSelectionSymbolizers(symbolizer);
            if (addSymbolizers != null) {
                newSymbolizers.addAll(addSymbolizers);
            }
        }
        // create new rule
        Rule newRule = styleBuilder.createRule(newSymbolizers.toArray(new Symbolizer[newSymbolizers.size()]));
        newRule.setFilter(rule.getFilter());
        newRule.setElseFilter(rule.isElseFilter());
        newRule.setName(rule.getName());
        newRules.add(newRule);
    }
    // TODO Handle case if there is more than one featureTypeName
    return styleBuilder.createFeatureTypeStyle(fts.featureTypeNames().stream().findFirst().orElse(new NameImpl("Feature")).getLocalPart(), newRules.toArray(new Rule[newRules.size()]));
}
Also used : NameImpl(org.geotools.feature.NameImpl) ArrayList(java.util.ArrayList) Rule(org.geotools.styling.Rule) LineSymbolizer(org.geotools.styling.LineSymbolizer) PolygonSymbolizer(org.geotools.styling.PolygonSymbolizer) Symbolizer(org.geotools.styling.Symbolizer) PointSymbolizer(org.geotools.styling.PointSymbolizer)

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