本文整理汇总了Java中org.opengis.feature.type.GeometryType类的典型用法代码示例。如果您正苦于以下问题:Java GeometryType类的具体用法?Java GeometryType怎么用?Java GeometryType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeometryType类属于org.opengis.feature.type包,在下文中一共展示了GeometryType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: GamaGisGeometry
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
public GamaGisGeometry(final Geometry g, final Feature feature) {
super(g);
if (feature != null) {
// We filter out the geometries (already loaded before)
for (final Property p : feature.getProperties()) {
if (!(p.getType() instanceof GeometryType)) {
final String type = p.getDescriptor().getType().getBinding().getSimpleName();
if ("String".equals(type)) {
String val = (String) p.getValue();
if (val != null && ((val.startsWith("'") && val.endsWith("'")) || (val.startsWith("\"") && val.endsWith("\""))))
val = val.substring(1, val.length() - 1);
setAttribute(p.getName().getLocalPart(), val);
} else
setAttribute(p.getName().getLocalPart(), p.getValue());
}
}
}
}
示例2: getAttributes
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
@Override
public IList<String> getAttributes(final IScope scope) {
final Map<String, String> attributes = new LinkedHashMap<>();
final SimpleFeatureCollection store = getFeatureCollection(scope);
final java.util.List<AttributeDescriptor> att_list = store.getSchema().getAttributeDescriptors();
for (final AttributeDescriptor desc : att_list) {
String type;
if (desc.getType() instanceof GeometryType) {
type = "geometry";
} else {
type = Types.get(desc.getType().getBinding()).toString();
}
attributes.put(desc.getName().getLocalPart(), type);
}
return GamaListFactory.createWithoutCasting(Types.STRING, attributes.keySet());
}
示例3: findDescription
import org.opengis.feature.type.GeometryType; //导入依赖的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: parseGeometry
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
private static GeometryTypeString parseGeometry(GeometryType type) {
GeometryTypeString geometryType;
//Geometry type
Class<?> clazz = type.getBinding();
if (Polygon.class.isAssignableFrom(clazz)
|| MultiPolygon.class.isAssignableFrom(clazz)) {
geometryType = GeometryTypeString.POLYGON;
} else if (LineString.class.isAssignableFrom(clazz)
|| MultiLineString.class.isAssignableFrom(clazz)) {
geometryType = GeometryTypeString.LINE;
} else {
geometryType = GeometryTypeString.POINT;
}
return geometryType;
}
示例5: createFeatureWithGeometry
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
private SimpleFeature createFeatureWithGeometry(
final Geometry geometry ) {
final Object[] values = new Object[builder.getFeatureType().getAttributeCount()];
for (int i = 0; i < values.length; i++) {
final AttributeDescriptor desc = builder.getFeatureType().getDescriptor(
i);
if (desc.getType() instanceof GeometryType) {
values[i] = geometry;
}
else {
final Class<?> binding = desc.getType().getBinding();
if (String.class.isAssignableFrom(binding)) {
values[i] = UUID.randomUUID().toString();
}
}
}
return builder.buildFeature(
UUID.randomUUID().toString(),
values);
}
示例6: equals
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
@Override
public boolean equals(Object other) {
if (!(other instanceof GeometryType)) {
return false;
}
if (!super.equals(other)) {
return false;
}
GeometryType o = (GeometryType) other;
if (CRS == null) {
return o.getCoordinateReferenceSystem() == null;
}
if (o.getCoordinateReferenceSystem() == null) {
return false;
}
return true;
}
示例7: getDefaultGeometryDescriptor
import org.opengis.feature.type.GeometryType; //导入依赖的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"));
}
示例8: equals
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
@Override
public boolean equals(Object other) {
if (!(other instanceof GeometryType)) {
return false;
}
if (!super.equals(other)) {
return false;
}
GeometryType o = (GeometryType) other;
if (CRS == null) {
return o.getCoordinateReferenceSystem() == null;
}
if (o.getCoordinateReferenceSystem() == null) {
return false;
}
return CRS.equals(o.getCoordinateReferenceSystem());
}
示例9: cloneWithDimensionality
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
/**
* Clones the given schema, changing the geometry attribute to match the given dimensionality.
*
* @param schema schema to clone
* @param dimensionality dimensionality for the geometry 1= points, 2= lines, 3= polygons
*
*/
private FeatureType cloneWithDimensionality(FeatureType schema, int dimensionality) {
SimpleFeatureType simpleFt = (SimpleFeatureType) schema;
SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName(schema.getName());
builder.setCRS(schema.getCoordinateReferenceSystem());
for (AttributeDescriptor desc : simpleFt.getAttributeDescriptors()) {
if (isMixedGeometry(desc)) {
GeometryDescriptor geomDescriptor = (GeometryDescriptor) desc;
GeometryType geomType = geomDescriptor.getType();
Class<?> geometryClass = getGeometryForDimensionality(dimensionality);
GeometryType gt = new GeometryTypeImpl(geomType.getName(), geometryClass,
geomType.getCoordinateReferenceSystem(), geomType.isIdentified(),
geomType.isAbstract(), geomType.getRestrictions(), geomType.getSuper(),
geomType.getDescription());
builder.add(new GeometryDescriptorImpl(gt, geomDescriptor.getName(),
geomDescriptor.getMinOccurs(), geomDescriptor.getMaxOccurs(),
geomDescriptor.isNillable(), geomDescriptor.getDefaultValue()));
} else {
builder.add(desc);
}
}
schema = builder.buildFeatureType();
return schema;
}
示例10: getPropertyDescriptorList
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
/**
* Gets the property descriptor list.
*
* @return the property descriptor list
*/
public Collection<PropertyDescriptor> getPropertyDescriptorList() {
if (schema != null) {
return schema.getDescriptors();
} else {
if (geometryType == GeometryTypeEnum.RASTER) {
if (rasterPropertyDescriptorList == null) {
rasterPropertyDescriptorList = new ArrayList<PropertyDescriptor>();
CoordinateReferenceSystem crs = null;
boolean isIdentifiable = false;
boolean isAbstract = false;
List<Filter> restrictions = null;
AttributeType superType = null;
InternationalString description = null;
GeometryType type = featureTypeFactory.createGeometryType(
new NameImpl(rasterGeometryField), GridCoverage2D.class, crs,
isIdentifiable, isAbstract, restrictions, superType, description);
GeometryDescriptor descriptor = featureTypeFactory.createGeometryDescriptor(
type, new NameImpl(rasterGeometryField), 0, 1, false, null);
rasterPropertyDescriptorList.add(descriptor);
}
return rasterPropertyDescriptorList;
}
}
return null;
}
示例11: addFeatures
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
/**
* Adds features to the store.
* @param featureStore the store.
* @param features the features to write
* @throws IOException if there is an issue writing the features
* @see com.foursquare.geo.shapes.ShapefileUtils#featureStore
*/
public static void addFeatures(AbstractDataStore featureStore, Iterable<? extends WritableFeature> features) throws IOException {
Transaction transaction = Transaction.AUTO_COMMIT;
SimpleFeatureType schema = featureStore.getSchema(featureStore.getNames().get(0));
FeatureWriter<SimpleFeatureType, SimpleFeature> writer = featureStore.getFeatureWriterAppend(
schema.getTypeName(),
transaction
);
List<Name> attributeNames = new ArrayList<Name>();
for (AttributeDescriptor desc : schema.getAttributeDescriptors()) {
if (!(desc.getType() instanceof GeometryType)) {
attributeNames.add(desc.getName());
}
}
for (WritableFeature feature : features) {
SimpleFeature newFeature = writer.next();
newFeature.setDefaultGeometry(feature.getDefaultGeometry());
for (Name name : attributeNames) {
newFeature.setAttribute(name, feature.getAttribute(name));
}
writer.write();
}
writer.close();
transaction.commit();
transaction.close();
}
示例12: createFeatureType
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
private static SimpleFeatureType createFeatureType(
final SimpleFeatureType featureType,
final Class<? extends Geometry> shapeClass ) {
try {
final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder();
builder.setName(featureType.getName().getLocalPart());
builder.setNamespaceURI(featureType.getName().getNamespaceURI());
builder.setCRS(featureType.getCoordinateReferenceSystem());
for (final AttributeDescriptor attr : featureType.getAttributeDescriptors()) {
if (attr.getType() instanceof GeometryType) {
builder.add(
attr.getLocalName(),
shapeClass);
}
else {
builder.add(
attr.getLocalName(),
attr.getType().getBinding());
}
}
return builder.buildFeatureType();
}
catch (final Exception e) {
LOGGER.warn(
"Schema Creation Error. Hint: Check the SRID.",
e);
}
return null;
}
示例13: getSchema
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
/** Get a constructed SimpleFeatureType based on all the available
* details for this table.
*
* @return
*/
public SimpleFeatureType getSchema() {
// Build the geometry descriptor for this 'image' SimpleFeatureType.
CoordinateReferenceSystem thisCRS = getBounds().getCoordinateReferenceSystem();
GeometryType gType = new GeometryTypeImpl(
new NameImpl("Envelope"),
Geometry.class,
new CoordinateReferenceSystemImpl( thisCRS.getName().getCode() ) );
// We only have two attributes - The raster data and a bounding box for the tile
ArrayList<AttributeType> attrs = new ArrayList<AttributeType>();
attrs.add(new AttributeTypeImpl(new NameImpl("the_image"), Byte[].class ) );
attrs.add(new AttributeTypeImpl(new NameImpl("the_geom"), Geometry.class) );
attrs.add(new AttributeTypeImpl(new NameImpl("tile_column"), Integer.class) );
attrs.add(new AttributeTypeImpl(new NameImpl("tile_row"), Integer.class) );
attrs.add(new AttributeTypeImpl(new NameImpl("zoom_level"), Integer.class) );
attrs.trimToSize();
// Construct the feature type
SimpleFeatureType featureType = new SimpleFeatureTypeImpl(
new NameImpl( tableName ),
attrs,
new GeometryDescriptorImpl(gType, new NameImpl("the_geom"))
);
return featureType;
}
示例14: determineGeometryType
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
/**
* Determine geometry type.
*
* @param type the type
*/
private void determineGeometryType(GeometryType type) {
Class<?> bindingType = type.getBinding();
dsInfo.setGeometryType(GeometryTypeMapping.getGeometryType(bindingType));
}
示例15: createFeatureType
import org.opengis.feature.type.GeometryType; //导入依赖的package包/类
/**
* You cannot call this once the dialog is closed, see the okPressed method.
* @param originalFeatureType
* @param expressions
* @param names
* @return a SimpleFeatureType created based on the contents of Text
*/
private SimpleFeatureType createFeatureType( String expressionString, SimpleFeatureType originalFeatureType,
List<String> names, List<Expression> expressions ) throws SchemaException {
SimpleFeatureTypeBuilder build = new SimpleFeatureTypeBuilder();
for( int i = 0; i < names.size(); i++ ) {
String name = names.get(i);
Expression expression = expressions.get(i);
Object value = expression.evaluate(sample);
// hack because sometimes expression returns null. I think the real bug is with
// AttributeExpression
Class< ? > binding = null;
if (value == null) {
if (expression instanceof PropertyName) {
String path = ((PropertyName) expression).getPropertyName();
AttributeType attributeType = sample.getFeatureType().getType(path);
if (attributeType == null) {
throw new ModelsIllegalargumentException("Attribute type is null", this.getClass().getSimpleName(), pm);
}
binding = attributeType.getClass();
}
} else {
binding = value.getClass();
}
if (binding == null) {
throw new ModelsIllegalargumentException("Binding is null", this.getClass().getSimpleName(), pm);
}
if (Geometry.class.isAssignableFrom(binding)) {
CoordinateReferenceSystem crs;
AttributeType originalAttributeType = originalFeatureType.getType(name);
if (originalAttributeType instanceof GeometryType) {
crs = ((GeometryType) originalAttributeType).getCoordinateReferenceSystem();
} else {
crs = originalFeatureType.getCoordinateReferenceSystem();
}
build.crs(crs);
build.add(name, binding);
} else {
build.add(name, binding);
}
}
build.setName(getNewTypeName(originalFeatureType.getTypeName()));
return build.buildFeatureType();
}