org.opengis.feature.type.PropertyDescriptor Java Examples
The following examples show how to use
org.opengis.feature.type.PropertyDescriptor.
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: DataSourceImpl.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Populate field map for the data source. */ private void populateFieldMap() { if(dataSourceInfo != null) { geometryFieldName = dataSourceInfo.getGeometryFieldName(); fieldNameMap.clear(); fieldTypeMap.clear(); logger.debug("Datasource fields:"); int index = 0; Collection<PropertyDescriptor> descriptorList = dataSourceInfo.getPropertyDescriptorList(); if(descriptorList != null) { for(PropertyDescriptor property : descriptorList) { logger.debug(String.format(" %-20s %s", property.getName(), property.getType().getBinding().getName())); fieldNameMap.put(index, property.getName()); fieldTypeMap.put(index, property.getType().getBinding()); index ++; } } } }
Example #2
Source File: DataSourceImpl.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Gets the attributes. * * @param expectedDataType the expected data type * @return the attributes */ /* (non-Javadoc) * @see com.sldeditor.datasource.impl.DataSourceInterface#getAttributes(java.lang.Class) */ @Override public List<String> getAttributes(Class<?> expectedDataType) { List<String> attributeNameList = new ArrayList<String>(); Collection<PropertyDescriptor> descriptorList = getPropertyDescriptorList(); if(descriptorList != null) { for(PropertyDescriptor property : descriptorList) { Class<?> bindingType = property.getType().getBinding(); if(AllowedAttributeTypes.isAllowed(bindingType, expectedDataType)) { attributeNameList.add(property.getName().toString()); } } } return attributeNameList; }
Example #3
Source File: DataSourceInfo.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** Populate field map for the data source. */ public void populateFieldMap() { fieldNameMap.clear(); fieldTypeMap.clear(); logger.debug("Datasource fields:"); int index = 0; Collection<PropertyDescriptor> descriptorList = getPropertyDescriptorList(); if (descriptorList != null) { for (PropertyDescriptor property : descriptorList) { if (property != null) { logger.debug( String.format( " %-20s %s", property.getName(), property.getType().getBinding().getName())); fieldNameMap.put(index, property.getName()); fieldTypeMap.put(index, property.getType().getBinding()); } index++; } } }
Example #4
Source File: DataSourceImpl.java From sldeditor with GNU General Public License v3.0 | 6 votes |
/** * Gets the attributes. * * @param expectedDataType the expected data type * @return the attributes */ /* * (non-Javadoc) * * @see com.sldeditor.datasource.impl.DataSourceInterface#getAttributes(java.lang.Class) */ @Override public List<String> getAttributes(Class<?> expectedDataType) { List<String> attributeNameList = new ArrayList<>(); Collection<PropertyDescriptor> descriptorList = getPropertyDescriptorList(); if (descriptorList != null) { for (PropertyDescriptor property : descriptorList) { Class<?> bindingType = property.getType().getBinding(); if (AllowedAttributeTypes.isAllowed(bindingType, expectedDataType)) { attributeNameList.add(property.getName().toString()); } } } return attributeNameList; }
Example #5
Source File: DataSourceImpl.java From sldeditor with GNU General Public License v3.0 | 6 votes |
@Override public List<String> getAllAttributes(boolean includeGeometry) { List<String> attributeNameList = new ArrayList<>(); Collection<PropertyDescriptor> descriptorList = getPropertyDescriptorList(); if (descriptorList != null) { for (PropertyDescriptor property : descriptorList) { boolean isGeometry = (property instanceof GeometryDescriptor); if ((isGeometry && includeGeometry) || !isGeometry) { attributeNameList.add(property.getName().toString()); } } } return attributeNameList; }
Example #6
Source File: DataSourceInfo.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Gets the property descriptor list. * * @return the property descriptor list */ public Collection<PropertyDescriptor> getPropertyDescriptorList() { if(schema != null) { return schema.getDescriptors(); } return null; }
Example #7
Source File: ShapeFileViewer.java From gama with GNU General Public License v3.0 | 5 votes |
@Override public void saveAsCSV() { final List<String> attributes = new ArrayList<>(); for (final PropertyDescriptor v : layer.getFeatureSource().getSchema().getDescriptors()) { attributes.add(v.getName().toString()); } saveAsCSV(attributes, null, null); }
Example #8
Source File: DataSourceInfoTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Test method for {@link * com.sldeditor.datasource.impl.DataSourceInfo#getPropertyDescriptorList()}. */ @SuppressWarnings({"unchecked", "rawtypes"}) @Test public void testGetPropertyDescriptorList() { URL url = SLDEditorFile.class .getClassLoader() .getResource("point/sld/shp/sld_cookbook_point.shp"); Map map = new HashMap(); map.put("url", url); DataStore dataStore; try { dataStore = DataStoreFinder.getDataStore(map); DataSourceInfo dsInfo = new DataSourceInfo(); String typeName = dataStore.getTypeNames()[0]; dsInfo.setTypeName(typeName); SimpleFeatureSource source = dataStore.getFeatureSource(typeName); SimpleFeatureType schema = source.getSchema(); assertNull(dsInfo.getPropertyDescriptorList()); dsInfo.setSchema(schema); Collection<PropertyDescriptor> fieldList = dsInfo.getPropertyDescriptorList(); assertTrue(fieldList.size() == 3); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } }
Example #9
Source File: DataSourceImplTest.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** Test method for {@link com.sldeditor.datasource.impl.DataSourceImpl#connect()}. */ @Test public void testConnectToInlineDataSource() { DataSourceImpl ds = new DataSourceImpl(); DummyInlineSLDFile editorFile = new DummyInlineSLDFile(); DummyDataSourceUpdate dataSourceUpdateListener = new DummyDataSourceUpdate(); ds.addListener(dataSourceUpdateListener); CreateDataSourceInterface internalDataSource = new DummyCreateDataSource(); CreateDataSourceInterface externalDataSource = new DummyCreateDataSource(); CreateDataSourceInterface inlineDataSource = new CreateInlineDataSource(); ds.setDataSourceCreation(internalDataSource, externalDataSource, inlineDataSource); ds.connect("typeName", editorFile, null); assertTrue(dataSourceUpdateListener.hasBeenCalled()); assertEquals(GeometryTypeEnum.UNKNOWN, dataSourceUpdateListener.geometryType); assertFalse(dataSourceUpdateListener.isConnectedToDataSourceFlag); Collection<PropertyDescriptor> fieldList = ds.getPropertyDescriptorList(); assertNull(fieldList); FeatureSource<SimpleFeatureType, SimpleFeature> exampleLayer = ds.getExampleFeatureSource(); assertNull(exampleLayer); Map<UserLayer, FeatureSource<SimpleFeatureType, SimpleFeature>> userLayerMap = ds.getUserLayerFeatureSource(); assertEquals(1, userLayerMap.size()); assertFalse(dataSourceUpdateListener.hasBeenCalled()); ds.updateUserLayers(); assertTrue(dataSourceUpdateListener.hasBeenCalled()); DataSourcePropertiesInterface dsi = ds.getDataConnectorProperties(); assertNotNull(dsi); }
Example #10
Source File: DataSourceImpl.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Gets the property descriptor list. * * @return the property descriptor list */ @Override public Collection<PropertyDescriptor> getPropertyDescriptorList() { if (dataSourceInfo != null) { return dataSourceInfo.getPropertyDescriptorList(); } return null; }
Example #11
Source File: DataSourceInfo.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * 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 #12
Source File: DataSourceImpl.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Gets the property descriptor list. * * @return the property descriptor list */ @Override public Collection<PropertyDescriptor> getPropertyDescriptorList() { if(dataSourceInfo != null) { return dataSourceInfo.getPropertyDescriptorList(); } return null; }
Example #13
Source File: DataSourceFactoryTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Override public Collection<PropertyDescriptor> getPropertyDescriptorList() { return null; }
Example #14
Source File: DataSourceImplTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Test method for {@link com.sldeditor.datasource.impl.DataSourceImpl#connect()}. Test method * for {@link * com.sldeditor.datasource.impl.DataSourceImpl#addListener(com.sldeditor.datasource.DataSourceUpdatedInterface)}. */ @Test public void testConnectToInternalDataSource() { DataSourceImpl ds = new DataSourceImpl(); DummyInternalSLDFile editorFile = new DummyInternalSLDFile(); DummyDataSourceUpdate dataSourceUpdateListener = new DummyDataSourceUpdate(); ds.addListener(dataSourceUpdateListener); ds.addListener(dataSourceUpdateListener); CreateDataSourceInterface internalDataSource = new CreateInternalDataSource(); CreateDataSourceInterface externalDataSource = new DummyCreateDataSource(); CreateDataSourceInterface inlineDataSource = new DummyCreateDataSource(); ds.setDataSourceCreation(internalDataSource, externalDataSource, inlineDataSource); ds.connect("typeName", editorFile, null); assertEquals(GeometryTypeEnum.POINT, dataSourceUpdateListener.geometryType); assertFalse(dataSourceUpdateListener.isConnectedToDataSourceFlag); Collection<PropertyDescriptor> fieldList = ds.getPropertyDescriptorList(); assertTrue(fieldList != null); List<String> actualFieldnameList = new ArrayList<String>(); for (PropertyDescriptor field : fieldList) { if (!(field instanceof GeometryDescriptorImpl)) { actualFieldnameList.add(field.getName().getLocalPart()); } } // Check fields extracted ok List<String> expectedFieldList = editorFile.getExpectedFieldList(); assertTrue(expectedFieldList.size() == actualFieldnameList.size()); // Not assuming fields are in the same order int count = 0; for (String fieldName : actualFieldnameList) { if (expectedFieldList.contains(fieldName)) { count++; } } assertTrue(expectedFieldList.size() == count); // Check for fields of certain types assertFalse(ds.getAttributes(Integer.class).isEmpty()); assertFalse(ds.getAttributes(Double.class).isEmpty()); assertEquals(2, ds.getAttributes(String.class).size()); // Add new field DataSourceAttributeData dataSourceField = new DataSourceAttributeData("bearing", Double.class, null); ds.addField(dataSourceField); assertTrue(ds.getAttributes(Double.class).size() == 2); // Update field DataSourceAttributeList attributeData = new DataSourceAttributeList(); ds.readAttributes(null); ds.readAttributes(attributeData); assertTrue(ds.getPropertyDescriptorList().size() == attributeData.getData().size()); List<DataSourceAttributeData> attributeDataList = attributeData.getData(); DataSourceAttributeData data = attributeDataList.remove(2); data.setType(Integer.class); attributeDataList.add(2, data); ds.updateFields(null); ds.updateFields(attributeData); List<String> actualAttributes = ds.getAttributes(Integer.class); assertTrue(actualAttributes.size() == 2); FeatureSource<SimpleFeatureType, SimpleFeature> features = ds.getFeatureSource(); try { assertEquals(1, features.getFeatures().size()); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } assertFalse(dataSourceUpdateListener.isConnectedToDataSourceFlag); ds.removeListener(dataSourceUpdateListener); assertFalse(dataSourceUpdateListener.isConnectedToDataSourceFlag); }
Example #15
Source File: DataSourceImplTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** Test method for {@link com.sldeditor.datasource.impl.DataSourceImpl#connect()}. */ @Test public void testConnectToExternalDataSource() { DataSourceImpl ds = new DataSourceImpl(); DummyExternalSLDFile editorFile = new DummyExternalSLDFile(); DummyDataSourceUpdate dataSourceUpdateListener = new DummyDataSourceUpdate(); ds.addListener(dataSourceUpdateListener); CreateDataSourceInterface internalDataSource = new DummyCreateDataSource(); CreateDataSourceInterface externalDataSource = new CreateExternalDataSource(); CreateDataSourceInterface inlineDataSource = new DummyCreateDataSource(); ds.setDataSourceCreation(internalDataSource, externalDataSource, inlineDataSource); ds.connect(editorFile.getTypeName(), editorFile, null); assertEquals(GeometryTypeEnum.POINT, dataSourceUpdateListener.geometryType); assertTrue(dataSourceUpdateListener.isConnectedToDataSourceFlag); Collection<PropertyDescriptor> fieldList = ds.getPropertyDescriptorList(); assertTrue(fieldList != null); List<String> actualFieldnameList = new ArrayList<String>(); for (PropertyDescriptor field : fieldList) { actualFieldnameList.add(field.getName().getLocalPart()); } // Check fields extracted ok List<String> expectedFieldList = editorFile.getExpectedFieldList(); assertTrue(expectedFieldList.size() == actualFieldnameList.size()); // Not assuming fields are in the same order int count = 0; for (String fieldName : actualFieldnameList) { if (expectedFieldList.contains(fieldName)) { count++; } } assertTrue(expectedFieldList.size() == count); // Check for fields of certain types assertEquals(1, ds.getAttributes(Integer.class).size()); assertEquals(1, ds.getAttributes(Long.class).size()); assertEquals(1, ds.getAttributes(Double.class).size()); assertEquals(1, ds.getAttributes(String.class).size()); // Add new field - shouldn't work because connections to external data sources are fixed DataSourceAttributeData dataSourceField = new DataSourceAttributeData("bearing", Double.class, null); ds.addField(dataSourceField); assertTrue(ds.getAttributes(Double.class).size() == 1); // Update field DataSourceAttributeList attributeData = new DataSourceAttributeList(); ds.readAttributes(attributeData); assertTrue(ds.getPropertyDescriptorList().size() == attributeData.getData().size()); List<DataSourceAttributeData> attributeDataList = attributeData.getData(); DataSourceAttributeData data = attributeDataList.remove(2); data.setType(Integer.class); attributeDataList.add(2, data); // Update fields - shouldn't work because connections to external data sources are fixed ds.updateFields(attributeData); assertTrue(ds.getAttributes(Integer.class).size() == 1); FeatureSource<SimpleFeatureType, SimpleFeature> features = ds.getFeatureSource(); try { assertTrue(features.getFeatures().size() > 1); } catch (IOException e) { e.printStackTrace(); fail(e.getMessage()); } assertFalse(dataSourceUpdateListener.isConnectedToDataSourceFlag); }
Example #16
Source File: EnvironmentVariablePanelTest.java From sldeditor with GNU General Public License v3.0 | 4 votes |
@Override public Collection<PropertyDescriptor> getPropertyDescriptorList() { return null; }
Example #17
Source File: ShapefileMappingGenerator.java From GeoTriples with Apache License 2.0 | 4 votes |
public void run() throws IOException { Map<String, URL> connect = new HashMap<String, URL>(); connect.put("url", new File(pathToShapefile).toURI().toURL()); DataStore dataStore = DataStoreFinder.getDataStore(connect); String[] typeNames = dataStore.getTypeNames(); for (int i = 0; i < typeNames.length; ++i) { String typeName = typeNames[i]; triplesMaps.put(typeName, ""); triplesMaps.put(typeName, triplesMaps.get(typeName) + printTriplesMap(typeName)); triplesMaps.put(typeName, triplesMaps.get(typeName) + printLogicalSource(typeName)); triplesMaps.put(typeName, triplesMaps.get(typeName) + printSubjectMap(baseURI, typeName)); FeatureSource<?, ?> featureSource = dataStore.getFeatureSource(typeName); FeatureType ft = featureSource.getSchema(); String typeNameGeo = typeNames[i] + "_Geometry"; for (PropertyDescriptor property : ft.getDescriptors()) { String identifier = property.getName().getLocalPart(); if (identifier.equals("the_geom")) { continue; } String datatype = TranslateDataTypeToXSD((property.getType().getBinding().getName())); Query q = new Query(); triplesMaps.put(typeName, triplesMaps.get(typeName) + printPredicateObjectMap(identifier, identifier, datatype, typeName)); } // triplesMaps.put(typeName, // triplesMaps.get(typeName) + printPredicateObjectMap(true, // "hasGeometry", // baseURI + (baseURI.endsWith("/") ? "" : "/") + typeNameGeo + // "/{GeoTriplesID}", null, // typeName, true)); triplesMaps .put(typeName, triplesMaps.get(typeName) + printPredicateObjectMap(true, "hasGeometry", baseURI + (baseURI.endsWith("/") ? "" : "/") + typeName + "/Geometry/{GeoTriplesID}", null, null, "ogc", null, typeName, true, false)); triplesMaps.put(typeNameGeo, ""); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printTriplesMap(typeNameGeo)); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printLogicalSource(typeName)); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printSubjectMap(baseURI, typeName, null, true)); triplesMaps.put(typeNameGeo, triplesMaps.get(typeNameGeo) + printGEOPredicateObjectMaps()); } printmapping(); printontology(); }
Example #18
Source File: ShapeFileParser.java From GeoTriples with Apache License 2.0 | 4 votes |
public List<TableDef> getTablesDefs() throws Exception { DataStore dataStore = null; List<ColumnDef> columns = null; TableDef onlytable = null; Set<Key> primkeys = new HashSet<Key>(); List<TableDef> tables = new ArrayList<TableDef>(); try { Map<String, URL> connect = new HashMap<String, URL>(); connect.put("url", shapefile.toURI().toURL()); dataStore = DataStoreFinder.getDataStore(connect); String[] typeNames = dataStore.getTypeNames(); for (int i = 0; i < typeNames.length; ++i) { String typeName = typeNames[i]; FeatureSource<?, ?> featureSource = dataStore .getFeatureSource(typeName); FeatureType ft = featureSource.getSchema(); columns = new ArrayList<ColumnDef>(); for (PropertyDescriptor property : ft.getDescriptors()) { Identifier identifier = Identifier.createDelimited(property .getName().getLocalPart()); DataType datatype = TableDefUtils.TranslateDataTypeToSQLType((property .getType().getBinding().getName())); ColumnDef col = new ColumnDef(identifier, datatype, property.isNillable()); columns.add(col); } //Identifier identifier = Identifier.createDelimited("gid"); //ColumnDef col = new ColumnDef(identifier, TranslateDataTypeToSQLType("Int"), false); //columns.add(col); //primkeys.add(Key.create(identifier)); TableName tablename = TableName.create(null, null, Identifier.create(true, dataStore.getTypeNames()[0])); onlytable = new TableDef(tablename, columns, null, primkeys, new HashSet<ForeignKey>()); tables.add(onlytable); } } catch (Throwable e) { throw new Exception(e.getMessage()); } finally { dataStore.dispose(); } return tables; }
Example #19
Source File: ShapeFileParserGDAL.java From GeoTriples with Apache License 2.0 | 4 votes |
public List<TableDef> getTablesDefs() throws Exception { DataStore dataStore = null; List<ColumnDef> columns = null; TableDef onlytable = null; Set<Key> primkeys = new HashSet<Key>(); List<TableDef> tables = new ArrayList<TableDef>(); try { Map<String, URL> connect = new HashMap<String, URL>(); connect.put("url", shapefile.toURI().toURL()); dataStore = DataStoreFinder.getDataStore(connect); String[] typeNames = dataStore.getTypeNames(); for (int i = 0; i < typeNames.length; ++i) { String typeName = typeNames[i]; FeatureSource<?, ?> featureSource = dataStore.getFeatureSource(typeName); FeatureType ft = featureSource.getSchema(); columns = new ArrayList<ColumnDef>(); for (PropertyDescriptor property : ft.getDescriptors()) { Identifier identifier = Identifier.createDelimited(property.getName().getLocalPart()); DataType datatype = TableDefUtils .TranslateDataTypeToSQLType((property.getType().getBinding().getName())); ColumnDef col = new ColumnDef(identifier, datatype, property.isNillable()); columns.add(col); } // Identifier identifier = Identifier.createDelimited("gid"); // ColumnDef col = new ColumnDef(identifier, // TranslateDataTypeToSQLType("Int"), false); // columns.add(col); // primkeys.add(Key.create(identifier)); TableName tablename = TableName.create(null, null, Identifier.create(true, dataStore.getTypeNames()[0])); onlytable = new TableDef(tablename, columns, null, primkeys, new HashSet<ForeignKey>()); tables.add(onlytable); } } catch (Throwable e) { throw new Exception(e.getMessage()); } finally { dataStore.dispose(); } return tables; }
Example #20
Source File: DataSourceInterface.java From sldeditor with GNU General Public License v3.0 | 2 votes |
/** * Gets the property descriptor list. * * @return the property descriptor list */ Collection<PropertyDescriptor> getPropertyDescriptorList();
Example #21
Source File: FieldConfigDSPropertiesTest.java From sldeditor with GNU General Public License v3.0 | 2 votes |
/** * Gets the property descriptor list. * * @return the property descriptor list */ @Override public Collection<PropertyDescriptor> getPropertyDescriptorList() { return null; }
Example #22
Source File: FieldConfigGeometryFieldTest.java From sldeditor with GNU General Public License v3.0 | 2 votes |
/** * Gets the property descriptor list. * * @return the property descriptor list */ @Override public Collection<PropertyDescriptor> getPropertyDescriptorList() { return null; }
Example #23
Source File: DataSourceInterface.java From sldeditor with GNU General Public License v3.0 | 2 votes |
/** * Gets the property descriptor list. * * @return the property descriptor list */ Collection<PropertyDescriptor> getPropertyDescriptorList();