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


Java SimpleFeatureCollection.features方法代码示例

本文整理汇总了Java中org.geotools.data.simple.SimpleFeatureCollection.features方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureCollection.features方法的具体用法?Java SimpleFeatureCollection.features怎么用?Java SimpleFeatureCollection.features使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.geotools.data.simple.SimpleFeatureCollection的用法示例。


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

示例1: correctFeatures

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
public static SimpleFeatureCollection correctFeatures(SimpleFeatureCollection fc){
 	SimpleFeatureIterator iterator=fc.features();
 	DefaultFeatureCollection outVector = new DefaultFeatureCollection();

 	while(iterator.hasNext()){
 		SimpleFeature sf=iterator.next();
 		Geometry gm=(Geometry)sf.getDefaultGeometry();
 		if(!gm.isValid()){
 			gm=JTSUtil.repair(gm);
 			System.out.println(gm.isValid());
 		}
sf.setDefaultGeometry(gm);
   outVector.add(sf);

 	}

 	return fc;
 }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:19,代码来源:SimpleShapefile.java

示例2: testGreaterDateFilterLong

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
@Test
public void testGreaterDateFilterLong() throws Exception {
    init();
    Date testDate = new Date(1005912798000l);
    FilterFactory ff = dataStore.getFilterFactory();

    Filter f = ff.greaterOrEqual(ff.property("installed_td"), ff.literal(testDate.getTime()));
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(7, features.size());
    SimpleFeatureIterator it = features.features();
    while (it.hasNext()) {
        SimpleFeature next = it.next();
        Date date = (Date) next.getAttribute("installed_td");
        assertTrue(date.after(testDate) || date.equals(testDate));
    }
    it.close();
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:18,代码来源:ElasticTemporalFilterIT.java

示例3: testAlternateGeometry

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
@Test
public void testAlternateGeometry() throws Exception {
    init("active", "geo2");
    SimpleFeatureType schema = featureSource.getSchema();
    GeometryDescriptor gd = schema.getGeometryDescriptor();
    assertNotNull(gd);
    assertEquals("geo2", gd.getLocalName());

    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    BBOX bbox = ff.bbox("geo2", 6.5, 23.5, 7.5, 24.5, "EPSG:4326");
    SimpleFeatureCollection features = featureSource.getFeatures(bbox);
    assertEquals(1, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.09");
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:ElasticGeometryFilterIT.java

示例4: readFeatures

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
private List<Map<String, Object>> readFeatures(SimpleFeatureCollection features) {
    final ObjectMapper mapper = new ObjectMapper();

    final List<Map<String, Object>> buckets = new ArrayList<>();
    try (SimpleFeatureIterator iterator = features.features()) {
        while (iterator.hasNext()) {
            final SimpleFeature feature = iterator.next();
            if (feature.getAttribute("_aggregation") != null) {
                final byte[] data = (byte[]) feature.getAttribute("_aggregation");
                try {
                    final Map<String,Object> aggregation = mapper.readValue(data, new TypeReference<Map<String,Object>>() {});
                    buckets.add(aggregation);
                } catch (IOException e) {
                    LOGGER.fine("Failed to parse aggregation value: " + e);
                }
            }
        }
    }
    return buckets;
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:21,代码来源:GeoHashGrid.java

示例5: testOgrStyleGeoPoint

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
@Test
public void testOgrStyleGeoPoint() throws Exception {
    init("not-active","geo4.coordinates");
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    BBOX bbox = ff.bbox("geo4.coordinates", 0, 0, 5, 5, "EPSG:4326");
    assertNotNull(featureSource.getSchema().getDescriptor("geo4.coordinates"));
    assertNull(featureSource.getSchema().getDescriptor("geo4.type"));

    SimpleFeatureCollection features = featureSource.getFeatures(bbox);
    assertEquals(1, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    SimpleFeature feature = fsi.next();
    assertEquals(feature.getID(), "active.13");
    assertNotNull(feature.getDefaultGeometry());
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:ElasticGeometryFilterIT.java

示例6: testDisjointFilter

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
@Test
public void testDisjointFilter() throws Exception {
    init("not-active","geo3");
    FilterFactory2 ff = (FilterFactory2) dataStore.getFilterFactory();
    GeometryFactory gf = new GeometryFactory();
    PackedCoordinateSequenceFactory sf = new PackedCoordinateSequenceFactory();
    Point ls = gf.createPoint(sf.create(new double[] { 0, 0 }, 2));
    Disjoint f = ff.disjoint(ff.property("geo3"), ff.literal(ls));
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(2, features.size());
    SimpleFeatureIterator fsi = features.features();
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.12");
    assertTrue(fsi.hasNext());
    assertEquals(fsi.next().getID(), "active.13");
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:17,代码来源:ElasticGeometryFilterIT.java

示例7: testLessDateFilterLong

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
@Test
public void testLessDateFilterLong() throws Exception {
    init();
    Date testDate = new Date(1005912798000l);
    FilterFactory ff = dataStore.getFilterFactory();

    Filter f = ff.lessOrEqual(ff.property("installed_td"), ff.literal(testDate.getTime()));
    SimpleFeatureCollection features = featureSource.getFeatures(f);
    assertEquals(4, features.size());
    SimpleFeatureIterator it = features.features();
    while (it.hasNext()) {
        SimpleFeature next = it.next();
        Date date = (Date) next.getAttribute("installed_td");
        assertTrue(date.before(testDate) || date.equals(testDate));
    }
    it.close();
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:18,代码来源:ElasticTemporalFilterIT.java

示例8: joinFeaures

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
/**
 *
 * @param shapes
 * @param shapes2
 * @throws Exception
 */
private static SimpleFeatureCollection joinFeaures(SimpleFeatureSource shapes, SimpleFeatureSource shapes2) throws Exception {
	SimpleFeatureCollection join =null;

    SimpleFeatureType schema = shapes.getSchema();
    String typeName = schema.getTypeName();
    String geomName = schema.getGeometryDescriptor().getLocalName();

    SimpleFeatureType schema2 = shapes2.getSchema();
    String typeName2 = schema2.getTypeName();
    String geomName2 = schema2.getGeometryDescriptor().getLocalName();
    FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();

    Query outerGeometry = new Query(typeName, Filter.INCLUDE, new String[] { geomName });
    SimpleFeatureCollection outerFeatures = shapes.getFeatures(outerGeometry);
    SimpleFeatureIterator iterator = outerFeatures.features();
    int max = 0;
    try {
        while (iterator.hasNext()) {
            SimpleFeature feature = iterator.next();
            try {
                Geometry geometry = (Geometry) feature.getDefaultGeometry();
                if (!geometry.isValid()) {
                    // skip bad data
                    continue;
                }
                Filter innerFilter = ff.intersects(ff.property(geomName2), ff.literal(geometry));
                Query innerQuery = new Query(typeName2, innerFilter, Query.NO_NAMES);
                join = shapes2.getFeatures(innerQuery);
                int size = join.size();
                max = Math.max(max, size);
            } catch (Exception skipBadData) {
            }
        }
    } finally {
        iterator.close();
    }
    return join;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:45,代码来源:SimpleShapefile.java

示例9: readAttributes

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
/**
 * Read attributes.
 *
 * @param attributeData the attribute data
 */
/* (non-Javadoc)
 * @see com.sldeditor.datasource.DataSourceInterface#updateAttributes(com.sldeditor.render.iface.RenderAttributeDataInterface)
 */
@Override
public void readAttributes(DataSourceAttributeListInterface attributeData) {
    if(attributeData == null)
    {
        return;
    }

    List<DataSourceAttributeData> valueMap = new ArrayList<DataSourceAttributeData>();

    SimpleFeatureCollection featureCollection = dataSourceInfo.getFeatureCollection();
    if(featureCollection != null)
    {
        SimpleFeatureIterator iterator = featureCollection.features();
        if(iterator.hasNext())
        {
            SimpleFeature feature = iterator.next();

            List<Object> attributes = feature.getAttributes();
            for (int i = 0; i < attributes.size(); i++)
            {
                Name fieldName = fieldNameMap.get(i);

                DataSourceAttributeData data = new DataSourceAttributeData(fieldName,
                        fieldTypeMap.get(i),
                        attributes.get(i));

                valueMap.add(data);
            }
        }
    }

    attributeData.setData(valueMap);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:42,代码来源:DataSourceImpl.java

示例10: determineGeometryType

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
/**
 * Determine geometry type.
 *
 * @param geometryDescriptor the geometry descriptor
 * @param simpleFeatureCollection the simple feature collection
 * @return the geometry type enum
 */
public static GeometryTypeEnum determineGeometryType(GeometryDescriptor geometryDescriptor,
        SimpleFeatureCollection simpleFeatureCollection) {

    if (geometryDescriptor == null) {
        return GeometryTypeEnum.UNKNOWN;
    }

    if (simpleFeatureCollection == null) {
        return GeometryTypeEnum.UNKNOWN;
    }

    Class<?> bindingType = geometryDescriptor.getType().getBinding();

    if (bindingType == Geometry.class) {
        Name geometryName = geometryDescriptor.getName();
        SimpleFeatureIterator iterator = simpleFeatureCollection.features();

        List<GeometryTypeEnum> geometryFeatures = new ArrayList<GeometryTypeEnum>();

        while (iterator.hasNext()) {
            SimpleFeature feature = iterator.next();

            Object value = feature.getAttribute(geometryName);

            if (value != null) {
                GeometryTypeEnum geometryType = GeometryTypeMapping
                        .getGeometryType(value.getClass());

                if (!geometryFeatures.contains(geometryType)) {
                    geometryFeatures.add(geometryType);
                }
            }
        }
        return (combineGeometryType(geometryFeatures));
    } else {
        return GeometryTypeMapping.getGeometryType(bindingType);
    }
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:46,代码来源:InlineFeatureUtils.java

示例11: selectFirst

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
private SimpleFeature selectFirst(SimpleFeatureCollection features) {
  SimpleFeature first = null;
  try (FeatureIterator<SimpleFeature> iterator = features.features()) {
    if (iterator.hasNext()) {
      first = iterator.next();
    }
  }
  return first;
}
 
开发者ID:skaringa,项目名称:tzdataservice,代码行数:10,代码来源:TzDataShpFileReadAndLocate.java

示例12: getWMSOutcomeTest

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
@Test(enabled = true, groups = { "suitability", "integration" })
  public void getWMSOutcomeTest() throws Exception {
    LOGGER.debug("getWMSOutcomeTest");
    // TODO Sometimes analysis of the whole area studies necessary,bbetter create a different test altogether  and disable it?
//    String areaAnalyzed = WifKeys.POLYGON_TEST;
     String areaAnalyzed = null;
    String crsArea = WifKeys.CRS_TEST;

    Boolean wmsOutcome = suitabilityScenarioService.getWMSOutcome(
        WifKeys.TEST_SUITABILITY_SCENARIO_ID, areaAnalyzed, crsArea);
    Assert.assertEquals(wmsOutcome, Boolean.TRUE);

    Map<String, Object> wifParameters = new HashMap<String, Object>();
    wifParameters.put(WifKeys.POLYGON, WifKeys.POLYGON_TEST);
    wifParameters.put(WifKeys.CRS_ORG, WifKeys.CRS_TEST);
    wifParameters.put(WifKeys.CRS_DEST, WifKeys.CRS_TEST);
    Filter filter = geodataFilterer.getFilterFromParameters(wifParameters);
    SimpleFeatureCollection uazCollection = geodataFinder
        .getFeatureCollectionfromDB("uaz_demonstration", filter);
    SimpleFeatureIterator it = uazCollection.features();
    Double score = 0.0;
    try {
      while (it.hasNext()) {
        SimpleFeature uazFeature = it.next();
        if (uazFeature.getID().equals("uaz_demonstration.730")) {

          score = (Double) uazFeature.getAttribute("SCORE_1");
        }
      }
    } finally {
      it.close();
    }
    // TODO this is the value when the polygon test is enforced
    Assert.assertEquals(score, new Double(10000.0));
    // TODO this is the value when the wwhole areatest is enforced
    // Assert.assertEquals((Double) score, new Double(8125.0));
  }
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:38,代码来源:SuitabilityDBOutcomeIT.java

示例13: testGetFeaturesWithNOTLogicFilter

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
@Test
public void testGetFeaturesWithNOTLogicFilter() throws Exception {
    init();
    FilterFactory ff = dataStore.getFilterFactory();
    PropertyIsEqualTo property1 = ff.equals(ff.property("vendor_s"), ff.literal("D-Link"));
    Not filter = ff.not(property1);
    SimpleFeatureCollection features = featureSource.getFeatures(filter);
    assertEquals(7, features.size());
    SimpleFeatureIterator iterator = features.features();
    while (iterator.hasNext()) {
        SimpleFeature f = iterator.next();
        assertTrue(!f.getAttribute("vendor_s").equals("D-Link"));
    }
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:15,代码来源:ElasticFeatureFilterIT.java

示例14: load

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
public void load (ShapeDataStore store) throws Exception {
    FileDataStore fds = FileDataStoreFinder.getDataStore(shapefile);
    SimpleFeatureSource src = fds.getFeatureSource();

    Query q = new Query();
    q.setCoordinateSystem(src.getInfo().getCRS());
    q.setCoordinateSystemReproject(CRS.decode("EPSG:4326", true));
    SimpleFeatureCollection sfc = src.getFeatures(q);

    for (SimpleFeatureIterator it = sfc.features(); it.hasNext();) {
        GeobufFeature feat = new GeobufFeature(it.next());
        feat.id = null;
        feat.numericId = Long.parseLong((String) feat.properties.get("GEOID10"));
        feat.properties = new HashMap<>();
        store.add(feat);
    }
}
 
开发者ID:conveyal,项目名称:seamless-census,代码行数:18,代码来源:TigerLineSource.java

示例15: readShapes

import org.geotools.data.simple.SimpleFeatureCollection; //导入方法依赖的package包/类
public void readShapes(final IScope scope) {
	final IList<IShape> list = getBuffer();
	int size = 0;
	final SimpleFeatureCollection fc = getFeatureCollection(scope);
	if (fc == null)
		return;
	final Envelope3D env = Envelope3D.of(fc.getBounds());
	size = fc.size();
	int index = 0;
	computeProjection(scope, env);
	try (SimpleFeatureIterator reader = fc.features()) {
		while (reader.hasNext()) {
			index++;
			if (index % 20 == 0)
				scope.getGui().getStatus(scope).setSubStatusCompletion(index / size);
			final SimpleFeature feature = reader.next();
			Geometry g = (Geometry) feature.getDefaultGeometry();
			if (g != null && !g.isEmpty() /* Fix for Issue 725 && 677 */ ) {
				g = gis.transform(g);
				if (!with3D) {
					g.apply(ZERO_Z);
					g.geometryChanged();
				}
				list.add(new GamaGisGeometry(g, feature));
			} else if (g == null) {
				// See Issue 725
				GAMA.reportError(scope,
						GamaRuntimeException
								.warning("GamaGeoJsonFile.fillBuffer; geometry could not be added  as it is "
										+ "nil: " + feature.getIdentifier(), scope),
						false);
			}
		}
	}
	if (size > list.size()) {
		GAMA.reportError(scope, GamaRuntimeException.warning("Problem with file " + getFile(scope) + ": only "
				+ list.size() + " of the " + size + " geometries could be added", scope), false);
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:40,代码来源:GamaGeoJsonFile.java


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