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


Java AttributeDescriptor.getType方法代码示例

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


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

示例1: getAttributes

import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的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());
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:18,代码来源:GamaGeoJsonFile.java

示例2: createFeatureWithGeometry

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

}
 
开发者ID:locationtech,项目名称:geowave,代码行数:22,代码来源:GeometryDataSetGenerator.java

示例3: addFeatures

import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的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();
}
 
开发者ID:foursquare,项目名称:shapefile-geo,代码行数:34,代码来源:ShapefileUtils.java

示例4: createFeatureType

import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的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;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:31,代码来源:CentroidManagerGeoWave.java

示例5: create

import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
/**
 * Creates the sample data from the supplied schema.
 *
 * @param schema the schema
 * @param fieldList the field list
 */
public void create(FeatureType schema, List<DataSourceAttributeData> fieldList) {
    if (schema == null) {
        return;
    }

    // Put fields into map for speed
    Map<String, DataSourceAttributeData> fieldMap = 
            new HashMap<String, DataSourceAttributeData>();
    if (fieldList != null) {
        for (DataSourceAttributeData attributeData : fieldList) {
            fieldMap.put(attributeData.getName(), attributeData);
        }
    }

    SimpleFeatureType featureType = (SimpleFeatureType) schema;
    memory = new MemoryDataStore();
    try {
        memory.createSchema(featureType);
    } catch (IOException e) {
        ConsoleManager.getInstance().exception(this, e);
        memory = null;
        return;
    }
    SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType);

    SimpleFeature feature = DataUtilities.template(featureType);

    builder.init((SimpleFeature) feature);
    int index = 0;
    for (AttributeDescriptor descriptor : featureType.getAttributeDescriptors()) {
        AttributeType attributeType = descriptor.getType();
        Object value = null;
        Class<?> fieldType = attributeType.getBinding();
        if (attributeType instanceof GeometryTypeImpl) {
            geometryType = GeometryTypeMapping.getGeometryType(fieldType);

            switch (geometryType) {
            case POLYGON:
                ExamplePolygonInterface examplePolygon = DataSourceFactory
                        .createExamplePolygon(null);
                value = examplePolygon.getPolygon();
                break;
            case LINE:
                ExampleLineInterface exampleLine = DataSourceFactory.createExampleLine(null);
                value = exampleLine.getLine();
                break;
            case POINT:
            default:
                ExamplePointInterface examplePoint = DataSourceFactory.createExamplePoint(null);
                value = examplePoint.getPoint();
                break;
            }
        } else {
            if ((fieldList != null) && (index < fieldList.size())) {
                DataSourceAttributeData attrData = fieldMap.get(descriptor.getLocalName());

                if (attrData != null) {
                    value = attrData.getValue();
                }
            }

            value = getFieldTypeValue(index, attributeType.getName().getLocalPart(), fieldType,
                    value);
        }
        builder.add(value);
        index++;
    }

    SimpleFeature newFeature = builder.buildFeature("1234");
    memory.addFeature(newFeature);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:78,代码来源:CreateSampleData.java

示例6: read

import org.opengis.feature.type.AttributeDescriptor; //导入方法依赖的package包/类
/**
 * Read attribute in position marked by <code>index</code>.
 * 
 * @param index Attribute position to read
 * @return Value for the attribtue in position <code>index</code>
 * @throws IOException
 * @throws ArrayIndexOutOfBoundsException
 */
public Object read(int index) throws IOException,
        ArrayIndexOutOfBoundsException {
    if (line == null) {
        throw new IOException(
                "No content available - did you remeber to call next?");
    }

    AttributeDescriptor attType = type.getDescriptor(index);

    String stringValue = null;
    try {
        // read the value
        stringValue = text[index];

        // trim off any whitespace
        if (stringValue != null) {
            stringValue = stringValue.trim();
        }
        if ("".equals(stringValue)) {
            stringValue = null;
        }
    } catch (RuntimeException e1) {
        e1.printStackTrace();
        stringValue = null;
    }

    // check for special <null> flag
    if ("<null>".equals(stringValue)) {
        stringValue = null;
    }
    if (stringValue == null) {
        if (attType.isNillable()) {
            return null;
        }
    }
    // Use of Converters to convert from String to requested java binding
    Object value = Converters.convert(stringValue, attType.getType()
            .getBinding());

    if (attType.getType() instanceof GeometryType) {
        // this is to be passed on in the geometry objects so the srs name
        // gets encoded
        CoordinateReferenceSystem crs = ((GeometryType) attType.getType())
                .getCoordinateReferenceSystem();
        if (crs != null) {
            // must be geometry, but check anyway
            if (value != null && value instanceof Geometry) {
                ((Geometry) value).setUserData(crs);
            }
        }
    }
    return value;
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:62,代码来源:PropertyAttributeReader.java


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