org.geotools.feature.NameImpl Java Examples

The following examples show how to use org.geotools.feature.NameImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticFeatureFilterIT.java    From elasticgeo with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testOnlySourceFieldsWithSourceFiltering() throws Exception {
    init();
    dataStore.setSourceFilteringEnabled(true);
    Name name = new NameImpl("active");
    for (final ElasticAttribute attribute : dataStore.getElasticAttributes(name) ){
        if (attribute.isStored()) {
            attribute.setUse(false);
        }
    }
    featureSource = (ElasticFeatureSource) dataStore.getFeatureSource(TYPE_NAME);

    assertEquals(11, featureSource.getCount(Query.ALL));

    SimpleFeatureIterator features = featureSource.getFeatures().features();
    for (int i=0; i<11; i++) {
        assertTrue(features.hasNext());
        features.next();
    }
}
 
Example #2
Source File: ElasticFeatureFilterIT.java    From elasticgeo with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testOnlyStoredFieldsWithSourceFiltering() throws Exception {
    init();
    dataStore.setSourceFilteringEnabled(true);
    Name name = new NameImpl("active");
    for (final ElasticAttribute attribute : dataStore.getElasticAttributes(name) ){
        if (!attribute.isStored()) {
            attribute.setUse(false);
        }
    }
    assertEquals(11, featureSource.getCount(Query.ALL));
    SimpleFeatureIterator features = featureSource.getFeatures().features();
    for (int i=0; i<11; i++) {
        assertTrue(features.hasNext());
        features.next();
    }
}
 
Example #3
Source File: ElasticFeatureFilterIT.java    From elasticgeo with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testOnlySourceFields() throws Exception {
    init();
    Name name = new NameImpl("active");
    for (final ElasticAttribute attribute : dataStore.getElasticAttributes(name) ){
        if (attribute.isStored()) {
            attribute.setUse(false);
        }
    }
    featureSource = (ElasticFeatureSource) dataStore.getFeatureSource(TYPE_NAME);

    assertEquals(11, featureSource.getCount(Query.ALL));

    SimpleFeatureIterator features = featureSource.getFeatures().features();
    for (int i=0; i<11; i++) {
        assertTrue(features.hasNext());
        features.next();
    }
}
 
Example #4
Source File: ElasticFeatureFilterIT.java    From elasticgeo with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testOnlyStoredFields() throws Exception {
    init();
    Name name = new NameImpl("active");
    for (final ElasticAttribute attribute : dataStore.getElasticAttributes(name) ){
        if (!attribute.isStored()) {
            attribute.setUse(false);
        }
    }
    assertEquals(11, featureSource.getCount(Query.ALL));
    SimpleFeatureIterator features = featureSource.getFeatures().features();
    for (int i=0; i<11; i++) {
        assertTrue(features.hasNext());
        features.next();
    }
}
 
Example #5
Source File: ElasticTestSupport.java    From elasticgeo with GNU General Public License v3.0 6 votes vote down vote up
void init(String status, String geometryField) throws Exception {
    indexDocuments(status);
    List<ElasticAttribute> attributes = dataStore.getElasticAttributes(new NameImpl(TYPE_NAME));
    config = new ElasticLayerConfiguration(TYPE_NAME);
    List<ElasticAttribute> layerAttributes = new ArrayList<>();
    for (ElasticAttribute attribute : attributes) {
        attribute.setUse(true);
        if (geometryField.equals(attribute.getName())) {
            ElasticAttribute copy = new ElasticAttribute(attribute);
            copy.setDefaultGeometry(true);
            layerAttributes.add(copy);
        } else {
            layerAttributes.add(attribute);
        }
    }
    config.getAttributes().clear();
    config.getAttributes().addAll(layerAttributes);
    dataStore.setLayerConfiguration(config);
    featureSource = (ElasticFeatureSource) dataStore.getFeatureSource(TYPE_NAME);
}
 
Example #6
Source File: DistributedRenderProcessUtils.java    From geowave with Apache License 2.0 5 votes vote down vote up
public static Expression getRenderingProcess() {
  if (SINGLETON_RENDER_PROCESS == null) {
    final ProcessFactory processFactory =
        new AnnotatedBeanProcessFactory(
            Text.text("Internal GeoWave Process Factory"),
            "internal",
            InternalDistributedRenderProcess.class);
    final Name processName = new NameImpl("internal", "InternalDistributedRender");
    final RenderingProcess process = (RenderingProcess) processFactory.create(processName);
    final Map<String, Parameter<?>> parameters = processFactory.getParameterInfo(processName);
    final InternalProcessFactory factory = new InternalProcessFactory();
    // this is kinda a hack, but the only way to instantiate a process
    // is
    // for it to have a registered process factory, so temporarily
    // register
    // the process factory
    Processors.addProcessFactory(factory);

    SINGLETON_RENDER_PROCESS =
        new RenderingProcessFunction(
            processName,
            Collections.singletonList(
                new ParameterFunction(
                    null,
                    Collections.singletonList(new LiteralExpressionImpl("data")))),
            parameters,
            process,
            null);
    Processors.removeProcessFactory(factory);
  }
  return SINGLETON_RENDER_PROCESS;
}
 
Example #7
Source File: DataSourceInfo.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source File: SldUtilities.java    From hortonmachine with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Converts the type name of all FeatureTypeStyles to Feature so that the all apply to any feature type.  This is admittedly dangerous
 * but is extremely useful because it means that the style can be used with any feature type.
 *
 * @param ftStyles
 */
private static void genericizeftStyles( List<FeatureTypeStyle> ftStyles ) {
    for( FeatureTypeStyle featureTypeStyle : ftStyles ) {
        featureTypeStyle.featureTypeNames().clear();
        featureTypeStyle.featureTypeNames().add(new NameImpl(GENERIC_FEATURE_TYPENAME));
    }
}
 
Example #9
Source File: ElasticFeatureFilterIT.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
@Test @Ignore
public void testSchemaWithoutLayerConfig() throws Exception {
    init();
    ElasticFeatureSource featureSource = new ElasticFeatureSource(new ContentEntry(dataStore, new NameImpl("invalid")),null);
    SimpleFeatureType schema = featureSource.getSchema();        
    assertNotNull(schema);
    assertEquals(0, schema.getAttributeCount());
}
 
Example #10
Source File: ElasticDataStore.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
public ElasticDataStore(RestClient restClient, RestClient proxyRestClient, String indexName, boolean enableRunAs) throws IOException {
    LOGGER.fine("Initializing data store for " + indexName);

    this.indexName = indexName;

    try {
        checkRestClient(restClient);
        if (proxyRestClient != null) {
            checkRestClient(proxyRestClient);
        }
        client = new RestElasticClient(restClient, proxyRestClient, enableRunAs);
    } catch (Exception e) {
        throw new IOException("Unable to create REST client", e);
    }
    LOGGER.fine("Created REST client: " + client);

    final List<String> types = getClient().getTypes(indexName);
    if (!types.isEmpty()) {
        baseTypeNames = types.stream().map(NameImpl::new).collect(Collectors.toList());
    } else {
        baseTypeNames = new ArrayList<>();
    }

    layerConfigurations = new ConcurrentHashMap<>();
    docTypes = new HashMap<>();

    arrayEncoding = ArrayEncoding.JSON;
}
 
Example #11
Source File: ElasticConfigurationPage.java    From elasticgeo with GNU General Public License v3.0 5 votes vote down vote up
private ElasticLayerConfiguration fillElasticAttributes(ResourceInfo ri) {

        ElasticLayerConfiguration layerConfig = (ElasticLayerConfiguration) ri.getMetadata()
                .get(ElasticLayerConfiguration.KEY);

        if (layerConfig == null) {
            layerConfig = new ElasticLayerConfiguration(ri.getName());
            ri.getMetadata().put(ElasticLayerConfiguration.KEY, layerConfig);
        }

        try {
            ElasticDataStore dataStore = (ElasticDataStore) ((DataStoreInfo) ri.getStore())
                    .getDataStore(new NullProgressListener());

            ArrayList<ElasticAttribute> result = new ArrayList<>();
            Map<String, ElasticAttribute> tempMap = new HashMap<>();
            final List<ElasticAttribute> attributes = layerConfig.getAttributes();
            for (ElasticAttribute att : attributes) {
                tempMap.put(att.getName(), att);
            }

            final String docType = layerConfig.getDocType();
            final Name layerName = new NameImpl(layerConfig.getLayerName());
            dataStore.getDocTypes().put(layerName, docType);
            for (ElasticAttribute at : dataStore.getElasticAttributes(layerName)) {
                if (tempMap.containsKey(at.getName())) {
                    at = tempMap.get(at.getName());
                }
                result.add(at);
            }
            layerConfig.getAttributes().clear();
            layerConfig.getAttributes().addAll(result);
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
        }
        Collections.sort(layerConfig.getAttributes());
        return layerConfig;
    }
 
Example #12
Source File: SelectedProcessFunction.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Gets the function name.
 *
 * @return the function name
 */
public Name getFunctionName() {
    if (builtInSelected) {
        if (builtInProcessFunction == null) {
            return null;
        }
        return builtInProcessFunction.getFunctionName();
    } else {
        if (selectedCustomFunction == null) {
            return null;
        }
        return new NameImpl(selectedCustomFunction.getTitle().getValue());
    }
}
 
Example #13
Source File: FieldConfigBase.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #14
Source File: ElasticConfigurationPanel.java    From elasticgeo with GNU General Public License v3.0 4 votes vote down vote up
private void saveLayer(FeatureTypeInfo ft) throws IOException {
    GeoServerApplication app = (GeoServerApplication) getApplication();
    Catalog catalog = app.getCatalog();

    String namespace = ft.getNamespace().getURI();
    Name qualifiedName = new NameImpl(namespace, _layerInfo.getName());
    LayerInfo layerInfo = catalog.getLayerByName(qualifiedName);

    boolean isNew = ft.getId() == null || app.getCatalog().getResource(ft.getId(),ResourceInfo.class) == null;

    FeatureTypeInfo typeInfo;
    if (layerInfo == null || isNew) {
        // New
        DataStoreInfo dsInfo;
        dsInfo = catalog.getStore(ft.getStore().getId(), DataStoreInfo.class);
        ElasticDataStore ds = (ElasticDataStore) dsInfo.getDataStore(null);
        CatalogBuilder builder = new CatalogBuilder(catalog);
        builder.setStore(dsInfo);
        ElasticLayerConfiguration layerConfig;
        layerConfig = new ElasticLayerConfiguration(_layerConfig);
        layerConfig.setLayerName(_layerInfo.getName());
        layerConfig.getAttributes().clear();
        List<ElasticAttribute> attributes = _layerConfig.getAttributes();
        layerConfig.getAttributes().addAll(attributes);
        ds.setLayerConfiguration(layerConfig);

        FeatureTypeInfo _typeInfo = (FeatureTypeInfo) _layerInfo.getResource();
        typeInfo = builder.buildFeatureType(ds.getFeatureSource(qualifiedName));
        typeInfo.setName(_layerInfo.getName());
        typeInfo.getMetadata().put(ElasticLayerConfiguration.KEY, layerConfig);
        typeInfo.setEnabled(_typeInfo.isEnabled());
        typeInfo.setAdvertised(_typeInfo.isAdvertised());
        typeInfo.setTitle(_typeInfo.getTitle());
        typeInfo.setDescription(_typeInfo.getDescription());
        typeInfo.setAbstract(_typeInfo.getAbstract());
        typeInfo.getKeywords().addAll(_typeInfo.getKeywords());
        typeInfo.getMetadataLinks().addAll(_typeInfo.getMetadataLinks());
        typeInfo.getDataLinks().addAll(_typeInfo.getDataLinks());
        typeInfo.setSRS(_typeInfo.getSRS());
        typeInfo.setProjectionPolicy(_typeInfo.getProjectionPolicy());
        typeInfo.setNativeBoundingBox(_typeInfo.getNativeBoundingBox());
        typeInfo.setLatLonBoundingBox(_typeInfo.getLatLonBoundingBox());
        typeInfo.setCircularArcPresent(_typeInfo.isCircularArcPresent());
        typeInfo.setLinearizationTolerance(_typeInfo.getLinearizationTolerance());

        layerInfo = builder.buildLayer(typeInfo);
        builder.updateLayer(layerInfo, _layerInfo);
        layerInfo.setName(_layerInfo.getName());
        layerInfo.setResource(typeInfo);
    } else {
        // Update
        typeInfo = (FeatureTypeInfo) layerInfo.getResource();
        typeInfo.getMetadata().put(ElasticLayerConfiguration.KEY, _layerConfig);
    }
}
 
Example #15
Source File: FunctionTableModelTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Test all the methods using a ProcessBriefType.
 *
 * <p>Not tested because it needs to interact with GeoServer to create a receive a remote custom
 * WPS function.
 */
@SuppressWarnings({"unchecked", "rawtypes"})
@Disabled
@Test
void testProcessBriefType() {
    FunctionTableModel model = new FunctionTableModel();

    assertEquals(0, model.getRowCount());

    model.addNewValue(0);
    ProcessBriefType customFunction = createCustomFunction();

    FunctionName name =
            new FunctionNameImpl(
                    new NameImpl("vec", "PointStacker"),
                    parameter("cellSize", Double.class),
                    new Parameter(
                            "outputBBOX", Number.class, null, null, false, 0, 100, null, null),
                    parameter("outputWidth", Number.class),
                    parameter("outputHeight", Number.class));

    assertFalse(name.getArguments().get(0).isRequired());
    assertTrue(name.getArguments().get(1).isRequired());

    model.populate(customFunction);

    assertEquals(3, model.getRowCount());
    assertEquals(4, model.getColumnCount());

    // Get value
    assertEquals("outputBBOX", model.getValueAt(0, 0));
    assertEquals(Number.class.getSimpleName(), model.getValueAt(0, 1));
    assertEquals(true, model.getValueAt(0, 2));
    assertEquals("env([wms_bbox])", model.getValueAt(0, 3));
    assertNull(model.getValueAt(0, 4));

    // Is editable
    assertFalse(model.isCellEditable(0, 0));
    assertFalse(model.isCellEditable(0, 1));
    assertTrue(model.isCellEditable(0, FunctionTableModel.getOptionalColumn()));
    assertFalse(model.isCellEditable(0, 3));
    assertFalse(model.isCellEditable(0, 4));

    // Set value
    model.setValueAt(true, 0, 2);
    assertTrue((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));
    model.setValueAt(false, 0, 2);
    assertFalse((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));

    // Get row
    assertNull(model.getValue(-1));
    assertNull(model.getValue(10));

    // Add a new value
    assertEquals(0, model.getNoOfOccurences(null));
    ProcessFunctionParameterValue value = model.getValue(0);
    assertEquals(1, model.getNoOfOccurences(value));
    model.addNewValue(0);
    assertEquals(4, model.getRowCount());

    assertEquals(2, model.getNoOfOccurences(value));

    // Remove value
    model.removeValue(3);
    assertEquals(3, model.getRowCount());

    // Get expression
    ProcessFunction actualFunction = model.getExpression(null);
    assertNull(actualFunction);

    model.setValueAt(true, 0, FunctionTableModel.getOptionalColumn());

    ProcessFunctionFactory factory = new ProcessFunctionFactory();
    actualFunction = model.getExpression(factory);
    assertNotNull(actualFunction);

    // Update expression
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();

    Expression expression = ff.literal(4.2);
    model.update(expression, 0);
    model.update(null, 1);
}
 
Example #16
Source File: FunctionTableModelTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/** Test all the methods using a ProcessFunction */
@SuppressWarnings({"unchecked", "rawtypes"})
@Test
void testProcessFunction() {
    FunctionTableModel model = new FunctionTableModel();

    assertEquals(0, model.getRowCount());

    model.addNewValue(0);
    ProcessFunction processFunction = createProcessFunction();

    FunctionName name =
            new FunctionNameImpl(
                    new NameImpl("vec", "PointStacker"),
                    parameter("cellSize", Double.class),
                    new Parameter(
                            "outputBBOX", Number.class, null, null, false, 0, 100, null, null),
                    parameter("outputWidth", Number.class),
                    parameter("outputHeight", Number.class));

    assertFalse(name.getArguments().get(0).isRequired());
    assertTrue(name.getArguments().get(1).isRequired());

    model.populate(name, processFunction);

    assertEquals(3, model.getRowCount());
    assertEquals(4, model.getColumnCount());

    // Get value
    assertEquals("outputBBOX", model.getValueAt(0, 0));
    assertEquals(Number.class.getSimpleName(), model.getValueAt(0, 1));
    assertEquals(true, model.getValueAt(0, 2));
    assertEquals("env([wms_bbox])", model.getValueAt(0, 3));
    assertNull(model.getValueAt(0, 4));

    // Is editable
    assertFalse(model.isCellEditable(0, 0));
    assertFalse(model.isCellEditable(0, 1));
    assertTrue(model.isCellEditable(0, FunctionTableModel.getOptionalColumn()));
    assertFalse(model.isCellEditable(0, 3));
    assertFalse(model.isCellEditable(0, 4));

    // Set value
    model.setValueAt(true, 0, 2);
    assertTrue((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));
    model.setValueAt(false, 0, 2);
    assertFalse((Boolean) model.getValueAt(0, FunctionTableModel.getOptionalColumn()));

    // Get row
    assertNull(model.getValue(-1));
    assertNull(model.getValue(10));

    // Add a new value
    assertEquals(0, model.getNoOfOccurences(null));
    ProcessFunctionParameterValue value = model.getValue(0);
    assertEquals(1, model.getNoOfOccurences(value));
    model.addNewValue(0);
    assertEquals(4, model.getRowCount());

    assertEquals(2, model.getNoOfOccurences(value));

    // Remove value
    model.removeValue(3);
    assertEquals(3, model.getRowCount());

    // Get expression
    ProcessFunction actualFunction = model.getExpression(null);
    assertNull(actualFunction);

    model.setValueAt(true, 0, FunctionTableModel.getOptionalColumn());

    ProcessFunctionFactory factory = new ProcessFunctionFactory();
    actualFunction = model.getExpression(factory);
    assertNotNull(actualFunction);

    // Update expression
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();

    Expression expression = ff.literal(4.2);
    model.update(expression, 0);
    model.update(null, 1);
}
 
Example #17
Source File: FieldConfigBaseTest.java    From sldeditor with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression)}.
 * Test method for {@link
 * com.sldeditor.ui.detail.config.FieldConfigBase#populate(org.opengis.filter.expression.Expression,
 * org.opengis.filter.expression.Expression)}.
 */
@Test
public void testPopulateExpressionExpression() {
    FieldIdEnum expectedFieldId = FieldIdEnum.NAME;
    String expectedLabel = "test label";
    TestFieldConfigBase field =
            new TestFieldConfigBase(
                    new FieldConfigCommonData(
                            String.class, expectedFieldId, expectedLabel, false, false));

    AttributeSelection attributeSelectionPanel =
            AttributeSelection.createAttributes(String.class, field, false);
    field.testAttributeSelectionPanel(attributeSelectionPanel);

    TestUpdateSymbolInterface listener = new TestUpdateSymbolInterface();
    field.addDataChangedListener(listener);

    assertFalse(listener.hasBeenCalled());
    FilterFactory ff = CommonFactoryFinder.getFilterFactory();

    // Test function
    DefaultFunctionFactory functionFactory = new DefaultFunctionFactory();
    FunctionName functionName = null;

    for (FunctionName func : functionFactory.getFunctionNames()) {
        if (func.getName() == "greaterThan") {
            functionName = func;
            break;
        }
    }

    assertNotNull(functionName);

    Expression testExpression =
            ff.function(functionName.getFunctionName(), ff.literal(1), ff.literal(2));
    field.populate(testExpression);
    // Updated because the attribute pulldown changed
    assertTrue(listener.hasBeenCalled());

    assertEquals(ExpressionTypeEnum.E_EXPRESSION, field.getExpressionType());
    Expression expression = field.getExpression();
    assertTrue(expression.toString().startsWith(functionName.getName()));

    // Attribute expression wrapped in a literal expression
    String testAttributeName = "test attribute";
    NameImpl name = new NameImpl(testAttributeName);
    AttributeExpressionImpl attributeExpression = new AttributeExpressionImpl(name);

    Expression literalExpression = ff.literal(attributeExpression);
    field.populate(literalExpression);
    assertEquals(ExpressionTypeEnum.E_ATTRIBUTE, field.getExpressionType());

    // Process Function
    // ProcessFunctionFactory factory = new ProcessFunctionFactory();
    // FunctionTableModel functionParameterTableModel = new FunctionTableModel();
    // ProcessFunction processFunction = functionParameterTableModel.getExpression(factory);
    // field.populate(processFunction);
    // assertEquals(ExpressionTypeEnum.E_VALUE, field.getExpressionType());
}
 
Example #18
Source File: CorrelativeFieldSelector.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Name getName() {
    return new NameImpl(NULL_NAME);
}
 
Example #19
Source File: GeoWaveGTDataStore.java    From geowave with Apache License 2.0 4 votes vote down vote up
@Override
public ContentFeatureSource getFeatureSource(final String typeName, final Transaction tx)
    throws IOException {
  return super.getFeatureSource(new NameImpl(null, typeName), tx);
}