當前位置: 首頁>>代碼示例>>Java>>正文


Java DataStore.getSchema方法代碼示例

本文整理匯總了Java中org.geotools.data.DataStore.getSchema方法的典型用法代碼示例。如果您正苦於以下問題:Java DataStore.getSchema方法的具體用法?Java DataStore.getSchema怎麽用?Java DataStore.getSchema使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.geotools.data.DataStore的用法示例。


在下文中一共展示了DataStore.getSchema方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getStatementFeatureType

import org.geotools.data.DataStore; //導入方法依賴的package包/類
private static SimpleFeatureType getStatementFeatureType(final DataStore dataStore) throws IOException, SchemaException {
    SimpleFeatureType featureType;

    final String[] datastoreFeatures = dataStore.getTypeNames();
    if (Arrays.asList(datastoreFeatures).contains(FEATURE_NAME)) {
        featureType = dataStore.getSchema(FEATURE_NAME);
    } else {
        featureType = DataUtilities.createType(FEATURE_NAME,
            SUBJECT_ATTRIBUTE + ":String," +
            PREDICATE_ATTRIBUTE + ":String," +
            OBJECT_ATTRIBUTE + ":String," +
            CONTEXT_ATTRIBUTE + ":String," +
            GEOMETRY_ATTRIBUTE + ":Geometry:srid=4326," +
            GEO_ID_ATTRIBUTE + ":String");

        dataStore.createSchema(featureType);
    }
    return featureType;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:20,代碼來源:GeoWaveGeoIndexer.java

示例2: getStatementFeatureType

import org.geotools.data.DataStore; //導入方法依賴的package包/類
private static SimpleFeatureType getStatementFeatureType(final DataStore dataStore) throws IOException, SchemaException {
    SimpleFeatureType featureType;

    final String[] datastoreFeatures = dataStore.getTypeNames();
    if (Arrays.asList(datastoreFeatures).contains(FEATURE_NAME)) {
        featureType = dataStore.getSchema(FEATURE_NAME);
    } else {
        final String featureSchema = SUBJECT_ATTRIBUTE + ":String," //
                + PREDICATE_ATTRIBUTE + ":String," //
                + OBJECT_ATTRIBUTE + ":String," //
                + CONTEXT_ATTRIBUTE + ":String," //
                + GEOMETRY_ATTRIBUTE + ":Geometry:srid=4326;geomesa.mixed.geometries='true'";
        featureType = SimpleFeatureTypes.createType(FEATURE_NAME, featureSchema);
        dataStore.createSchema(featureType);
    }
    return featureType;
}
 
開發者ID:apache,項目名稱:incubator-rya,代碼行數:18,代碼來源:GeoMesaGeoIndexer.java

示例3: example2

import org.geotools.data.DataStore; //導入方法依賴的package包/類
private static void example2() throws IOException {
    System.out.println("example2 start\n");
    // example2 start
    Map<String, Serializable> params = new HashMap<String, Serializable>();
    params.put("directory", directory);
    DataStore store = DataStoreFinder.getDataStore(params);

    SimpleFeatureType type = store.getSchema("example");

    System.out.println("       typeName: " + type.getTypeName());
    System.out.println("           name: " + type.getName());
    System.out.println("attribute count: " + type.getAttributeCount());

    AttributeDescriptor id = type.getDescriptor(0);
    System.out.println("attribute 'id'    name:" + id.getName());
    System.out.println("attribute 'id'    type:" + id.getType().toString());
    System.out.println("attribute 'id' binding:"
            + id.getType().getDescription());

    AttributeDescriptor name = type.getDescriptor("name");
    System.out.println("attribute 'name'    name:" + name.getName());
    System.out.println("attribute 'name' binding:"
            + name.getType().getBinding());
    // example2 end
    System.out.println("\nexample2 end\n");
}
 
開發者ID:ianturton,項目名稱:geotools-cookbook,代碼行數:27,代碼來源:PropertyExamples.java

示例4: prepare

import org.geotools.data.DataStore; //導入方法依賴的package包/類
public void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector) {
    final DataStore ds;
    try {
        ds = DataStoreFinder.getDataStore(connectionParams);
        SimpleFeatureType featureType = ds.getSchema(featureName);
        featureBuilder = new SimpleFeatureBuilder(featureType);
        featureWriter = ds.getFeatureWriterAppend(featureName, Transaction.AUTO_COMMIT);
    } catch (IOException e) {
        throw new RuntimeException("Unable to initialize feature writer", e);
    }
}
 
開發者ID:geomesa,項目名稱:geomesa-tutorials,代碼行數:12,代碼來源:OSMKafkaBolt.java

示例5: cloneFeature

import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
 * Clones the given SimpleFeature using a DataStore fetch schema.
 * 
 * @param store
 * @param typeName
 * @param feature
 * @return
 * @throws IOException
 */
public static SimpleFeature cloneFeature(DataStore store, String typeName,
		SimpleFeature feature, Map<String, String> attributeMappings) throws IOException {
	SimpleFeatureType schema = store.getSchema(typeName);
	SimpleFeatureBuilder builder = new SimpleFeatureBuilder(schema);
	for(AttributeDescriptor attribute : schema.getAttributeDescriptors()) {			
		String sourceAttributeName = mapAttributeName(attributeMappings,
				attribute.getLocalName());
		builder.add(feature.getAttribute(sourceAttributeName));
	}
	return builder.buildFeature(null);
}
 
開發者ID:geosolutions-it,項目名稱:OpenSDI-Manager2,代碼行數:21,代碼來源:GeoCollectUtils.java

示例6: getShapefileFieldnames

import org.geotools.data.DataStore; //導入方法依賴的package包/類
@Override
public List<String> getShapefileFieldnames(File shapefileOrODLRG) {
	// turn an .odlrg file reference into a shapefile reference 
	if(Strings.equalsStd(FilenameUtils.getExtension(shapefileOrODLRG.getName()), RogReaderUtils.RENDER_GEOMETRY_FILE_EXT)){
		String s = FilenameUtils.removeExtension(shapefileOrODLRG.getAbsolutePath());
		s += ".shp";
		shapefileOrODLRG = new File(s);
	}

	DataStore shapefile = null;
	try {
		Map<String, URL> map = new HashMap<String, URL>();
		map.put("url", shapefileOrODLRG.toURI().toURL());
		shapefile = DataStoreFinder.getDataStore(map);

		// check not corrupt
		if (shapefile.getTypeNames().length != 1) {
			throw new RuntimeException("Shapefile should only contain one type");
		}

		String typename = shapefile.getTypeNames()[0];
		SimpleFeatureType schema = shapefile.getSchema(typename);
		int nAttrib = schema.getAttributeCount();
		ArrayList<String> ret = new ArrayList<>();
		for (int i = 0; i < nAttrib; i++) {
			ret.add(schema.getDescriptor(i).getLocalName());
		}
		return ret;

	} catch (Throwable e) {
		throw Exceptions.asUnchecked(e);
	} finally {

		if (shapefile != null) {
			shapefile.dispose();
		}
	}
}
 
開發者ID:PGWelch,項目名稱:com.opendoorlogistics,代碼行數:39,代碼來源:IOImpl.java

示例7: importDataIntoStore

import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
 * 
 * @param features
 * @param name
 * @param storeInfo
 * @return
 * @throws IOException
 * @throws ProcessException
 */
private SimpleFeatureType importDataIntoStore(SimpleFeatureCollection features, String name,
        DataStoreInfo storeInfo) throws IOException, ProcessException {
    SimpleFeatureType targetType;
    // grab the data store
    DataStore ds = (DataStore) storeInfo.getDataStore(null);

    // decide on the target ft name
    SimpleFeatureType sourceType = features.getSchema();
    if (name != null) {
        SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
        tb.init(sourceType);
        tb.setName(name);
        sourceType = tb.buildFeatureType();
    }

    // create the schema
    ds.createSchema(sourceType);

    // try to get the target feature type (might have slightly different
    // name and structure)
    targetType = ds.getSchema(sourceType.getTypeName());
    if (targetType == null) {
        // ouch, the name was changed... we can only guess now...
        // try with the typical Oracle mangling
        targetType = ds.getSchema(sourceType.getTypeName().toUpperCase());
    }

    if (targetType == null) {
        throw new WPSException(
                "The target schema was created, but with a name "
                        + "that we cannot relate to the one we provided the data store. Cannot proceeed further");
    } else {
        // check the layer is not already there
        String newLayerName = storeInfo.getWorkspace().getName() + ":"
                + targetType.getTypeName();
        LayerInfo layer = this.catalog.getLayerByName(newLayerName);
        // todo: we should not really reach here and know beforehand what the targetType
        // name is, but if we do we should at least get a way to drop it
        if (layer != null) {
            throw new ProcessException("Target layer " + newLayerName
                    + " already exists in the catalog");
        }
    }

    // try to establish a mapping with old and new attributes. This is again
    // just guesswork until we have a geotools api that will give us the
    // exact mapping to be performed
    Map<String, String> mapping = buildAttributeMapping(sourceType, targetType);

    // start a transaction and fill the target with the input features
    Transaction t = new DefaultTransaction();
    SimpleFeatureStore fstore = (SimpleFeatureStore) ds.getFeatureSource(targetType.getTypeName());
    fstore.setTransaction(t);
    SimpleFeatureIterator fi = features.features();
    SimpleFeatureBuilder fb = new SimpleFeatureBuilder(targetType);
    while (fi.hasNext()) {
        SimpleFeature source = fi.next();
        fb.reset();
        for (String sname : mapping.keySet()) {
            fb.set(mapping.get(sname), source.getAttribute(sname));
        }
        SimpleFeature target = fb.buildFeature(null);
        fstore.addFeatures(DataUtilities.collection(target));
    }
    t.commit();
    t.close();

    return targetType;
}
 
開發者ID:geosolutions-it,項目名稱:soil_sealing,代碼行數:79,代碼來源:FeaturesImporter.java

示例8: getAttributesForDatasource

import org.geotools.data.DataStore; //導入方法依賴的package包/類
/**
 * getAttributesForDatasource
 * Returns a list of attribute types for a datasource. If your DataStore was
 * a database, this would return the columns in the table to be imported.
 * You will probably use this when setting up the attributes on the Datasource.
 * Note that these are Geotools AttributeTypes and have nothing to do with
 * Tombolo's Attribute objects.
 * @param datasource The datasource being imported
 * @return A list of attributes for the datasource
 * @throws IOException
 */
protected List<AttributeType> getAttributesForDatasource(Datasource datasource) throws IOException {
    DataStore dataStore = null;
    try {
        dataStore = getDataStoreForDatasource(datasource);
        SimpleFeatureType schema = dataStore.getSchema(getTypeNameForDatasource(datasource));
        return schema.getTypes();
    } finally {
        if (null != dataStore) dataStore.dispose();
    }
}
 
開發者ID:FutureCitiesCatapult,項目名稱:TomboloDigitalConnector,代碼行數:22,代碼來源:AbstractGeotoolsDataStoreImporter.java


注:本文中的org.geotools.data.DataStore.getSchema方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。