public SimpleFeature createPoint(final Coordinate coordinate, final Object[] attributeValues, final String id) { Point p = this.fac.createPoint(coordinate); return this.createPoint(p, attributeValues, id); }
public PointFeatureFactory create() { SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(this.name); b.setCRS(this.crs); b.add("the_geom", Point.class); for (Map.Entry<String, Class<?>> attr : this.attributes.entrySet()) { b.add(attr.getKey(), attr.getValue()); } SimpleFeatureType featureType = b.buildFeatureType(); return new PointFeatureFactory(this.attributes, featureType); } }
public SimpleFeature createPoint(final Coordinate coordinate) { return this.createPoint(coordinate, Collections.<String, Object> emptyMap(), null); }
@Test public void testShapeFileWriterWithSelfCreatedContent_withMatsimFactory_Point() throws IOException { String outFile = utils.getOutputDirectory() + "test.shp"; PointFeatureFactory ff = new PointFeatureFactory.Builder() .setName("EvacuationArea") .setCrs(DefaultGeographicCRS.WGS84) .addAttribute("name", String.class) .create(); SimpleFeature f = ff.createPoint(new Coordinate(10, 20)); Collection<SimpleFeature> features = new ArrayList<SimpleFeature>(); features.add(f); Geometry g0 = (Geometry) f.getDefaultGeometry(); ShapeFileWriter.writeGeometries(features, outFile); SimpleFeatureSource s1 = ShapeFileReader.readDataFile(outFile); SimpleFeatureCollection fts1 = s1.getFeatures(); SimpleFeatureIterator it1 = fts1.features(); SimpleFeature ft1 = it1.next(); Geometry g1 = (Geometry) ft1.getDefaultGeometry(); Assert.assertEquals(g0.getCoordinates().length, g1.getCoordinates().length); } }