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


Java SimpleFeatureCollection类代码示例

本文整理汇总了Java中org.geotools.data.simple.SimpleFeatureCollection的典型用法代码示例。如果您正苦于以下问题:Java SimpleFeatureCollection类的具体用法?Java SimpleFeatureCollection怎么用?Java SimpleFeatureCollection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: correctFeatures

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的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;
 }
 
开发者ID:ec-europa,项目名称:sumo,代码行数:19,代码来源:SimpleShapefile.java

示例2: execute

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
@DescribeResult(name = "result", description = "Clipped feature collection")
public SimpleFeatureCollection execute(
        @DescribeParameter(name = "features", description = "Input feature collection") SimpleFeatureCollection features,
        @DescribeParameter(name = "clip", description = "Geometry to use for clipping (in same CRS as input features)") Geometry clip,
        @DescribeParameter(name = "preserveZ", min=0,description = "Attempt to preserve Z values from the original geometry (interpolate value for new points)") Boolean preserveZ)
        throws ProcessException {
    // only get the geometries in the bbox of the clip
    Envelope box = clip.getEnvelopeInternal();
    String srs = null;
    if(features.getSchema().getCoordinateReferenceSystem() != null) {
        srs = CRS.toSRS(features.getSchema().getCoordinateReferenceSystem());
    }
    BBOX bboxFilter = ff.bbox("", box.getMinX(), box.getMinY(), box.getMaxX(), box.getMaxY(), srs);
    
    // default value for preserve Z
    if(preserveZ == null) {
        preserveZ = false;
    }
    
    // return dynamic collection clipping geometries on the fly
    return new ClippingFeatureCollection(features.subCollection(bboxFilter), clip, preserveZ);
}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:23,代码来源:ClipProcess.java

示例3: createCorrectFeatureCollection

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
private SimpleFeatureCollection createCorrectFeatureCollection(FeatureCollection<?, ?> fc) {

        List<SimpleFeature> simpleFeatureList = new ArrayList<SimpleFeature>();
        SimpleFeatureType featureType = null;
        FeatureIterator<?> iterator = fc.features();
        String uuid = UUID.randomUUID().toString();
        int i = 0;
        while (iterator.hasNext()) {
            SimpleFeature feature = (SimpleFeature) iterator.next();

            //if (i == 0) {
                featureType = gtHelper.createFeatureType(feature.getProperties(), (Geometry) feature.getDefaultGeometry(), uuid, feature.getFeatureType().getCoordinateReferenceSystem());
                QName qname = gtHelper.createGML3SchemaForFeatureType(featureType);
                SchemaRepository.registerSchemaLocation(qname.getNamespaceURI(), qname.getLocalPart());
            //}
            SimpleFeature resultFeature = gtHelper.createFeature("ID" + i, (Geometry) feature.getDefaultGeometry(), featureType, feature.getProperties());

            simpleFeatureList.add(resultFeature);
            i++;
        }
        iterator.close();

        ListFeatureCollection resultFeatureCollection = new ListFeatureCollection(featureType, simpleFeatureList);
        return resultFeatureCollection;

    }
 
开发者ID:52North,项目名称:javaps-geotools-backend,代码行数:27,代码来源:GML3BasicGenerator.java

示例4: issueInsert

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
/**
 * Issues a fake dataStoreChange insert event that affects two tile layers: "theLayer" and
 * "theGroup"
 */
private void issueInsert(Map<Object, Object> extendedProperties,
        ReferencedEnvelope affectedBounds) {
    
    TransactionType transaction = EasyMock.createNiceMock(TransactionType.class);
    EasyMock.expect(transaction.getExtendedProperties()).andStubReturn(extendedProperties);
    
    TransactionEvent event = EasyMock.createNiceMock(TransactionEvent.class);
    
    EasyMock.expect(event.getRequest()).andStubReturn(transaction);
    
    EasyMock.expect(event.getLayerName()).andStubReturn(featureTypeQName1);
    
    InsertElementType insert = EasyMock.createNiceMock(InsertElementType.class);
    
    EasyMock.expect(event.getSource()).andStubReturn(insert);
    EasyMock.expect(event.getType()).andStubReturn(TransactionEventType.PRE_INSERT);
    
    SimpleFeatureCollection affectedFeatures = EasyMock.createNiceMock(SimpleFeatureCollection.class);
    EasyMock.expect(affectedFeatures.getBounds()).andStubReturn(affectedBounds);
    EasyMock.expect(event.getAffectedFeatures()).andStubReturn(affectedFeatures);
    EasyMock.replay(transaction, event, insert, affectedFeatures);
    listener.dataStoreChange(event);
}
 
开发者ID:MapStory,项目名称:ms-gs-plugins,代码行数:28,代码来源:BoundsUpdateTransactionListenerTest.java

示例5: compareCarteRecale

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
/**
 * 
 * @param reseauRecale1
 * @param reseauRecale2
 * @throws Exception
 */
private void compareCarteRecale(CarteTopo reseauRecale1,  CarteTopo reseauRecale2) throws Exception {

    CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
    
    GML encode = new GML(Version.WFS1_0);
    encode.setNamespace("geotools", "http://geotools.org");
    
    // Arcs recales du reseau 1
    SimpleFeatureCollection arcs1 = GeOxygeneGeoToolsTypes.convert2FeatureCollection(reseauRecale1.getPopArcs(), sourceCRS);
    ByteArrayOutputStream output1 = new ByteArrayOutputStream();
    encode.encode(output1, arcs1);
    
    // Arcs recales du reseau 2
    SimpleFeatureCollection arcs2 = GeOxygeneGeoToolsTypes.convert2FeatureCollection(reseauRecale2.getPopArcs(), sourceCRS);
    ByteArrayOutputStream output2 = new ByteArrayOutputStream();
    encode.encode(output2, arcs2);
    
    // On compare : est-ce que le XML est comparable ????
    assertXMLEqual(output1.toString(), output2.toString());
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:27,代码来源:ITRecalageAppariement.java

示例6: save

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
/**
 * Save. TODO Make this a real automated test.
 * 
 * @param uploadForm
 *          the upload form
 * @param map
 *          the map
 * @return the string
 * @throws ShapeFile2PostGISCreationException
 * @throws ZipFileExtractionException
 */
@RequestMapping(value = "/saveAndShow", method = RequestMethod.POST)
public String save(@ModelAttribute("uploadForm") UploadForm uploadForm,
    Model map) throws ShapeFile2PostGISCreationException,
    ZipFileExtractionException {
  LOGGER.info("Saving the following file:");
  MultipartFile multipartFile = uploadForm.getFile();
  String filename = multipartFile.getOriginalFilename();
  LOGGER.info("Filename = {}", filename);
  File resultFile = fileToPostgisExporter.getZipFile(multipartFile);
  LOGGER.info("AbsolutePath = {}", resultFile.getAbsolutePath());
  File zipFile = new File(resultFile.getAbsolutePath());
  SimpleFeatureCollection featureCollection = fileToPostgisExporter
      .zipFileToPostGIS(zipFile);
  map.addAttribute("files", filename);
  map.addAttribute("features", featureCollection.size());
  return "file_upload_success";
}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:29,代码来源:FileUploadController.java

示例7: exportUAZ

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
/**
 * Export uaz.
 * 
 * @param project
 *          the project
 * @param userId
 *          the user id
 * @return the string
 * @throws IOException
 *           Signals that an I/O exception has occurred.
 * @throws DataStoreCreationException
 *           the data store creation exception
 * @throws MiddlewarePersistentException
 */
public String exportUAZ(final WifProject project, final String userId)
    throws IOException, DataStoreCreationException,
    MiddlewarePersistentException {
  LOGGER.info("Entering exportUAZ/share in my aurin");
  LOGGER.info("using the following server: {} for database/schema: {}",
      postgisDataStoreConfig.getDataStoreParams().get(HOST.key),
      postgisDataStoreConfig.getDataStoreParams().get(DATABASE.key) + "/"
          + postgisDataStoreConfig.getDataStoreParams().get(SCHEMA.key));
  final String tableName = project.getSuitabilityConfig()
      .getUnifiedAreaZone();
  final DataStore dataStore = DataStoreFinder
      .getDataStore(postgisDataStoreConfig.getDataStoreParams());
  final SimpleFeatureSource featureSource = dataStore
      .getFeatureSource(tableName);
  final SimpleFeatureCollection features = featureSource.getFeatures();

  final String result = shareUAZSnapshot(features, userId, project);
  LOGGER
      .info("exporting finished, information sent to AURIN/middleware persistence!");
  return result;
}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:36,代码来源:PostgisToDataStoreExporter.java

示例8: getWifUAZfromShpFile

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
/**
 * Gets the wif ua zfrom shp file.
 *
 * @param uAZShpURL
 *          the u az shp url
 * @return the wif ua zfrom shp file
 */
public SimpleFeatureCollection getWifUAZfromShpFile(final URL uAZShpURL) {

  LOGGER.info("uAZShpURL FilePath: {} ", uAZShpURL.getFile());
  SimpleFeatureCollection uazFeatureCollection = FeatureCollections
      .newCollection();
  FileDataStore storeUD;
  try {
    storeUD = openFileDataStore(uAZShpURL.getFile());
    final SimpleFeatureSource featureSourceUD = storeUD.getFeatureSource();
    uazFeatureCollection = featureSourceUD.getFeatures();
    LOGGER.debug("featureCollection size : {} ", uazFeatureCollection.size());
  } catch (final IOException e) {
    LOGGER.error("getWifUAZfromShpFile ", e.getMessage());
  }

  return uazFeatureCollection;
}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:25,代码来源:GeodataFinder.java

示例9: getWifUAZfromDB

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
/**
 * Gets the wif ua zfrom db.
 *
 * @param uazTbl
 *          the uaz tbl
 * @return the wif ua zfrom db
 */
public SimpleFeatureCollection getWifUAZfromDB(final String uazTbl) {

  LOGGER.info("getWifUAZfromDB for table : {}", uazTbl);
  SimpleFeatureCollection uazFeatureCollection = FeatureCollections
      .newCollection();
  DataStore wifDataStore;

  try {
    wifDataStore = openPostgisDataStore();
    final SimpleFeatureSource featureSourceUD = wifDataStore
        .getFeatureSource(uazTbl);
    uazFeatureCollection = featureSourceUD.getFeatures();
    LOGGER.info("UAZ featureCollection size : {} ",
        uazFeatureCollection.size());
  } catch (final IOException e) {
    LOGGER.error("could not access table {} ", uazTbl);
  }

  return uazFeatureCollection;
}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:28,代码来源:GeodataFinder.java

示例10: zipFileToPostGIS

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
/**
 * Zip file to post gis.
 * 
 * @param shpFile
 *          the shp file
 * @return the simple feature collection
 * @throws ShapeFile2PostGISCreationException
 *           the shape file2 post gis creation exception
 */
public SimpleFeatureCollection zipFileToPostGIS(final File shpFile)
    throws ShapeFile2PostGISCreationException {
  final String msg = "Converting shape file operation failed...";

  try {

    final FileDataStore store = FileDataStoreFinder.getDataStore(shpFile);
    final SimpleFeatureSource featureSource = store.getFeatureSource();
    final SimpleFeatureCollection features = featureSource.getFeatures();
    LOGGER.info("Shape filename = {}", featureSource.getSchema()
        .getTypeName());
    final CoordinateReferenceSystem crs = featureSource.getSchema()
        .getCoordinateReferenceSystem();
    validatorCRS.validateSimple(crs, msg);
    return features;
  } catch (final Exception e) {
    LOGGER.error(msg, e.getMessage());
    throw new ShapeFile2PostGISCreationException(msg, e);
  }
}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:30,代码来源:FileToPostgisExporter.java

示例11: getOutcomeTest

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的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));
}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:25,代码来源:SuitabilityGeoJSONOutcomeIT.java

示例12: validateTest

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
/**
 * Creates the project test.
 * 
 * @throws Exception
 *           the exception
 */
@Test(enabled = true, groups = { "setup", "service" })
public void validateTest() throws Exception {
  // String path = "shapefiles/Perth_small_test.shp";
  // File input = fileUtils.getJsonFile(path);
  // String path =
  // "C:\\Users\\Marcos Nino-Ruiz\\Documents\\WhatIF\\nw\\Perth_Union_40000\\Perth_Union_40000.shp";
  String path = "C:\\Users\\Marcos Nino-Ruiz\\Documents\\WhatIF\\nw\\Perth_Union_200000\\Perth_Union_200000.shp";
  File input = new File(path);

  SimpleFeatureCollection featureCollection = fileToPostgisExporter
      .zipFileToPostGIS(input);
  CoordinateReferenceSystem crs = featureCollection.getSchema()
      .getCoordinateReferenceSystem();
  // crs = validatorCRS.validate(crs, "");
  crs = validatorCRS.validateSimple(crs, "");

}
 
开发者ID:AURIN,项目名称:online-whatif,代码行数:24,代码来源:ValidatorCRSIT.java

示例13: getStyle

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
@SuppressWarnings("unchecked")
   public Style getStyle(SimpleFeatureCollection collection, String attribute) {
this.attribute = attribute;
Style style = styler.getStyle(collection, attribute);
List<String> titles = styler.getTitles();
List<Color> colors = styler.getColors();
for (int i = 0; i < titles.size(); i++) {

    tableModel.setValueAt(titles.get(i), i, TITLE_COL);

    tableModel.setValueAt(colors.get(i), i, COLOR_COL);
}
this.repaint();
return style;

   }
 
开发者ID:ianturton,项目名称:ShapefileViewer,代码行数:17,代码来源:JLegendPanel.java

示例14: OSMInfo

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的package包/类
public OSMInfo(final URL url, final long modificationStamp) {
	super(modificationStamp);
	CoordinateReferenceSystem crs = null;
	ReferencedEnvelope env2 = new ReferencedEnvelope();

	int number = 0;
	try {
		final File f = new File(url.toURI());
		final GamaOsmFile osmfile = new GamaOsmFile(null, f.getAbsolutePath());
		attributes.putAll(osmfile.getOSMAttributes(GAMA.getRuntimeScope()));

		final SimpleFeatureType TYPE = DataUtilities.createType("geometries", "geom:LineString");
		final ArrayList<SimpleFeature> list = new ArrayList<SimpleFeature>();
		for (final IShape shape : osmfile.iterable(null)) {
			list.add(SimpleFeatureBuilder.build(TYPE, new Object[] { shape.getInnerGeometry() }, null));
		}
		final SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, list);
		final SimpleFeatureSource featureSource = DataUtilities.source(collection);

		env2 = featureSource.getBounds();
		number = osmfile.nbObjects;
		crs = osmfile.getOwnCRS(null);
	} catch (final Exception e) {
		System.out.println("Error in reading metadata of " + url);
		hasFailed = true;

	} finally {

		// approximation of the width and height in meters.
		width = env2 != null ? env2.getWidth() * (FastMath.PI / 180) * 6378137 : 0;
		height = env2 != null ? env2.getHeight() * (FastMath.PI / 180) * 6378137 : 0;
		itemNumber = number;
		this.crs = crs;
	}

}
 
开发者ID:gama-platform,项目名称:gama,代码行数:37,代码来源:GamaOsmFile.java

示例15: getAttributes

import org.geotools.data.simple.SimpleFeatureCollection; //导入依赖的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


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