当前位置: 首页>>代码示例>>Java>>正文


Java FeatureId类代码示例

本文整理汇总了Java中org.opengis.filter.identity.FeatureId的典型用法代码示例。如果您正苦于以下问题:Java FeatureId类的具体用法?Java FeatureId怎么用?Java FeatureId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FeatureId类属于org.opengis.filter.identity包,在下文中一共展示了FeatureId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addFeatureIdExample

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
private void addFeatureIdExample(SimpleFeatureCollection collection ) throws Exception {
    // addFeatureIdExample start
    Transaction transaction = new DefaultTransaction("Add Example");
    SimpleFeatureStore store = (SimpleFeatureStore) dataStore.getFeatureSource(typeName);
    store.setTransaction(transaction);
    try {
        List<FeatureId> added = store.addFeatures( collection );
        System.out.println( added ); // prints out the temporary feature ids
        
        transaction.commit();
        System.out.println( added ); // prints out the final feature ids
        
        Set<FeatureId> selection = new HashSet<FeatureId>( added );
        FilterFactory ff = CommonFactoryFinder.getFilterFactory();
        Filter selected = ff.id( selection ); // filter selecting all the features just added
    }
    catch( Exception problem){
        transaction.rollback();
        throw problem;
    }
    // addFeatureIdExample end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:23,代码来源:SimpleFeatureStoreExamples.java

示例2: removeExample2

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
private void removeExample2() throws Exception {
    // removeExample2 start
    Transaction transaction = new DefaultTransaction("removeExample");
    SimpleFeatureStore store = (SimpleFeatureStore) dataStore.getFeatureSource(typeName);
    store.setTransaction(transaction);
    
    FilterFactory ff = CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
    Filter filter = ff.id(Collections.singleton(ff.featureId("fred")));
    try {
        final Set<FeatureId> removed = new HashSet<FeatureId>();
        SimpleFeatureCollection collection = store.getFeatures( new Query( typeName, filter, Query.NO_NAMES ));
        collection.accepts( new FeatureVisitor(){
            public void visit(Feature feature) {
                removed.add( feature.getIdentifier() );
            }
        }, null );
        store.removeFeatures(filter);
        transaction.commit();
    } catch (Exception eek) {
        transaction.rollback();
    }
    // removeExample2 end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:24,代码来源:SimpleFeatureStoreExamples.java

示例3: createSelectedStyle

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
/**
 * Create a Style where features with given IDs are painted
 * yellow, while others are painted with the default colors.
 */
private Style createSelectedStyle(Set<FeatureId> IDs) {
    Rule selectedRule = createRule(SELECTED_COLOUR, SELECTED_COLOUR);
    selectedRule.setFilter(ff.id(IDs));

    Rule otherRule = createRule(LINE_COLOUR, FILL_COLOUR);
    otherRule.setElseFilter(true);

    FeatureTypeStyle fts = sf.createFeatureTypeStyle();
    fts.rules().add(selectedRule);
    fts.rules().add(otherRule);

    Style style = sf.createStyle();
    style.featureTypeStyles().add(fts);
    return style;
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:20,代码来源:SelectionLab.java

示例4: deleteInPosition

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
/**
 * Delete all the features we have with this prefix
 * This prefix is empty on the server.
 *
 * @param position
 */
private void deleteInPosition(Sha1SyncPositionHash position) {
    Sha1Value prefix = new Sha1Value(position.position());
    HashAndFeatureValue find = new HashAndFeatureValue(prefix, null, null);
    // TODO, hmm, better search?
    int i = Collections.binarySearch(m_featureSha1s, find, new IdAndValueSha1Comparator(versionFeatures));
    if (i < 0) {
        i = -i - 1;
    }
    for ( ; i < m_featureSha1s.size(); i++) {
        HashAndFeatureValue value = m_featureSha1s.get(i);
        if (!versionFeatures.getBucketPrefixSha1(value).isPrefixMatch(prefix.get())) {
            break;
        }
        FeatureId fid = value.getFeature().getIdentifier();
        m_potentialDeletes.add(fid);
    }

}
 
开发者ID:xandris,项目名称:geoserver-sync,代码行数:25,代码来源:AbstractClientSynchronizer.java

示例5: addFeatures

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
/**
 * see interface for details.
 * @param fc
 *
 * @throws IOException
 */
public List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType, SimpleFeature> fc) throws IOException {
    FeatureStore<SimpleFeatureType, SimpleFeature> store = store();

    //check if the feature collection needs to be retyped
    if (!store.getSchema().equals(fc.getSchema())) {
        fc = new RetypingFeatureCollection(DataUtilities.simple(fc), store.getSchema());
    }

    return store().addFeatures(fc);
}
 
开发者ID:STEMLab,项目名称:geoserver-3d-extension,代码行数:17,代码来源:GeoServerFeatureStore.java

示例6: createSelectedStyle

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
private Style createSelectedStyle(FeatureId ids) {
    Rule selectedRule = createRule(SELECTED_COLOUR, SELECTED_COLOUR);
    selectedRule.setFilter(ff.id(ids));

    Rule otherRule = createRule(OUTLINE_COLOR, FILL_COLOR);
    otherRule.setElseFilter(true);

    FeatureTypeStyle fts = sf.createFeatureTypeStyle();
    fts.rules().add(selectedRule);
    fts.rules().add(otherRule);

    Style style = sf.createStyle();
    style.featureTypeStyles().add(fts);
    return style;
}
 
开发者ID:gdi-by,项目名称:downloadclient,代码行数:16,代码来源:WMSMapSwing.java

示例7: testGetFeaturesWithIdFilter

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
@Test
public void testGetFeaturesWithIdFilter() throws Exception {
    init();
    FilterFactory ff = dataStore.getFilterFactory();
    Id id = ff.id(new HashSet<FeatureId>(Arrays.asList(ff.featureId("01"),
            ff.featureId("07"))));
    SimpleFeatureCollection features = featureSource.getFeatures(id);
    assertEquals(2, features.size());
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:10,代码来源:ElasticFeatureFilterIT.java

示例8: idSet

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
public void idSet(){
    // idSet start
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    Filter filter;
    
    Set<FeatureId> selected = new HashSet<FeatureId>();
    selected.add(ff.featureId("CITY.98734597823459687235"));
    selected.add(ff.featureId("CITY.98734592345235823474"));
    
    filter = ff.id(selected);
    // idSet end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:13,代码来源:FilterExamples.java

示例9: grabSelectedIds

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
/**
 * How to find Features using IDs?
 * 
 * Each Feature has a FeatureID; you can use these FeatureIDs to request the feature again later.
 * 
 * If you have a Set<String> of feature IDs, which you would like to query from a shapefile:
 * 
 * @param selection
 *            Set of FeatureIDs identifying requested content
 * @return Selected Features
 * @throws IOException
 */
// grabSelectedIds start
SimpleFeatureCollection grabSelectedIds(Set<String> selection) throws IOException {
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
    
    Set<FeatureId> fids = new HashSet<FeatureId>();
    for (String id : selection) {
        FeatureId fid = ff.featureId(id);
        fids.add(fid);
    }
    Filter filter = ff.id(fids);
    return featureSource.getFeatures(filter);
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:25,代码来源:FilterExamples.java

示例10: addFeaturesEvents

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
private void addFeaturesEvents(SimpleFeatureCollection collection ) throws Exception {
    // addEvents start
    Transaction transaction = new DefaultTransaction("Add Example");
    SimpleFeatureStore store = (SimpleFeatureStore) dataStore.getFeatureSource(typeName);
    store.setTransaction(transaction);

    class CommitListener implements FeatureListener {
        public void changed(FeatureEvent featureEvent) {
            if (featureEvent instanceof BatchFeatureEvent ){
                BatchFeatureEvent batchEvent = (BatchFeatureEvent) featureEvent;
                
                System.out.println( "area changed:" + batchEvent.getBounds() );
                System.out.println( "created fids:" + batchEvent.fids );
            }
            else {
                System.out.println( "bounds:" + featureEvent.getBounds() );
                System.out.println( "change:" + featureEvent.filter );
            }
        }
    }
    CommitListener listener = new CommitListener();
    store.addFeatureListener( listener );
    try {
        List<FeatureId> added = store.addFeatures( collection );
        transaction.commit();
    }
    catch( Exception problem){
        transaction.rollback();
        throw problem;
    }
    // addEvents end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:33,代码来源:SimpleFeatureStoreExamples.java

示例11: example4

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
private static void example4() throws IOException {
    System.out.println("example4 start\n");
    // example4 start
    Map<String, Serializable> params = new HashMap<String, Serializable>();
    params.put("directory", directory);
    DataStore store = DataStoreFinder.getDataStore(params);

    FilterFactory ff = CommonFactoryFinder.getFilterFactory();

    Set<FeatureId> selection = new HashSet<FeatureId>();
    selection.add(ff.featureId("fid1"));

    Filter filter = ff.id(selection);
    Query query = new Query("example", filter);

    FeatureReader<SimpleFeatureType, SimpleFeature> reader = store
            .getFeatureReader(query, Transaction.AUTO_COMMIT);

    try {
        while (reader.hasNext()) {
            SimpleFeature feature = reader.next();
            System.out.println("feature " + feature.getID());

            for (Property property : feature.getProperties()) {
                System.out.print("\t");
                System.out.print(property.getName());
                System.out.print(" = ");
                System.out.println(property.getValue());
            }
        }
    } finally {
        reader.close();
    }
    // example4 end
    System.out.println("\nexample4 end\n");
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:37,代码来源:PropertyExamples.java

示例12: displaySelectedFeatures

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
/**
 * Sets the display to paint selected features yellow and
 * unselected features in the default style.
 *
 * @param IDs identifiers of currently selected features
 */
public void displaySelectedFeatures(Set<FeatureId> IDs) {
    Style style;

    if (IDs.isEmpty()) {
        style = createDefaultStyle();

    } else {
        style = createSelectedStyle(IDs);
    }

    Layer layer = mapFrame.getMapContent().layers().get(0);
    ((FeatureLayer) layer).setStyle(style);
    mapFrame.getMapPane().repaint();
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:21,代码来源:SelectionLab.java

示例13: processGmlResponse

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
void processGmlResponse(Response response) throws IOException, SAXException, ParserConfigurationException {
    FeatureCollection<?, ?> features;
    if (response instanceof ResponseFeatureCollection) {
        ResponseFeatureCollection responseFeatures = (ResponseFeatureCollection) response;
        features = responseFeatures.getFeatureCollection();
    } else {
        CountingInputStream counter = new CountingInputStream(response.getResultStream());
        long s = System.currentTimeMillis();
        features = (FeatureCollection<?, ?>) parseWfs(counter);
        long e = System.currentTimeMillis();
        m_parseMillis = e - s;
        m_rxGml += counter.getByteCount();
    }

    FeatureIterator<?> it = features.features();
    try {
        while (it.hasNext()) {
            Feature feature = it.next();
            FeatureId fid = feature.getIdentifier();
            m_potentialDeletes.remove(fid);
            if (!m_features.containsKey(fid)) {
                m_listener.featureCreate(fid, feature);
                m_numCreates++;
            } else {
                m_listener.featureUpdate(fid, feature);
                m_numUpdates++;
            }
        }
    } finally {
        it.close();
    }
}
 
开发者ID:xandris,项目名称:geoserver-sync,代码行数:33,代码来源:AbstractClientSynchronizer.java

示例14: byFid

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
private Feature byFid(Map<Identifier, FeatureAccessor> clientMap, FeatureId fid) {
	FeatureAccessor featureAccessor = clientMap.get(fid);
	if (featureAccessor == null) {
		return null;
	}
	return featureAccessor.getFeature();
}
 
开发者ID:xandris,项目名称:geoserver-sync,代码行数:8,代码来源:GeoserverClientSynchronizerIntegrationTest.java

示例15: getRetypedSimpleFeature

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
@Override
public SimpleFeature getRetypedSimpleFeature(
		SimpleFeatureBuilder builder,
		SimpleFeature original ) {

	final SimpleFeatureType target = builder.getFeatureType();
	for (int i = 0; i < target.getAttributeCount(); i++) {
		final AttributeDescriptor attributeType = target.getDescriptor(i);
		Object value = null;

		if (original.getFeatureType().getDescriptor(
				attributeType.getName()) != null) {
			final Name name = attributeType.getName();
			value = retypeAttributeValue(
					original.getAttribute(name),
					name);
		}

		builder.add(value);
	}
	String featureId = getFeatureId(original);
	if (featureId == null) {
		// a null ID will default to use the original
		final FeatureId id = RetypingFeatureCollection.reTypeId(
				original.getIdentifier(),
				original.getFeatureType(),
				target);
		featureId = id.getID();
	}
	final SimpleFeature retyped = builder.buildFeature(featureId);
	retyped.getUserData().putAll(
			original.getUserData());
	return retyped;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:35,代码来源:AbstractFieldRetypingSource.java


注:本文中的org.opengis.filter.identity.FeatureId类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。