Java Code Examples for org.opengis.feature.type.FeatureType#getDescriptors()
The following examples show how to use
org.opengis.feature.type.FeatureType#getDescriptors() .
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: 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 2
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 3
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; }