• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FeatureId类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: create

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
@Override
@Transactional(rollbackFor = { Throwable.class })
public Object create(Object feature) throws LayerException {
	SimpleFeatureSource source = getFeatureSource();
	if (source instanceof SimpleFeatureStore) {
		SimpleFeatureStore store = (SimpleFeatureStore) source;
		DefaultFeatureCollection collection = new DefaultFeatureCollection();
		collection.add((SimpleFeature) feature);
		transactionSynchronization.synchTransaction(store);
		try {
			List<FeatureId> ids = store.addFeatures(collection);
			// fetch it again to get the generated values !!!
			if (ids.size() == 1) {
				return read(ids.get(0).getID());
			}
		} catch (IOException ioe) {
			featureModelUsable = false;
			throw new LayerException(ioe, ExceptionCode.LAYER_MODEL_IO_EXCEPTION);
		}
		return feature;
	} else {
		log.error("Don't know how to create or update " + getFeatureSourceName() + ", class "
				+ source.getClass().getName() + " does not implement SimpleFeatureStore");
		throw new LayerException(ExceptionCode.CREATE_OR_UPDATE_NOT_IMPLEMENTED, getFeatureSourceName(), source
				.getClass().getName());
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:28,代码来源:GeoToolsLayer.java


示例17: selectFeatures

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
/**
 * This method is called by our feature selection tool when
 * the user has clicked on the map.
 *
 * @param pos map (world) coordinates of the mouse cursor
 */
void selectFeatures(MapMouseEvent ev) {

    System.out.println("Mouse click at: " + ev.getMapPosition());

    /*
     * Construct a 5x5 pixel rectangle centred on the mouse click position
     */
    Point screenPos = ev.getPoint();
    Rectangle screenRect = new Rectangle(screenPos.x-2, screenPos.y-2, 5, 5);
    
    /*
     * Transform the screen rectangle into bounding box in the coordinate
     * reference system of our map context. Note: we are using a naive method
     * here but GeoTools also offers other, more accurate methods.
     */
    AffineTransform screenToWorld = mapFrame.getMapPane().getScreenToWorldTransform();
    Rectangle2D worldRect = screenToWorld.createTransformedShape(screenRect).getBounds2D();
    ReferencedEnvelope bbox = new ReferencedEnvelope(
            worldRect,
            mapFrame.getMapContent().getCoordinateReferenceSystem());

    /*
     * Create a Filter to select features that intersect with
     * the bounding box
     */
    Filter filter = ff.intersects(ff.property(geometryAttributeName), ff.literal(bbox));

    /*
     * Use the filter to identify the selected features
     */
    try {
        SimpleFeatureCollection selectedFeatures =
                featureSource.getFeatures(filter);

        SimpleFeatureIterator iter = selectedFeatures.features();
        Set<FeatureId> IDs = new HashSet<FeatureId>();
        try {
            while (iter.hasNext()) {
                SimpleFeature feature = iter.next();
                IDs.add(feature.getIdentifier());

                System.out.println("   " + feature.getIdentifier());
            }

        } finally {
            iter.close();
        }

        if (IDs.isEmpty()) {
            System.out.println("   no feature selected");
        }

        displaySelectedFeatures(IDs);

    } catch (Exception ex) {
        ex.printStackTrace();
        return;
    }
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:66,代码来源:SelectionLab.java


示例18: getIdentifier

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
public FeatureId getIdentifier() {
	return simpleFeature.getIdentifier();
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:4,代码来源:SimpleFeatureWrapper.java


示例19: getIdentifier

import org.opengis.filter.identity.FeatureId; //导入依赖的package包/类
/** Not Implemented Use getID() */
public FeatureId getIdentifier() {return null;}
 
开发者ID:opengeospatial,项目名称:Java-OpenMobility,代码行数:3,代码来源:SimpleFeatureImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JavaModuleSourceRootTypes类代码示例发布时间:2022-05-22
下一篇:
Java EnableProcessApplication类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap