Commit d2fd154a authored by Eric Duminil's avatar Eric Duminil
Browse files

Allow floats too

parent 7a083c59
...@@ -7,7 +7,6 @@ import java.util.ArrayList; ...@@ -7,7 +7,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.geotools.data.DataStore; import org.geotools.data.DataStore;
import org.geotools.data.DataStoreFinder; import org.geotools.data.DataStoreFinder;
import org.geotools.data.FeatureSource; import org.geotools.data.FeatureSource;
...@@ -17,13 +16,15 @@ import org.locationtech.jts.geom.Point; ...@@ -17,13 +16,15 @@ import org.locationtech.jts.geom.Point;
import org.opengis.feature.simple.SimpleFeature; import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType; import org.opengis.feature.simple.SimpleFeatureType;
public class TreeKatasterData {
public class TreeKatasterData
{
public static final double TRUNK_PERCENTAGE = 0.2; public static final double TRUNK_PERCENTAGE = 0.2;
public static final double CROWN_PERCENTAGE = 1 - TRUNK_PERCENTAGE; public static final double CROWN_PERCENTAGE = 1 - TRUNK_PERCENTAGE;
private List<Tree> trees; private List<Tree> trees;
public static TreeKatasterData parseTreeKatasterData(Path path) throws IOException { public static TreeKatasterData parseTreeKatasterData(Path path) throws IOException {
TreeKatasterData result = new TreeKatasterData(); TreeKatasterData result = new TreeKatasterData();
Map<String, Object> readParameters = new HashMap<>(); Map<String, Object> readParameters = new HashMap<>();
...@@ -50,7 +51,7 @@ public class TreeKatasterData { ...@@ -50,7 +51,7 @@ public class TreeKatasterData {
if (treeHeightObject == null) { if (treeHeightObject == null) {
continue; continue;
} }
int treeHeight = Integer.parseInt(treeHeightObject.toString()); float treeHeight = Float.parseFloat(treeHeightObject.toString());
double crownHeight = CROWN_PERCENTAGE * treeHeight; double crownHeight = CROWN_PERCENTAGE * treeHeight;
double trunkHeight = TRUNK_PERCENTAGE * treeHeight; double trunkHeight = TRUNK_PERCENTAGE * treeHeight;
tree.setCrownHeight(crownHeight); tree.setCrownHeight(crownHeight);
...@@ -65,7 +66,7 @@ public class TreeKatasterData { ...@@ -65,7 +66,7 @@ public class TreeKatasterData {
if (trunkCirc == null) { if (trunkCirc == null) {
continue; continue;
} }
int circInCm = Integer.parseInt(trunkCirc.toString()); float circInCm = Float.parseFloat(trunkCirc.toString());
if (circInCm == 0) { if (circInCm == 0) {
circInCm = 89; circInCm = 89;
} }
...@@ -75,7 +76,7 @@ public class TreeKatasterData { ...@@ -75,7 +76,7 @@ public class TreeKatasterData {
} }
return result; return result;
} }
public List<Tree> getTrees() { public List<Tree> getTrees() {
if (trees == null) { if (trees == null) {
trees = new ArrayList<>(); trees = new ArrayList<>();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment