本文整理汇总了Java中org.opengis.feature.type.GeometryDescriptor类的典型用法代码示例。如果您正苦于以下问题:Java GeometryDescriptor类的具体用法?Java GeometryDescriptor怎么用?Java GeometryDescriptor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeometryDescriptor类属于org.opengis.feature.type包,在下文中一共展示了GeometryDescriptor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addGeometryProperties
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
protected List<PropertyName> addGeometryProperties (FeatureTypeInfo meta, List<PropertyName> oldProperties) throws IOException {
List<AttributeTypeInfo> atts = meta.attributes();
Iterator ii = atts.iterator();
List<PropertyName> properties = new ArrayList<PropertyName>(oldProperties);
while (ii.hasNext()) {
AttributeTypeInfo ati = (AttributeTypeInfo) ii.next();
PropertyName propName = filterFactory.property (ati.getName());
if(meta.getFeatureType().getDescriptor(ati.getName()) instanceof GeometryDescriptor
&& !properties.contains(propName) ) {
properties.add(propName);
}
}
return properties;
}
示例2: getAllAttributes
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
@Override
public List<String> getAllAttributes(boolean includeGeometry) {
List<String> attributeNameList = new ArrayList<String>();
Collection<PropertyDescriptor> descriptorList = getPropertyDescriptorList();
if (descriptorList != null) {
for (PropertyDescriptor property : descriptorList) {
boolean isGeometry = (property instanceof GeometryDescriptor);
if ((isGeometry && includeGeometry) || !isGeometry) {
attributeNameList.add(property.getName().toString());
}
}
}
return attributeNameList;
}
示例3: findDescription
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
public static ShapeFileDesc findDescription(File file) throws IOException {
FileDataStore store = FileDataStoreFinder.getDataStore(file);
SimpleFeatureType schema = store.getSchema();
GeometryDescriptor geometryDescriptor = schema.getGeometryDescriptor();
GeometryType type = geometryDescriptor.getType();
CoordinateReferenceSystem coordinateReferenceSystem = geometryDescriptor.getCoordinateReferenceSystem();
List<AttributeDescriptor> attributeDescriptors = schema.getAttributeDescriptors();
List<String> labels = new ArrayList();
for (AttributeDescriptor a : attributeDescriptors) {
labels.add(a.getLocalName());
//labels
System.out.println(a.getLocalName());
}
//projection system
// System.out.println(coordinateReferenceSystem.getCoordinateSystem().getName().toString());
//type
System.out.println(parseGeometry(type));
double w = store.getFeatureSource().getBounds().getWidth();
double h = store.getFeatureSource().getBounds().getHeight();
return new ShapeFileDesc(coordinateReferenceSystem == null ? null : coordinateReferenceSystem.getCoordinateSystem().getName().toString(),
parseGeometry(type), labels, Math.sqrt(w * w + h * h));
}
示例4: testAlternateGeometry
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的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");
}
示例5: FeatureGeometrySubstitutor
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
/**
* @param oldFeatureType the {@link FeatureType} of the existing features.
* @throws FactoryRegistryException
* @throws SchemaException
*/
public FeatureGeometrySubstitutor( SimpleFeatureType oldFeatureType, Class< ? > newGeometryType ) throws Exception {
List<AttributeDescriptor> oldAttributeDescriptors = oldFeatureType.getAttributeDescriptors();
// create the feature type
SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder();
b.setName(oldFeatureType.getName());
b.setCRS(oldFeatureType.getCoordinateReferenceSystem());
if (newGeometryType == null) {
b.addAll(oldAttributeDescriptors);
} else {
for( AttributeDescriptor attributeDescriptor : oldAttributeDescriptors ) {
if (attributeDescriptor instanceof GeometryDescriptor) {
b.add("the_geom", newGeometryType);
} else {
b.add(attributeDescriptor);
}
}
}
newFeatureType = b.buildFeatureType();
}
示例6: feature2AlphanumericToHashmap
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
public static LinkedHashMap<String, String> feature2AlphanumericToHashmap( SimpleFeature feature ) {
LinkedHashMap<String, String> attributes = new LinkedHashMap<>();
List<AttributeDescriptor> attributeDescriptors = feature.getFeatureType().getAttributeDescriptors();
int index = 0;
for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) {
if (!(attributeDescriptor instanceof GeometryDescriptor)) {
String fieldName = attributeDescriptor.getLocalName();
Object attribute = feature.getAttribute(index);
if (attribute == null) {
attribute = "";
}
String value = attribute.toString();
attributes.put(fieldName, value);
}
index++;
}
return attributes;
}
示例7: buildOutputFeatureType
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
/**
* build the new featuretype for the output geometries
*
* @param inputSchema
* @param attributesSet
* @return
*/
protected SimpleFeatureType buildOutputFeatureType(final SimpleFeatureType inputSchema, final HashSet<String> attributesSet, final String aggregateAttributeName) {
final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
typeBuilder.setName("aggregate");
typeBuilder.setCRS(inputSchema.getCoordinateReferenceSystem());
final GeometryDescriptor geomDescriptor = inputSchema.getGeometryDescriptor();
typeBuilder.add(geomDescriptor.getName().toString(),
geomDescriptor.getType().getClass(),
inputSchema.getCoordinateReferenceSystem());
Iterator<String> attributesSetIt = attributesSet.iterator();
while(attributesSetIt.hasNext()) {
final String attributeName = attributesSetIt.next();
AttributeDescriptor descriptor = inputSchema.getDescriptor(attributeName);
LOGGER.finer("Adding attribute "+attributeName+" to new SimpleFeatureType");
typeBuilder.add(attributeName, descriptor.getType().getClass());
}
// column to store the counts
LOGGER.finer("Adding attribute "+aggregateAttributeName+" to new SimpleFeatureType");
typeBuilder.add(aggregateAttributeName, Integer.class);
return typeBuilder.buildFeatureType();
}
示例8: buildPolygonFeatureType
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
/**
* return a FeatureType like the inputFeatureType just with Polygon as geometrytype
*
* @param inputFeatureType
* @return
*/
private SimpleFeatureType buildPolygonFeatureType(final SimpleFeatureType inputFeatureType) {
final SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder();
typeBuilder.setName("polyonAggregate");
typeBuilder.setCRS(inputFeatureType.getCoordinateReferenceSystem());
final GeometryDescriptor geomDescriptor = inputFeatureType.getGeometryDescriptor();
typeBuilder.add(geomDescriptor.getName().toString(), Polygon.class,
inputFeatureType.getCoordinateReferenceSystem());
for (final AttributeDescriptor descriptor: inputFeatureType.getAttributeDescriptors()) {
if (!(descriptor instanceof GeometryDescriptor)) {
LOGGER.fine("Adding attribute "+descriptor.getName().toString()+" to new SimpleFeatureType");
typeBuilder.add(descriptor);
}
}
typeBuilder.add(POLYGON_WIDTH_ATTRIBUTE_NAME, Double.class);
return typeBuilder.buildFeatureType();
}
开发者ID:geops,项目名称:trafimage-geoserver-transformations,代码行数:26,代码来源:AggregateSimilarLinesAsPolygonsProcess.java
示例9: selectColumns
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
void selectColumns(SimpleFeatureType featureType, String prefix, Query query, StringBuilder sql)
throws IOException {
//other columns
for (AttributeDescriptor att : featureType.getAttributeDescriptors()) {
String columnName = att.getLocalName();
if (att instanceof GeometryDescriptor) {
sql.append(columnName + "_x,");
sql.append(columnName + "_y");
} else {
sql.append(columnName);
}
sql.append(",");
}
}
示例10: updatePointDataSource
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
public void updatePointDataSource(Product product) {
if (product != null) {
final Class pointClass = com.vividsolutions.jts.geom.Point.class;
final ProductNodeGroup<VectorDataNode> vectorDataGroup = product.getVectorDataGroup();
final List<VectorDataNode> vectorDataNodes = new ArrayList<VectorDataNode>();
for (VectorDataNode vectorDataNode : vectorDataGroup.toArray(new VectorDataNode[vectorDataGroup.getNodeCount()])) {
final GeometryDescriptor geometryDescriptor = vectorDataNode.getFeatureType().getGeometryDescriptor();
if (geometryDescriptor != null &&
pointClass.isAssignableFrom(geometryDescriptor.getType().getBinding())) {
vectorDataNodes.add(vectorDataNode);
}
}
final ValueSet valueSet = new ValueSet(vectorDataNodes.toArray());
pointDataSourceProperty.getDescriptor().setValueSet(valueSet);
} else {
pointDataSourceProperty.getDescriptor().setValueSet(null);
dataFieldProperty.getDescriptor().setValueSet(null);
try {
pointDataSourceProperty.setValue(null);
dataFieldProperty.setValue(null);
} catch (ValidationException ignore) {
}
}
}
示例11: setGeometry
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
/**
* Retrieve information about the feature geometry
*/
private void setGeometry() {
GeometryDescriptor geomDesc = featureSource.getSchema().getGeometryDescriptor();
geometryAttributeName = geomDesc.getLocalName();
Class<?> clazz = geomDesc.getType().getBinding();
if (Polygon.class.isAssignableFrom(clazz) ||
MultiPolygon.class.isAssignableFrom(clazz)) {
geometryType = GeomType.POLYGON;
} else if (LineString.class.isAssignableFrom(clazz) ||
MultiLineString.class.isAssignableFrom(clazz)) {
geometryType = GeomType.LINE;
} else {
geometryType = GeomType.POINT;
}
}
示例12: SimpleFeatureTypeImpl
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
/** Creates default userData values.<p>
* The Geometry field <b>is not</b> added by default even when a defaultGeom is provided,
* therefore ensure it is in the attributeTypes list prior to constructing. defaultGeom
* is used to find the Geometry attribute within setDefaultGeom()
*
* @param id The FeatureType id
* @param name The name implementation to be used for finding and displaying this type
* @param attributeTypes A list of AttributeType's each feature of this type must/ will hold.
* @param defaultGeom Descriptor of the Geometry field
*/
public SimpleFeatureTypeImpl(int id, Name name, List<AttributeType> attributeTypes, GeometryDescriptor defaultGeom) {
this.id = id;
this.name = (NameImpl)name;
this.defaultGeometry = defaultGeom;
/* 17/09/13 - Changed if empty list don't add default geom (for new GML2/3 parsing),
* but if null initialise with an empty list and add the geometry definition */
/* 26/03/15 - Changed so Geometry is no longer a part of the attribute type list */
if (attributeTypes==null) {
this.attributeTypes = new ArrayList<AttributeType>();
} else {
this.attributeTypes = attributeTypes;
}
}
示例13: getDefaultGeometryDescriptor
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
/** Build a GeometryDescriptor from a JTS {@link Geometry} with the name of 'the_geom'.<p>
* This method will attempt to get a valid SRID from the Geometry. If it can't
* get one then WGS84 (EPSG:4326) will be set on the GeometryDescriptor, therefore it is
* always best to set it first using {@linkplain Geometry#setSRID(int)}
*
* @param geometry
* @return A new {@link GeometryDescriptor}
*/
public static GeometryDescriptor getDefaultGeometryDescriptor(Geometry geometry) {
Name gName = new NameImpl(geometry.getGeometryType());
GeometryType gType = null;
// Does the geometry contain an SRID we can use?
int srid = geometry.getSRID();
if (srid>0) {
CoordinateReferenceSystem crs = new CoordinateReferenceSystemImpl("EPSG:"+srid);
gType = new GeometryTypeImpl(gName, Geometry.class, crs);
} else {
// Create assuming EPSG:4326
gType = new GeometryTypeImpl(gName, Geometry.class);
}
return new GeometryDescriptorImpl(gType, new NameImpl("the_geom"));
}
示例14: isGeomTypeValid
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
/** Check that the supplied geometry type name is valid for a GeoPackage
*
* @param geomDescriptor The GeometryDescriptor to check from.
* @return True if its valid
*/
public boolean isGeomTypeValid(GeometryDescriptor geomDescriptor) {
String geomType = geomDescriptor.getType().getName().getLocalPart().toLowerCase();
if (geomType.equals("geometry")) {
return true;
} else if (geomType.equals("point")) {
return true;
} else if (geomType.equals("linestring")) {
return true;
} else if (geomType.equals("polygon")) {
return true;
} else if (geomType.equals("multipoint")) {
return true;
} else if (geomType.equals("multilinestring")) {
return true;
} else if (geomType.equals("multipolygon")) {
return true;
} else if (geomType.equals("geomcollection")) {
return true;
} else {
return false;
}
}
示例15: buildTargetSchema
import org.opengis.feature.type.GeometryDescriptor; //导入依赖的package包/类
/**
* When clipping lines and polygons can turn into multilines and multipolygons
*/
private SimpleFeatureType buildTargetSchema(SimpleFeatureType schema) {
SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder();
for (AttributeDescriptor ad : schema.getAttributeDescriptors()) {
if(ad instanceof GeometryDescriptor) {
GeometryDescriptor gd = (GeometryDescriptor) ad;
Class<?> binding = ad.getType().getBinding();
if(Point.class.isAssignableFrom(binding) || GeometryCollection.class.isAssignableFrom(binding)) {
tb.add(ad);
} else {
Class target;
if(LineString.class.isAssignableFrom(binding)) {
target = MultiLineString.class;
} else if(Polygon.class.isAssignableFrom(binding)) {
target = MultiPolygon.class;
} else {
throw new RuntimeException("Don't know how to handle geometries of type "
+ binding.getCanonicalName());
}
tb.minOccurs(ad.getMinOccurs());
tb.maxOccurs(ad.getMaxOccurs());
tb.nillable(ad.isNillable());
tb.add(ad.getLocalName(), target, gd.getCoordinateReferenceSystem());
}
} else {
tb.add(ad);
}
}
tb.setName(schema.getName());
return tb.buildFeatureType();
}