From 02c51358673a82631244d817fa61dff7dc62a051 Mon Sep 17 00:00:00 2001 From: dimitarsazdovski Date: Fri, 15 Sep 2017 21:14:44 +0200 Subject: [PATCH] Changes according to remarks (#2624) --- .../src/main/java/com/baeldung/geotools/ShapeFile.java | 10 +++++----- .../java/com/baeldung/geotools/GeoToolsUnitTest.java | 4 +--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/geotools/src/main/java/com/baeldung/geotools/ShapeFile.java b/geotools/src/main/java/com/baeldung/geotools/ShapeFile.java index e195989489..32b783fbd7 100644 --- a/geotools/src/main/java/com/baeldung/geotools/ShapeFile.java +++ b/geotools/src/main/java/com/baeldung/geotools/ShapeFile.java @@ -41,9 +41,7 @@ public class ShapeFile { SimpleFeatureType CITY = createFeatureType(); - SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(CITY); - - addLocations(featureBuilder, collection); + addLocations(CITY, collection); File shapeFile = getNewShapeFile(); @@ -72,7 +70,7 @@ public class ShapeFile { return CITY; } - public static void addLocations(SimpleFeatureBuilder featureBuilder, DefaultFeatureCollection collection) { + public static void addLocations(SimpleFeatureType CITY, DefaultFeatureCollection collection) { Map> locations = new HashMap<>(); @@ -113,8 +111,10 @@ public class ShapeFile { .get(0), location.getValue() .get(1))); + + SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(CITY); featureBuilder.add(point); - featureBuilder.add(name); + featureBuilder.add(location.getKey()); SimpleFeature feature = featureBuilder.buildFeature(null); collection.add(feature); } diff --git a/geotools/src/test/java/com/baeldung/geotools/GeoToolsUnitTest.java b/geotools/src/test/java/com/baeldung/geotools/GeoToolsUnitTest.java index fad8740598..ffb45c1c5d 100644 --- a/geotools/src/test/java/com/baeldung/geotools/GeoToolsUnitTest.java +++ b/geotools/src/test/java/com/baeldung/geotools/GeoToolsUnitTest.java @@ -16,9 +16,7 @@ public class GeoToolsUnitTest { SimpleFeatureType CITY = ShapeFile.createFeatureType(); - SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(CITY); - - ShapeFile.addLocations(featureBuilder, collection); + ShapeFile.addLocations(CITY, collection); assertNotNull(collection);