本文整理汇总了Java中org.geotools.data.simple.SimpleFeatureIterator.next方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureIterator.next方法的具体用法?Java SimpleFeatureIterator.next怎么用?Java SimpleFeatureIterator.next使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.data.simple.SimpleFeatureIterator
的用法示例。
在下文中一共展示了SimpleFeatureIterator.next方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: correctFeatures
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的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;
}
示例2: CommunityAreas
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
public CommunityAreas() {
communities = new HashMap<>();
try {
File f = new File(shapeFilePath);
ShapefileDataStore shapefile = new ShapefileDataStore(f.toURI().toURL());
SimpleFeatureIterator features = shapefile.getFeatureSource().getFeatures().features();
SimpleFeature shp;
while (features.hasNext()) {
shp = features.next();
int id = Integer.parseInt((String) shp.getAttribute("AREA_NUMBE"));
String name = (String) shp.getAttribute("COMMUNITY");
MultiPolygon boundary = (MultiPolygon) shp.getDefaultGeometry();
CommunityArea ca = new CommunityArea(id, name, boundary);
communities.put(id, ca);
}
features.close();
shapefile.dispose();
} catch (IOException e) {
e.printStackTrace();
}
}
示例3: Tracts
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
public Tracts() {
tracts = new HashMap<>();
try {
SimpleFeatureIterator features = getShapeFileFeatures();
SimpleFeature shp;
while (features.hasNext()) {
shp = features.next();
int id = Integer.parseInt((String) shp.getAttribute("tractce10"));
MultiPolygon boundary = (MultiPolygon) shp.getDefaultGeometry();
Tract t = new Tract(id, boundary);
tracts.put(id, t);
}
features.close();
shapefile.dispose();
} catch (IOException e) {
e.printStackTrace();
}
}
示例4: testAllShapesArePolygon
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
public void testAllShapesArePolygon() {
try {
SimpleFeatureIterator features = Tracts.getShapeFileFeatures();
SimpleFeature shp = features.next();
int fieldSize = shp.getType().getTypes().size();
assertEquals(fieldSize, 10);
assertEquals(shp.getType().getType(3).getName().getLocalPart(), "tractce10");
assertEquals(shp.getType().getType(0).getName().getLocalPart(), "MultiPolygon");
for (int i = 0; i < fieldSize; i++){
System.out.println(shp.getType().getType(i).getName().getLocalPart());
}
int cnt = 1;
while (features.hasNext()) {
shp = features.next();
MultiPolygon g = (MultiPolygon) shp.getDefaultGeometry();
cnt ++;
}
assertEquals(cnt, 801);
features.close();
Tracts.shapefile.dispose();
} catch (IOException e) {
e.printStackTrace();
}
}
示例5: getFeature
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
/**
* Gets the feature.
*
* @param row the row
* @return the feature
*/
private SimpleFeature getFeature(int row) {
if (featureCollection != null) {
if (row != lastRow) {
SimpleFeatureIterator iterator = featureCollection.features();
SimpleFeature feature = iterator.next();
int index = 0;
while (iterator.hasNext() && (index < row)) {
feature = iterator.next();
index++;
}
lastRow = row;
cachedFeature = feature;
}
return cachedFeature;
}
return null;
}
示例6: getOutcomeTest
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
@Test(enabled = true, groups = { "suitability", "integration" })
public void getOutcomeTest() throws Exception {
String areaAnalyzed = WifKeys.POLYGON_TEST;
String crsArea = WifKeys.CRS_TEST;
SimpleFeatureCollection suitabilityAnalysis = suitabilityScenarioService
.getOutcome(WifKeys.TEST_SUITABILITY_SCENARIO_ID, areaAnalyzed, crsArea);
SimpleFeatureIterator it = suitabilityAnalysis.features();
LOGGER.debug("results feature size: " + suitabilityAnalysis.size());
Assert.assertEquals(suitabilityAnalysis.size(), (8));
Double score = 0.0;
try {
while (it.hasNext()) {
SimpleFeature uazFeature = it.next();
score += (Double) uazFeature.getAttribute("SCORE_1");
}
} finally {
it.close();
}
LOGGER.debug("Score = " + score);
Assert.assertNotEquals(score, new Double(0));
// FIXME This was before, please check
// Assert.assertEquals(score, new Double(90000));
}
示例7: testGreaterDateFilterLong
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的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();
}
示例8: testGetFeaturesWithORLogicFilter
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
@Test
public void testGetFeaturesWithORLogicFilter() throws Exception {
init();
FilterFactory ff = dataStore.getFilterFactory();
PropertyIsEqualTo property1 = ff.equals(ff.property("vendor_s"), ff.literal("D-Link"));
PropertyIsEqualTo property2 = ff.equals(ff.property("vendor_s"), ff.literal("Linksys"));
Or filter = ff.or(property1, property2);
SimpleFeatureCollection features = featureSource.getFeatures(filter);
assertEquals(6, features.size());
SimpleFeatureIterator iterator = features.features();
while (iterator.hasNext()) {
SimpleFeature f = iterator.next();
assertTrue(f.getAttribute("vendor_s").equals("D-Link")
|| f.getAttribute("vendor_s").equals("Linksys"));
}
}
示例9: printFeatures
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
/**
* @param featureIterator iterator of features to print
* @throws IOException
*/
public static void printFeatures(SimpleFeatureIterator featureIterator) throws IOException {
// Iterate features of shp file
while (featureIterator.hasNext()) {
SimpleFeature f = featureIterator.next();
List<Object> attributes = f.getAttributes();
for (int i = 0; i < attributes.size(); i++) {
// MultiLineString geometry =
// (MultiLineString)attributes.get(0);
Object attribute = attributes.get(i);
if (!(attribute instanceof MultiLineString))
System.out.println(attributes.get(i).toString());
}
System.out.println("---------");
}
}
示例10: testGetFeaturesWithQuery
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
@Test
public void testGetFeaturesWithQuery() throws Exception {
init();
FilterFactory ff = dataStore.getFilterFactory();
PropertyIsEqualTo filter = ff.equals(ff.property("modem_b"), ff.literal(true));
Query query = new Query();
query.setPropertyNames(new String[] { "standard_ss", "security_ss" });
query.setFilter(filter);
SimpleFeatureCollection features = featureSource.getFeatures(query);
assertEquals(8, features.size());
SimpleFeatureIterator iterator = features.features();
try {
assertTrue(iterator.hasNext());
SimpleFeature feature = iterator.next();
assertEquals(2, feature.getAttributeCount());
String st = (String) feature.getAttribute("standard_ss");
// changed from "IEEE 802.11b" in SolrFeatureSourceTest
assertTrue(st.contains("IEEE 802.11b"));
} finally {
iterator.close();
}
}
示例11: testReadStringArrayWithCsvStrategy
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
@Test
public void testReadStringArrayWithCsvStrategy() throws Exception {
init();
dataStore.setArrayEncoding(ArrayEncoding.CSV);
FilterFactory ff = dataStore.getFilterFactory();
PropertyIsEqualTo filter = ff.equals(ff.property("modem_b"), ff.literal(true));
SimpleFeatureCollection features = featureSource.getFeatures(filter);
assertEquals(8, features.size());
SimpleFeatureIterator iterator = features.features();
try {
assertTrue(iterator.hasNext());
SimpleFeature feature = iterator.next();
String st = (String) feature.getAttribute("standard_ss");
// changed from "IEEE 802.11b" in SolrFeatureSourceTest
assertTrue(URLDecoder.decode(st, StandardCharsets.UTF_8.toString()).startsWith("IEEE 802.11"));
} finally {
iterator.close();
}
}
示例12: testOnlySourceFieldsWithSourceFiltering
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
@Test
public void testOnlySourceFieldsWithSourceFiltering() throws Exception {
init();
dataStore.setSourceFilteringEnabled(true);
Name name = new NameImpl("active");
for (final ElasticAttribute attribute : dataStore.getElasticAttributes(name) ){
if (attribute.isStored()) {
attribute.setUse(false);
}
}
featureSource = (ElasticFeatureSource) dataStore.getFeatureSource(TYPE_NAME);
assertEquals(11, featureSource.getCount(Query.ALL));
SimpleFeatureIterator features = featureSource.getFeatures().features();
for (int i=0; i<11; i++) {
assertTrue(features.hasNext());
features.next();
}
}
示例13: run
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
public void run() {
try {
removeAllRenderables();
SimpleFeatureIterator featureIterator = getfeatureCollection().features();
while( featureIterator.hasNext() ) {
SimpleFeature lineFeature = featureIterator.next();
boolean doExtrude = false;
if (mApplyExtrusion && (mHeightFieldName != null || mHasConstantHeight)) {
doExtrude = true;
}
addLine(lineFeature, doExtrude);
}
featureIterator.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例14: example5
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
private static void example5() throws IOException, CQLException {
System.out.println("example5 start\n");
// example5 start
Map<String, Serializable> params = new HashMap<String, Serializable>();
params.put("directory", directory);
DataStore store = DataStoreFinder.getDataStore(params);
SimpleFeatureSource featureSource = store.getFeatureSource("example");
Filter filter = CQL.toFilter("name = 'dave'");
SimpleFeatureCollection features = featureSource.getFeatures(filter);
System.out.println("found :" + features.size() + " feature");
SimpleFeatureIterator iterator = features.features();
try {
while (iterator.hasNext()) {
SimpleFeature feature = iterator.next();
Geometry geometry = (Geometry) feature.getDefaultGeometry();
System.out.println(feature.getID() + " location " + geometry);
}
} catch (Throwable t) {
iterator.close();
}
// example5 end
System.out.println("\nexample5 end\n");
}
示例15: readParameters
import org.geotools.data.simple.SimpleFeatureIterator; //导入方法依赖的package包/类
private List<ShapeFileParameter> readParameters(DataStore dataStore) {
if (dataStore == null)
return Collections.emptyList();
try {
Map<String, ShapeFileParameter> params = new HashMap<>();
String typeName = dataStore.getTypeNames()[0];
SimpleFeatureCollection source = dataStore.getFeatureSource(
typeName).getFeatures();
SimpleFeatureIterator it = source.features();
while (it.hasNext()) {
SimpleFeature feature = it.next();
readParameters(params, feature);
}
it.close();
List<ShapeFileParameter> list = new ArrayList<>();
list.addAll(params.values());
return list;
} catch (Exception e) {
log.error("failed to get parameters from shape file", e);
return Collections.emptyList();
}
}