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


Java SimpleFeature.getAttribute方法代码示例

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


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

示例1: CommunityAreas

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的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();
    }
}
 
开发者ID:thekingofkings,项目名称:embedding,代码行数:23,代码来源:CommunityAreas.java

示例2: buildTimedValuesFromFeature

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的package包/类
private List<TimedValue> buildTimedValuesFromFeature(Datasource datasource, SimpleFeature feature, Subject subject) {
    List<TimedValue> timedValues = new ArrayList<>();
    LocalDateTime modified;
    try {
         modified = getTimestampForFeature(feature);
    } catch (ParsingException pe) {
        log.warn("Unable to get timestamp for feature: {}", feature);
        return timedValues;
    }
    for (Attribute attribute : datasource.getTimedValueAttributes()){
        if (feature.getAttribute(attribute.getLabel()) == null)
            continue;
        Double value = Double.parseDouble(feature.getAttribute(attribute.getLabel()).toString());
        timedValues.add(new TimedValue(subject, attribute, modified, value));
    }
    return timedValues;
}
 
开发者ID:FutureCitiesCatapult,项目名称:TomboloDigitalConnector,代码行数:18,代码来源:AbstractGeotoolsDataStoreImporter.java

示例3: getValueAt

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的package包/类
@Override
public Object getValueAt(int row, int column) {
    if ((row < 0) || (row >= getRowCount())) {
        return null;
    }

    if ((column < 0) || (column >= getColumnCount())) {
        return null;
    }

    SimpleFeature feature = getFeature(row);

    if (feature != null) {
        if (column == geometryFieldIndex) {
            Object defaultGeometry = feature.getDefaultGeometry();
            return defaultGeometry;
        } else {
            Object attributeData = feature.getAttribute(column);
            return attributeData;
        }
    }
    return null;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:24,代码来源:InLineFeatureModel.java

示例4: highlightSelectedPolygon

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的package包/类
/**
 * hightlight the selected Polygon.
 * @param polygonID the selected Polygon
 */
public void highlightSelectedPolygon(String polygonID) {
    for (SimpleFeature simpleFeature : polygonFeatureCollection) {
        String featureID = (String) simpleFeature.getAttribute("id");
        if (featureID.equals(polygonID)) {
            Style style =
                createSelectedStyle(simpleFeature.getIdentifier());
            org.geotools.map.Layer layer = null;
            for (org.geotools.map.Layer layers : mapPane.getMapContent()
                    .layers()) {
                String t = layers.getTitle();
                if (t != null && t.equals(POLYGON_LAYER_TITLE)) {
                    layer = layers;
                }
            }
            if (layer instanceof FeatureLayer) {
                ((FeatureLayer) layer).setStyle(style);
            }
        }
    }
}
 
开发者ID:gdi-by,项目名称:downloadclient,代码行数:25,代码来源:WMSMapSwing.java

示例5: hasNext

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的package包/类
public boolean hasNext() {
    while (next == null && delegate.hasNext()) {
        boolean clippedOut = false;
        
        // try building the clipped feature out of the original feature, if the
        // default geometry is clipped out, skip it
        SimpleFeature f = delegate.next();
        for (AttributeDescriptor ad : f.getFeatureType().getAttributeDescriptors()) {
            Object attribute = f.getAttribute(ad.getName());
            if (ad instanceof GeometryDescriptor) {
                Class target = ad.getType().getBinding();
                attribute = clipGeometry((Geometry) attribute, target, ((GeometryDescriptor) ad).getCoordinateReferenceSystem());
                if (attribute == null && f.getFeatureType().getGeometryDescriptor() == ad) {
                    // the feature has been clipped out
                    fb.reset();
                    clippedOut = true;
                    break;
                }
            } 
            fb.add(attribute);
        }
        
        if(!clippedOut) {
            // build the next feature
            next = fb.buildFeature(f.getID());
        }
        fb.reset();
    }

    return next != null;
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:32,代码来源:ClipProcess.java

示例6: getTimeZone

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的package包/类
private String getTimeZone(double lat, double lon){
    Point point = geometryFactory.createPoint(new Coordinate(lon,lat));
    List<Object> regions = quadtree.query(point.getEnvelopeInternal());
    for(Object o : regions){
        SimpleFeature feature = (SimpleFeature) o;
        Geometry geom = (Geometry) feature.getDefaultGeometry();
        if(point.within(geom)) {
            return (String)(feature.getAttribute("TZID"));
        }
    }
    throwError(BAD_REQUEST.getStatusCode(),"could not localize location " + lat + ", " + lon);
    return null;
}
 
开发者ID:graphhopper,项目名称:timezone,代码行数:14,代码来源:TimeZoneService.java

示例7: buildFixedValuesFromFeature

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的package包/类
private List<FixedValue> buildFixedValuesFromFeature(Datasource datasource, SimpleFeature feature, Subject subject) {
    List<FixedValue> fixedValues = new ArrayList<>();

    for (Attribute attribute : datasource.getFixedValueAttributes()){
        if (feature.getAttribute(attribute.getLabel()) == null)
            continue;
        String value = feature.getAttribute(attribute.getLabel()).toString();
        fixedValues.add(new FixedValue(subject, attribute, value));
    }
    return fixedValues;
}
 
开发者ID:FutureCitiesCatapult,项目名称:TomboloDigitalConnector,代码行数:12,代码来源:AbstractGeotoolsDataStoreImporter.java

示例8: determineGeometryType

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的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

示例9: updateFeature

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的package包/类
public static void updateFeature(SimpleFeature feature) {
    Point point = (Point) feature.getDefaultGeometry();
    Double step = (Double) feature.getAttribute("step");

    Double newLong = nudgeLong(point.getX() + step);

    Geometry newPoint = WKTUtils$.MODULE$.read("POINT(" + newLong + " " + point.getY() + ")");

    feature.setAttribute("dtg", new Date());
    feature.setDefaultGeometry(newPoint);
}
 
开发者ID:geomesa,项目名称:geomesa-tutorials,代码行数:12,代码来源:KafkaLoadTester.java

示例10: prepareOperations

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的package包/类
/**
 * Filters operations and triggers the analysis
 */
private void prepareOperations(List<IVgiFeature> batch) {
	for (IVgiFeature feature : batch) {
		
		/** Filter by tag */
		if (!feature.filterByTag(settings.getFilterTag())) continue;
		
		if (settings.getCurrentPolygon() != null || settings.isWriteGeometryFiles()) {
			if (settings.getCurrentPolygon() != null) {
				if (!settings.getCurrentPolygon().getPolygon().getEnvelopeInternal().intersects(feature.getBBox())) continue;
			}
			
			SimpleFeature f = geometryAssemblerConsumer.assembleGeometry(feature, null);
			if (f == null) continue;
			
			if (((Geometry)f.getDefaultGeometry()).getGeometryType().equals("LineString")) {
				double length = GeomUtils.calculateLengthMeterFromWGS84LineStringAndoyer((LineString)f.getDefaultGeometry());
				f.setAttribute("length", length);
			}
			
			if (settings.getCurrentPolygon() != null) {
				Geometry geometry = (Geometry)f.getDefaultGeometry();
				if (geometry == null || geometry.disjoint(settings.getCurrentPolygon().getPolygon())) continue;					
			}
			
			if (settings.isWriteGeometryFiles()) {
				if (!mapFeatures.containsKey(f.getFeatureType())) mapFeatures.put(f.getFeatureType(), new DefaultFeatureCollection(f.getFeatureType().getTypeName(), f.getFeatureType()));
				if (!(boolean)f.getAttribute("deleted")) {
					mapFeatures.get(f.getFeatureType()).add(f);
				}
			}
		}
		
		featureList.add(feature);
	}
	
	analyzeFeatures();
}
 
开发者ID:SGroe,项目名称:vgi-analytics-framework,代码行数:41,代码来源:VgiAnalysisConsumer.java

示例11: exportOk

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的package包/类
@Test
public void exportOk() throws Exception {
    String schemaName = "shpexport".toLowerCase();
    Connection con = null;
    try{
        con = TestUtilSql.connectPG();
        TestUtilSql.createOrReplaceSchema(con, schemaName);
        Statement s1 = con.createStatement();
        s1.execute("CREATE TABLE "+schemaName+".exportdata(t_id serial, \"Aint\" integer, adec decimal(7,1), atext varchar(40), aenum varchar(120),adate date, atimestamp timestamp, aboolean boolean,geom_so geometry(POINT,2056))");
        s1.execute("INSERT INTO "+schemaName+".exportdata(t_id, \"Aint\", adec, atext, adate, atimestamp, aboolean,geom_so) VALUES (1,2,3.4,'abc','2013-10-21','2015-02-16T08:35:45.000','true',ST_GeomFromText('POINT(2638000.0 1175250.0)',2056))");
        s1.execute("INSERT INTO "+schemaName+".exportdata(t_id) VALUES (2)");
        s1.close();
        TestUtilSql.grantDataModsInSchemaToUser(con, schemaName, TestUtilSql.PG_CON_DMLUSER);

        con.commit();
        TestUtilSql.closeCon(con);

        GradleVariable[] gvs = {GradleVariable.newGradleProperty(TestUtilSql.VARNAME_PG_CON_URI, TestUtilSql.PG_CON_URI)};
        TestUtil.runJob("jobs/ShpExport", gvs);

        //check results
        {
            System.out.println("cwd "+new File(".").getAbsolutePath());
            //Open the file for reading
            FileDataStore dataStore = FileDataStoreFinder.getDataStore(new File("jobs/ShpExport/data.shp"));
            SimpleFeatureSource featuresSource = dataStore.getFeatureSource();
            SimpleFeatureIterator featureCollectionIter=featuresSource.getFeatures().features();
            // feature object
            {
                SimpleFeature shapeObj=(SimpleFeature) featureCollectionIter.next();
                Object attr1=shapeObj.getAttribute("Aint");
                assertEquals(2,attr1);
                Object attr2=shapeObj.getAttribute("atext");
                assertEquals("abc",attr2);
                Object attr3=shapeObj.getAttribute("adec");
                assertEquals(3.4,attr3);
                Object attr4=shapeObj.getAttribute(ShapeReader.GEOTOOLS_THE_GEOM);
                assertEquals(new Coordinate(2638000.0,1175250.0),((Point)attr4).getCoordinate());
                Object attr5=shapeObj.getAttribute("adate");
                assertEquals(new java.util.Date(2013-1900,10-1,21),attr5);
                Object attr6=shapeObj.getAttribute("aboolean");
                assertEquals(String.class.getName(),attr6.getClass().getName());
                assertEquals("true",attr6);
                Object attr7=shapeObj.getAttribute("atimestamp");
                assertEquals(String.class.getName(),attr7.getClass().getName());
                assertEquals("2015-02-16T08:35:45.000",attr7);
            }
            featureCollectionIter.close();
            dataStore.dispose();
        }
    }
    finally {
        TestUtilSql.closeCon(con);
    }
}
 
开发者ID:sogis,项目名称:gretl,代码行数:56,代码来源:ShpExportTest.java

示例12: convert2IFeatureCollection

import org.opengis.feature.simple.SimpleFeature; //导入方法依赖的package包/类
public static IFeatureCollection<?> convert2IFeatureCollection(SimpleFeatureCollection collection) {
	logger.info("Schema name = " + collection.getSchema().getName() + " - "
			+ collection.getSchema().getName().getLocalPart());
	SchemaDefaultFeature schemaDefaultFeature = new SchemaDefaultFeature();
	schemaDefaultFeature.setNom(collection.getSchema().getName().getLocalPart());
	schemaDefaultFeature.setNomSchema(collection.getSchema().getName().getLocalPart());
	/** Créer un featuretype de jeu correspondant */
	fr.ign.cogit.geoxygene.schema.schemaConceptuelISOJeu.FeatureType newFeatureType = new fr.ign.cogit.geoxygene.schema.schemaConceptuelISOJeu.FeatureType();
	newFeatureType.setTypeName(collection.getSchema().getName().getLocalPart());
	int nbFields = collection.getSchema().getAttributeCount();
	Map<Integer, String[]> attLookup = new HashMap<Integer, String[]>(0);
	for (int i = 0; i < nbFields; i++) {
		AttributeType type = new AttributeType();
		String nomField = collection.getSchema().getAttributeDescriptors().get(i).getLocalName();
		String memberName = nomField;
		String valueType = collection.getSchema().getAttributeDescriptors().get(i).getType().getBinding()
				.getSimpleName();
		type.setNomField(nomField);
		type.setMemberName(memberName);
		type.setValueType(valueType);
		newFeatureType.addFeatureAttribute(type);
		attLookup.put(new Integer(i), new String[] { nomField, memberName });
		logger.info("Attribute " + i + " added " + nomField + " : " + valueType);
	}
	/** Création d'un schéma associé au featureType */
	newFeatureType
			.setGeometryType(geometryType(collection.getSchema().getGeometryDescriptor().getType().getBinding()));
	logger.info("Schema Created with " + newFeatureType.getGeometryType());
	schemaDefaultFeature.setFeatureType(newFeatureType);
	newFeatureType.setSchema(schemaDefaultFeature);
	schemaDefaultFeature.setAttLookup(attLookup);
	Population<DefaultFeature> population = new Population<DefaultFeature>(schemaDefaultFeature.getNom());
	population.setFeatureType(newFeatureType);
	SimpleFeatureIterator iterator = collection.features();
	int id = 0;
	while (iterator.hasNext()) {
		SimpleFeature feature = (SimpleFeature) iterator.next();
		DefaultFeature defaultFeature = new DefaultFeature();
		defaultFeature.setFeatureType(schemaDefaultFeature.getFeatureType());
		defaultFeature.setSchema(schemaDefaultFeature);
		try {
			Geometry geom = (Geometry) feature.getDefaultGeometry();
			IGeometry geometry = AdapterFactory.toGM_Object(geom);
			defaultFeature.setGeom(geometry);
		} catch (Exception e) {
			e.printStackTrace();
		}
		Object[] attributes = new Object[nbFields];
		for (int i = 0; i < nbFields; i++) {
			attributes[i] = feature.getAttribute(i);
		}
		defaultFeature.setAttributes(attributes);
		defaultFeature.setId(id++);
		population.add(defaultFeature);
	}
	logger.info(population.size() + " Features converted");
	return population;
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:59,代码来源:GeOxygeneGeoToolsTypes.java


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